Skip to content
Snippets Groups Projects
Commit e3a0ed25 authored by graham's avatar graham
Browse files

ENH: Switchable ability to check and ignore out of bounds positions

from ManualInjection.

Doubles time taken to inject when used, as cells being found twice.
parent 61b5633d
Branches
Tags
No related merge requests found
Info<< "Reading transportProperties\n" << endl;
Info<< "\nReading transportProperties\n" << endl;
IOdictionary transportProperties
(
......@@ -31,7 +31,7 @@
rhoInfValue
);
Info<< "\nReading field U\n" << endl;
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
......@@ -127,7 +127,7 @@
if (HdotGradHheader.headerOk())
{
Info<< "\nReading field HdotGradH\n" << endl;
Info<< "Reading field HdotGradH" << endl;
HdotGradHPtr_.reset
(
......
......@@ -129,10 +129,11 @@ void Foam::InjectionModel<CloudType>::prepareForNextTimeStep
template<class CloudType>
void Foam::InjectionModel<CloudType>::findCellAtPosition
bool Foam::InjectionModel<CloudType>::findCellAtPosition
(
label& cellI,
vector& position
vector& position,
bool errorOnNotFound
)
{
const volVectorField& cellCentres = owner_.mesh().C();
......@@ -176,17 +177,26 @@ void Foam::InjectionModel<CloudType>::findCellAtPosition
if (procI == -1)
{
FatalErrorIn
(
"Foam::InjectionModel<CloudType>::findCellAtPosition"
"("
"label&, "
"vector&"
")"
)<< "Cannot find parcel injection cell. "
<< "Parcel position = " << p0 << nl
<< abort(FatalError);
if (errorOnNotFound)
{
FatalErrorIn
(
"Foam::InjectionModel<CloudType>::findCellAtPosition"
"("
"label&, "
"vector&"
")"
) << "Cannot find parcel injection cell. "
<< "Parcel position = " << p0 << nl
<< abort(FatalError);
}
else
{
return false;
}
}
return true;
}
......
......@@ -180,7 +180,12 @@ protected:
//- Find the cell that contains the supplied position
// Will modify position slightly towards the owner cell centroid to
// ensure that it lies in a cell and not edge/face
virtual void findCellAtPosition(label& cellI, vector& position);
virtual bool findCellAtPosition
(
label& cellI,
vector& position,
bool errorOnNotFound = true
);
//- Set number of particles to inject given parcel properties
virtual scalar setNumberOfParticles
......
......@@ -25,6 +25,8 @@ License
#include "ManualInjection.H"
#include "mathematicalConstants.H"
#include "PackedBoolList.H"
#include "Switch.H"
using namespace Foam::constant::mathematical;
......@@ -100,6 +102,40 @@ Foam::ManualInjection<CloudType>::ManualInjection
)
)
{
Switch checkAndIgnoreOutOfBounds
(
this->coeffDict().lookupOrDefault("checkAndIgnoreOutOfBounds", false)
);
label nRejected = 0;
if (checkAndIgnoreOutOfBounds)
{
// Dummy cell
label cellI = -1;
PackedBoolList keep(positions_.size(), true);
forAll(positions_, pI)
{
if (!this->findCellAtPosition(cellI, positions_[pI], false))
{
keep[pI] = false;
nRejected++;
}
}
if (nRejected > 0)
{
inplaceSubset(keep, positions_);
inplaceSubset(keep, diameters_);
Info<< " " << nRejected
<< " particles ignored, out of bounds." << endl;
}
}
// Construct parcel diameters
forAll(diameters_, i)
{
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment