33 namespace functionObjects
44 const word& functionName,
48 if (fieldNames_.empty())
50 fieldNames_ = defaultFieldNames;
53 if (resultName_.empty())
55 if (!fieldNames_.empty())
57 resultName_ = functionName +
'(' + fieldNames_[0];
58 for (
label i=1; i<fieldNames_.size(); i++)
60 resultName_ +=
',' + fieldNames_[i];
66 resultName_ = functionName;
80 const word& resultName
84 fieldNames_(fieldNames),
85 resultName_(resultName)
89 if (fieldNames_.size() < 2)
92 <<
"functionObject::" <<
type() <<
" " << name
93 <<
" requires at least 2 fields only " 94 << fieldNames_.size() <<
" provided: " << fieldNames_
112 if (fieldNames_.empty() || dict.
found(
"fields"))
114 dict.
lookup(
"fields") >> fieldNames_;
117 if (dict.
found(
"result"))
119 dict.
lookup(
"result") >> resultName_;
141 #define findFieldType(Type, GeoField) \ 144 || mesh_.foundObject<GeoField<Type>>(fieldNames_[i]); 151 notFoundFieldNames.
append(fieldNames_[i]);
155 if (!notFoundFieldNames.
empty())
158 <<
"functionObjects::" <<
type() <<
" " <<
name()
159 <<
" cannot find fields " << notFoundFieldNames <<
endl;
164 <<
"functionObjects::" <<
type() <<
" " <<
name()
165 <<
" fields are not compatible with the " <<
type()
166 <<
" function" <<
endl;
183 return writeObject(resultName_);
189 return clearObject(resultName_);
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#define forAll(list, i)
Loop across all elements in list.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
#define findFieldType(Type, GeoField)
virtual bool write()
Write the result fields.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
void setResultName(const word &functionName, const wordList &defaultFieldNames=wordList::null())
Set the result name.
virtual bool read(const dictionary &)
Read the fieldsExpression data.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Generic GeometricField class.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual bool read(const dictionary &)
Read optional controls.
bool read(const char *, int32_t &)
fieldsExpression(const word &name, const Time &runTime, const dictionary &dict, const wordList &fieldNames=wordList::null(), const word &resultName=word::null)
Construct from Time and dictionary.
virtual bool execute()
Calculate the result fields.
A class for handling words, derived from string.
virtual bool clear()
Clear the result fields from the objectRegistry.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
virtual ~fieldsExpression()
Destructor.
word name(const complex &)
Return a string representation of a complex.
defineTypeNameAndDebug(Qdot, 0)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
virtual wordList fields() const
Return the list of fields required.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
FOR_ALL_FIELD_TYPES(DefineFvWallInfoType)
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.