53 const polyMesh& pMesh,
55 const IOobject::readOption readOption,
56 const IOobject::writeOption writeOption
59 if (!pMesh.foundObject<LagrangianMesh>(
name))
61 wordList wantedPatchTypes(pMesh.boundaryMesh().size());
65 const polyPatch& patch = pMesh.boundaryMesh()[
patchi];
70 : cloudVelocityLagrangianPatch::typeName;
73 LagrangianMesh* lMesh =
86 return pMesh.lookupObjectRef<LagrangianMesh>(
name);
90 #define ACCESS_STATE_FIELDS(Type, nullArg) \
94 PtrList<Foam::CloudStateField<Type>>& cloud::stateFields() const \
96 return CAT3(state, CAPITALIZE(Type), Fields_); \
100 #undef ACCESS_STATE_FIELDS
103 void Foam::cloud::clearStateFields()
105 #define CLEAR_TYPE_STATE_FIELDS(Type, nullArg) \
106 forAll(stateFields<Type>(), i) \
108 stateFields<Type>()[i].clear(); \
111 #undef CLEAR_TYPE_STATE_FIELDS
115 #define ACCESS_DERIVED_FIELDS(Type, nullArg) \
119 PtrList<Foam::CloudDerivedField<Type>>& cloud::derivedFields() const \
121 return CAT3(derived, CAPITALIZE(Type), Fields_); \
125 #undef ACCESS_DERIVED_FIELDS
128 void Foam::cloud::clearDerivedFields(
const bool final)
130 #define CLEAR_TYPE_DERIVED_FIELDS(Type, nullArg) \
131 forAll(derivedFields<Type>(), i) \
133 derivedFields<Type>()[i].clear(final); \
136 #undef CLEAR_TYPE_DERIVED_FIELDS
140 #define ACCESS_AVERAGE_FIELDS(Type, nullArg) \
144 PtrList<Foam::CloudAverageField<Type>>& cloud::averageFields() const \
146 return CAT3(average, CAPITALIZE(Type), Fields_); \
150 #undef ACCESS_AVERAGE_FIELDS
153 void Foam::cloud::removeFromAverageFields(
const LagrangianSubMesh& subMesh)
155 #define REMOVE_FROM_TYPE_AVERAGE_FIELDS(Type, nullArg) \
156 forAll(averageFields<Type>(), i) \
158 averageFields<Type>()[i].remove(subMesh); \
161 #undef REMOVE_FROM_TYPE_AVERAGE_FIELDS
165 void Foam::cloud::addToAverageFields
167 const LagrangianSubMesh& subMesh,
171 #define ADD_TO_TYPE_AVERAGE_FIELDS(Type, nullArg) \
172 forAll(averageFields<Type>(), i) \
174 averageFields<Type>()[i].add(subMesh, !final); \
177 #undef ADD_TO_TYPE_AVERAGE_FIELDS
181 void Foam::cloud::correctAverageFields
183 const LagrangianSubMesh& subMesh,
187 #define CORRECT_TYPE_AVERAGE_FIELDS(Type, nullArg) \
188 forAll(averageFields<Type>(), i) \
190 averageFields<Type>()[i].correct(subMesh, !final); \
193 #undef CORRECT_TYPE_AVERAGE_FIELDS
197 void Foam::cloud::clearAverageFields()
199 #define CLEAR_TYPE_AVERAGE_FIELDS(Type, nullArg) \
200 forAll(averageFields<Type>(), i) \
202 averageFields<Type>()[i].clear(true); \
205 #undef CLEAR_TYPE_AVERAGE_FIELDS
209 void Foam::cloud::resetAverageFields()
211 #define RESET_TYPE_AVERAGE_FIELDS(Type, nullArg) \
212 forAll(averageFields<Type>(), i) \
214 averageFields<Type>()[i].reset(); \
217 #undef RESET_TYPE_AVERAGE_FIELDS
236 Foam::cloud::readStates()
const
238 typeIOobject<LagrangianLabelDynamicField> stateIo
244 autoPtr<Foam::LagrangianLabelDynamicField>
254 Foam::cloud::initialStates()
const
257 if (!statePtr_.valid())
return autoPtr<List<LagrangianState>>();
260 autoPtr<List<LagrangianState>> resultPtr
264 List<LagrangianState>& result = resultPtr();
282 void Foam::cloud::clearStates()
288 bool Foam::cloud::storeStates()
291 bool needStates =
false;
295 const LagrangianSubMesh& patchMesh =
296 mesh_.boundary()[
patchi].mesh();
298 if (!patchMesh.empty()) needStates =
true;
301 reduce(needStates, orOp<bool>());
304 if (needStates && !statePtr_.valid())
321 calculatedLagrangianPatchLabelField::typeName
324 LagrangianModels().modelTypeFieldSourceTypes
327 noneStateLagrangianLabelFieldSource
337 void Foam::cloud::storeStates(
const LagrangianSubMesh& subMesh)
343 const label i = subMesh.start() + subi;
350 statePtr_()[i] =
static_cast<label>(state);
354 mesh_.states()[i] = state;
362 const LagrangianSubMesh& subMesh
371 scalarField(cellLengthScaleVf_, subMesh.sub(mesh_.celli()))
376 void Foam::cloud::track
379 const scalar maxTimeStepFraction,
380 const scalar maxCellLengthScaleFraction
383 const LagrangianSubMesh& subMesh = fraction.mesh();
392 time().deltaT()*
U(subMesh)
396 if (maxTimeStepFraction < 1)
398 forAll(deltaFraction, subi)
400 if (deltaFraction[subi] > maxTimeStepFraction)
403 deltaFraction[subi] = maxTimeStepFraction;
409 if (maxCellLengthScaleFraction < rootGreat)
413 maxCellLengthScaleFraction
414 *cellLengthScale(subMesh)
422 forAll(deltaFraction, subi)
424 if (deltaFraction[subi] > maxDFraction[subi])
427 deltaFraction[subi] = maxDFraction[subi];
435 case trackingType::linear:
439 LagrangianMesh::linearDisplacement
441 deltaFraction*displacement
448 case trackingType::parabolic:
453 LagrangianMesh::parabolicDisplacement
455 deltaFraction*displacement,
456 sqr(deltaFraction*time().deltaT())/2*dUdt(subMesh)
467 bool Foam::cloud::writeData(Ostream&)
const
479 clearDerivedFields(
true);
480 clearAverageFields();
487 clearDerivedFields(
true);
488 clearAverageFields();
505 {
"linear",
"parabolic"};
530 LagrangianModelsPtr_(nullptr),
531 statePtr_(readStates()),
532 cellLengthScaleVf_(
mag(
cbrt(mesh_.
mesh().cellVolumes()))),
538 mesh().schemes().schemesDict().lookup<
word>(
"tracking")
568 Info<<
"Selecting " << typeName
569 <<
" with name " <<
name
572 if (!polyMeshConstructorTablePtr_)
575 << typeName <<
"s table is empty"
579 polyMeshConstructorTable::iterator cstrIter;
581 cstrIter = polyMeshConstructorTablePtr_->find(
type);
583 if (cstrIter == polyMeshConstructorTablePtr_->end())
585 libs.
open(
"lib" +
type + typeName.capitalise() +
".so");
588 cstrIter = polyMeshConstructorTablePtr_->find(
type);
590 if (cstrIter == polyMeshConstructorTablePtr_->end())
593 <<
"Unknown " << typeName <<
" type "
595 <<
"Valid " << typeName <<
"s are :" <<
endl
596 << polyMeshConstructorTablePtr_->sortedToc()
603 cloudPtr->LagrangianModels();
625 if (!LagrangianModelsPtr_)
630 return *LagrangianModelsPtr_;
640 bool predict =
false;
641 if (context == contextType::fvModel)
647 solutionControl::typeName
654 solutionControl::typeName
659 if (mesh_.solution().lookup<
bool>(
"outerCorrectors"))
662 resetAverageFields();
684 const scalar maxTimeStepFraction =
685 mesh_.solution().lookup<scalar>(
"maxTimeStepFraction");
686 const scalar maxCellLengthScaleFraction =
687 mesh_.solution().lookup<scalar>(
"maxCellLengthScaleFraction");
688 const label nCorrectors = mesh_.solution().lookup<
label>(
"nCorrectors");
711 removeFromAverageFields(preModifiedMesh);
714 addToAverageFields(modifiedMesh,
true);
717 if (reCalculateModified())
719 removeFromAverageFields(modifiedMesh);
728 addToAverageFields(modifiedMesh,
false);
734 correctAverageFields(modifiedMesh,
true);
754 #define EVAL_TYPE_DERIVED_PATCH_FIELDS(Type, GeoField) \
756 HashTable<GeoField<Type>*> fields \
758 mesh_.lookupClass<GeoField<Type>>() \
761 forAllIter(typename HashTable<GeoField<Type>*>, fields, iter) \
763 forAll(mesh_.boundary(), patchi) \
765 const LagrangianPatch& patch = mesh_.boundary()[patchi]; \
769 patch.mesh().size() \
770 && !polyPatch::constraintType(patch.type()) \
773 iter()->boundaryFieldRef()[patchi].evaluate \
775 NullObjectNonConstRef<PstreamBuffers>(), \
784 #undef EVAL_TYPE_DERIVED_PATCH_FIELDS
805 internalMesh.
sub(fraction)
808 removeFromAverageFields(internalMesh);
814 maxCellLengthScaleFraction
819 (internalFraction - internalFraction.
oldTime())
820 *mesh_.time().deltaT()
823 addToAverageFields(internalMesh,
false);
825 for (
label i = 0; i <= nCorrectors; ++ i)
827 const bool final = i == nCorrectors;
833 clearDerivedFields(
final);
834 correctAverageFields(internalMesh,
final);
843 const labelList subMeshGlobalSizes = mesh_.subMeshGlobalSizes();
847 static const label onPatchZeroi =
850 if (subMeshGlobalSizes[onPatchZeroi +
patchi] <= 0)
continue;
854 mesh_.boundary()[
patchi].mesh()
859 patchMesh.
sub(fraction)
862 removeFromAverageFields(patchMesh);
868 maxCellLengthScaleFraction
871 storeStates(patchMesh);
875 (patchFraction - patchFraction.
oldTime())
876 *mesh_.time().deltaT()
879 addToAverageFields(patchMesh,
false);
881 for (
label i = 0; i <= nCorrectors; ++ i)
883 const bool final = i == nCorrectors;
889 clearDerivedFields(
final);
890 correctAverageFields(patchMesh,
final);
901 removeFromAverageFields(mesh_.subIncomplete());
905 mesh_.crossFaces(fraction);
908 addToAverageFields(mesh_.subIncomplete(),
true);
921 mesh_.storePosition();
927 cellLengthScaleVf_ =
mag(
cbrt(mesh_.mesh().cellVolumes()));
933 mesh_.topoChange(map);
935 cellLengthScaleVf_ =
mag(
cbrt(mesh_.mesh().cellVolumes()));
943 cellLengthScaleVf_ =
mag(
cbrt(mesh_.mesh().cellVolumes()));
949 mesh_.distribute(map);
951 cellLengthScaleVf_ =
mag(
cbrt(mesh_.mesh().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 CLEAR_TYPE_STATE_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)
#define ACCESS_STATE_FIELDS(Type, nullArg)
Functions for calculating the time derivative for a Lagrangian equation.
#define forAll(list, i)
Loop across all elements in list.
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 Mesh &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.
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...
SubList< Type > sub(const List< Type > &list) const
Return a sub-list 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 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.
virtual void preCrossFaces(const LagrangianScalarInternalDynamicField &fraction)
Hook before face crossings.
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 initialise(const bool predict)
Initialisation hook.
cloud(const polyMesh &mesh, const word &name, const contextType context, const IOobject::readOption readOption=IOobject::READ_IF_PRESENT, const IOobject::writeOption writeOption=IOobject::AUTO_WRITE)
Construct from a mesh and a name.
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.
static autoPtr< cloud > New(const polyMesh &mesh, const word &name, const word &type)
Selector.
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.
virtual void calculate(const LagrangianSubScalarField &deltaT, const bool final)
Update the cloud properties.
const LagrangianMesh & mesh() const
Access the mesh.
virtual void solve()
Solve the cloud's evolution over the current time-step.
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
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.
Pimple no-loop control class. Implements various option flags, but leaves loop controls to the deriva...
bool finalIter() const
Flag to indicate the final iteration.
bool firstIter() const
Flag to indicate the first iteration.
label nCorr() const
Maximum number of correctors.
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.
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
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...
const fvMesh & mesh() const
Return the mesh.
A class for managing temporary objects.
A class for handling words, derived from string.
pimpleControl pimple(mesh)
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dlLibraryTable libs
Table of loaded dynamic libraries.
List< word > wordList
A List of words.
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
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
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 dimless
const dimensionSet dimLength
Ostream & incrIndent(Ostream &os)
Increment the indent level.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
LagrangianState
Lagrangian state enumeration.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const dimensionSet dimTime
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void cbrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
LagrangianSubSubField< scalar > LagrangianSubScalarSubField
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
LagrangianSubField< scalar > LagrangianSubScalarField
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)