42 const Type* baseFieldPtr = obr.
findObject<Type>(fieldName_);
49 const Type& baseField = *baseFieldPtr;
57 scalar
Dt = this->
Dt();
60 meanField = (1 -
beta)*meanField +
beta*baseField;
67 scalar
Dt = this->
Dt();
70 if (
Dt -
dt >= window_)
75 meanField = (1 -
beta)*meanField +
beta*baseField;
89 label
n = windowTimes_.size();
90 const Type& lastField =
93 if (
n <= round(window_))
95 scalar
beta = 1.0/scalar(
n);
96 meanField = (1 -
beta)*meanField +
beta*baseField;
100 meanField += (baseField - lastField)/scalar(
n - 1);
110 meanField = 0*baseField;
112 auto timeIter = windowTimes_.cbegin();
113 auto nameIter = windowFieldNames_.cbegin();
115 const Type* wOld =
nullptr;
121 ++timeIter, ++nameIter
125 const scalar
dt = timeIter();
128 meanField +=
dt*(*w);
132 meanField -=
dt*(*wOld);
138 meanField /= windowTimes_.first();
145 <<
"Unhandled baseType enumeration "
146 << baseTypeNames_[base_]
156 <<
"Unhandled windowType enumeration "
157 << windowTypeNames_[windowType_]
166template<
class Type1,
class Type2>
177 const Type1* baseFieldPtr = obr.
findObject<Type1>(fieldName_);
184 const Type1& baseField = *baseFieldPtr;
185 const Type1& meanField = obr.
lookupObject<Type1>(meanFieldName_);
187 Type2& prime2MeanField =
192 case windowType::NONE:
195 scalar Dt = this->Dt();
199 (1 -
beta)*prime2MeanField
205 case windowType::APPROXIMATE:
208 scalar Dt = this->Dt();
211 if (Dt - dt >= window_)
217 (1 -
beta)*prime2MeanField
223 case windowType::EXACT:
226 prime2MeanField = 0*prime2MeanField;
228 auto timeIter = windowTimes_.cbegin();
229 auto nameIter = windowFieldNames_.cbegin();
239 if (!timeIter.good())
return false;
248 scalar windowLength = timeIter();
250 const Type1* wOld =
nullptr;
256 ++timeIter, ++nameIter
259 const word& fieldName = nameIter();
260 const scalar dt = timeIter();
261 const Type1* w = obr.
findObject<Type1>(fieldName);
263 prime2MeanField += dt*(
sqr((*w) - meanField));
267 prime2MeanField -= dt*(
sqr((*wOld) - meanField));
273 prime2MeanField /= windowLength;
280 <<
"Unhandled windowType enumeration "
281 << windowTypeNames_[windowType_]
scalar deltaTValue() const noexcept
Return time step value.
bool calculatePrime2MeanField(const objectRegistry &obr) const
Calculate prime-squared average fields.
const word & fieldName() const
Return const access to the field name.
scalar dt(const scalar deltaT) const
Return the current time interval.
scalar Dt() const
Return the total time interval.
bool calculateMeanField(const objectRegistry &obr) const
Calculate the mean field value.
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
Type & lookupObjectRef(const word &name, const bool recursive=false) const
Lookup and return non-const reference to the object of the given Type. Fatal if not found or the wron...
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)