39 namespace functionObjects
94 void Foam::functionObjects::fieldValues::volFieldValue::
95 writeFileHeaderLocation<Foam::scalar>()
101 case operationType::minMag:
102 case operationType::maxMag:
103 file() <<
tab <<
"location" <<
tab <<
"cell";
106 file() <<
tab <<
"processor";
120 if (operation_ != operationType::none)
122 zone_.writeFileHeader(*
this,
file());
124 writeCommented(
file(),
"Time");
126 if (writeNCells_)
file() <<
tab <<
"Cells";
127 if (writeVolume_)
file() <<
tab <<
"Volume";
131 file() <<
tab << operationTypeNames_[operation_] <<
"(";
133 forAll(weightFieldNames_, i)
135 file() << weightFieldNames_[i] <<
',';
138 file() << fields_[fieldi] <<
")";
142 #define writeFileHeaderLocationFieldType(fieldType, none) \
143 if (validField<fieldType>(fields_[fieldi])) \
145 writeFileHeaderLocation<fieldType>(); \
148 #undef writeHeaderLocationFieldType
172 case operationType::minMag:
182 case operationType::maxMag:
190 return processValuesTypeType(values, weights, V, result);
207 operation_(operationTypeNames_.
read(
dict.lookup(
"operation"))),
209 writeNCells_(
dict.lookupOrDefault(
"writeNumberOfCells", false)),
210 writeVolume_(
dict.lookupOrDefault(
"writeVolume", false)),
211 writeLocation_(
dict.lookupOrDefault(
"writeLocation", false))
226 operation_(operationTypeNames_.
read(
dict.lookup(
"operation"))),
228 writeNCells_(
dict.lookupOrDefault(
"writeNumberOfCells", false)),
229 writeVolume_(
dict.lookupOrDefault(
"writeVolume", false)),
230 writeLocation_(
dict.lookupOrDefault(
"writeLocation", false))
251 if (
dict.found(
"weightFields"))
253 dict.lookup(
"weightFields") >> weightFieldNames_;
255 else if (
dict.found(
"weightField"))
257 weightFieldNames_.setSize(1);
259 dict.lookup(
"weightField") >> weightFieldNames_[0];
262 dict.readIfPresent(
"scaleFactor", scaleFactor_);
266 Info<<
" number of cells = " << zone_.nGlobalCells() <<
nl;
267 if (zone_.nGlobalCells())
269 Info<<
" volume = " << zone_.V() <<
nl;
271 Info<<
" operation = " << operationTypeNames_[operation_] <<
nl;
272 if (weightFieldNames_.size() == 1)
274 Info<<
" weight field = " << weightFieldNames_[0] <<
nl;
276 if (weightFieldNames_.size() > 1)
278 Info<<
" weight fields =";
279 forAll(weightFieldNames_, i)
Info<<
' ' << weightFieldNames_[i];
282 if (scaleFactor_ != scalar(1))
284 Info<<
" scale factor = " << scaleFactor_;
295 bool anyFields =
false;
298 #define validFieldType(fieldType, none) \
299 anyFields = anyFields || validField<fieldType>(fields_[i]);
301 #undef validFieldType
303 if (!anyFields && fields_.size() > 1)
305 cannotFindObjects(fields_);
309 if (anyFields && operation_ != operationType::none)
315 if (anyFields && operation_ != operationType::none &&
Pstream::master())
321 if (anyFields && operation_ != operationType::none &&
Pstream::master())
325 file() <<
tab << zone_.nGlobalCells();
334 Log <<
" number of cells = " << zone_.nGlobalCells() <<
endl;
338 Log <<
" volume = " << zone_.V() <<
endl;
343 forAll(weightFieldNames_, i)
345 weights *= getFieldValues<scalar>(weightFieldNames_[i]);
352 const word& fieldName = fields_[i];
355 #define writeValuesFieldType(fieldType, none) \
356 ok = ok || writeValues<fieldType>(fieldName, weights, V);
358 #undef writeValuesFieldType
362 cannotFindObject(fieldName);
367 if (anyFields && operation_ != operationType::none &&
Pstream::master())
398 zone_.topoChange(map);
424 zone_.distribute(map);
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
Initialise the NamedEnum HashTable from the static list of names.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static bool master(const label communicator=0)
Am I the master process.
static bool & parRun()
Is this a parallel run?
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Abstract base-class for Time/database functionObjects.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual void movePoints(const polyMesh &mesh)
Update topology using the given map.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
Base class for field value -based function objects.
const dictionary & dict() const
Return the reference to the construction dictionary.
virtual bool read(const dictionary &dict)
Read from dictionary.
virtual bool write()
Write.
Provides a 'fvCellZone' specialisation of the fieldValue function object.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
void writeFileHeaderLocation()
Output file header location information for a given type.
operationType operation_
Operation to apply to values.
volFieldValue(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
static const NamedEnum< operationType, 12 > operationTypeNames_
Operation type names.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual void writeFileHeader(const label i)
Output file header information.
virtual void movePoints(const polyMesh &)
Update for mesh motion.
virtual ~volFieldValue()
Destructor.
virtual bool write()
Calculate and write.
bool processValues(const Field< Type > &values, const scalarField &weights, const scalarField &V, Result< ResultType > &result) const
Apply the operation to the values, and return true if successful.
virtual bool read(const dictionary &)
Read from dictionary.
operationType
Operation type enumeration.
const fvMesh & mesh_
Reference to the fvMesh.
OFstream & file()
Return access to the file (if only 1)
Registry of regIOobjects.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
const polyMesh & mesh() const
Return polyMesh.
Class containing mesh-to-mesh mapping information.
const polyMesh & mesh() const
Return polyMesh.
Mesh consisting of general polyhedral cells.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const polyMesh & mesh() const
Return polyMesh.
A class for handling words, derived from string.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define Log
Report write to Foam::Info if the local log switch is true.
defineTypeNameAndDebug(fieldValueDelta, 0)
addToRunTimeSelectionTable(functionObject, fieldValueDelta, dictionary)
bool read(const char *, int32_t &)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Forward declare the result structure.
#define writeFileHeaderLocationFieldType(fieldType, none)
#define writeValuesFieldType(fieldType, none)
#define validFieldType(fieldType, none)