53 { operationType::opSum,
"sum" },
54 { operationType::opAdd,
"add" },
55 { operationType::opSubtract,
"subtract" },
56 { operationType::opDivide,
"divide" },
57 { operationType::opCmptDivide,
"cmptDivide" },
58 { operationType::opMin,
"min" },
59 { operationType::opMax,
"max" },
60 { operationType::opAverage,
"average" },
80 const word groupPrefix(
"Group");
87 forAll(entries[i], functioni)
92 " - " + foNames[functioni] +
":" + entries[i][functioni]
121 operation_(opSubtract),
140 operation_ = operationTypeNames_.get(
"operation",
dict);
143 functions_.resize(functionsDict.
size());
145 if (functions_.empty())
148 <<
"No functions specified"
153 resultFields_.resize(functions_.size());
156 for (
const entry& dEntry : functionsDict)
158 if (!dEntry.isDict())
161 <<
"Functions must be specified in dictionary format"
182 resultFields_[functioni] =
186 if (resultFields_[functioni].size())
188 Info<<
" " << functions_[functioni].name()
189 <<
" " << resultFields_[functioni];
193 Info<<
" " << functions_[functioni].name()
194 <<
" - using all available entries";
207 if (functions_.empty())
214 const label nFunction = functions_.size();
222 forAll(functions_, functioni)
224 auto&
f = functions_[functioni];
225 foNames[functioni] =
f.name();
235 e = objectResultEntries(
f.name());
247 entries[entryi].
resize(nFunction);
248 types[entryi].
resize(nFunction);
252 if (
e.size() != nEntries)
254 const word& f0Name = functions_[0].name();
257 <<
"Inconsistent number of result entries" <<
nl
258 <<
" " << f0Name <<
" entries:" << entries0 <<
nl
259 <<
" " <<
f.name() <<
" entries:" <<
e
265 entries[entryi][functioni] =
e[entryi];
266 types[entryi][functioni] = objectResultType(
f.name(),
e[entryi]);
271 <<
"Unable to find function object result" <<
nl
272 <<
" function object : " <<
f.name() <<
nl
273 <<
" result name : " <<
e[entryi] <<
nl
274 <<
" available results : "
275 << objectResultEntries(
f.name())
283 writeFileHeader(foNames, entries, types, file());
284 writtenHeader_ =
true;
287 writeCurrentTime(file());
291 const wordList& entryi = entries[i];
292 const word& expectedType = types[i][0];
295 forAll(foTypes, functioni)
297 const word& foType = foTypes[functioni];
299 if (foType != expectedType)
302 <<
"Inconsistent function result types" <<
nl
303 <<
" " << functions_[0].name()
304 <<
" result type:" << expectedType <<
nl
305 <<
" " << functions_[functioni].name()
306 <<
" result type:" << foType
313 applyOperation<scalar>(expectedType, foNames, entryi)
314 || applyOperation<vector>(expectedType, foNames, entryi)
315 || applyOperation<sphericalTensor>(expectedType, foNames, entryi)
316 || applyOperation<symmTensor>(expectedType, foNames, entryi)
317 || applyOperation<tensor>(expectedType, foNames, entryi)
322 Log <<
"Operation not applied between functions:" <<
nl
324 <<
"with result names:" <<
nl
325 <<
flatOutput(entryi, FlatOutput::BareComma{})
330 Log << (nEntries == 0 ?
" none" :
"") <<
endl;
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
label size() const noexcept
The number of elements in list.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
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.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
word dictName() const
The local dictionary name (final part of scoped name).
A keyword and a list of tokens is an 'entry'.
Abstract base-class for Time/database function objects.
const word & name() const noexcept
Return the name of this functionObject.
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
static autoPtr< functionObject > New(const word &name, const Time &runTime, const dictionary &dict)
Select from dictionary, based on its "type" entry.
Computes a selected operation between multiple function objects.
multiFieldValue(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
virtual void writeFileHeader(const wordList &foNames, const List< wordList > &entries, const List< wordList > &types, Ostream &os) const
Output file header information.
static const Enum< operationType > operationTypeNames_
Operation type names.
virtual bool execute()
Execute the function-object operations.
virtual bool write()
Write the function-object results.
operationType
Operation type enumeration.
@ opSubtract
Subtract values from first entry.
Base class for function objects, adding functionality to read/write state information (data required ...
word objectResultType(const word &objectName, const word &entryName) const
Return the type of result.
stateFunctionObject(const stateFunctionObject &)=delete
No copy construct.
wordList objectResultEntries() const
Retrieve the result entries.
const Time & time() const
Return time database.
Base class for writing single files from the function objects.
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
void writeHeaderValue(Ostream &os, const string &property, const Type &value) const
Write a (commented) header property and value pair.
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
virtual bool read(const dictionary &dict)
Read.
bool writtenHeader_
Flag to identify whether the header has been written.
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.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
#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.
List< word > wordList
List of word.
bool read(const char *buf, int32_t &val)
Same as readInt32.
messageStream Info
Information stream (stdout output on master, null elsewhere).
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
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.
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).
#define forAll(list, i)
Loop across all elements in list.
Surround with '\0' and '\0' separate with ','.