mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user