39template<
class CloudType>
52 duration_(this->
coeffDict().getScalar(
"duration")),
72 volumeAccumulator_(0.0),
74 selfSeed_(this->
coeffDict().getOrDefault(
"selfSeed", false)),
80 this->
coeffDict().subDict(
"sizeDistribution"),
88 flowRateProfile_->userTimeToTime(time);
89 growthRate_->userTimeToTime(time);
98 generationCells_ = generationCells.
toc();
103 inflationCells |= generationCells;
105 inflationCells_ = inflationCells.
toc();
109 scalar generationVolume = 0.0;
111 forAll(generationCells_, gCI)
113 label cI = generationCells_[gCI];
118 scalar totalGenerationVolume = generationVolume;
122 fraction_ = generationVolume/totalGenerationVolume;
126 this->
volumeTotal_ = fraction_*flowRateProfile_->integrate(0.0, duration_);
131template<
class CloudType>
138 generationSetName_(im.generationSetName_),
139 inflationSetName_(im.inflationSetName_),
140 generationCells_(im.generationCells_),
141 inflationCells_(im.inflationCells_),
142 duration_(im.duration_),
143 flowRateProfile_(im.flowRateProfile_.clone()),
144 growthRate_(im.growthRate_.clone()),
145 newParticles_(im.newParticles_),
146 volumeAccumulator_(im.volumeAccumulator_),
147 fraction_(im.fraction_),
148 selfSeed_(im.selfSeed_),
150 sizeDistribution_(im.sizeDistribution_.
clone())
156template<
class CloudType>
163template<
class CloudType>
168template<
class CloudType>
171 return this->
SOI_ + duration_;
175template<
class CloudType>
187 scalar gR = growthRate_->value(time1);
189 scalar dT = time1 - time0;
193 forAll(inflationCells_, iCI)
195 label cI = inflationCells_[iCI];
203 scalar dTarget = pPtr->dTarget();
205 pPtr->d() =
min(dTarget, pPtr->d() + gR*dT);
211 newParticles_.clear();
219 if ((time0 >= 0.0) && (time0 < duration_))
221 volumeAccumulator_ +=
222 fraction_*flowRateProfile_->integrate(time0, time1);
228 label maxIterations =
max
231 (10*volumeAccumulator_)
232 /CloudType::parcelType::volume(sizeDistribution_().
minValue())
235 label iterationNo = 0;
240 while (!generationCells_.empty() && volumeAccumulator_ > 0)
242 if (iterationNo > maxIterations)
245 <<
"Maximum particle split iterations ("
246 << maxIterations <<
") exceeded" <<
endl;
251 label cI = generationCells_
256 generationCells_.size() - 1
266 if (selfSeed_ && !cellCentresUsed.
found(cI))
268 scalar dNew = sizeDistribution_().sample();
279 volumeAccumulator_ -= CloudType::parcelType::volume(dNew);
281 cellCentresUsed.
insert(cI);
294 scalar pD = pPtr->d();
297 if ((pD/pPtr->dTarget()) < rnd.
sample01<scalar>())
326 scalar
x = a/
sqrt(3.0);
327 scalar r = a/(2.0*
sqrt(6.0));
329 scalar d = a/(2.0*
sqrt(3.0));
331 scalar dNew = sizeDistribution_().sample();
332 scalar volNew = CloudType::parcelType::volume(dNew);
342 volumeAccumulator_ -= volNew;
344 dNew = sizeDistribution_().sample();
353 volumeAccumulator_ -= volNew;
355 dNew = sizeDistribution_().sample();
364 volumeAccumulator_ -= volNew;
366 dNew = sizeDistribution_().sample();
375 volumeAccumulator_ -= volNew;
379 volumeAccumulator_ += CloudType::parcelType::volume
410 gatheredNewParticles,
417 newParticles_ = combinedNewParticles;
423 return newParticles_.size();
427template<
class CloudType>
434 if ((time0 >= 0.0) && (time0 < duration_))
436 return fraction_*flowRateProfile_->integrate(time0, time1);
443template<
class CloudType>
455 position = newParticles_[parcelI].first().first();
457 this->findCellAtPosition
468template<
class CloudType>
477 parcel.
U() = newParticles_[parcelI].first().second();
479 parcel.d() = newParticles_[parcelI].second().first();
481 parcel.dTarget() = newParticles_[parcelI].second().second();
485template<
class CloudType>
492template<
class CloudType>
#define R(A, B, C, D, E, F, K, M)
const List< DynamicList< molecule * > > & cellOccupancy
const CloudType & owner() const
Return const access to the owner cloud.
void deleteParticle(ParticleType &p)
Remove particle from cloud and delete.
Random & rndGen()
Return reference to the random object.
const List< DynamicList< ParcelType * > > & cellOccupancy() const
Return the cell occupancy addressing.
const fvMesh & mesh() const
Return reference to the mesh.
const vector & U() const
Return const access to velocity.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
bool found(const Key &key) const
Same as contains().
Inflation injection - creates new particles by splitting existing particles within in a set of genera...
virtual autoPtr< InjectionModel< CloudType > > clone() const
Construct and return a clone.
virtual scalar volumeToInject(const scalar time0, const scalar time1)
Volume of parcels to introduce relative to SOI.
virtual label parcelsToInject(const scalar time0, const scalar time1)
Number of parcels to introduce relative to SOI.
InflationInjection(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
virtual void setPositionAndCell(const label parcelI, const label nParcels, const scalar time, vector &position, label &cellOwner, label &tetFacei, label &tetPti)
Set the injection position and owner cell, tetFace and tetPt.
virtual bool validInjection(const label parcelI)
Return flag to identify whether or not injection of parcelI is.
virtual void setProperties(const label parcelI, const label nParcels, const scalar time, typename CloudType::parcelType &parcel)
Set the parcel properties.
virtual ~InflationInjection()
Destructor.
virtual void updateMesh()
Set injector locations when mesh is updated.
virtual bool fullyDescribed() const
Flag to identify whether model fully describes the parcel.
scalar timeEnd() const
Return the end-of-injection time.
Templated injection model class.
static autoPtr< InjectionModel< CloudType > > New(const dictionary &dict, CloudType &owner)
Selector with lookup from dictionary.
scalar volumeTotal_
Total volume of particles introduced by this injector [m^3] Note: scaled to ensure massTotal is achie...
InjectionModel(CloudType &owner)
Construct null from owner.
scalar massTotal_
Total mass to inject [kg].
virtual bool findCellAtPosition(label &celli, label &tetFacei, label &tetPti, vector &position, bool errorOnNotFound=true)
Find the cell that contains the supplied position.
scalar SOI_
Start of injection [s].
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An ordered pair of two objects of type <T> with first() and second() elements.
Type position(const Type &start, const Type &end)
Return a sample on the interval [start,end].
Type sample01()
Return a sample whose components lie in the range [0,1].
virtual scalar userTimeToTime(const scalar theta) const
Convert the user-time (e.g. CA deg) to real-time (s).
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
@ gatherList
gatherList [manual algorithm]
@ broadcast
broadcast [MPI]
A collection of cell labels.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect,...
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
vector position() const
Return current particle position.
Mesh consisting of general polyhedral cells.
const scalarField & cellVolumes() const
const vectorField & cellCentres() const
Lookup type of boundary radiation properties.
const dictionary & coeffDict() const
Return const access to the coefficients dictionary.
const dictionary & dict() const
Return const access to the cloud dictionary.
const word & modelName() const
Return const access to the name of the sub-model.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
#define WarningInFunction
Report a warning using Foam::Warning.
AccessType combine(const UList< T > &lists, AccessOp aop=accessOp< T >())
Combines sub-lists into a single list.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
DSMCCloud< dsmcParcel > CloudType
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
Tuple2< Pair< vector >, Pair< scalar > > vectorPairScalarPair
#define forAll(list, i)
Loop across all elements in list.
Object access operator or list access operator (default is pass-through).