40 { windowType::NONE,
"none" },
41 { windowType::APPROXIMATE,
"approximate" },
42 { windowType::EXACT,
"exact" }
68 forAll(fieldNames_, fieldi)
70 const word& fieldName = fieldNames_[fieldi];
72 if (
dict.found(fieldName))
75 valueDict.readEntry(
"totalTime", totalTime_[fieldi]);
80 totalTime_[fieldi] = 0;
88 forAll(fieldNames_, fieldi)
90 const word& fieldName = fieldNames_[fieldi];
92 if (
dict.found(fieldName))
95 valueDict.add(
"totalTime", totalTime_[fieldi],
true);
100 valueDict.add(
"totalTime", totalTime_[fieldi],
true);
101 dict.add(fieldName, valueDict);
109 forAll(fieldNames_, fieldi)
112 totalTime_[fieldi] = 0;
124 stateFunctionObject& state,
125 const bool writeToFile
130 resetOnRestart_(false),
131 windowType_(windowType::NONE),
133 functionObjectName_(
"unknown-functionObject"),
135 tolerance_(
dict.getOrDefault<scalar>(
"tolerance", -1)),
152 resetOnRestart_ =
false;
154 dict.readEntry(
"functionObject", functionObjectName_);
155 dict.readEntry(
"fields", fieldNames_);
156 if (
dict.readIfPresent(
"window", window_))
158 window_ = state_.time().userTimeToTime(window_);
162 windowType_ = windowTypeNames.get(
"windowType",
dict);
166 totalTime_.resize(fieldNames_.size(),
Zero);
168 dict.readIfPresent(
"resetOnRestart", resetOnRestart_);
170 dict.readIfPresent(
"log",
log);
181 scalar dt = state_.time().deltaTValue();
183 Log <<
indent << state_.type() <<
": " << prefix_.c_str()
184 <<
" averages:" <<
nl;
186 file() << state_.time().timeName();
190 bool converged =
true;
192 forAll(fieldNames_, fieldi)
194 totalTime_[fieldi] += dt;
196 const bool processed =
198 calc<label, scalar>(fieldi, converged,
dict)
199 || calc<scalar>(fieldi, converged,
dict)
200 || calc<vector>(fieldi, converged,
dict)
201 || calc<sphericalTensor>(fieldi, converged,
dict)
202 || calc<symmTensor>(fieldi, converged,
dict)
203 || calc<tensor>(fieldi, converged,
dict)
208 unprocessedFields.append(fieldNames_[fieldi]);
210 file() <<
tab <<
"n/a";
216 if (unprocessedFields.size())
219 <<
"From function object: " << functionObjectName_ <<
nl 220 <<
"Unprocessed fields:" <<
nl;
222 for (
const word& fieldName : unprocessedFields)
227 if (unprocessedFields.size() == fieldNames_.size())
windowType
Averaging window types.
virtual OFstream & file()
Return access to the file (if only 1)
virtual void writeState(dictionary &dict)
Write state to dictionary for restarts.
Ostream & indent(Ostream &os)
Indent stream.
dimensionedScalar log(const dimensionedScalar &ds)
virtual void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr char tab
The tab '\t' character(0x09)
static const Enum< windowType > windowTypeNames
Names for windowType enumeration.
virtual bool calculate(dictionary &dict)
Calculate the averages.
#define forAll(list, i)
Loop across all elements in list.
wordList fieldNames_
List of fields on which to operate.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
virtual void readState(dictionary &dict)
Read state from dictionary.
A class for handling words, derived from Foam::string.
virtual bool read(const dictionary &dict)
Read the field value average data.
virtual void writeFileHeader(Ostream &os) const
Output file header information.
OBJstream os(runTime.globalPath()/outputName)
virtual bool read(const dictionary &dict)
Read.
#define WarningInFunction
Report a warning using Foam::Warning.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
valueAverageBase(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state, const bool writeToFile=true)
Construct from Time and dictionary.
Registry of regIOobjects.
virtual void resetState(dictionary &dict)
Reset state.
static constexpr const zero Zero
Global zero (0)
virtual void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.