41 namespace functionObjects
59 {
"faceZone",
"faceSet",
"patch"};
64 Foam::wordList Foam::functionObjects::cloudSurfaceDistribution::readFields
66 const dictionary&
dict,
71 const bool haveFields =
dict.found(key +
"s");
72 const bool haveField =
dict.found(key);
74 if (
notNull(defaultValue) && !haveFields && !haveField)
79 if (haveFields == haveField)
82 <<
"keywords " << key <<
"s and " << key <<
" both "
83 << (haveFields ?
"" :
"un") <<
"defined in "
84 <<
"dictionary " <<
dict.name()
100 Foam::functionObjects::cloudSurfaceDistribution::readSelectionType
102 const dictionary&
dict
106 if (
dict.found(
"select"))
108 return selectionTypeNames.read(
dict.lookup(
"select"));
118 if (!
dict.found(keys[i]))
continue;
124 return selectionTypeNames[keys[keyi]];
128 return selectionTypeNames.read(
dict.lookup(
"select"));
133 Foam::functionObjects::cloudSurfaceDistribution::componentNames
138 #define FIELD_RANGE_COMPONENT_NAMES(Type, GeoField) \
139 if (mesh().foundObject<GeoField<Type>>(fields_[fieldi])) \
141 return pTraits<Type>::componentNames; \
152 void Foam::functionObjects::cloudSurfaceDistribution::readCoeffs
154 const dictionary&
dict,
159 const hashedWordList oldFields(fields_);
163 bool continued =
false;
166 continued = continued || oldFields.found(fields_[fieldi]);
170 const wordList oldWeightFields(weightFields_);
172 if (continued && weightFields_ != oldWeightFields)
175 <<
"Cannot change weight fields at run-time"
180 const selectionType oldSelectionType = selectionType_;
181 selectionType_ = readSelectionType(
dict);
182 const word oldSelectionName = selectionName_;
183 selectionName_ =
dict.lookup<word>(selectionTypeNames[selectionType_]);
186 selectionType_ != oldSelectionType
187 || selectionName_ != oldSelectionName
191 <<
"Cannot change the selected surface at run-time"
196 const label oldNBins = nBins_;
198 if (continued && nBins_ != oldNBins)
201 <<
"Cannot change the number of bins at run-time"
213 if (fields_ != oldFields)
215 List<List<scalarField>> oldSums;
216 oldSums.transfer(sums_);
217 sums_.resize(fields_.size());
219 List<List<Pair<scalar>>> oldRanges;
220 oldRanges.transfer(ranges_);
221 ranges_.resize(fields_.size());
225 nSamples_.resize(fields_.size());
229 if (!oldFields.found(fields_[fieldi]))
continue;
231 const label oldFieldi = oldFields[fields_[fieldi]];
233 sums_[fieldi].transfer(oldSums[oldFieldi]);
234 ranges_[fieldi].transfer(oldRanges[oldFieldi]);
235 nSamples_[fieldi] = oldNSamples[oldFieldi];
241 Foam::IOobject Foam::functionObjects::cloudSurfaceDistribution::propsDictIo
249 name() +
"Properties",
260 Foam::boolList Foam::functionObjects::cloudSurfaceDistribution::selected
267 const polyBoundaryMesh& pbm =
c.mesh().mesh().boundaryMesh();
272 static_cast<label>(fraction.mesh().group())
277 const List<LagrangianState> states =
279 ? List<LagrangianState>(fraction.mesh().sub(
c.mesh().states()))
284 const SubField<label> facei = fraction.mesh().sub(
c.mesh().facei());
286 boolList result(facei.size(),
false);
288 switch (selectionType_)
290 case selectionType::faceZone:
292 const faceZone& z =
c.mesh().mesh().faceZones()[selectionName_];
296 result = z.lookupMap().found(facei[subi]);
300 case selectionType::faceSet:
305 result = selectionSet_.found(facei[subi]);
309 case selectionType::patch:
311 result =
patchi == pbm[selectionName_].index();
320 template<
template<
class>
class GeoField>
321 bool Foam::functionObjects::cloudSurfaceDistribution::multiplyWeight
323 const LagrangianSubMesh& subMesh,
324 const label weightFieldi,
328 if (!
mesh().foundObject<GeoField<scalar>>(weightFields_[weightFieldi]))
331 const GeoField<scalar>& w =
334 weight *= subMesh.sub(w.primitiveField());
340 template<
template<
class>
class GeoField,
class Type>
341 bool Foam::functionObjects::cloudSurfaceDistribution::addField
343 const LagrangianSubMesh& subMesh,
349 if (!
mesh().foundObject<GeoField<Type>>(fields_[fieldi]))
return false;
351 const GeoField<Type>& field =
355 if (sums_[fieldi].empty())
357 sums_[fieldi].resize(pTraits<Type>::nComponents);
358 ranges_[fieldi].resize(pTraits<Type>::nComponents);
360 for (
direction d = 0; d < pTraits<Type>::nComponents; ++ d)
362 sums_[fieldi][d].resize(nBins_ + 1, scalar(0));
363 ranges_[fieldi][d] = Pair<scalar>(vGreat, -vGreat);
366 nSamples_[fieldi] = 0;
370 for (
direction d = 0; d < pTraits<Type>::nComponents; ++ d)
372 Pair<scalar>&
range = ranges_[fieldi][d];
373 const Pair<scalar> range0 = ranges_[fieldi][d];
376 bool rangeHasChanged =
false;
380 if (!selected[subi])
continue;
382 const scalar
x =
component(field[subMesh.start() + subi], d);
387 rangeHasChanged =
true;
393 rangeHasChanged =
true;
398 reduce(rangeHasChanged, orOp<bool>());
407 if (rangeHasChanged && nSamples_[fieldi])
411 sums_[fieldi][d].resize(nBins_ + 1, scalar(0));
416 (1 - scalar(nodei0)/nBins_)*range0.first()
417 + scalar(nodei0)/nBins_*range0.second();
421 const label bini =
min(
max(floor(
f*nBins_), 0), nBins_ - 1);
422 const scalar g =
f*nBins_ - scalar(bini);
424 sums_[fieldi][d][bini] += sum0[nodei0]*(1 - g);
425 sums_[fieldi][d][bini + 1] += sum0[nodei0]*g;
432 if (!selected[subi])
continue;
434 const scalar
x =
component(field[subMesh.start() + subi], d);
438 const label bini =
min(
max(floor(
f*nBins_), 0), nBins_ - 1);
439 const scalar g =
f*nBins_ - scalar(bini);
441 sums_[fieldi][d][bini] += weight[subi]*(1 - g);
442 sums_[fieldi][d][bini + 1] += weight[subi]*g;
449 if (!selected[subi])
continue;
451 nSamples_[fieldi] ++;
458 void Foam::functionObjects::cloudSurfaceDistribution::writeDistribution
460 const word& fieldName,
461 const word& componentName,
469 const fileName& outputPath =
482 const word fieldComponentName =
484 + (componentName.empty() ?
"" :
"_")
491 coordSet(
true, fieldComponentName,
x),
514 selectionType_(readSelectionType(
dict)),
515 selectionName_(
dict.lookup<
word>(selectionTypeNames[selectionType_])),
543 readCoeffs(
dict,
false);
562 readCoeffs(
dict,
false);
606 selectionType_ == selectionType::patch
611 const boolList selected(this->selected(fraction));
615 forAll(weightFields_, weightFieldi)
617 #define MULTIPLY_WEIGHT(GeoField) \
618 && !multiplyWeight<GeoField>(subMesh, weightFieldi, weight)
629 <<
"Weight field " << weightFields_[weightFieldi]
637 #define ADD_FIELD(Type, GeoField) \
638 && !addField<GeoField, Type>(subMesh, selected, weight, fieldi)
648 cannotFindObject(fields_[fieldi]);
662 const char*
const* componentNames = this->componentNames(fieldi);
688 const scalar
f = scalar(nodei)/nBins_;
714 if (!
mesh().
time().writeTime())
return true;
717 propsDict.add(
"select", selectionTypeNames[selectionType_]);
718 propsDict.add(selectionTypeNames[selectionType_], selectionName_);
741 if (selectionType_ == selectionType::faceSet)
753 if (selectionType_ == selectionType::faceSet)
765 if (selectionType_ == selectionType::faceSet)
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const Mesh & mesh() const
Return 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.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
LagrangianGroup group() const
Return the group.
label size() const
Return size.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
static const List< word > & null()
Return a null List.
Initialise the NamedEnum HashTable from the static list of names.
FixedList< word, nEnum > namesType
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
T & first()
Return the first element of the list.
T & last()
Return the last element of the list.
static bool master(const label communicator=0)
Am I the master process.
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
static tmp< scalarField > integrate(const scalarField &x, const scalarField &y)
Integrate the values y with respect to the coordinates x.
Abstract base-class for Time/database functionObjects.
Base class for function objects relating to a Lagrangian mesh.
Base class for function objects that refer to a cloud. Provides hooks into the cloud solution process...
Function to generate a plot of the distribution of the values of particles that pass through a face-z...
cloudSurfaceDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
selectionType
Selection type enumeration.
virtual ~cloudSurfaceDistribution()
Destructor.
static const NamedEnum< selectionType, 3 > selectionTypeNames
Selection type names.
virtual wordList fields() const
Return the list of fields required.
virtual bool executeAtStart() const
Return false so this function does not execute at the start.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual void postCrossFaces(const LagrangianSubScalarSubField &fraction)
Hook following face crossings of a specific sub-mesh.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual bool clear()
Clear the number flux.
virtual bool execute()
Do nothing. Everything happens in faces crossing hooks.
virtual void preCrossFaces(const LagrangianSubScalarSubField &fraction)
Hook before face crossings of a specific sub-mesh.
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
virtual bool write()
Write the number flux.
virtual bool read(const dictionary &)
Read parameters.
Function object that solves for the evolution of a cloud. Only provides one-way coupling with a finit...
virtual bool read(const dictionary &)
Read optional controls.
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Writes run time, CPU time and clock time and optionally the CPU and clock times per time step.
static const word outputPrefix
Directory prefix.
const polyMesh & mesh() const
Return reference to polyMesh.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
static word defaultRegion
Return the default region name.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
static autoPtr< setWriter > New(const word &writeType, const IOstream::streamFormat writeFormat=IOstream::ASCII, const IOstream::compressionType writeCompression=IOstream::UNCOMPRESSED)
Select given write options.
timeIOdictionary derived from IOdictionary with globalFile set false to enable writing to processor t...
Templated form of IOobject providing type information for file reading and header type checking.
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
A class for handling words, derived from string.
static const word null
An empty word.
#define ADD_FIELD(Type, GeoField)
#define MULTIPLY_WEIGHT(GeoField)
#define FIELD_RANGE_COMPONENT_NAMES(Type, GeoField)
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const dimensionedScalar c
Speed of light in a vacuum.
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< word > wordList
A List of words.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
List< bool > boolList
Bool container classes.
List< scalar > scalarList
A List of scalars.
LagrangianState
Lagrangian state enumeration.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void component(LagrangianPatchField< typename LagrangianPatchField< Type >::cmptType > &sf, const LagrangianPatchField< Type > &f, const direction d)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
DimensionedField< Type, LagrangianMesh > LagrangianInternalField
GeometricField< Type, LagrangianMesh, LagrangianPrimitiveDynamicField > LagrangianDynamicField
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
LagrangianSubSubField< scalar > LagrangianSubScalarSubField
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
static const label labelMax
GeometricField< Type, LagrangianMesh > LagrangianField
IOdictionary propsDict(systemDict("particleTracksDict", args, runTime))