32 template<
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);
62 template<
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())
132 template<
class CloudType>
135 const RecycleInteraction<CloudType>& pim
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_)
155 template<
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
193 static_cast<parcelType*
>(
p.
clone().ptr())
196 ++nRemoved_[addri][idx];
197 massRemoved_[addri][idx] +=
p.nParticle()*
p.mass();
203 template<
class CloudType>
213 auto& rnd = this->owner().rndGen();
215 forAll(recycledParcels_, addri)
217 auto& patchParcels = recycledParcels_[addri];
218 auto& injectionPatch = injectionPatchPtr_[addri];
223 const scalar fraction01 = rnd.template sample01<scalar>();
226 const label toProci = injectionPatch.whichProc(fraction01);
229 transferParcels[toProci].
append(patchParcels.remove(pIter));
231 patchAddr[toProci].
append(addri);
242 forAll(transferParcels, proci)
244 if (transferParcels[proci].size())
249 << transferParcels[proci]
253 transferParcels[proci].
clear();
260 bool transferred =
false;
261 for (
const label
n : allNTrans)
279 if (allNTrans[proci])
285 typename parcelType::iNew(this->owner().
mesh())
291 for (parcelType& newp : newParticles)
297 const label addri = patchAddr[parceli];
298 injectionPatchPtr_[addri].setPositionAndCell
308 newp.relocate(newPosition, cellOwner);
309 newp.U() = this->owner().U()[cellOwner];
310 newp.nParticle() *= recycleFraction_;
315 ? injIdToIndex_.lookup(newp.typeId(), 0)
318 ++nInjected_[addri][idx];
319 massInjected_[addri][idx] += newp.nParticle()*newp.mass();
321 this->owner().addParticle(newParticles.remove(&newp));
329 forAll(recycledParcels_, addri)
337 injectionPatchPtr_[addri].setPositionAndCell
348 parcelType* newp = recycledParcels_[addri].remove(iter);
349 newp->relocate(newPosition, cellOwner);
350 newp->nParticle() *= recycleFraction_;
353 newp->U() = this->owner().U()[cellOwner];
358 ? injIdToIndex_.lookup(newp->typeId(), 0)
361 ++nInjected_[addri][idx];
362 massInjected_[addri][idx] += newp->nParticle()*newp->mass();
364 this->owner().addParticle(newp);
371 template<
class CloudType>
383 label lsd = nRemoved_[patchi].size();
384 npr0[patchi].setSize(lsd,
Zero);
385 mpr0[patchi].setSize(lsd,
Zero);
386 npi0[patchi].setSize(lsd,
Zero);
387 mpi0[patchi].setSize(lsd,
Zero);
390 this->getModelProperty(
"nRemoved", npr0);
391 this->getModelProperty(
"massRemoved", mpr0);
392 this->getModelProperty(
"nInjected", npi0);
393 this->getModelProperty(
"massInjected", mpi0);
401 npr[i] = npr[i] + npr0[i];
408 mpr[i] = mpr[i] + mpr0[i];
415 npi[i] = npi[i] + npi0[i];
422 mpi[i] = mpi[i] + mpi0[i];
425 if (injIdToIndex_.size())
429 labelList indexToInjector(injIdToIndex_.size());
432 indexToInjector[iter.val()] = iter.key();
437 const word& outPatchName = recyclePatches_[i].first();
439 os <<
" Parcel fate: patch " << outPatchName
440 <<
" (number, mass)" <<
nl;
444 os <<
" - removed (injector " << indexToInjector[indexi]
445 <<
") = " << npr[i][indexi]
446 <<
", " << mpr[i][indexi] <<
nl;
449 <<
tab << npr[i][indexi] <<
tab << mpr[i][indexi];
452 const word& inPatchName = recyclePatches_[i].second();
454 os <<
" Parcel fate: patch " << inPatchName
455 <<
" (number, mass)" <<
nl;
459 os <<
" - injected (injector " << indexToInjector[indexi]
460 <<
") = " << npi[i][indexi]
461 <<
", " << mpi[i][indexi] <<
nl;
463 <<
tab << npi[i][indexi] <<
tab << mpi[i][indexi];
467 this->file() <<
endl;
473 const word& outPatchName = recyclePatches_[i].first();
475 os <<
" Parcel fate: patch " << outPatchName
476 <<
" (number, mass)" <<
nl
477 <<
" - removed = " << npr[i][0] <<
", " << mpr[i][0]
481 <<
tab << npr[i][0] <<
tab << mpr[i][0];
486 const word& inPatchName = recyclePatches_[i].second();
488 os <<
" Parcel fate: patch " << inPatchName
489 <<
" (number, mass)" <<
nl
490 <<
" - injected = " << npi[i][0] <<
", " << mpi[i][0]
494 <<
tab << npi[i][0] <<
tab << mpi[i][0];
497 this->file() <<
endl;
500 if (this->writeTime())
502 this->setModelProperty(
"nRemoved", npr);
503 this->setModelProperty(
"massRemoved", mpr);
504 this->setModelProperty(
"nInjected", npi);
505 this->setModelProperty(
"massInjected", mpi);
510 massInjected_ =
Zero;