45 if (!foundObject<Type>(fieldName))
55 Log <<
" Reading/initialising field " << meanFieldName <<
endl;
57 if (foundObject<Type>(meanFieldName))
61 Log <<
" Cannot allocate average field " << meanFieldName
62 <<
" since an object with that name already exists."
63 <<
" Disabling averaging for field." <<
endl;
69 const Type& baseField = lookupObject<Type>(fieldName);
107 addMeanFieldType<VolFieldType>(item);
108 addMeanFieldType<SurfaceFieldType>(item);
109 addMeanFieldType<SurfFieldType>(item);
120 if (restartOnOutput_)
127 const Type* fieldPtr = findObject<Type>(fieldName);
149 if (
io.typeHeaderOk<Type>(
true))
152 obr().store(
new Type(
io, fieldPtr->mesh()));
157 <<
"Unable to read window " << Type::typeName <<
" " <<
name
158 <<
". Averaging restart behaviour may be compromised"
177 restoreWindowFieldsType<VolFieldType>(item);
178 restoreWindowFieldsType<SurfaceFieldType>(item);
179 restoreWindowFieldsType<SurfFieldType>(item);
184template<
class Type1,
class Type2>
192 if (!foundObject<Type1>(fieldName))
200 Log <<
" Reading/initialising field " << prime2MeanFieldName <<
nl;
202 if (foundObject<Type2>(prime2MeanFieldName))
204 else if (obr().
found(prime2MeanFieldName))
206 Log <<
" Cannot allocate average field " << prime2MeanFieldName
207 <<
" since an object with that name already exists."
208 <<
" Disabling averaging for field." <<
endl;
214 const Type1& baseField = lookupObject<Type1>(fieldName);
215 const Type1& meanField = lookupObject<Type1>(meanFieldName);
232 sqr(baseField) -
sqr(meanField)
239template<
class Type1,
class Type2>
258 <<
"To calculate the prime-squared average, the "
259 <<
"mean average must also be selected for field "
263 addPrime2MeanFieldType<VolFieldType1, VolFieldType2>(item);
264 addPrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>(item);
265 addPrime2MeanFieldType<SurfFieldType1, SurfFieldType2>(item);
277 if (!foundObject<Type>(fieldName))
282 const Type& baseField = lookupObject<Type>(fieldName);
305 DebugInfo <<
"Create and store: " << windowFieldName <<
endl;
307 item.
addToWindow(windowFieldName, obr().time().deltaTValue());
320 if (item.storeWindowFields())
322 storeWindowFieldType<VolFieldType>(item);
323 storeWindowFieldType<SurfaceFieldType>(item);
324 storeWindowFieldType<SurfFieldType>(item);
339 item.calculateMeanField<VolFieldType>(obr());
340 item.calculateMeanField<SurfaceFieldType>(obr());
341 item.calculateMeanField<SurfFieldType>(obr());
346template<
class Type1,
class Type2>
359 item.calculatePrime2MeanField<VolFieldType1, VolFieldType2>(obr());
360 item.calculatePrime2MeanField<SurfaceFieldType1, SurfaceFieldType2>
364 item.calculatePrime2MeanField<SurfFieldType1, SurfFieldType2>(obr());
369template<
class Type1,
class Type2>
377 if (!foundObject<Type1>(fieldName))
382 const Type1& meanField = lookupObject<Type1>(item.
meanFieldName());
386 prime2MeanField +=
sqr(meanField);
390template<
class Type1,
class Type2>
403 if (item.prime2Mean())
405 addMeanSqrToPrime2MeanType<VolFieldType1, VolFieldType2>(item);
406 addMeanSqrToPrime2MeanType<SurfaceFieldType1, SurfaceFieldType2>
410 addMeanSqrToPrime2MeanType<SurfFieldType1, SurfFieldType2>(item);
419 const word& fieldName
422 if (foundObject<Type>(fieldName))
424 const Type&
f = lookupObject<Type>(fieldName);
441 const word& fieldName = item.meanFieldName();
442 writeFieldType<VolFieldType>(fieldName);
443 writeFieldType<SurfaceFieldType>(fieldName);
444 writeFieldType<SurfFieldType>(fieldName);
447 if (item.prime2Mean())
449 const word& fieldName = item.prime2MeanFieldName();
450 writeFieldType<VolFieldType>(fieldName);
451 writeFieldType<SurfaceFieldType>(fieldName);
452 writeFieldType<SurfFieldType>(fieldName);
455 if (item.writeWindowFields())
460 const word& fieldName = fieldNameIter();
461 writeFieldType<VolFieldType>(fieldName);
462 writeFieldType<SurfaceFieldType>(fieldName);
463 writeFieldType<SurfFieldType>(fieldName);
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A FIFO stack based on a singly-linked list.
Generic GeometricField class.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Helper class to describe what form of averaging to apply. A set will be applied to each base field in...
const FIFOStack< word > & windowFieldNames() const
Return the list of window field names (windowType = EXACT)
const word & fieldName() const
Return const access to the field name.
bool mean() const
Return const access to the mean flag.
void addToWindow(const word &fieldName, const scalar deltaT)
Add field to window.
scalar window() const
Return the window length (iterations or seconds)
word windowFieldName(const word &prefix) const
Helper function to construct a window field name.
bool prime2Mean() const
Return const access to the prime-squared mean flag.
const word & prime2MeanFieldName() const
Return const access to the prime-squared mean field name.
bool active() const
Return const access to the active flag.
const word & meanFieldName() const
Return const access to the mean field name.
Switch restartOnOutput_
Restart the averaging process on output.
void writeFields() const
Write fields.
void addMeanSqrToPrime2MeanType(const fieldAverageItem &item) const
Add mean-squared field value to prime-squared mean field.
void addMeanFieldType(fieldAverageItem &item)
Add mean average field to database.
void addMeanField(fieldAverageItem &item)
Add mean average field to database.
void calculatePrime2MeanFields() const
Calculate prime-squared average fields.
void addPrime2MeanFieldType(fieldAverageItem &item)
Add prime-squared average field to database.
void storeWindowFieldType(fieldAverageItem &item)
void writeFieldType(const word &fieldName) const
Write fields.
void calculateMeanFields() const
Calculate mean average fields.
void restoreWindowFields(const fieldAverageItem &item)
void addPrime2MeanField(fieldAverageItem &item)
Add prime-squared average field to database.
void addMeanSqrToPrime2Mean() const
Add mean-squared field value to prime-squared mean field.
void restoreWindowFieldsType(const fieldAverageItem &item)
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
const Time & time() const
Return time database.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Fields (face and point) for polySurface.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.