52 const polyMesh& pMesh,
54 const IOobject::readOption readOption,
55 const IOobject::writeOption writeOption
58 if (!pMesh.foundObject<LagrangianMesh>(
name))
60 wordList wantedPatchTypes(pMesh.boundary().size());
64 const polyPatch& pPatch = pMesh.boundary()[
patchi];
72 LagrangianMesh* lMesh =
85 return pMesh.lookupObjectRef<LagrangianMesh>(
name);
89 #define ACCESS_DERIVED_FIELDS(Type, nullArg) \
93 PtrList<Foam::CloudDerivedField<Type>>& cloud::derivedFields() const \
95 return CAT3(derived, CAPITALIZE(Type), Fields_); \
99 #undef ACCESS_DERIVED_FIELDS
102 void Foam::cloud::clearDerivedFields(
const bool final)
104 #define CLEAR_TYPE_DERIVED_FIELDS(Type, nullArg) \
105 forAll(derivedFields<Type>(), i) \
107 derivedFields<Type>()[i].clear(final); \
110 #undef CLEAR_TYPE_DERIVED_FIELDS
114 #define ACCESS_AVERAGE_FIELDS(Type, nullArg) \
118 PtrList<Foam::CloudAverageField<Type>>& cloud::averageFields() const \
120 return CAT3(average, CAPITALIZE(Type), Fields_); \
124 #undef ACCESS_AVERAGE_FIELDS
127 void Foam::cloud::removeFromAverageFields(
const LagrangianSubMesh& subMesh)
129 #define REMOVE_FROM_TYPE_AVERAGE_FIELDS(Type, nullArg) \
130 forAll(averageFields<Type>(), i) \
132 averageFields<Type>()[i].remove(subMesh); \
135 #undef REMOVE_FROM_TYPE_AVERAGE_FIELDS
139 void Foam::cloud::addToAverageFields
141 const LagrangianSubMesh& subMesh,
145 #define ADD_TO_TYPE_AVERAGE_FIELDS(Type, nullArg) \
146 forAll(averageFields<Type>(), i) \
148 averageFields<Type>()[i].add(subMesh, !final); \
151 #undef ADD_TO_TYPE_AVERAGE_FIELDS
155 void Foam::cloud::correctAverageFields
157 const LagrangianSubMesh& subMesh,
161 #define CORRECT_TYPE_AVERAGE_FIELDS(Type, nullArg) \
162 forAll(averageFields<Type>(), i) \
164 averageFields<Type>()[i].correct(subMesh, !final); \
167 #undef CORRECT_TYPE_AVERAGE_FIELDS
171 void Foam::cloud::clearAverageFields()
173 #define CLEAR_TYPE_AVERAGE_FIELDS(Type, nullArg) \
174 forAll(averageFields<Type>(), i) \
176 averageFields<Type>()[i].clear(true); \
179 #undef CLEAR_TYPE_AVERAGE_FIELDS
183 void Foam::cloud::resetAverageFields()
185 #define RESET_TYPE_AVERAGE_FIELDS(Type, nullArg) \
186 forAll(averageFields<Type>(), i) \
188 averageFields<Type>()[i].reset(); \
191 #undef RESET_TYPE_AVERAGE_FIELDS
210 Foam::cloud::readStates()
const
212 typeIOobject<LagrangianLabelDynamicField> stateIo
218 autoPtr<Foam::LagrangianLabelDynamicField>
228 Foam::cloud::initialStates()
const
231 if (!statePtr_.valid())
return autoPtr<List<LagrangianState>>();
234 autoPtr<List<LagrangianState>> resultPtr
256 void Foam::cloud::clearStates()
262 bool Foam::cloud::storeStates()
265 bool needStates =
false;
269 const LagrangianSubMesh& patchMesh =
270 mesh_.boundary()[
patchi].mesh();
272 if (!patchMesh.empty()) needStates =
true;
275 reduce(needStates, orOp<bool>());
278 if (needStates && !statePtr_.valid())
298 LagrangianModels().modelTypeFieldSourceTypes
301 noneStateLagrangianLabelFieldSource
311 void Foam::cloud::storeStates(
const LagrangianSubMesh& subMesh)
317 const label i = subMesh.start() + subi;
324 statePtr_()[i] =
static_cast<label>(state);
328 mesh_.states()[i] = state;
336 const LagrangianSubMesh& subMesh
345 scalarField(cellLengthScaleVf_, subMesh.sub(mesh_.celli()))
350 void Foam::cloud::track
353 const scalar maxTimeStepFraction,
354 const scalar maxCellLengthScaleFraction
357 const LagrangianSubMesh& subMesh =
fraction.mesh();
366 time().deltaT()*
U(subMesh)
370 if (maxTimeStepFraction < 1)
372 forAll(deltaFraction, subi)
374 if (deltaFraction[subi] > maxTimeStepFraction)
377 deltaFraction[subi] = maxTimeStepFraction;
383 if (maxCellLengthScaleFraction < rootGreat)
387 maxCellLengthScaleFraction
388 *cellLengthScale(subMesh)
396 forAll(deltaFraction, subi)
398 if (deltaFraction[subi] > maxDFraction[subi])
401 deltaFraction[subi] = maxDFraction[subi];
409 case trackingType::linear:
413 LagrangianMesh::linearDisplacement
415 deltaFraction*displacement
422 case trackingType::parabolic:
427 LagrangianMesh::parabolicDisplacement
429 deltaFraction*displacement,
430 sqr(deltaFraction*
time().deltaT())/2*dUdt(subMesh)
441 bool Foam::cloud::writeData(Ostream&)
const
452 clearDerivedFields(
true);
453 clearAverageFields();
462 {
"linear",
"parabolic"};
472 LagrangianModelsPtr_(nullptr),
473 statePtr_(readStates()),
474 cellLengthScaleVf_(
mag(
cbrt(mesh_.poly().cellVolumes()))),
501 LagrangianModelsPtr_(nullptr),
502 statePtr_(readStates()),
503 cellLengthScaleVf_(
mag(
cbrt(mesh_.poly().cellVolumes()))),
535 <<
" with name " <<
name
538 if (!LagrangianMeshConstructorTablePtr_)
545 LagrangianMeshConstructorTable::iterator cstrIter;
547 cstrIter = LagrangianMeshConstructorTablePtr_->find(
type);
549 if (cstrIter == LagrangianMeshConstructorTablePtr_->end())
554 cstrIter = LagrangianMeshConstructorTablePtr_->find(
type);
556 if (cstrIter == LagrangianMeshConstructorTablePtr_->end())
559 <<
"Unknown " <<
typeName <<
" type "
562 << LagrangianMeshConstructorTablePtr_->sortedToc()
577 cloudPtr->LagrangianModels();
599 if (!LagrangianModelsPtr_)
604 return *LagrangianModelsPtr_;
614 clearDerivedFields(
true);
615 if (!initial || !
final)
617 resetAverageFields();
621 clearAverageFields();
625 mesh_.reset(initial,
final);
630 const scalar maxTimeStepFraction =
631 mesh_.solution().lookup<scalar>(
"maxTimeStepFraction");
632 const scalar maxCellLengthScaleFraction =
633 mesh_.solution().lookup<scalar>(
"maxCellLengthScaleFraction");
634 const label nCorrectors = mesh_.solution().lookup<
label>(
"nCorrectors");
657 removeFromAverageFields(preModifiedMesh);
660 addToAverageFields(modifiedMesh,
true);
663 if (reCalculateModified())
665 removeFromAverageFields(modifiedMesh);
674 addToAverageFields(modifiedMesh,
false);
682 correctAverageFields(modifiedMesh,
true);
702 #define EVAL_TYPE_DERIVED_PATCH_FIELDS(Type, GeoField) \
704 HashTable<GeoField<Type>*> fields \
706 mesh_.lookupClass<GeoField<Type>>() \
709 forAllIter(typename HashTable<GeoField<Type>*>, fields, iter) \
711 forAll(mesh_.boundary(), patchi) \
713 const LagrangianPatch& patch = mesh_.boundary()[patchi]; \
717 patch.mesh().size() \
718 && !patch.poly().constraint() \
721 iter()->boundaryFieldRef()[patchi].evaluate \
723 NullObjectNonConstRef<PstreamBuffers>(), \
732 #undef EVAL_TYPE_DERIVED_PATCH_FIELDS
756 removeFromAverageFields(internalMesh);
762 maxCellLengthScaleFraction
767 (internalFraction - internalFraction.
oldTime())
768 *mesh_.time().deltaT()
771 addToAverageFields(internalMesh,
false);
773 for (
label i = 0; i <= nCorrectors; ++ i)
775 const bool final = i == nCorrectors;
783 clearDerivedFields(
final);
784 correctAverageFields(internalMesh,
final);
791 const labelList subMeshGlobalSizes = mesh_.subMeshGlobalSizes();
795 static const label onPatchZeroi =
798 if (subMeshGlobalSizes[onPatchZeroi +
patchi] <= 0)
continue;
802 mesh_.boundary()[
patchi].mesh()
810 removeFromAverageFields(patchMesh);
816 maxCellLengthScaleFraction
819 storeStates(patchMesh);
823 (patchFraction - patchFraction.
oldTime())
824 *mesh_.time().deltaT()
827 addToAverageFields(patchMesh,
false);
829 for (
label i = 0; i <= nCorrectors; ++ i)
831 const bool final = i == nCorrectors;
839 clearDerivedFields(
final);
840 correctAverageFields(patchMesh,
final);
849 removeFromAverageFields(mesh_.subIncomplete());
856 addToAverageFields(mesh_.subIncomplete(),
true);
869 mesh_.storePosition();
875 cellLengthScaleVf_ =
mag(
cbrt(mesh_.poly().cellVolumes()));
881 mesh_.topoChange(map);
883 cellLengthScaleVf_ =
mag(
cbrt(mesh_.poly().cellVolumes()));
891 cellLengthScaleVf_ =
mag(
cbrt(mesh_.poly().cellVolumes()));
897 mesh_.distribute(map);
899 cellLengthScaleVf_ =
mag(
cbrt(mesh_.poly().cellVolumes()));
#define ACCESS_DERIVED_FIELDS(Type, nullArg)
#define CLEAR_TYPE_DERIVED_FIELDS(Type, nullArg)
#define CORRECT_TYPE_AVERAGE_FIELDS(Type, nullArg)
#define REMOVE_FROM_TYPE_AVERAGE_FIELDS(Type, nullArg)
#define RESET_TYPE_AVERAGE_FIELDS(Type, nullArg)
#define ACCESS_AVERAGE_FIELDS(Type, nullArg)
#define ADD_TO_TYPE_AVERAGE_FIELDS(Type, nullArg)
#define CLEAR_TYPE_AVERAGE_FIELDS(Type, nullArg)
#define EVAL_TYPE_DERIVED_PATCH_FIELDS(Type, GeoField)
Functions for calculating the time derivative for a Lagrangian equation.
#define forAll(list, i)
Loop across all elements in list.
static LagrangianModels & New(const word &name, const LagrangianMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const GeoMesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
readOption
Enumeration defining the read options.
const word & name() const
Return name.
writeOption
Enumeration defining the write options.
Class to define the scope of Lagrangian mesh state changes.
Class containing Lagrangian geometry and topology.
static const word fractionName
Name of the tracked fraction field.
List of Lagrangian models, constructed as a (Lagrangian) mesh object. Provides similar functions to t...
void correct()
Correct the LagrangianModels.
virtual void postSource(const LagrangianSubScalarField &deltaT, const bool final)
Hook after source evaluation.
virtual void preSource(const LagrangianSubScalarField &deltaT, const bool final)
Hook before source evaluation.
LagrangianSubMesh preModify(LagrangianMesh &mesh) const
Identify elements in the Lagrangian mesh which are to be.
LagrangianSubMesh modify(LagrangianMesh &mesh, const LagrangianSubMesh &modifiedMesh) const
Instantaneously modify and/or create and remove elements in the.
void calculate(const LagrangianSubScalarField &deltaT, const bool final)
Solve equations and/or update continually changing properties.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
word sub(const word &fieldName) const
Return the name of a field corresponding to this sub-mesh.
static const List< word > & null()
Return a null List.
Initialise the NamedEnum HashTable from the static list of names.
const Field0Type & oldTime() const
Return the old-time field.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
void clear()
Delete object (if the pointer is valid) and set pointer to.
List of references to the cloud function objects. Designed to be constructed temporarily for the scop...
virtual void preCrossFaces(const LagrangianInternalScalarDynamicField &fraction)
Hook before face crossings.
virtual void postCrossFaces(const LagrangianSubScalarSubField &fraction)
Hook following face crossings of a specific sub-mesh.
virtual void calculate(const LagrangianSubScalarField &deltaT, const bool final)
Solve equations and/or update continually changing properties.
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
contextType
Context in which this cloud is used.
virtual void solve(const bool initial, const bool final)
Solve the cloud's evolution over the current time-step.
static autoPtr< cloud > New(const polyMesh &mesh, const word &name, const contextType context, const dictionary &dict, const word &type, const IOobject::readOption readOption=IOobject::READ_IF_PRESENT, const IOobject::writeOption writeOption=IOobject::AUTO_WRITE)
Selectors.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual void storePosition()
Store the positions for use during mapping.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Foam::LagrangianModels & LagrangianModels() const
Access the models.
virtual void movePoints(const polyMesh &)
Update for mesh motion.
static const Foam::cloud & lookup(const LagrangianMesh &mesh)
Lookup the cloud associated with a mesh.
virtual ~cloud()
Destructor.
virtual void partition()
Partition hook.
cloud(LagrangianMesh &mesh, const contextType context)
Construct from a mesh and context. Reads the velocity field.
const LagrangianMesh & mesh() const
Access the mesh.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Motion of the mesh specified as a list of pointMeshMovers.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Mesh consisting of general polyhedral cells.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A class for managing temporary objects.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
A class for handling words, derived from string.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
label calculate(const fvMesh &mesh, const labelHashSet &patchIDs, const scalar minFaceFraction, GeometricField< scalar, GeoMesh > &distance)
Calculate distance data from patches.
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dlLibraryTable libs
Table of loaded dynamic libraries.
List< word > wordList
A List of words.
const dimensionSet & dimless
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
LagrangianState groupToState(const LagrangianGroup &group)
Convert from a state enumeration to the corresponding group enumerations.
const NamedEnum< enum cloud::trackingType, 2 > cloudTrackingNames
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
LagrangianDynamicField< label > LagrangianLabelDynamicField
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dimensionSet & dimLength
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
LagrangianState
Lagrangian state enumeration.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const dimensionSet & dimTime
defineRunTimeSelectionTable(fvConstraint, dictionary)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void cbrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
LagrangianSubSubField< scalar > LagrangianSubScalarSubField
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Ostream & indentOrNl(Ostream &os)
Indent stream or add newline if indent level == 0.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
LagrangianSubField< scalar > LagrangianSubScalarField
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
LagrangianSubField< vector > LagrangianSubVectorField
faceListList boundary(nPatches)