37 template<
class CloudType>
52 tag[particlei] =
p.tag();
53 position[particlei] =
p.position();
55 soi[particlei] =
p.soi();
67 ListListOps::combine<List<label>>
76 ListListOps::combine<List<point>>
85 ListListOps::combine<List<vector>>
94 ListListOps::combine<List<scalar>>
103 ListListOps::combine<List<scalar>>
112 maxTag =
max(maxTag, tag[particlei]);
115 label nInjectors = maxTag + 1;
125 const label tagi = tag[i];
126 const scalar t = soi[i];
127 injStartTime[tagi] =
min(t, injStartTime[tagi]);
128 injEndTime[tagi] =
max(t, injEndTime[tagi]);
129 injPosition[tagi].
append(position[i]);
131 injDiameter[tagi].
append(d[i]);
136 scalar sumVolume = 0;
137 startTime_.setSize(nInjectors, 0);
138 endTime_.setSize(nInjectors, 0);
139 sizeDistribution_.setSize(nInjectors);
140 position_.setSize(nInjectors);
141 U_.setSize(nInjectors);
142 volumeFlowRate_.setSize(nInjectors, 0);
144 scalar minTime = GREAT;
147 Random& rnd = this->owner().rndGen();
152 const label nParticle = diameters.
size();
153 const scalar dTime = injEndTime[i] - injStartTime[i];
155 if ((nParticle > 1) && (dTime > ROOTVSMALL))
157 minTime =
min(minTime, injStartTime[i]);
159 startTime_[injectori] = injStartTime[i];
160 endTime_[injectori] = injEndTime[i];
163 position_[injectori].
setSize(resampleSize_);
164 U_[injectori].setSize(resampleSize_);
168 for (label samplei = 0; samplei < resampleSize_; ++samplei)
171 positioni[samplei] = injPosition[i][posi] + positionOffset_;
172 Ui[samplei] = injU[i][posi];
177 forAll(diameters, particlei)
179 sumPow3 +=
pow3(diameters[particlei]);
184 volumeFlowRate_[injectori] =
volume/dTime;
187 sizeDistribution_.
set 203 startTime_.setSize(injectori);
204 endTime_.setSize(injectori);
205 position_.setSize(injectori);
206 U_.setSize(injectori);
207 volumeFlowRate_.setSize(injectori);
208 sizeDistribution_.setSize(injectori);
211 forAll(startTime_, injectori)
213 startTime_[injectori] -= minTime;
214 endTime_[injectori] -= minTime;
219 this->volumeTotal_ = sumVolume;
222 Info<<
" Read " << position_.size() <<
" injectors with " 223 << tag.size() <<
" total particles" <<
endl;
229 template<
class CloudType>
235 const word& modelName
239 cloudName_(this->coeffDict().
lookup(
"cloud")),
240 startTime_(this->template getModelProperty<
scalarList>(
"startTime")),
241 endTime_(this->template getModelProperty<
scalarList>(
"endTime")),
242 position_(this->template getModelProperty<
List<
vectorList>>(
"position")),
243 positionOffset_(this->coeffDict().
lookup(
"positionOffset")),
246 this->template getModelProperty<
scalarList>(
"volumeFlowRate")
249 binWidth_(this->coeffDict().getScalar(
"binWidth")),
253 ceil(this->coeffDict().getScalar(
"parcelsPerInjector"))
257 this->coeffDict().getOrDefault(
"resampleSize", label(100))
259 applyDistributionMassTotal_
261 this->coeffDict().getBool(
"applyDistributionMassTotal")
265 this->coeffDict().getOrDefault(
"ignoreOutOfBounds", false)
267 nParcelsInjected_(this->parcelsAddedTotal()),
268 nParcelsInjected0_(0),
269 currentInjectori_(0),
299 Info<<
" Set mass to inject from distribution: " 305 template<
class CloudType>
309 const InjectedParticleDistributionInjection<CloudType>& im
313 cloudName_(im.cloudName_),
314 startTime_(im.startTime_),
315 endTime_(im.endTime_),
316 position_(im.position_),
317 positionOffset_(im.positionOffset_),
318 volumeFlowRate_(im.volumeFlowRate_),
320 binWidth_(im.binWidth_),
321 sizeDistribution_(im.sizeDistribution_.size()),
322 parcelsPerInjector_(im.parcelsPerInjector_),
323 resampleSize_(im.resampleSize_),
324 applyDistributionMassTotal_(im.applyDistributionMassTotal_),
325 ignoreOutOfBounds_(im.ignoreOutOfBounds_),
326 nParcelsInjected_(im.nParcelsInjected_),
327 nParcelsInjected0_(im.nParcelsInjected0_),
328 currentInjectori_(0),
338 new distributionModels::general
340 im.sizeDistribution_[injectori]
350 template<
class CloudType>
358 template<
class CloudType>
363 template<
class CloudType>
371 template<
class CloudType>
381 nParcelsInjected0_ = 0;
383 if (startTime_.empty() || this->volumeTotal_ < ROOTVSMALL)
388 scalar targetVolume = 0;
389 forAll(startTime_, injectori)
391 if (time1 > startTime_[injectori])
393 scalar totalDuration =
394 min(time1, endTime_[injectori]) - startTime_[injectori];
396 targetVolume += volumeFlowRate_[injectori]*totalDuration;
400 const label targetParcels =
403 scalar(startTime_.size()*parcelsPerInjector_)
404 *targetVolume/this->volumeTotal_
407 const label nParcels = targetParcels - nParcelsInjected_;
413 template<
class CloudType>
422 forAll(startTime_, injectori)
424 if ((time1 > startTime_[injectori]) && (time1 <= endTime_[injectori]))
426 scalar duration =
min(time1, endTime_[injectori]) - time0;
427 volume += volumeFlowRate_[injectori]*duration;
435 template<
class CloudType>
439 const label nParcels,
447 Random& rnd = this->owner().rndGen();
448 currentInjectori_ = rnd.
globalPosition<label>(0, position_.size() - 1);
449 currentSamplei_ = rnd.
globalPosition<label>(0, resampleSize_ - 1);
451 position = position_[currentInjectori_][currentSamplei_];
454 this->findCellAtPosition
464 template<
class CloudType>
474 parcel.U() = U_[currentInjectori_][currentSamplei_];
477 parcel.d() = sizeDistribution_[currentInjectori_].sample();
481 nParcelsInjected0_++;
485 template<
class CloudType>
493 template<
class CloudType>
503 template<
class CloudType>
508 if (this->writeTime())
510 this->setModelProperty(
"startTime", startTime_);
511 this->setModelProperty(
"endTime", endTime_);
512 this->setModelProperty(
"position", position_);
513 this->setModelProperty(
"volumeFlowRate", volumeFlowRate_);
514 this->setModelProperty(
"U", U_);
515 forAll(sizeDistribution_, i)
Different types of constants.
void initialise()
Initialise injectors.
virtual ~InjectedParticleDistributionInjection()
Destructor.
void size(const label n)
Older name for setAddressableSize.
scalar massTotal_
Total mass to inject [kg].
DSMCCloud< dsmcParcel > CloudType
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
void append(const T &val)
Append an element at the end of the list.
Templated injection model class.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
void info()
Write injection info.
const word dictName("faMeshDefinition")
virtual bool validInjection(const label parcelI)
Return flag to identify whether or not injection of parcelI is.
Object access operator or list access operator (default is pass-through)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
Primarily stores particle properties so that it can be injected at a later time. Note that this store...
scalar timeEnd() const
Return the end-of-injection time.
virtual scalar volumeToInject(const scalar time0, const scalar time1)
Volume of parcels to introduce relative to SOI.
virtual void updateMesh()
Set injector locations when mesh is updated.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
Lookup type of boundary radiation properties.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
scalarList startTime_
List of start time per injector.
const dictionary & dict() const
Return const access to the cloud dictionary.
const CloudType & owner() const
Return const access to the owner cloud.
#define forAll(list, i)
Loop across all elements in list.
label size() const noexcept
The number of elements in table.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
bool applyDistributionMassTotal_
Flag to apply mass calculated from distribution instead of.
A class for handling words, derived from Foam::string.
bool getModelDict(const word &entryName, dictionary &dict) const
Retrieve dictionary, return true if set.
constexpr scalar pi(M_PI)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
virtual void setProperties(const label parcelI, const label nParcels, const scalar time, typename CloudType::parcelType &parcel)
Set the parcel properties.
virtual void info()
Write injection info.
ParcelType parcelType
Type of parcel the cloud was instantiated for.
const wordList volume
Standard volume field types (scalar, vector, tensor, etc)
Type globalPosition(const Type &start, const Type &end)
Return a sample on the interval [start,end].
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual label parcelsToInject(const scalar time0, const scalar time1)
Number of parcels to introduce relative to SOI.
PtrList< distributionModels::general > sizeDistribution_
List of size distribution model per injector.
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual linear/tree communicat...
dimensionedScalar pow3(const dimensionedScalar &ds)
virtual bool fullyDescribed() const
Flag to identify whether model fully describes the parcel.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Particle-size distribution model wherein random samples are drawn from a given arbitrary probability ...
scalar volumeTotal_
Total volume of particles introduced by this injector [m^3] Note: scaled to ensure massTotal is achie...
virtual dictionary writeDict(const word &dictName) const
Write data in dictionary format.
InjectedParticleDistributionInjection(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Templated base class for dsmc cloud.
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.
const List< typename ParcelType::constantProperties > & constProps() const
Return all of the constant properties.