46 void Foam::Lagrangian::volumeInjection::readCoeffs(
const dictionary& modelDict)
48 zone_.
read(modelDict);
50 haveNumber_ = modelDict.found(
"number");
51 const bool haveNumberDensity = modelDict.found(
"numberDensity");
53 if (haveNumber_ == haveNumberDensity)
56 <<
"keywords number and numberDensity are both "
57 << (haveNumber_ ?
"" :
"un") <<
"defined in "
58 <<
"dictionary " << modelDict.name()
62 numberOrNumberDensity_ =
64 ? modelDict.lookup<scalar>(
"number",
dimless)
68 modelDict.lookupOrDefault<scalar>
90 numberOrNumberDensity_(NaN),
92 globalRndGen_(
"globalRndGen", stateDict,
name, true),
93 localRndGen_(
"localRndGen", stateDict,
name, false),
96 readCoeffs(modelDict);
113 if (t0 <= time_ && time_ < t1)
return;
115 if (
mesh().poly().moving())
131 if (!(t0 <= time_ && time_ < t1))
return mesh.subNone();
133 const scalar
fraction = (time_ - t0)/(t1 - t0);
136 localRndGen_.start(timeIndex_ ==
time().timeIndex());
137 globalRndGen_.start(timeIndex_ ==
time().timeIndex());
138 timeIndex_ =
time().timeIndex();
143 const labelList& setCellCells = zone_.zone();
160 forAll(setCells, setCelli)
162 forAll(setCells[setCelli], cellFacei)
164 setCellNTets[setCelli] +=
165 faces[setCells[setCelli][cellFacei]].nTriangles();
178 forAll(setCells, setCelli)
180 const cell&
c = setCells[setCelli];
186 const face&
f = faces[
c[cFacei]];
188 for (
label fTrii = 1; fTrii <=
f.nTriangles(); ++ fTrii)
190 setCellTetFaceAndFaceTri[setCelli][cellTeti] =
193 setCellSumVolume[setCelli] +=
194 tetIndices(setCellCells[setCelli],
c[cFacei], fTrii)
198 setCellTetSumVolume[setCelli][cellTeti] =
199 setCellSumVolume[setCelli];
205 for (
label setCelli = 1; setCelli < setCells.
size(); ++ setCelli)
207 setCellSumVolume[setCelli] += setCellSumVolume[setCelli - 1];
213 setCells.
size() ? setCellSumVolume.
last() : scalar(0);
218 procSumVolume[proci] += procSumVolume[proci - 1];
222 const label numberInt =
224 ? round(numberOrNumberDensity_)
225 : round(numberOrNumberDensity_*procSumVolume.
last());
242 const label i = (i0 + i1)/2;
244 (
volume < volumes[i] ? i1 : i0) = i;
268 const label proci = findVolume(procSumVolume,
volume[volumei]);
272 const label setCelli =
273 findVolume(setCellSumVolume,
volume[volumei]);
274 const label celli = setCellCells[setCelli];
275 const label cellTeti =
276 findVolume(setCellTetSumVolume[setCelli],
volume[volumei]);
279 injectCells.
append(celli);
282 setCellTetFaceAndFaceTri[setCelli][cellTeti].
first()
286 setCellTetFaceAndFaceTri[setCelli][cellTeti].
second()
310 return injectionMesh;
316 zone_.topoChange(map);
331 zone_.distribute(map);
339 readCoeffs(modelDict);
353 writeEntry(os,
"globalRndGen", globalRndGen_);
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Base class for Lagrangian injections. Minimal wrapper over LagrangianSource. Implements some utility ...
Class containing Lagrangian geometry and topology.
const Time & time() const
Return time.
static const word fractionName
Name of the tracked fraction field.
Base class for Lagrangian models.
virtual bool read(const dictionary &modelDict)
Read dictionary.
const LagrangianMesh & mesh() const
The mesh.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
Volume injection model. This injects particles instantaneously within the volume of a set of cells....
virtual void correct()
Correct the LagrangianModel.
virtual void writeState(Ostream &os) const
Write state.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
LagrangianSubMesh modify(LagrangianMesh &mesh, const LagrangianSubMesh &) const
Create new elements in the Lagrangian mesh.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
volumeInjection(const word &name, const LagrangianMesh &mesh, const dictionary &modelDict, const dictionary &stateDict)
Construct from components.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual void writeProcessorState(Ostream &os) const
Write state.
virtual bool read(const dictionary &modelDict)
Read dictionary.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
dimensionedScalar deltaT() const
Return time step.
virtual dimensionedScalar beginTime() const
Return begin time (initial start time)
const unitSet & userUnits() const
Return the user-time unit conversion.
A List with indirect addressing.
label size() const
Return the number of elements in the list.
label size() const
Return the number of elements in the UList.
T & last()
Return the last element of the list.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
A cell is defined as a list of faces with extra functionality.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
const Type & value() const
Return const reference to value.
A face is a list of labels corresponding to mesh vertices.
const Time & time() const
Return the top-level database.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
const polyMesh & poly() const
Return reference to polyMesh.
bool read(const dictionary &dict, const bool defaultIsAll=false, const bool onDemand=false)
Read coefficients dictionary.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & oldPoints() const
Return old points for mesh motion.
virtual const pointField & points() const
Return raw points.
virtual const pointField & oldCellCentres() const
Return old cell centres for mesh motion.
bool moving() const
Is the mesh moving?
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const vectorField & cellCentres() const
const cellList & cells() const
bool writeState(const bool write) const
Write state.
virtual void writeProcessorState(Ostream &os) const
Write processor state.
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
tetPointRef tet(const polyMesh &mesh, const pointField &meshPoints, const pointField &cellCentres) const
Return the geometry corresponding to this tet and the given.
scalar mag() const
Return volume.
A class for handling words, derived from string.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
defineTypeNameAndDebug(collisionPhaseTransfer, 0)
addToRunTimeSelectionTable(LagrangianModel, collisionPhaseTransfer, dictionary)
const dimensionedScalar c
Speed of light in a vacuum.
const dimensionSet volume
errorManipArg< error, int > exit(error &err, const int errNo=1)
Pair< label > labelPair
Label pair.
const dimensionSet & dimless
Field< barycentric > barycentricField
Barycentric field.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
barycentric barycentric01(randomGenerator &rndGen)
Generate a random barycentric coordinate within the unit tetrahedron.
const dimensionSet & dimVolume
labelList second(const UList< labelPair > &p)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
labelList first(const UList< labelPair > &p)
Field< label > labelField
Specialisation of Field<T> for label.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)