36namespace functionObjects
53 { operationType::opSum,
"sum" },
54 { operationType::opAdd,
"add" },
55 { operationType::opSubtract,
"subtract" },
56 { operationType::opMin,
"min" },
57 { operationType::opMax,
"max" },
58 { operationType::opAverage,
"average" },
72 const word groupPrefix(
"Group");
79 forAll(entries[i], functioni)
84 " - " + foNames[functioni] +
":" + entries[i][functioni]
113 operation_(opSubtract),
132 operation_ = operationTypeNames_.get(
"operation",
dict);
135 functions_.resize(functionsDict.size());
137 if (functions_.empty())
140 <<
"No functions specified"
145 resultFields_.resize(functions_.size());
148 for (
const entry& dEntry : functionsDict)
150 if (!dEntry.isDict())
153 <<
"Functions must be specified in dictionary format"
174 resultFields_[functioni] =
178 if (resultFields_[functioni].size())
180 Info<<
" " << functions_[functioni].name()
181 <<
" " << resultFields_[functioni];
185 Info<<
" " << functions_[functioni].name()
186 <<
" - using all available entries";
199 if (functions_.empty())
206 const label nFunction = functions_.size();
214 forAll(functions_, functioni)
216 auto&
f = functions_[functioni];
217 foNames[functioni] =
f.name();
227 e = objectResultEntries(
f.name());
239 entries[entryi].
resize(nFunction);
240 types[entryi].
resize(nFunction);
244 if (
e.size() != nEntries)
246 const word& f0Name = functions_[0].name();
249 <<
"Inconsistent number of result entries" <<
nl
250 <<
" " << f0Name <<
" entries:" << entries0 <<
nl
251 <<
" " <<
f.name() <<
" entries:" <<
e
257 entries[entryi][functioni] =
e[entryi];
258 types[entryi][functioni] = objectResultType(
f.name(),
e[entryi]);
263 <<
"Unable to find function object result" <<
nl
264 <<
" function object : " <<
f.name() <<
nl
265 <<
" result name : " <<
e[entryi] <<
nl
266 <<
" available results : "
267 << objectResultEntries(
f.name())
275 writeFileHeader(foNames, entries, types, file());
276 writtenHeader_ =
true;
279 writeCurrentTime(file());
283 const wordList& entryi = entries[i];
284 const word& expectedType = types[i][0];
287 forAll(foTypes, functioni)
289 const word& foType = foTypes[functioni];
291 if (foType != expectedType)
294 <<
"Inconsistent function result types" <<
nl
295 <<
" " << functions_[0].name()
296 <<
" result type:" << expectedType <<
nl
297 <<
" " << functions_[functioni].name()
298 <<
" result type:" << foType
305 applyOperation<scalar>(expectedType, foNames, entryi)
306 || applyOperation<vector>(expectedType, foNames, entryi)
307 || applyOperation<sphericalTensor>(expectedType, foNames, entryi)
308 || applyOperation<symmTensor>(expectedType, foNames, entryi)
309 || applyOperation<tensor>(expectedType, foNames, entryi)
314 Log <<
"Operation not applied between functions:" <<
nl
316 <<
"with result names:" <<
nl
322 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.
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.
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,...
virtual bool read()
Re-read model coefficients if they have changed.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
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
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.
Computes a selected operation between multiple function objects.
virtual bool read(const dictionary &dict)
Read from 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()
Do nothing.
virtual bool write()
Calculate and write.
operationType
Operation type enumeration.
Base class for function objects, adding functionality to read/write state information (data required ...
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.
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
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.
List< word > wordList
A List of words.
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.
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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for 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 ','.