32template<
class CloudType>
39 const word& outPatchName = recyclePatches_[i].first();
41 forAll(nRemoved_[i], injectori)
44 this->writeTabbed(
os, outPatchName +
"_nRemoved_" + suffix);
45 this->writeTabbed(
os, outPatchName +
"_massRemoved_" + suffix);
48 const word& inPatchName = recyclePatches_[i].second();
50 forAll(nInjected_[i], injectori)
53 this->writeTabbed(
os, inPatchName +
"_nInjected_" + suffix);
54 this->writeTabbed(
os, inPatchName +
"_massInjected_" + suffix);
62template<
class CloudType>
71 recyclePatches_(this->coeffDict().
lookup(
"recyclePatches")),
72 recyclePatchesIds_(recyclePatches_.size()),
73 recycledParcels_(recyclePatches_.size()),
74 nRemoved_(recyclePatches_.size()),
75 massRemoved_(nRemoved_.size()),
76 nInjected_(nRemoved_.size()),
77 massInjected_(nRemoved_.size()),
78 injectionPatchPtr_(nRemoved_.size()),
81 this->coeffDict().template getCheck<scalar>
89 this->coeffDict().getOrDefault(
"outputByInjectorId", false)
96 for (
const auto& inj :
cloud.injectors())
132template<
class CloudType>
140 recyclePatches_(pim.recyclePatches_),
141 recyclePatchesIds_(pim.recyclePatchesIds_),
142 nRemoved_(pim.nRemoved_),
143 massRemoved_(pim.massRemoved_),
144 nInjected_(pim.nInjected_),
145 massInjected_(pim.massInjected_),
146 injIdToIndex_(pim.injIdToIndex_),
147 injectionPatchPtr_(),
148 recycleFraction_(pim.recycleFraction_),
149 outputByInjectorId_(pim.outputByInjectorId_)
155template<
class CloudType>
167 ? injIdToIndex_.lookup(
p.typeId(), 0)
173 forAll(recyclePatchesIds_, i)
175 if (recyclePatchesIds_[i].first() == pp.
index())
190 keepParticle =
false;
191 recycledParcels_[addri].append
196 ++nRemoved_[addri][idx];
197 massRemoved_[addri][idx] +=
p.nParticle()*
p.mass();
203template<
class CloudType>
216 auto& rnd = this->owner().rndGen();
218 forAll(recycledParcels_, addri)
220 auto& patchParcels = recycledParcels_[addri];
221 auto& injectionPatch = injectionPatchPtr_[addri];
226 const scalar fraction01 = rnd.template sample01<scalar>();
229 const label toProci = injectionPatch.whichProc(fraction01);
232 auto* osptr = UOPstreamPtrs.
get(toProci);
236 UOPstreamPtrs.
set(toProci, osptr);
240 (*osptr) << addri << fraction01 <<
p;
243 delete(patchParcels.remove(&
p));
256 for (
const int proci : pBufs.
allProcs())
273 injectionPatchPtr_[addri].setPositionAndCell
283 newp->relocate(newPosition, cellOwner);
284 newp->nParticle() *= recycleFraction_;
287 newp->U() = this->owner().U()[cellOwner];
293 ? injIdToIndex_.lookup(newp->typeId(), 0)
297 ++nInjected_[addri][idx];
298 massInjected_[addri][idx] += newp->nParticle()*newp->mass();
300 this->owner().addParticle(newp);
307 forAll(recycledParcels_, addri)
311 parcelType* newp = recycledParcels_[addri].remove(&
p);
317 injectionPatchPtr_[addri].setPositionAndCell
328 newp->relocate(newPosition, cellOwner);
329 newp->nParticle() *= recycleFraction_;
332 newp->U() = this->owner().U()[cellOwner];
338 ? injIdToIndex_.lookup(newp->typeId(), 0)
341 ++nInjected_[addri][idx];
342 massInjected_[addri][idx] += newp->nParticle()*newp->mass();
344 this->owner().addParticle(newp);
351template<
class CloudType>
363 const label lsd = nRemoved_[patchi].size();
370 this->getModelProperty(
"nRemoved", npr0);
371 this->getModelProperty(
"massRemoved", mpr0);
372 this->getModelProperty(
"nInjected", npi0);
373 this->getModelProperty(
"massInjected", mpi0);
381 npr[i] = npr[i] + npr0[i];
388 mpr[i] = mpr[i] + mpr0[i];
395 npi[i] = npi[i] + npi0[i];
402 mpi[i] = mpi[i] + mpi0[i];
405 if (injIdToIndex_.size())
409 labelList indexToInjector(injIdToIndex_.size());
412 indexToInjector[iter.val()] = iter.key();
417 const word& outPatchName = recyclePatches_[i].first();
419 os <<
" Parcel fate: patch " << outPatchName
420 <<
" (number, mass)" <<
nl;
424 os <<
" - removed (injector " << indexToInjector[indexi]
425 <<
") = " << npr[i][indexi]
426 <<
", " << mpr[i][indexi] <<
nl;
429 <<
tab << npr[i][indexi] <<
tab << mpr[i][indexi];
432 const word& inPatchName = recyclePatches_[i].second();
434 os <<
" Parcel fate: patch " << inPatchName
435 <<
" (number, mass)" <<
nl;
439 os <<
" - injected (injector " << indexToInjector[indexi]
440 <<
") = " << npi[i][indexi]
441 <<
", " << mpi[i][indexi] <<
nl;
443 <<
tab << npi[i][indexi] <<
tab << mpi[i][indexi];
447 this->file() <<
endl;
453 const word& outPatchName = recyclePatches_[i].first();
455 os <<
" Parcel fate: patch " << outPatchName
456 <<
" (number, mass)" <<
nl
457 <<
" - removed = " << npr[i][0] <<
", " << mpr[i][0]
461 <<
tab << npr[i][0] <<
tab << mpr[i][0];
466 const word& inPatchName = recyclePatches_[i].second();
468 os <<
" Parcel fate: patch " << inPatchName
469 <<
" (number, mass)" <<
nl
470 <<
" - injected = " << npi[i][0] <<
", " << mpi[i][0]
474 <<
tab << npi[i][0] <<
tab << mpi[i][0];
477 this->file() <<
endl;
480 if (this->writeTime())
482 this->setModelProperty(
"nRemoved", npr);
483 this->setModelProperty(
"massRemoved", mpr);
484 this->setModelProperty(
"nInjected", npi);
485 this->setModelProperty(
"massInjected", mpi);
490 massInjected_ =
Zero;
Templated base class for dsmc cloud.
ParcelType parcelType
Type of parcel the cloud was instantiated for.
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
bool empty() const noexcept
True if the hash table is empty.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
bool eof() const noexcept
True if end of input seen.
void setSize(const label n)
Alias for resize()
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Templated patch interaction model class.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
UPstream::rangeType allProcs() const noexcept
Range of ranks indices associated with PstreamBuffers.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
label recvDataCount(const label proci) const
void finishedSends(const bool wait=true)
Mark sends as done.
static void listCombineGather(const List< commsStruct > &comms, List< T > &values, const CombineOp &cop, const int tag, const label comm)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Patch interaction model to perform parcel transfer and recycle from one patch to another.
virtual void postEvolve()
Post-evolve hook.
const fvMesh & mesh_
Reference to mesh.
List< Pair< label > > recyclePatchesIds_
Patch IDs of recyclePatches.
Map< label > injIdToIndex_
Injector ID to local index map.
List< List< scalar > > massInjected_
Mass of parcels injected.
List< List< label > > nRemoved_
Number of parcels removed.
List< Pair< word > > recyclePatches_
Outlet-inlet patch pair to apply parcel recycling.
List< List< label > > nInjected_
Number of parcels injected.
virtual void writeFileHeader(Ostream &os)
Output file header information.
List< List< scalar > > massRemoved_
Mass of parcels removed.
CloudType::parcelType parcelType
bool outputByInjectorId_
Flag to output escaped/mass particles sorted by injectorID.
PtrList< patchInjectionBase > injectionPatchPtr_
Injection patch pointer.
@ nonBlocking
"nonBlocking"
static bool & parRun() noexcept
Test if this a parallel run.
A cloud is a registry collection of lagrangian particles.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
InfoProxy< ensightCells > info() const
Return info proxy.
A traits class, which is primarily used for primitives.
label index() const noexcept
The index of this patch in the boundaryMesh.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
A patch is a list of labels that address the faces in the global face list.
Lookup type of boundary radiation properties.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static constexpr const zero Zero
Global zero (0)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
constexpr char nl
The newline '\n' character (0x0a)
constexpr char tab
The tab '\t' character(0x09)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.