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
|
IOdictionary transportProperties
|
||||||
(
|
(
|
||||||
@ -31,7 +31,7 @@
|
|||||||
rhoInfValue
|
rhoInfValue
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< "\nReading field U\n" << endl;
|
Info<< "Reading field U\n" << endl;
|
||||||
volVectorField U
|
volVectorField U
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
@ -127,7 +127,7 @@
|
|||||||
|
|
||||||
if (HdotGradHheader.headerOk())
|
if (HdotGradHheader.headerOk())
|
||||||
{
|
{
|
||||||
Info<< "\nReading field HdotGradH\n" << endl;
|
Info<< "Reading field HdotGradH" << endl;
|
||||||
|
|
||||||
HdotGradHPtr_.reset
|
HdotGradHPtr_.reset
|
||||||
(
|
(
|
||||||
|
|||||||
@ -129,10 +129,11 @@ void Foam::InjectionModel<CloudType>::prepareForNextTimeStep
|
|||||||
|
|
||||||
|
|
||||||
template<class CloudType>
|
template<class CloudType>
|
||||||
void Foam::InjectionModel<CloudType>::findCellAtPosition
|
bool Foam::InjectionModel<CloudType>::findCellAtPosition
|
||||||
(
|
(
|
||||||
label& cellI,
|
label& cellI,
|
||||||
vector& position
|
vector& position,
|
||||||
|
bool errorOnNotFound
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const volVectorField& cellCentres = owner_.mesh().C();
|
const volVectorField& cellCentres = owner_.mesh().C();
|
||||||
@ -175,6 +176,8 @@ void Foam::InjectionModel<CloudType>::findCellAtPosition
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (procI == -1)
|
if (procI == -1)
|
||||||
|
{
|
||||||
|
if (errorOnNotFound)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
@ -183,10 +186,17 @@ void Foam::InjectionModel<CloudType>::findCellAtPosition
|
|||||||
"label&, "
|
"label&, "
|
||||||
"vector&"
|
"vector&"
|
||||||
")"
|
")"
|
||||||
)<< "Cannot find parcel injection cell. "
|
) << "Cannot find parcel injection cell. "
|
||||||
<< "Parcel position = " << p0 << nl
|
<< "Parcel position = " << p0 << nl
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -180,7 +180,12 @@ protected:
|
|||||||
//- Find the cell that contains the supplied position
|
//- Find the cell that contains the supplied position
|
||||||
// Will modify position slightly towards the owner cell centroid to
|
// Will modify position slightly towards the owner cell centroid to
|
||||||
// ensure that it lies in a cell and not edge/face
|
// 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
|
//- Set number of particles to inject given parcel properties
|
||||||
virtual scalar setNumberOfParticles
|
virtual scalar setNumberOfParticles
|
||||||
|
|||||||
@ -25,6 +25,8 @@ License
|
|||||||
|
|
||||||
#include "ManualInjection.H"
|
#include "ManualInjection.H"
|
||||||
#include "mathematicalConstants.H"
|
#include "mathematicalConstants.H"
|
||||||
|
#include "PackedBoolList.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
|
||||||
using namespace Foam::constant::mathematical;
|
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
|
// Construct parcel diameters
|
||||||
forAll(diameters_, i)
|
forAll(diameters_, i)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user