Go to the documentation of this file.
37 namespace functionObjects
76 functionObjectName_(
"unknown-functionObject"),
80 resetOnRestart_(
false)
86 forAll(fieldNames_, fieldi)
88 const word& fieldName = fieldNames_[fieldi];
90 if (
dict.found(fieldName))
93 valueDict.
readEntry(
"totalTime", totalTime_[fieldi]);
98 writeFileHeader(file());
116 resetOnRestart_ =
false;
118 dict.readEntry(
"functionObject", functionObjectName_);
119 dict.readEntry(
"fields", fieldNames_);
120 if (
dict.readIfPresent(
"window", window_))
122 window_ = obr().time().userTimeToTime(window_);
125 totalTime_.setSize(fieldNames_.size());
128 totalTime_[i] = time_.deltaTValue();
131 dict.readIfPresent(
"resetOnRestart", resetOnRestart_);
139 scalar dt = obr_.time().deltaTValue();
143 file() << time_.timeName();
147 forAll(fieldNames_, fieldi)
149 const word& fieldName(fieldNames_[fieldi]);
150 const word meanName(fieldName +
"Mean");
152 scalar Dt = totalTime_[fieldi];
153 scalar
alpha = (Dt - dt)/Dt;
158 if (Dt - dt >= window_)
160 alpha = (window_ - dt)/window_;
165 bool processed =
false;
166 calc<scalar>(fieldName, meanName,
alpha,
beta, processed);
167 calc<vector>(fieldName, meanName,
alpha,
beta, processed);
168 calc<sphericalTensor>(fieldName, meanName,
alpha,
beta, processed);
169 calc<symmTensor>(fieldName, meanName,
alpha,
beta, processed);
170 calc<tensor>(fieldName, meanName,
alpha,
beta, processed);
174 unprocessedFields.append(fieldi);
178 file() <<
tab <<
"n/a";
182 totalTime_[fieldi] += dt;
187 if (unprocessedFields.size())
190 <<
"From function object: " << functionObjectName_ <<
nl
191 <<
"Unprocessed fields:" <<
nl;
193 forAll(unprocessedFields, i)
195 label fieldi = unprocessedFields[i];
196 Log <<
" " << fieldNames_[fieldi] <<
nl;
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual void writeFileHeader(Ostream &os) const
Output file header information.
A class for handling words, derived from Foam::string.
virtual bool execute()
Execute.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
bool read(const char *buf, int32_t &val)
Same as readInt32.
Ostream & endl(Ostream &os)
Add newline and flush stream.
addToRunTimeSelectionTable(functionObject, add, dictionary)
#define forAll(list, i)
Loop across all elements in list.
virtual void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
virtual bool read(const dictionary &dict)
Read.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
word name(const complex &c)
Return string representation of complex.
virtual bool read(const dictionary &)
Read the field value average data.
wordList fieldNames_
List of fields on which to operate.
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual bool read(const dictionary &dict)
Read optional controls.
Macros for easy insertion into run-time selection tables.
virtual bool write()
Write the value average.
valueAverage(const valueAverage &)=delete
No copy construct.
virtual ~valueAverage()
Destructor.
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Specialization of Foam::functionObject for a region and providing a reference to the region Foam::obj...
functionObject base class for writing single files
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
#define WarningInFunction
Report a warning using Foam::Warning.
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
#define Log
Report write to Foam::Info if the local log switch is true.