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;
131 if (!(t0 <= time_ && time_ < t1))
return mesh.subNone();
133 const scalar fraction = (time_ - t0)/(t1 - t0);
136 localRndGen_.start(timeIndex_ == db().time().timeIndex());
137 globalRndGen_.start(timeIndex_ == db().time().timeIndex());
142 const labelList& setCellCells = zone_.zone();
159 forAll(setCells, setCelli)
161 forAll(setCells[setCelli], cellFacei)
163 setCellNTets[setCelli] +=
164 faces[setCells[setCelli][cellFacei]].nTriangles();
177 forAll(setCells, setCelli)
179 const cell&
c = setCells[setCelli];
185 const face&
f = faces[
c[cFacei]];
187 for (
label fTrii = 1; fTrii <=
f.nTriangles(); ++ fTrii)
189 setCellTetFaceAndFaceTri[setCelli][cellTeti] =
192 setCellSumVolume[setCelli] +=
193 tetIndices(setCellCells[setCelli],
c[cFacei], fTrii)
197 setCellTetSumVolume[setCelli][cellTeti] =
198 setCellSumVolume[setCelli];
204 for (
label setCelli = 1; setCelli < setCells.
size(); ++ setCelli)
206 setCellSumVolume[setCelli] += setCellSumVolume[setCelli - 1];
212 setCells.
size() ? setCellSumVolume.
last() : scalar(0);
217 procSumVolume[proci] += procSumVolume[proci - 1];
221 const label numberInt =
223 ? round(numberOrNumberDensity_)
224 : round(numberOrNumberDensity_*procSumVolume.
last());
241 const label i = (i0 + i1)/2;
243 (volume < volumes[i] ? i1 : i0) = i;
248 volume -= volumes[i0];
264 scalarField volume(globalRndGen_.scalar01(numberInt)*procSumVolume.
last());
267 const label proci = findVolume(procSumVolume, volume[volumei]);
271 const label setCelli =
272 findVolume(setCellSumVolume, volume[volumei]);
273 const label celli = setCellCells[setCelli];
274 const label cellTeti =
275 findVolume(setCellTetSumVolume[setCelli], volume[volumei]);
278 injectCells.
append(celli);
281 setCellTetFaceAndFaceTri[setCelli][cellTeti].
first()
285 setCellTetFaceAndFaceTri[setCelli][cellTeti].
second()
309 return injectionMesh;
315 zone_.topoChange(map);
330 zone_.distribute(map);
338 readCoeffs(modelDict);
352 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...
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.
label timeIndex() const
Return current time index.
dimensionedScalar deltaT() const
Return time step.
const unitConversion & userUnits() const
Return the user-time unit conversion.
virtual dimensionedScalar beginTime() const
Return begin time (initial start time)
A List with indirect addressing.
label size() const
Return the number of elements in the list.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
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 & mesh() const
Return reference to polyMesh.
bool read(const dictionary &dict)
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 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.
addToRunTimeSelectionTable(LagrangianModel, constantCoefficientVirtualMass, dictionary)
defineTypeNameAndDebug(constantCoefficientVirtualMass, 0)
const dimensionedScalar c
Speed of light in a vacuum.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Pair< label > labelPair
Label pair.
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.
const dimensionSet dimless
barycentric barycentric01(randomGenerator &rndGen)
Generate a random barycentric coordinate within the unit tetrahedron.
labelList second(const UList< labelPair > &p)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
labelList first(const UList< labelPair > &p)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
const dimensionSet dimVolume
Field< label > labelField
Specialisation of Field<T> for label.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.