Commit dda4777e authored by Andrew Heather's avatar Andrew Heather
Browse files

moved setInjectorCellAndPosition functionality to injection model

parent e3571327
......@@ -35,65 +35,6 @@ License
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class ParcelType>
void Foam::KinematicCloud<ParcelType>::setInjectorCellAndPosition
(
label& pCell,
vector& pPosition
)
{
const vector originalPosition = pPosition;
bool foundCell = false;
pCell = mesh_.findCell(pPosition);
if (pCell >= 0)
{
const vector& C = mesh_.C()[pCell];
pPosition += 1.0e-6*(C - pPosition);
foundCell = mesh_.pointInCell
(
pPosition,
pCell
);
}
reduce(foundCell, orOp<bool>());
// Last chance - find nearest cell and try that one
// - the point is probably on an edge
if (!foundCell)
{
pCell = mesh_.findNearestCell(pPosition);
if (pCell >= 0)
{
const vector& C = mesh_.C()[pCell];
pPosition += 1.0e-6*(C - pPosition);
foundCell = mesh_.pointInCell
(
pPosition,
pCell
);
}
reduce(foundCell, orOp<bool>());
}
if (!foundCell)
{
FatalErrorIn
(
"void KinematicCloud<ParcelType>::findInjectorCell"
"(label&, vector&)"
)<< "Cannot find parcel injection cell. "
<< "Parcel position = " << originalPosition << nl
<< abort(FatalError);
}
}
template<class ParcelType>
Foam::scalar Foam::KinematicCloud<ParcelType>::setNumberOfParticles
(
......@@ -419,7 +360,7 @@ void Foam::KinematicCloud<ParcelType>::inject
// Determine the injection cell
label pCell = -1;
setInjectorCellAndPosition(pCell, pPosition);
this->injection().findInjectorCellAndPosition(pCell, pPosition);
if (pCell >= 0)
{
......
......@@ -223,13 +223,6 @@ protected:
// Protected member functions
//- Set parcel position and cell into which parcel is introduced
void setInjectorCellAndPosition
(
label& pCell,
vector& pPosition
);
//- Set the number of particles per parcel
scalar setNumberOfParticles
(
......
......@@ -269,7 +269,7 @@ void Foam::ReactingCloud<ParcelType>::inject
// Determine the injection cell
label pCell = -1;
this->setInjectorCellAndPosition(pCell, pPosition);
this->injection().findInjectorCellAndPosition(pCell, pPosition);
if (pCell >= 0)
{
......
......@@ -159,6 +159,57 @@ void Foam::InjectionModel<CloudType>::prepareForNextTimeStep
}
template<class CloudType>
void Foam::InjectionModel<CloudType>::findInjectorCellAndPosition
(
label& cellI,
vector& position
)
{
const vector p0 = position;
bool foundCell = false;
cellI = owner_.mesh().findCell(position);
if (cellI >= 0)
{
const vector& C = owner_.mesh().C()[cellI];
position += 1.0e-6*(C - position);
foundCell = owner_.mesh().pointInCell(position, cellI);
}
reduce(foundCell, orOp<bool>());
// Last chance - find nearest cell and try that one
// - the point is probably on an edge
if (!foundCell)
{
cellI = owner_.mesh().findNearestCell(position);
if (cellI >= 0)
{
const vector& C = owner_.mesh().C()[cellI];
position += 1.0e-6*(C - position);
foundCell = owner_.mesh().pointInCell(position, cellI);
}
reduce(foundCell, orOp<bool>());
}
if (!foundCell)
{
FatalErrorIn
(
"InjectionModel<CloudType>::setInjectorCellAndPosition"
"(label&, vector&)"
)<< "Cannot find parcel injection cell. "
<< "Parcel position = " << p0 << nl
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "NewInjectionModel.C"
......
......@@ -208,6 +208,14 @@ public:
// Injection geometry
//- Find the cell that contains the injector position
// Will modify position slightly towards the owner cell centroid
virtual void findInjectorCellAndPosition
(
label& cellI,
vector& position
);
//- Return the injection position
virtual vector position
(
......
Supports Markdown
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