43 const Type* fieldPtr = findObject<Type>(item.
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 = *fieldPtr;
106 typedef typename VolFieldType::Internal VolFieldInternalType;
116 addMeanFieldType<VolFieldType>(item)
117 || addMeanFieldType<VolFieldInternalType>(item)
118 || addMeanFieldType<SurfaceFieldType>(item)
119 || addMeanFieldType<SurfFieldType>(item)
133 if (restartOnOutput_)
140 const Type* fieldPtr = findObject<Type>(fieldName);
151 const word&
name = fieldIter();
163 if (
io.typeHeaderOk<Type>(
true))
166 obr().store(
new Type(
io, fieldPtr->mesh()));
171 <<
"Unable to read window " << Type::typeName <<
" " <<
name 172 <<
". Averaging restart behaviour may be compromised" 188 typedef typename VolFieldType::Internal VolFieldInternalType;
196 restoreWindowFieldsType<VolFieldType>(item)
197 || restoreWindowFieldsType<VolFieldInternalType>(item)
198 || restoreWindowFieldsType<SurfaceFieldType>(item)
199 || restoreWindowFieldsType<SurfFieldType>(item)
205 template<
class Type1,
class Type2>
208 fieldAverageItem& item
211 const auto* baseFieldPtr = findObject<Type1>(item.fieldName());
218 const word& meanFieldName = item.meanFieldName();
219 const word& prime2MeanFieldName = item.prime2MeanFieldName();
221 Log <<
" Reading/initialising field " << prime2MeanFieldName <<
nl;
223 if (foundObject<Type2>(prime2MeanFieldName))
225 else if (obr().
found(prime2MeanFieldName))
227 Log <<
" Cannot allocate average field " << prime2MeanFieldName
228 <<
" since an object with that name already exists." 229 <<
" Disabling averaging for field." <<
endl;
231 item.prime2Mean() =
false;
235 const auto& baseField = *baseFieldPtr;
236 const Type1& meanField = lookupObject<Type1>(meanFieldName);
253 sqr(baseField) -
sqr(meanField)
264 template<
class Type1,
class Type2>
271 typedef typename VolFieldType1::Internal VolFieldInternalType1;
276 typedef typename VolFieldType2::Internal VolFieldInternalType2;
287 <<
"To calculate the prime-squared average, the " 288 <<
"mean average must also be selected for field " 293 addPrime2MeanFieldType<VolFieldType1, VolFieldType2>(item)
294 || addPrime2MeanFieldType<VolFieldInternalType1, VolFieldInternalType2>
298 || addPrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>(item)
299 || addPrime2MeanFieldType<SurfFieldType1, SurfFieldType2>(item);
312 const auto* fPtr = findObject<Type>(item.
fieldName());
319 const Type& baseField = *fPtr;
342 DebugInfo <<
"Create and store: " << windowFieldName <<
endl;
354 typedef typename VolFieldType::Internal VolFieldInternalType;
364 storeWindowFieldType<VolFieldType>(item)
365 || storeWindowFieldType<VolFieldInternalType>(item)
366 || storeWindowFieldType<SurfaceFieldType>(item)
367 || storeWindowFieldType<SurfFieldType>(item)
377 typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
378 typedef typename VolFieldType::Internal VolFieldInternalType;
379 typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
380 typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
382 const auto& obr = this->obr();
384 for (
const fieldAverageItem& item : faItems_)
397 template<
class Type1,
class Type2>
401 typedef typename VolFieldType1::Internal VolFieldInternalType1;
406 typedef typename VolFieldType2::Internal VolFieldInternalType2;
410 const auto& obr = this->obr();
412 for (
const fieldAverageItem& item : faItems_)
418 <VolFieldInternalType1, VolFieldInternalType2>(obr)
420 <SurfaceFieldType1, SurfaceFieldType2>(obr)
427 template<
class Type1,
class Type2>
430 const fieldAverageItem& item
433 if (!foundObject<Type1>(item.fieldName()))
438 const Type1& meanField = lookupObject<Type1>(item.meanFieldName());
440 Type2& prime2MeanField = lookupObjectRef<Type2>(item.prime2MeanFieldName());
442 prime2MeanField +=
sqr(meanField);
448 template<
class Type1,
class Type2>
452 typedef typename VolFieldType1::Internal VolFieldInternalType1;
457 typedef typename VolFieldType2::Internal VolFieldInternalType2;
463 if (item.prime2Mean())
467 addMeanSqrToPrime2MeanType<VolFieldType1, VolFieldType2>(item)
468 || addMeanSqrToPrime2MeanType
469 <VolFieldInternalType1, VolFieldInternalType2>(item)
470 || addMeanSqrToPrime2MeanType
471 <SurfaceFieldType1, SurfaceFieldType2>(item)
472 || addMeanSqrToPrime2MeanType
473 <SurfFieldType1, SurfFieldType2>(item)
483 const word& fieldName
486 const auto* fPtr = findObject<Type>(fieldName);
490 DebugInfo<<
"writing " << Type::typeName <<
": " << fieldName <<
endl;
491 return fPtr->
write();
502 typedef typename VolFieldType::Internal VolFieldInternalType;
506 for (
const fieldAverageItem& item : faItems_)
510 const word& fieldName = item.meanFieldName();
514 writeFieldType<VolFieldType>(fieldName)
515 || writeFieldType<VolFieldInternalType>(fieldName)
516 || writeFieldType<SurfaceFieldType>(fieldName)
517 || writeFieldType<SurfFieldType>(fieldName)
521 if (item.prime2Mean())
523 const word& fieldName = item.prime2MeanFieldName();
527 writeFieldType<VolFieldType>(fieldName)
528 || writeFieldType<VolFieldInternalType>(fieldName)
529 || writeFieldType<SurfaceFieldType>(fieldName)
530 || writeFieldType<SurfFieldType>(fieldName)
534 if (item.writeWindowFields())
536 FIFOStack<word> fieldNames = item.windowFieldNames();
539 const word& fieldName = fieldNameIter();
543 writeFieldType<VolFieldType>(fieldName)
544 || writeFieldType<VolFieldInternalType>(fieldName)
545 || writeFieldType<SurfaceFieldType>(fieldName)
546 || writeFieldType<SurfFieldType>(fieldName)
const word & meanFieldName() const
Return const access to the mean field name.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool addPrime2MeanFieldType(fieldAverageItem &item)
Add prime-squared average field to database.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
Fields (face and point) for polySurface.
bool mean() const
Return const access to the mean flag.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word windowFieldName(const word &prefix) const
Helper function to construct a window field name.
bool store()
Register object with its registry and transfer ownership to the registry.
scalar window() const
Return the window length (iterations or seconds)
bool addMeanFieldType(fieldAverageItem &item)
Add mean average field to database.
Generic GeometricField class.
Ignore writing from objectRegistry::writeObject()
void calculatePrime2MeanFields() const
Calculate prime-squared average fields.
bool active() const
Return const access to the active flag.
void writeFields() const
Write fields.
const word & fieldName() const
Return const access to the field name.
bool addMeanSqrToPrime2MeanType(const fieldAverageItem &item) const
Add mean-squared field value to prime-squared mean field.
Switch restartOnOutput_
Restart the averaging process on output.
bool restoreWindowFieldsType(const fieldAverageItem &item)
void addToWindow(const word &fieldName, const scalar deltaT)
Add field to window.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
Reading is optional [identical to LAZY_READ].
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
void calculateMeanFields() const
Calculate mean average fields.
#define DebugInfo
Report an information message using Foam::Info.
const FIFOStack< word > & windowFieldNames() const
Return the list of window field names (windowType = EXACT)
bool addPrime2MeanField(fieldAverageItem &item)
Add prime-squared average field to database.
bool addMeanField(fieldAverageItem &item)
Add mean average field to database.
bool storeWindowFieldType(fieldAverageItem &item)
#define WarningInFunction
Report a warning using Foam::Warning.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
bool storeWindowFields() const
Return true if we wish to store window fields.
Helper class to describe what form of averaging to apply. A set will be applied to each base field in...
bool writeFieldType(const word &fieldName) const
Write fields.
const Time & time() const
Return time database.
void addMeanSqrToPrime2Mean() const
Add mean-squared field value to prime-squared mean field.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
bool prime2Mean() const
Return const access to the prime-squared mean flag.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Request registration (bool: true)
void restoreWindowFields(const fieldAverageItem &item)
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
bool calculatePrime2MeanField(const objectRegistry &obr) const
Calculate prime-squared average fields.
forAllConstIters(mixture.phases(), phase)
bool calculateMeanField(const objectRegistry &obr) const
Calculate the mean field value.