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);
98 fieldAverageItem& item
107 addMeanFieldType<VolFieldType>(item);
108 addMeanFieldType<SurfaceFieldType>(item);
109 addMeanFieldType<SurfFieldType>(item);
117 const fieldAverageItem& item
120 if (restartOnOutput_)
125 const word& fieldName = item.fieldName();
127 const Type* fieldPtr = findObject<Type>(fieldName);
134 const FIFOStack<word>& fieldNames = item.windowFieldNames();
138 const word&
name = fieldIter();
150 if (
io.typeHeaderOk<Type>(
true))
153 obr().store(
new Type(
io, fieldPtr->mesh()));
158 <<
"Unable to read window " << Type::typeName <<
" " <<
name 159 <<
". Averaging restart behaviour may be compromised" 169 const fieldAverageItem& item
172 typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
173 typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
174 typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
176 if (item.window() > 0)
178 restoreWindowFieldsType<VolFieldType>(item);
179 restoreWindowFieldsType<SurfaceFieldType>(item);
180 restoreWindowFieldsType<SurfFieldType>(item);
185 template<
class Type1,
class Type2>
188 fieldAverageItem& item
191 const word& fieldName = item.fieldName();
193 if (!foundObject<Type1>(fieldName))
198 const word& meanFieldName = item.meanFieldName();
199 const word& prime2MeanFieldName = item.prime2MeanFieldName();
201 Log <<
" Reading/initialising field " << prime2MeanFieldName <<
nl;
203 if (foundObject<Type2>(prime2MeanFieldName))
205 else if (obr().
found(prime2MeanFieldName))
207 Log <<
" Cannot allocate average field " << prime2MeanFieldName
208 <<
" since an object with that name already exists." 209 <<
" Disabling averaging for field." <<
endl;
211 item.prime2Mean() =
false;
215 const Type1& baseField = lookupObject<Type1>(fieldName);
216 const Type1& meanField = lookupObject<Type1>(meanFieldName);
233 sqr(baseField) -
sqr(meanField)
240 template<
class Type1,
class Type2>
243 fieldAverageItem& item
254 if (item.prime2Mean())
259 <<
"To calculate the prime-squared average, the " 260 <<
"mean average must also be selected for field " 264 addPrime2MeanFieldType<VolFieldType1, VolFieldType2>(item);
265 addPrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>(item);
266 addPrime2MeanFieldType<SurfFieldType1, SurfFieldType2>(item);
274 fieldAverageItem& item
277 const word& fieldName = item.fieldName();
278 if (!foundObject<Type>(fieldName))
283 const Type& baseField = lookupObject<Type>(fieldName);
285 const word windowFieldName = item.windowFieldName(this->
name());
308 item.addToWindow(windowFieldName, obr().time().deltaTValue());
321 if (item.storeWindowFields())
323 storeWindowFieldType<VolFieldType>(item);
324 storeWindowFieldType<SurfaceFieldType>(item);
325 storeWindowFieldType<SurfFieldType>(item);
334 typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
335 typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
336 typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
338 for (
const fieldAverageItem& item : faItems_)
340 item.calculateMeanField<VolFieldType>(obr());
341 item.calculateMeanField<SurfaceFieldType>(obr());
342 item.calculateMeanField<SurfFieldType>(obr());
347 template<
class Type1,
class Type2>
358 for (
const fieldAverageItem& item : faItems_)
360 item.calculatePrime2MeanField<VolFieldType1, VolFieldType2>(obr());
361 item.calculatePrime2MeanField<SurfaceFieldType1, SurfaceFieldType2>
365 item.calculatePrime2MeanField<SurfFieldType1, SurfFieldType2>(obr());
370 template<
class Type1,
class Type2>
373 const fieldAverageItem& item
376 const word& fieldName = item.fieldName();
378 if (!foundObject<Type1>(fieldName))
383 const Type1& meanField = lookupObject<Type1>(item.meanFieldName());
385 Type2& prime2MeanField = lookupObjectRef<Type2>(item.prime2MeanFieldName());
387 prime2MeanField +=
sqr(meanField);
391 template<
class Type1,
class Type2>
404 if (item.prime2Mean())
406 addMeanSqrToPrime2MeanType<VolFieldType1, VolFieldType2>(item);
407 addMeanSqrToPrime2MeanType<SurfaceFieldType1, SurfaceFieldType2>
411 addMeanSqrToPrime2MeanType<SurfFieldType1, SurfFieldType2>(item);
420 const word& fieldName
423 if (foundObject<Type>(fieldName))
425 const Type&
f = lookupObject<Type>(fieldName);
438 for (
const fieldAverageItem& item : faItems_)
442 const word& fieldName = item.meanFieldName();
443 writeFieldType<VolFieldType>(fieldName);
444 writeFieldType<SurfaceFieldType>(fieldName);
445 writeFieldType<SurfFieldType>(fieldName);
448 if (item.prime2Mean())
450 const word& fieldName = item.prime2MeanFieldName();
451 writeFieldType<VolFieldType>(fieldName);
452 writeFieldType<SurfaceFieldType>(fieldName);
453 writeFieldType<SurfFieldType>(fieldName);
456 if (item.writeWindowFields())
458 FIFOStack<word> fieldNames = item.windowFieldNames();
461 const word& fieldName = fieldNameIter();
462 writeFieldType<VolFieldType>(fieldName);
463 writeFieldType<SurfaceFieldType>(fieldName);
464 writeFieldType<SurfFieldType>(fieldName);
const word & meanFieldName() const
Return const access to the mean field name.
void storeWindowFieldType(fieldAverageItem &item)
errorManipArg< error, int > exit(error &err, const int errNo=1)
void restoreWindowFieldsType(const fieldAverageItem &item)
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.
bool store()
Register object with its registry and transfer ownership to the registry.
Generic GeometricField class.
void addMeanField(fieldAverageItem &item)
Add mean average field to database.
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.
Switch restartOnOutput_
Restart the averaging process on output.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void writeFieldType(const word &fieldName) const
Write fields.
void addMeanSqrToPrime2MeanType(const fieldAverageItem &item) const
Add mean-squared field value to prime-squared mean field.
A class for handling words, derived from Foam::string.
Reading is optional [identical to LAZY_READ].
void calculateMeanFields() const
Calculate mean average fields.
#define DebugInfo
Report an information message using Foam::Info.
void addPrime2MeanField(fieldAverageItem &item)
Add prime-squared average field to database.
#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...
Helper class to describe what form of averaging to apply. A set will be applied to each base field in...
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)
void addPrime2MeanFieldType(fieldAverageItem &item)
Add prime-squared average field to database.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Request registration (bool: true)
void restoreWindowFields(const fieldAverageItem &item)
void addMeanFieldType(fieldAverageItem &item)
Add mean average field to database.
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
forAllConstIters(mixture.phases(), phase)