49 template<
class CloudType>
52 dispersionModel_.reset
61 patchInteractionModel_.reset
70 stochasticCollisionModel_.reset
79 surfaceFilmModel_.reset
120 solution_.integrationSchemes()
126 template<
class CloudType>
127 template<
class TrackCloudType>
130 TrackCloudType&
cloud,
131 typename parcelType::trackingData&
td 136 log = solution_.log();
138 if (solution_.steadyState())
146 if (solution_.coupled())
155 evolveCloud(cloud,
td);
157 if (solution_.coupled())
159 cloud.scaleSources();
165 cloud.postEvolve(
td);
167 if (solution_.steadyState())
169 cloud.restoreState();
174 template<
class CloudType>
177 if (!cellOccupancyPtr_)
179 cellOccupancyPtr_.reset
181 new List<DynamicList<parcelType*>>(mesh_.nCells())
184 else if (cellOccupancyPtr_().size() != mesh_.nCells())
189 cellOccupancyPtr_().setSize(mesh_.nCells());
192 List<DynamicList<parcelType*>>&
cellOccupancy = cellOccupancyPtr_();
199 for (parcelType&
p : *
this)
206 template<
class CloudType>
212 if (cellOccupancyPtr_)
214 buildCellOccupancy();
219 template<
class CloudType>
220 template<
class TrackCloudType>
223 TrackCloudType& cloud,
224 typename parcelType::trackingData&
td 227 if (solution_.coupled())
229 cloud.resetSourceTerms();
232 if (solution_.transient())
234 label preInjectionSize = this->size();
240 if (preInjectionSize != this->size())
242 updateCellOccupancy();
243 preInjectionSize = this->size();
246 injectors_.inject(cloud,
td);
250 cloud.motion(cloud,
td);
252 stochasticCollision().update(
td, solution_.trackTime());
258 injectors_.injectSteadyState(cloud,
td, solution_.trackTime());
260 td.part() = parcelType::trackingData::tpLinearTrack;
261 CloudType::move(
cloud,
td, solution_.trackTime());
266 template<
class CloudType>
269 const typename parcelType::trackingData&
td 276 this->writePositions();
279 this->dispersion().cacheFields(
false);
281 this->patchInteraction().postEvolve();
283 forces_.cacheFields(
false);
285 functions_.postEvolve(
td);
287 solution_.nextIter();
289 if (this->db().time().writeTime())
291 outputProperties_.writeObject
295 IOstreamOption::ASCII,
296 this->db().time().writeCompression()
302 if (this->dampingModel().active())
304 this->dampingModel().cacheFields(
false);
306 if (this->packingModel().active())
308 this->packingModel().cacheFields(
false);
313 template<
class CloudType>
316 CloudType::cloudReset(
c);
320 forces_.transfer(
c.forces_);
322 functions_.transfer(
c.functions_);
324 injectors_.transfer(
c.injectors_);
326 dispersionModel_.reset(
c.dispersionModel_.ptr());
327 patchInteractionModel_.reset(
c.patchInteractionModel_.ptr());
328 stochasticCollisionModel_.reset(
c.stochasticCollisionModel_.ptr());
329 surfaceFilmModel_.reset(
c.surfaceFilmModel_.ptr());
331 packingModel_.reset(
c.packingModel_.ptr());
332 dampingModel_.reset(
c.dampingModel_.ptr());
333 isotropyModel_.reset(
c.isotropyModel_.ptr());
335 UIntegrator_.reset(
c.UIntegrator_.ptr());
341 template<
class CloudType>
354 cloudCopyPtr_(nullptr),
361 mesh_.time().constant(),
363 IOobject::READ_MODIFIED,
376 IOobject::READ_IF_PRESENT,
381 solution_(mesh_, particleProperties_.subDict(
"solution")),
382 constProps_(particleProperties_),
385 particleProperties_.subOrEmptyDict
392 rndGen_(Pstream::myProcNo()),
394 cellLengthScale_(
mag(
cbrt(mesh_.V()))),
404 subModelProperties_.subOrEmptyDict
415 particleProperties_.subOrEmptyDict(
"cloudFunctions"),
420 subModelProperties_.subOrEmptyDict(
"injectionModels"),
423 dispersionModel_(nullptr),
424 patchInteractionModel_(nullptr),
425 stochasticCollisionModel_(nullptr),
426 surfaceFilmModel_(nullptr),
428 packingModel_(nullptr),
429 dampingModel_(nullptr),
430 isotropyModel_(nullptr),
432 UIntegrator_(nullptr),
439 IOobject::scopedName(this->
name(),
"rhokTrans"),
442 IOobject::READ_IF_PRESENT,
443 IOobject::AUTO_WRITE,
456 IOobject::scopedName(this->
name(),
"UTrans"),
459 IOobject::READ_IF_PRESENT,
460 IOobject::AUTO_WRITE,
473 IOobject::scopedName(this->
name(),
"UCoeff"),
476 IOobject::READ_IF_PRESENT,
477 IOobject::AUTO_WRITE,
486 if (solution_.active())
493 this->deleteLostParticles();
497 if (solution_.resetSourcesOnStartup())
504 template<
class CloudType>
507 KinematicCloud<CloudType>&
c,
513 cloudCopyPtr_(nullptr),
515 particleProperties_(
c.particleProperties_),
516 outputProperties_(
c.outputProperties_),
517 solution_(
c.solution_),
518 constProps_(
c.constProps_),
519 subModelProperties_(
c.subModelProperties_),
520 rndGen_(
c.rndGen_, true),
521 cellOccupancyPtr_(nullptr),
522 cellLengthScale_(
c.cellLengthScale_),
527 pAmbient_(
c.pAmbient_),
529 functions_(
c.functions_),
530 injectors_(
c.injectors_),
531 dispersionModel_(
c.dispersionModel_->clone()),
532 patchInteractionModel_(
c.patchInteractionModel_->clone()),
533 stochasticCollisionModel_(
c.stochasticCollisionModel_->clone()),
534 surfaceFilmModel_(
c.surfaceFilmModel_->clone()),
536 packingModel_(
c.packingModel_->clone()),
537 dampingModel_(
c.dampingModel_->clone()),
538 isotropyModel_(
c.isotropyModel_->clone()),
540 UIntegrator_(
c.UIntegrator_->clone()),
547 IOobject::scopedName(this->
name(),
"rhokTrans"),
552 IOobject::NO_REGISTER
563 IOobject::scopedName(this->
name(),
"UTrans"),
568 IOobject::NO_REGISTER
579 IOobject::scopedName(this->
name(),
"UCoeff"),
584 IOobject::NO_REGISTER
593 template<
class CloudType>
603 cloudCopyPtr_(nullptr),
610 mesh_.time().constant(),
621 name +
"OutputProperties",
632 subModelProperties_(),
634 cellOccupancyPtr_(nullptr),
635 cellLengthScale_(
c.cellLengthScale_),
640 pAmbient_(
c.pAmbient_),
641 forces_(*this,
mesh),
644 dispersionModel_(nullptr),
645 patchInteractionModel_(nullptr),
646 stochasticCollisionModel_(nullptr),
647 surfaceFilmModel_(nullptr),
649 packingModel_(nullptr),
650 dampingModel_(nullptr),
651 isotropyModel_(nullptr),
653 UIntegrator_(nullptr),
663 template<
class CloudType>
667 const scalar lagrangianDt
671 if (constProps_.rho0() != -1)
673 parcel.rho() = constProps_.rho0();
678 template<
class CloudType>
682 const scalar lagrangianDt,
683 const bool fullyDescribed
686 const scalar carrierDt = mesh_.time().deltaTValue();
687 parcel.stepFraction() = (carrierDt - lagrangianDt)/carrierDt;
689 if (parcel.typeId() == -1)
691 parcel.typeId() = constProps_.parcelTypeId();
694 if (parcel.rho() == -1)
697 <<
"The kinematic cloud needs rho0 in the constantProperties " 698 <<
" dictionary. " <<
nl 704 template<
class CloudType>
709 static_cast<KinematicCloud<CloudType>*
> 711 clone(this->
name() +
"Copy").ptr()
717 template<
class CloudType>
720 cloudReset(cloudCopyPtr_());
721 cloudCopyPtr_.clear();
725 template<
class CloudType>
728 rhokTrans().field() =
Zero;
729 UTrans().field() =
Zero;
734 template<
class CloudType>
743 const scalar coeff = solution_.relaxCoeff(
name);
748 template<
class CloudType>
756 const scalar coeff = solution_.relaxCoeff(
name);
761 template<
class CloudType>
768 this->
relax(UTrans_(), cloudOldTime.
UTrans(),
"U");
769 this->
relax(UCoeff_(), cloudOldTime.
UCoeff(),
"U");
773 template<
class CloudType>
776 this->scale(rhokTrans_(),
"rhok");
777 this->scale(UTrans_(),
"U");
778 this->scale(UCoeff_(),
"U");
782 template<
class CloudType>
785 const typename parcelType::trackingData&
td 790 label nGeometricD = mesh_.nGeometricD();
792 Log_<<
"\nSolving" << nGeometricD <<
"-D cloud " << this->
name() <<
endl;
794 this->dispersion().cacheFields(
true);
795 forces_.cacheFields(
true);
797 pAmbient_ = constProps_.dict().template
798 getOrDefault<scalar>(
"pAmbient", pAmbient_);
800 if (this->dampingModel().active() || this->packingModel().active())
802 const_cast<typename parcelType::trackingData&
>(
td).updateAverages(*
this);
805 if (this->dampingModel().active())
807 this->dampingModel().cacheFields(
true);
809 if (this->packingModel().active())
811 this->packingModel().cacheFields(
true);
814 updateCellOccupancy();
816 functions_.preEvolve(
td);
820 template<
class CloudType>
823 if (solution_.canEvolve())
825 typename parcelType::trackingData
td(*
this);
831 template<
class CloudType>
832 template<
class TrackCloudType>
835 TrackCloudType& cloud,
836 typename parcelType::trackingData&
td 839 td.part() = parcelType::trackingData::tpLinearTrack;
840 CloudType::move(cloud,
td, solution_.trackTime());
842 if (isotropyModel_->active())
844 td.updateAverages(cloud);
845 isotropyModel_->calculate();
848 updateCellOccupancy();
852 template<
class CloudType>
867 if (isA<wallPolyPatch>(
pp))
869 const label patchi =
pp.index();
870 const label patchFacei =
pp.whichFace(
p.face());
876 if (U_.boundaryField()[patchi].fixesValue())
878 const vector Uw1(U_.boundaryField()[patchi][patchFacei]);
880 U_.oldTime().boundaryField()[patchi][patchFacei];
882 const scalar
f =
p.currentTimeFraction();
884 const vector Uw(Uw0 +
f*(Uw1 - Uw0));
888 Up = (nnw & Up) + Uw - (nnw & Uw);
894 template<
class CloudType>
897 updateCellOccupancy();
898 injectors_.updateMesh();
899 cellLengthScale_ =
mag(
cbrt(mesh_.V()));
903 template<
class CloudType>
912 template<
class CloudType>
915 const vector linearMomentum =
918 const scalar linearKineticEnergy =
923 const scalar particlePerParcel =
931 <<
" Current number of parcels = " << nTotParcel <<
nl 932 <<
" Current mass in system = " 934 <<
" Linear momentum = " << linearMomentum <<
nl 935 <<
" |Linear momentum| = " <<
mag(linearMomentum) <<
nl 936 <<
" Linear kinetic energy = " << linearKineticEnergy <<
nl 937 <<
" Average particle per parcel = " << particlePerParcel <<
nl;
942 this->patchInteraction().info();
944 if (this->packingModel().active())
948 if (this->db().time().writeTime())
953 const scalar alphaMin =
gMin(
alpha().primitiveField());
956 Log_<<
" Min cell volume fraction = " << alphaMin <<
nl 981 reduce(nMin, minOp<scalar>());
983 Log_<<
" Min dense number of parcels = " << nMin <<
endl;
988 template<
class CloudType>
991 parcelType::readObjects(*
this, obr);
995 template<
class CloudType>
998 parcelType::writeObjects(*
this, obr);
Template class for intrusive linked lists.
DSMCCloud< dsmcParcel > CloudType
void scaleSources()
Apply scaling to (transient) cloud sources.
void setModels()
Set cloud sub-models.
void relaxSources(const KinematicCloud< CloudType > &cloudOldTime)
Apply relaxation to (steady state) cloud sources.
void storeState()
Store the current cloud state.
dimensionedScalar log(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type gMin(const FieldField< Field, Type > &f)
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
void evolveCloud(TrackCloudType &cloud, typename parcelType::trackingData &td)
Evolve the cloud.
constexpr char nl
The newline '\n' character (0x0a)
void setParcelThermoProperties(parcelType &parcel, const scalar lagrangianDt)
Set parcel thermo properties.
void postEvolve(const typename parcelType::trackingData &td)
Post-evolve.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void relax(DimensionedField< Type, volMesh > &field, const DimensionedField< Type, volMesh > &field0, const word &name) const
Relax field.
volVectorField::Internal & UTrans()
Return reference to momentum source.
Base class for packing models.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
virtual void writeObjects(objectRegistry &obr) const
Write particle fields as objects into the obr registry.
GeometricField< vector, fvPatchField, volMesh > volVectorField
void updateCellOccupancy()
Update (i.e. build) the cellOccupancy if it has.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
void buildCellOccupancy()
Build the cellOccupancy.
Templated patch interaction model class.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
void updateMesh()
Update mesh.
dimensionedScalar alphaMax("alphaMax", dimless/dimTime, laminarTransport)
volScalarField::Internal & rhokTrans()
Return reference to mass for kinematic source.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
#define Log_
Report write to Foam::Info if the class log switch is true.
volScalarField::Internal & UCoeff()
Return coefficient for carrier phase U equation.
void resetSourceTerms()
Reset the cloud source terms.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
const word cloudName(propsDict.get< word >("cloud"))
A class for handling words, derived from Foam::string.
void motion(TrackCloudType &cloud, typename parcelType::trackingData &td)
Particle motion.
A cloud is a registry collection of lagrangian particles.
virtual void readObjects(const objectRegistry &obr)
Read particle fields from objects in the obr registry.
dimensionedScalar cbrt(const dimensionedScalar &ds)
void checkParcelProperties(parcelType &parcel, const scalar lagrangianDt, const bool fullyDescribed)
Check parcel properties.
errorManip< error > abort(error &err)
Base cloud calls templated on particle type.
const uniformDimensionedVectorField & g
regionModels::surfaceFilmModel & surfaceFilm
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
Type gMax(const FieldField< Field, Type > &f)
Templated wall surface film model class.
const dimensionedScalar mu
Atomic mass unit.
Base class for collisional return-to-isotropy models.
void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve.
Virtual abstract base class for templated KinematicCloud.
Templated base class for kinematic cloud.
void patchData(const parcelType &p, const polyPatch &pp, vector &normal, vector &Up) const
Calculate the patch normal and velocity to interact with,.
const List< DynamicList< molecule * > > & cellOccupancy
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
void evolve()
Evolve the cloud.
Templated stochastic collision model class.
Mesh data needed to do the Finite Volume discretisation.
const dimensionedScalar c
Speed of light in a vacuum.
Base class for dispersion modelling.
void info()
Print cloud information.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
return returnReduce(nRefine-oldNRefine, sumOp< label >())
void restoreState()
Reset the current cloud to the previously stored state.
void scale(DimensionedField< Type, volMesh > &field, const word &name) const
Scale field.
void cloudReset(KinematicCloud< CloudType > &c)
Reset state of cloud.
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
A class for managing temporary objects.
Registry of regIOobjects.
virtual void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the.
A patch is a list of labels that address the faces in the global face list.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Tensor of scalars, i.e. Tensor<scalar>.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Templated base class for dsmc cloud.
Base class for collisional damping models.
void solve(TrackCloudType &cloud, typename parcelType::trackingData &td)
Solve the cloud - calls all evolution functions.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)
const dimensionSet dimVelocity