38 template<
class CloudType>
43 scalar& newVolumeFraction
48 newVolumeFraction = 0.0;
49 bool validInjection =
false;
55 return validInjection;
59 scalar t0 = timeStep0_ - SOI_;
60 scalar t1 = time - SOI_;
63 newParcels = this->parcelsToInject(t0, t1);
67 this->volumeToInject(t0, t1)
68 /(volumeTotal_ + ROOTVSMALL);
70 if (newVolumeFraction > 0)
75 validInjection =
true;
81 validInjection =
false;
87 validInjection =
false;
90 return validInjection;
94 template<
class CloudType>
142 position += SMALL*(cellCentres[celli] - position);
173 <<
"Cannot find parcel injection cell. "
174 <<
"Parcel position = " <<
p0 <<
nl
187 template<
class CloudType>
191 const scalar volumeFraction,
192 const scalar diameter,
197 switch (parcelBasis_)
201 scalar volumep =
pi/6.0*
pow3(diameter);
202 scalar volumeTot = massTotal_/
rho;
204 nP = (volumeFraction*volumeTot + delayedVolume_)/(parcels*volumep);
209 nP = massTotal_/(
rho*volumeTotal_);
214 nP = nParticleFixed_;
221 <<
"Unknown parcelBasis type" <<
nl
230 template<
class CloudType>
233 const label parcelsAdded,
234 const scalar massAdded
239 if (allParcelsAdded > 0)
242 <<
"Cloud: " << this->owner().name()
243 <<
" injector: " << this->modelName() <<
nl
244 <<
" Added " << allParcelsAdded <<
" new parcels" <<
nl <<
endl;
248 parcelsAddedTotal_ += allParcelsAdded;
254 time0_ = this->owner().db().time().value();
263 template<
class CloudType>
268 volumeTotal_(this->template getModelProperty<scalar>(
"volumeTotal")),
270 massFlowRate_(owner.db().time(),
"massFlowRate"),
271 massInjected_(this->template getModelProperty<scalar>(
"massInjected")),
272 nInjections_(this->template getModelProperty<label>(
"nInjections")),
275 this->template getModelProperty<scalar>(
"parcelsAddedTotal")
277 parcelBasis_(pbNumber),
278 nParticleFixed_(0.0),
280 timeStep0_(this->template getModelProperty<scalar>(
"timeStep0")),
281 minParticlesPerParcel_(1),
284 ignoreOutOfBounds_(false)
288 template<
class CloudType>
293 const word& modelName,
294 const word& modelType
299 volumeTotal_(this->
template getModelProperty<scalar>(
"volumeTotal")),
301 massFlowRate_(owner.db().time(),
"massFlowRate"),
302 massInjected_(this->
template getModelProperty<scalar>(
"massInjected")),
303 nInjections_(this->
template getModelProperty<scalar>(
"nInjections")),
306 this->
template getModelProperty<scalar>(
"parcelsAddedTotal")
308 parcelBasis_(pbNumber),
309 nParticleFixed_(0.0),
310 time0_(owner.db().time().value()),
311 timeStep0_(this->
template getModelProperty<scalar>(
"timeStep0")),
312 minParticlesPerParcel_
314 this->coeffDict().getOrDefault(
"minParticlesPerParcel", scalar(1))
317 injectorID_(this->coeffDict().getOrDefault(
"injectorID", -1)),
320 this->coeffDict().getOrDefault(
"ignoreOutOfBounds",
false)
329 if (injectorID_ != -1)
331 Info<<
" injector ID: " << injectorID_ <<
endl;
334 if (owner.solution().active())
336 if (owner.solution().transient())
338 this->coeffDict().readEntry(
"massTotal", massTotal_);
339 this->coeffDict().readEntry(
"SOI", SOI_);
343 massFlowRate_.reset(this->coeffDict());
344 massTotal_ = massFlowRate_.value(owner.db().time().value());
345 this->coeffDict().readIfPresent(
"SOI", SOI_);
349 SOI_ = owner.db().time().userTimeToTime(SOI_);
351 const word parcelBasisType(this->coeffDict().getWord(
"parcelBasisType"));
353 if (parcelBasisType ==
"mass")
355 parcelBasis_ = pbMass;
357 else if (parcelBasisType ==
"number")
359 parcelBasis_ = pbNumber;
361 else if (parcelBasisType ==
"fixed")
363 parcelBasis_ = pbFixed;
364 this->coeffDict().readEntry(
"nParticle", nParticleFixed_);
366 Info<<
" Choosing nParticle to be a fixed value, massTotal "
367 <<
"variable now does not determine anything."
373 <<
"parcelBasisType must be either 'number', 'mass' or 'fixed'"
379 template<
class CloudType>
406 template<
class CloudType>
411 template<
class CloudType>
415 if (this->owner().
solution().
transient())
417 nTotal = parcelsToInject(0.0, timeEnd() - timeStart());
421 nTotal = parcelsToInject(0.0, 1.0);
424 return massTotal_/nTotal;
428 template<
class CloudType>
429 template<
class TrackCloudType>
432 TrackCloudType&
cloud,
433 typename CloudType::parcelType::trackingData& td
441 const scalar time = this->owner().db().time().value();
444 label parcelsAdded = 0;
445 scalar massAdded = 0.0;
446 label newParcels = 0;
447 scalar newVolumeFraction = 0.0;
448 scalar delayedVolume = 0;
450 if (prepareForNextTimeStep(time, newParcels, newVolumeFraction))
452 const scalar trackTime = this->owner().solution().trackTime();
456 const scalar deltaT =
457 max(0.0,
min(trackTime,
min(time - SOI_, timeEnd() - time0_)));
460 const scalar padTime =
max(0.0, SOI_ - time0_);
463 for (label parcelI = 0; parcelI < newParcels; parcelI++)
465 if (validInjection(parcelI))
468 scalar timeInj = time0_ + padTime + deltaT*parcelI/newParcels;
492 const scalar dt = time - timeInj;
501 cloud.setParcelThermoProperties(*pPtr, dt);
504 setProperties(parcelI, newParcels, timeInj, *pPtr);
507 cloud.checkParcelProperties(*pPtr, dt, fullyDescribed());
527 if (pPtr->nParticle() >= minParticlesPerParcel_)
530 massAdded += pPtr->nParticle()*pPtr->mass();
532 if (pPtr->move(
cloud, td, dt))
534 pPtr->typeId() = injectorID_;
535 cloud.addParticle(pPtr);
544 delayedVolume += pPtr->nParticle()*pPtr->volume();
554 postInjectCheck(parcelsAdded, massAdded);
558 template<
class CloudType>
559 template<
class TrackCloudType>
562 TrackCloudType&
cloud,
563 typename CloudType::parcelType::trackingData& td,
564 const scalar trackTime
572 const scalar time = this->owner().db().time().value();
585 label parcelsAdded = 0;
586 scalar massAdded = 0.0;
589 label newParcels = parcelsToInject(0.0, 1.0);
592 for (label parcelI = 0; parcelI < newParcels; parcelI++)
595 scalar newVolumeFraction = 1.0/scalar(newParcels);
625 cloud.setParcelThermoProperties(*pPtr, 0.0);
628 setProperties(parcelI, newParcels, 0.0, *pPtr);
631 cloud.checkParcelProperties(*pPtr, 0.0, fullyDescribed());
646 pPtr->typeId() = injectorID_;
649 cloud.addParticle(pPtr);
651 massAdded += pPtr->nParticle()*pPtr->mass();
656 postInjectCheck(parcelsAdded, massAdded);
660 template<
class CloudType>
663 os <<
" Injector " << this->modelName() <<
":" <<
nl
664 <<
" - parcels added = " << parcelsAddedTotal_ <<
nl
665 <<
" - mass introduced = " << massInjected_ <<
nl;
667 if (this->writeTime())
669 this->setModelProperty(
"volumeTotal", volumeTotal_);
670 this->setModelProperty(
"massInjected", massInjected_);
671 this->setModelProperty(
"nInjections", nInjections_);
672 this->setModelProperty(
"parcelsAddedTotal", parcelsAddedTotal_);
673 this->setModelProperty(
"timeStep0", timeStep0_);