31 template<
class Type,
class Type2>
41 const word valueType =
51 const Type2 currentValue =
55 const word meanName(fieldName +
"Mean");
63 const scalar
beta = dt/Dt;
64 meanValue = (1 -
beta)*meanValue +
beta*currentValue;
81 meanValue = (1 -
beta)*meanValue +
beta*currentValue;
94 for (scalar& dti : windowTimes)
100 bool removeValue =
true;
101 while (removeValue && windowTimes.size())
103 removeValue = windowTimes.first() >
window_;
113 windowTimes.push(dt);
114 windowValues.
push(currentValue);
117 auto timeIter = windowTimes.cbegin();
118 auto valueIter = windowValues.
cbegin();
121 Type2 valueOld(
Zero);
127 ++i, ++timeIter, ++valueIter
130 const Type2& value = valueIter();
131 const scalar dt = timeIter();
133 meanValue += dt*value;
137 meanValue -= dt*valueOld;
143 meanValue /= windowTimes.first();
146 fieldDict.
set(
"windowTimes", windowTimes);
147 fieldDict.
set(
"windowValues", windowValues);
153 scalar
delta =
mag(meanValue - currentValue);
155 Log <<
indent <<
" " << meanName <<
": " << meanValue
stateFunctionObject & state_
Reference to the state functionObject.
virtual OFstream & file()
Return access to the file (if only 1)
Ostream & indent(Ostream &os)
Indent stream.
scalar deltaTValue() const noexcept
Return time step value.
word objectResultType(const word &objectName, const word &entryName) const
Return the type of result.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
bool calc(const label fieldi, bool &converged, dictionary &dict)
Templated function to calculate the average.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
word functionObjectName_
Name of function object to retrieve data from.
constexpr char nl
The newline '\n' character (0x0a)
A traits class, which is primarily used for primitives.
void setResult(const word &entryName, const Type &value)
Add result.
constexpr char tab
The tab '\t' character(0x09)
windowType windowType_
Window type.
scalar window_
Averaging window.
wordList fieldNames_
List of fields on which to operate.
void push(const T &elem)
Push an element onto the back of the stack.
A class for handling words, derived from Foam::string.
Type getObjectResult(const word &objectName, const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve result from named object.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
const_iterator cbegin() const
Iterator to first item in list with const access.
Type getResult(const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve result.
List< scalar > totalTime_
Average time per field.
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
T pop()
Pop the bottom element off the stack.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
const Time & time() const
Return time database.
scalar tolerance_
Optional tolerance to check for converged results.
static constexpr const zero Zero
Global zero (0)