48 void Foam::Lagrangian::patchInjection::readCoeffs(
const dictionary& modelDict)
50 patchName_ = modelDict.lookup<word>(
"patch");
57 mesh().time().userUnits(),
67 void Foam::Lagrangian::patchInjection::calcSumAreas()
75 const tmp<pointField> tPoints
87 patchFaceNTris[patchFacei] = patch[patchFacei].nTriangles();
92 patchFaceSumArea_.resize(patch.size());
93 patchFaceSumArea_ = 0;
94 patchFaceTriSumArea_.resize(patchFaceNTris);
97 const label facei = patch.start() + patchFacei;
98 const face&
f = patch[patchFacei];
100 for (
label fTrii = 0; fTrii <
f.nTriangles(); ++ fTrii)
102 patchFaceSumArea_[patchFacei] +=
103 tetIndices(
mesh().
mesh().faceOwner()[facei], facei, fTrii + 1)
107 patchFaceTriSumArea_[patchFacei][fTrii] =
108 patchFaceSumArea_[patchFacei];
111 for (
label patchFacei = 1; patchFacei < patch.size(); ++ patchFacei)
113 patchFaceSumArea_[patchFacei] += patchFaceSumArea_[patchFacei - 1];
117 procSumArea_ = scalar(-vGreat);
119 patch.size() ? patchFaceSumArea_.last() : scalar(0);
124 procSumArea_[proci] += procSumArea_[proci - 1];
141 patchName_(
word::null),
142 numberRate_(nullptr),
143 numberDeferred_(stateDict.lookupOrDefault<scalar>(
"numberDeferred", 0)),
144 globalRndGen_(
"globalRndGen", stateDict,
name, true),
145 localRndGen_(
"localRndGen", stateDict,
name, false),
147 procSumArea_(
Pstream::nProcs()),
149 patchFaceTriSumArea_()
151 readCoeffs(modelDict);
169 localRndGen_.start(timeIndex_ == db().time().
timeIndex());
170 globalRndGen_.start(timeIndex_ == db().time().
timeIndex());
171 timeIndex_ = db().time().timeIndex();
175 const scalar number = numberRate_->integral(t0, t1) + numberDeferred_;
176 const label numberInt = floor(number);
177 numberDeferred_ = number - numberInt;
180 const scalarField fraction(globalRndGen_.scalar01(numberInt));
197 const label i = (i0 + i1)/2;
199 (volume < volumes[i] ? i1 : i0) = i;
204 volume -= volumes[i0];
225 scalarField area(globalRndGen_.scalar01(numberInt)*procSumArea_.last());
228 const label proci = findVolume(procSumArea_, area[areai]);
232 const label patchFacei =
233 findVolume(patchFaceSumArea_, area[areai]);
234 const label facei = facei0 + patchFacei;
235 const label faceTrii =
236 findVolume(patchFaceTriSumArea_[patchFacei], area[areai]);
242 injectFaces.
append(facei);
243 injectFaceTris.
append(faceTrii + 1);
244 injectFraction.
append(fraction[areai]);
267 injectionMesh.
mesh(),
273 injectionMesh.
size(),
274 injectionMesh.
start()
284 return injectionMesh;
322 readCoeffs(modelDict);
336 writeEntry(os,
"numberDeferred", numberDeferred_);
337 writeEntry(os,
"globalRndGen", globalRndGen_);
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
Templated 2D Barycentric derived from VectorSpace. Has 3 components, one of which is redundant.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
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.
static autoPtr< Function1< scalar > > New(const word &name, const Function1s::unitConversions &units, const dictionary &dict)
Select from dictionary.
Base class for Lagrangian injections. Minimal wrapper over LagrangianSource. Implements some utility ...
Class containing Lagrangian geometry and topology.
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...
SubList< Type > sub(const List< Type > &list) const
Return a sub-list corresponding to this sub-mesh.
label size() const
Return size.
const LagrangianMesh & mesh() const
Return the mesh.
label start() const
Return start.
virtual void correct()
Correct the LagrangianModel.
patchInjection(const word &name, const LagrangianMesh &mesh, const dictionary &modelDict, const dictionary &stateDict)
Construct from components.
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.
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.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Inter-processor communications stream.
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.
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.
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)
List of references to the cloud function objects. Designed to be constructed temporarily for the scop...
virtual void postCrossFaces(const LagrangianSubScalarSubField &fraction)
Hook following face crossings of a specific sub-mesh.
Base class for Lagrangian models that refer to a cloud. Not a Lagrangian model in itself....
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
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.
const Time & time() const
Return the top-level database.
const polyMesh & mesh() const
Return reference to polyMesh.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
label index() const
Return the index of this patch in the boundaryMesh.
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 labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
bool writeState(const bool write) const
Write state.
virtual void writeProcessorState(Ostream &os) const
Write processor state.
A class for handling words, derived from string.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
addToRunTimeSelectionTable(LagrangianModel, constantCoefficientVirtualMass, dictionary)
defineTypeNameAndDebug(constantCoefficientVirtualMass, 0)
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
List< label > labelList
A List of labels.
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 dimRate
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Field< label > labelField
Specialisation of Field<T> for label.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
LagrangianGroup
Lagrangian group enumeration.
barycentric2D barycentric2D01(randomGenerator &rndGen)
Generate a random barycentric coordinate within the unit triangle.