36 template<
class CloudType>
45 generationSetName_(this->coeffDict().lookup(
"generationCellSet")),
46 inflationSetName_(this->coeffDict().lookup(
"inflationCellSet")),
69 volumeAccumulator_(0.0),
71 selfSeed_(this->coeffDict().lookupOrDefault(
"selfSeed",
false)),
77 this->coeffDict().subDict(
"sizeDistribution"),
82 duration_ = owner.db().time().userTimeToTime(duration_);
89 cellSet generationCells(this->owner().
mesh(), generationSetName_);
91 generationCells_ = generationCells.
toc();
93 cellSet inflationCells(this->owner().
mesh(), inflationSetName_);
96 inflationCells |= generationCells;
98 inflationCells_ = inflationCells.
toc();
102 scalar generationVolume = 0.0;
104 forAll(generationCells_, gCI)
106 label cI = generationCells_[gCI];
108 generationVolume += this->owner().mesh().cellVolumes()[cI];
111 scalar totalGenerationVolume = generationVolume;
115 fraction_ = generationVolume/totalGenerationVolume;
119 this->volumeTotal_ = fraction_*flowRateProfile_.integrate(0.0, duration_);
120 this->massTotal_ *= fraction_;
124 template<
class CloudType>
131 generationSetName_(im.generationSetName_),
132 inflationSetName_(im.inflationSetName_),
133 generationCells_(im.generationCells_),
134 inflationCells_(im.inflationCells_),
135 duration_(im.duration_),
136 flowRateProfile_(im.flowRateProfile_),
137 growthRate_(im.growthRate_),
138 newParticles_(im.newParticles_),
139 volumeAccumulator_(im.volumeAccumulator_),
140 fraction_(im.fraction_),
141 selfSeed_(im.selfSeed_),
143 sizeDistribution_(im.sizeDistribution_().clone().ptr())
149 template<
class CloudType>
156 template<
class CloudType>
161 template<
class CloudType>
164 return this->SOI_ + duration_;
168 template<
class CloudType>
178 this->owner().cellOccupancy();
180 scalar gR = growthRate_.value(time1);
182 scalar dT = time1 - time0;
186 forAll(inflationCells_, iCI)
188 label cI = inflationCells_[iCI];
192 forAll(cellOccupancy[cI], cPI)
194 pPtr = cellOccupancy[cI][cPI];
196 scalar dTarget = pPtr->dTarget();
198 pPtr->d() =
min(dTarget, pPtr->d() + gR*dT);
204 newParticles_.clear();
212 if ((time0 >= 0.0) && (time0 < duration_))
214 volumeAccumulator_ +=
215 fraction_*flowRateProfile_.integrate(time0, time1);
224 (10*volumeAccumulator_)
225 /CloudType::parcelType::volume(sizeDistribution_().
minValue())
228 label iterationNo = 0;
233 while (!generationCells_.empty() && volumeAccumulator_ > 0)
235 if (iterationNo > maxIterations)
238 <<
"Maximum particle split iterations (" 239 << maxIterations <<
") exceeded" <<
endl;
244 label cI = generationCells_
249 generationCells_.size() - 1
257 if (cellOccupancy[cI].empty())
259 if (selfSeed_ && !cellCentresUsed.
found(cI))
261 scalar dNew = sizeDistribution_().sample();
272 volumeAccumulator_ -= CloudType::parcelType::volume(dNew);
274 cellCentresUsed.
insert(cI);
287 scalar pD = pPtr->d();
290 if ((pD/pPtr->dTarget()) < rnd.
sample01<scalar>())
295 const point& pP = pPtr->position();
296 const vector& pU = pPtr->U();
319 scalar
x = a/
sqrt(3.0);
320 scalar r = a/(2.0*
sqrt(6.0));
322 scalar d = a/(2.0*
sqrt(3.0));
324 scalar dNew = sizeDistribution_().sample();
325 scalar volNew = CloudType::parcelType::volume(dNew);
335 volumeAccumulator_ -= volNew;
337 dNew = sizeDistribution_().sample();
346 volumeAccumulator_ -= volNew;
348 dNew = sizeDistribution_().sample();
357 volumeAccumulator_ -= volNew;
359 dNew = sizeDistribution_().sample();
368 volumeAccumulator_ -= volNew;
372 volumeAccumulator_ += CloudType::parcelType::volume
377 this->owner().deleteParticle(*pPtr);
403 gatheredNewParticles,
410 newParticles_ = combinedNewParticles;
416 return newParticles_.size();
420 template<
class CloudType>
427 if ((time0 >= 0.0) && (time0 < duration_))
429 return fraction_*flowRateProfile_.integrate(time0, time1);
438 template<
class CloudType>
450 position = newParticles_[parcelI].first().first();
452 this->findCellAtPosition
463 template<
class CloudType>
472 parcel.U() = newParticles_[parcelI].first().second();
474 parcel.d() = newParticles_[parcelI].second().first();
476 parcel.dTarget() = newParticles_[parcelI].second().second();
480 template<
class CloudType>
487 template<
class CloudType>
virtual scalar volumeToInject(const scalar time0, const scalar time1)
Volume of parcels to introduce relative to SOI.
virtual ~InflationInjection()
Destructor.
#define forAll(list, i)
Loop across all elements in list.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
A 2-tuple for storing two objects of different types.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual bool fullyDescribed() const
Flag to identify whether model fully describes the parcel.
Templated injection model class.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
virtual void updateMesh()
Set injector locations when mesh is updated.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
Vector< scalar > vector
A scalar version of the templated Vector.
bool insert(const Key &key)
Insert a new entry.
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
InflationInjection(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Type sample01()
Return a sample whose components lie in the range 0-1.
stressControl lookup("compactNormalStress") >> compactNormalStress
An ordered pair of two objects of type <T> with first() and second() elements.
bool found(const Key &) const
Return true if hashedEntry is found in table.
A class for handling words, derived from string.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
static autoPtr< distributionModel > New(const dictionary &dict, cachedRandom &rndGen)
Selector.
const vectorField & cellCentres() const
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
virtual bool validInjection(const label parcelI)
Return flag to identify whether or not injection of parcelI is.
ParcelType parcelType
Type of parcel the cloud was instantiated for.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Inflation injection - creates new particles by splitting existing particles within in a set of genera...
static bool & parRun()
Is this a parallel run?
static label nProcs(const label communicator=0)
Number of processes in parallel run.
const List< DynamicList< molecule * > > & cellOccupancy
#define R(A, B, C, D, E, F, K, M)
#define WarningInFunction
Report a warning using Foam::Warning.
A collection of cell labels.
scalar timeEnd() const
Return the end-of-injection time.
Mesh consisting of general polyhedral cells.
Type position(const Type &start, const Type &end)
Return a sample between start and end.
List< Key > toc() const
Return the table of contents.
virtual label parcelsToInject(const scalar time0, const scalar time1)
Number of parcels to introduce relative to SOI.
Templated base class for dsmc cloud.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
virtual void setProperties(const label parcelI, const label nParcels, const scalar time, typename CloudType::parcelType &parcel)
Set the parcel properties.