56 { operationType::opNone,
"none" },
57 { operationType::opMin,
"min" },
58 { operationType::opMax,
"max" },
59 { operationType::opSum,
"sum" },
60 { operationType::opSumMag,
"sumMag" },
61 { operationType::opAverage,
"average" },
62 { operationType::opVolAverage,
"volAverage" },
63 { operationType::opVolIntegrate,
"volIntegrate" },
64 { operationType::opCoV,
"CoV" },
67 { operationType::opWeightedSum,
"weightedSum" },
68 { operationType::opWeightedAverage,
"weightedAverage" },
69 { operationType::opWeightedVolAverage,
"weightedVolAverage" },
70 { operationType::opWeightedVolIntegrate,
"weightedVolIntegrate" },
79 { postOperationType::postOpNone,
"none" },
81 { postOperationType::postOpSqrt,
"sqrt" },
113 if (weightFieldNames_.size())
123 writeCommented(
os,
"Time");
127 for (
const word& fieldName : fields_)
129 os <<
tab << operationTypeNames_[operation_]
130 <<
"(" << fieldName <<
")";
143 label nProcessed = 0;
145 for (
const word& fieldName : fields_)
149 writeValues<scalar>(fieldName, V, weightField)
150 || writeValues<vector>(fieldName, V, weightField)
151 || writeValues<sphericalTensor>(fieldName, V, weightField)
152 || writeValues<symmTensor>(fieldName, V, weightField)
153 || writeValues<tensor>(fieldName, V, weightField)
161 <<
"Requested field " << fieldName
162 <<
" not found in database and not processed"
182 operation_(operationTypeNames_.get(
"operation",
dict)),
185 postOperationTypeNames_.getOrDefault
189 postOperationType::postOpNone,
209 operation_(operationTypeNames_.get(
"operation",
dict)),
212 postOperationTypeNames_.getOrDefault
216 postOperationType::postOpNone,
235 weightFieldNames_.clear();
242 if (
dict.readIfPresent(
"weightFields", weightFieldNames_))
248 weightFieldNames_.resize(1);
250 if (
dict.readIfPresent(
"weightField", weightFieldNames_.first()))
253 if (
"none" == weightFieldNames_.first())
256 weightFieldNames_.clear();
265 <<
"The '" << operationTypeNames_[operation_]
266 <<
"' operation is missing a weightField." <<
nl
267 <<
"Either provide the weightField, "
268 <<
"use weightField 'none' to suppress weighting," <<
nl
269 <<
"or use a different operation."
273 Info<<
" weight field = ";
274 if (weightFieldNames_.empty())
298 writeCurrentTime(file());
315 for (
const word& weightName : weightFieldNames_)
317 if (validField<scalar>(weightName))
319 tmp<scalarField> tfld = getFieldValues<scalar>(weightName,
true);
321 if (scalarWeights.empty())
323 scalarWeights = tfld;
327 scalarWeights *= tfld;
330 else if (weightName !=
"none")
338 <<
"weightField " << weightName
339 <<
" not found or an unsupported type" <<
nl
346 writeAll(V, scalarWeights);
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Abstract base-class for Time/database function objects.
const word & name() const noexcept
Return the name of this functionObject.
Intermediate class for handling field value-based function objects.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
wordList fields_
Names of operand fields.
fieldValue(const word &name, const Time &runTime, const dictionary &dict, const word &valueType)
Construct from name, Time and dictionary.
const dictionary & dict() const noexcept
Return the reference to the construction dictionary.
virtual bool write()
Write the function-object results.
Provides a 'volRegion' specialization of the fieldValue function object.
bool writeValues(const word &fieldName, const scalarField &V, const scalarField &weightField)
Templated helper function to output field values.
tmp< Field< Type > > getFieldValues(const word &fieldName, const bool mandatory=false) const
Insert field values into values list.
postOperationType postOperation_
Optional post-evaluation operation.
bool usesVol() const noexcept
True if the operation needs the cell-volume.
postOperationType
Post-operation type enumeration.
@ postOpNone
No additional operation after calculation.
@ postOpMag
Component-wise mag after normal operation.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
operationType operation_
Operation to apply to values.
label writeAll(const scalarField &V, const scalarField &weightField)
Helper function to output field values.
static const Enum< operationType > operationTypeNames_
Operation type names.
volFieldValue(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
wordList weightFieldNames_
Weight field name(s) - optional.
virtual void writeFileHeader(Ostream &os) const
Output file header information.
bool validField(const word &fieldName) const
Return true if the field name is valid.
tmp< Field< Type > > filterField(const Field< Type > &field) const
Filter a field according to cellIds.
bool is_weightedOp() const noexcept
True if the operation variant uses a weight-field.
static const Enum< postOperationType > postOperationTypeNames_
Operation type names.
virtual bool write()
Write the function-object results.
operationType
Operation type enumeration.
@ opVolIntegrate
Volume integral.
@ opCoV
Coefficient of variation.
@ opWeightedVolIntegrate
Weighted volume integral.
@ opVolAverage
Volume average.
@ opWeightedVolAverage
Weighted volume average.
const fvMesh & mesh_
Reference to the fvMesh.
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Volume (cell) region selection class.
scalar V() const
Return total volume of the selected region.
volRegion(const fvMesh &mesh, const dictionary &dict)
Construct from fvMesh and dictionary.
bool update()
Update the cached values as required.
void writeFileHeader(const writeFile &wf, Ostream &file) const
Output file header information.
void writeHeaderValue(Ostream &os, const string &property, const Type &value) const
Write a (commented) header property and value pair.
virtual OFstream & file()
Return access to the file (if only 1).
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
virtual void writeCurrentTime(Ostream &os) const
Write the current time to stream.
Registry of regIOobjects.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
bool read(const char *buf, int32_t &val)
Same as readInt32.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
errorManip< error > abort(error &err)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
constexpr char tab
The tab '\t' character(0x09).
Surround with '\0' and '\0' separate with ','.