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;
125 const bool writeToFile
130 resetOnRestart_(false),
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())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
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.
void size(const label n)
Older name for setAddressableSize.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Computes the natural logarithm of an input volScalarField.
Base class for function objects, adding functionality to read/write state information (data required ...
Base class that computes the ensemble- or time-based singular-value average values,...
windowType
Averaging window types.
wordList fieldNames_
List of fields on which to operate.
virtual void writeState(dictionary &dict)
Write state to dictionary for restarts.
virtual bool calculate(dictionary &dict)
Calculate the averages.
virtual bool read(const dictionary &dict)
Read the field value average data.
virtual void writeFileHeader(Ostream &os) const
Output file header information.
static const Enum< windowType > windowTypeNames
Names for windowType enumeration.
virtual void resetState(dictionary &dict)
Reset state.
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.
virtual void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
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.
bool readState()
Read state from file, applying relaxation as requested.
Registry of regIOobjects.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
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.
Ostream & indent(Ostream &os)
Indent stream.
static constexpr const zero Zero
Global zero (0)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
constexpr char nl
The newline '\n' character (0x0a)
constexpr char tab
The tab '\t' character(0x09)
#define forAll(list, i)
Loop across all elements in list.