36 const word& meanFieldName =
faItems_[fieldi].meanFieldName();
55 Log <<
" Cannot read average field " << meanFieldName
56 <<
" since an object with that name already exists."
57 <<
" Disabling averaging for field." <<
endl;
63 Log <<
" Reading field " << meanFieldName <<
endl;
74 if (faItems_[fieldi].mean())
76 readMeanFieldType<VolField<Type>>(fieldi);
77 readMeanFieldType<VolInternalField<Type>>(fieldi);
78 readMeanFieldType<SurfaceField<Type>>(fieldi);
89 const word& fieldName = faItems_[fieldi].fieldName();
90 const word& meanFieldName = faItems_[fieldi].meanFieldName();
92 if (obr_.foundObject<Type>(meanFieldName))
96 else if (obr_.found(meanFieldName))
98 Log <<
" Cannot initialise average field " << meanFieldName
99 <<
" since an object with that name already exists."
100 <<
" Disabling averaging for field." <<
endl;
102 faItems_[fieldi].mean() =
false;
106 Log <<
" Initialising field " << meanFieldName <<
endl;
108 const Type& baseField = obr_.lookupObject<Type>(fieldName);
133 if (faItems_[fieldi].mean())
135 const word& fieldName = faItems_[fieldi].fieldName();
139 initialiseMeanFieldType<VolField<Type>>(fieldi);
143 initialiseMeanFieldType<VolInternalField<Type>>(fieldi);
147 initialiseMeanFieldType<SurfaceField<Type>>(fieldi);
153 template<
class Type1,
class Type2>
159 const word& prime2MeanFieldName = faItems_[fieldi].prime2MeanFieldName();
176 if (obr_.found(prime2MeanFieldName))
178 Log <<
" Cannot read average field " << prime2MeanFieldName
179 <<
" since an object with that name already exists."
180 <<
" Disabling averaging for field." <<
endl;
182 faItems_[fieldi].mean() =
false;
186 Log <<
" Reading field " << prime2MeanFieldName <<
endl;
188 obr_.store(
new Type2(prime2MeanFieldIo, mesh_));
194 template<
class Type1,
class Type2>
200 if (faItems_[fieldi].prime2Mean())
202 if (!faItems_[fieldi].mean())
205 <<
"To calculate the prime-squared average, the "
206 <<
"mean average must also be selected for field "
210 readPrime2MeanFieldType
212 readPrime2MeanFieldType
214 readPrime2MeanFieldType
220 template<
class Type1,
class Type2>
226 const word& fieldName = faItems_[fieldi].fieldName();
227 const word& meanFieldName = faItems_[fieldi].meanFieldName();
228 const word& prime2MeanFieldName = faItems_[fieldi].prime2MeanFieldName();
230 if (obr_.foundObject<Type2>(prime2MeanFieldName))
234 else if (obr_.found(prime2MeanFieldName))
236 Log <<
" Cannot initialise average field " << prime2MeanFieldName
237 <<
" since an object with that name already exists."
238 <<
" Disabling averaging for field." <<
nl;
240 faItems_[fieldi].prime2Mean() =
false;
244 Log <<
" Initialising field " << prime2MeanFieldName <<
nl;
246 const Type1& baseField = obr_.lookupObject<Type1>(fieldName);
247 const Type1& meanField = obr_.lookupObject<Type1>(meanFieldName);
259 sqr(baseField) -
sqr(meanField)
266 template<
class Type1,
class Type2>
272 if (faItems_[fieldi].prime2Mean())
274 const word& fieldName = faItems_[fieldi].fieldName();
276 if (!faItems_[fieldi].mean())
279 <<
"To calculate the prime-squared average, the "
280 <<
"mean average must also be selected for field "
286 initialisePrime2MeanFieldType
291 initialisePrime2MeanFieldType
296 initialisePrime2MeanFieldType
309 const word& fieldName = faItems_[fieldi].fieldName();
311 const Type& baseField = obr_.lookupObject<Type>(fieldName);
314 obr_.lookupObjectRef<Type>(faItems_[fieldi].meanFieldName());
316 scalar dt = time_.deltaTValue();
317 scalar Dt = totalTime_[fieldi];
322 Dt = scalar(totalIter_[fieldi]);
329 const scalar w = window();
337 meanField = (1 - beta)*meanField + beta*baseField;
346 if (faItems_[fieldi].mean())
348 const word& fieldName = faItems_[fieldi].fieldName();
352 calculateMeanFieldType<VolField<Type>>(fieldi);
356 calculateMeanFieldType<VolInternalField<Type>>(fieldi);
360 calculateMeanFieldType<SurfaceField<Type>>(fieldi);
367 template<
class Type1,
class Type2>
373 const word& fieldName = faItems_[fieldi].fieldName();
375 const Type1& baseField = obr_.lookupObject<Type1>(fieldName);
376 const Type1& meanField =
377 obr_.lookupObject<Type1>(faItems_[fieldi].meanFieldName());
379 Type2& prime2MeanField =
380 obr_.lookupObjectRef<Type2>(faItems_[fieldi].prime2MeanFieldName());
382 scalar dt = time_.deltaTValue();
383 scalar Dt = totalTime_[fieldi];
388 Dt = scalar(totalIter_[fieldi]);
395 const scalar w = window();
404 (1 - beta)*prime2MeanField
405 + beta*
sqr(baseField)
410 template<
class Type1,
class Type2>
415 if (faItems_[fieldi].prime2Mean())
417 const word& fieldName = faItems_[fieldi].fieldName();
421 calculatePrime2MeanFieldType
426 calculatePrime2MeanFieldType
431 calculatePrime2MeanFieldType
439 template<
class Type1,
class Type2>
445 const Type1& meanField =
446 obr_.lookupObject<Type1>(faItems_[fieldi].meanFieldName());
448 Type2& prime2MeanField =
449 obr_.lookupObjectRef<Type2>(faItems_[fieldi].prime2MeanFieldName());
451 prime2MeanField +=
sqr(meanField);
455 template<
class Type1,
class Type2>
460 if (faItems_[fieldi].prime2Mean())
462 const word& fieldName = faItems_[fieldi].fieldName();
466 addMeanSqrToPrime2MeanType
471 addMeanSqrToPrime2MeanType
476 addMeanSqrToPrime2MeanType
487 const word& fieldName
490 if (obr_.foundObject<Type>(fieldName))
492 const Type&
f = obr_.lookupObject<Type>(fieldName);
503 if (faItems_[fieldi].mean())
505 const word& fieldName = faItems_[fieldi].meanFieldName();
506 writeFieldType<VolField<Type>>(fieldName);
507 writeFieldType<VolInternalField<Type>>(fieldName);
508 writeFieldType<SurfaceField<Type>>(fieldName);
510 if (faItems_[fieldi].prime2Mean())
512 const word& fieldName = faItems_[fieldi].prime2MeanFieldName();
513 writeFieldType<VolField<Type>>(fieldName);
514 writeFieldType<VolInternalField<Type>>(fieldName);
515 writeFieldType<SurfaceField<Type>>(fieldName);
#define forAll(list, i)
Loop across all elements in list.
Generic GeometricField class.
bool found(const Key &) const
Return true if hashedEntry is found in table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
bool headerOk()
Read header of local object without type-checking.
const word & headerClassName() const
Return name of the class name read from header.
const word & name() const
Return const reference to name.
const Time & time_
Reference to time.
void readPrime2MeanField(const label fieldi)
Read the prime-squared average field.
void initialiseMeanField(const label fieldi)
Initialise the mean average field.
void readMeanFieldType(const label fieldi)
Read the mean average field.
void writeFields() const
Write fields.
void readPrime2MeanFieldType(const label fieldi)
Read the prime-squared average field.
void calculatePrime2MeanFields() const
Calculate prime-squared average fields.
void initialisePrime2MeanFieldType(const label fieldi)
Initialise the prime-squared average field.
PtrList< fieldAverageItem > faItems_
List of field average items, describing what averages to be.
void addMeanSqrToPrime2MeanType(const label fieldi) const
Add mean-squared field value to prime-squared mean field.
void readMeanField(const label fieldi)
Read the mean average field.
void calculatePrime2MeanFieldType(const label fieldi) const
Calculate prime-squared average fields.
void writeFieldType(const word &fieldName) const
Write fields.
void calculateMeanFieldType(const label fieldi) const
Calculate mean average fields.
void initialiseMeanFieldType(const label fieldi)
Initialise the mean average field.
void initialisePrime2MeanField(const label fieldi)
Initialise the prime-squared average field.
void calculateMeanFields() const
Calculate mean average fields.
void addMeanSqrToPrime2Mean() const
Add mean-squared field value to prime-squared mean field.
const fvMesh & mesh_
Reference to the fvMesh.
const objectRegistry & obr_
Reference to the region objectRegistry.
void store()
Transfer ownership of this object to its registry.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define Log
Report write to Foam::Info if the local log switch is true.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
typename VolField< Type >::Internal VolInternalField