mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fieldAverage - allow averaging on internal fields - see #3242
BUG: fieldAverage - handle duplicate entries
This commit is contained in:
@ -308,13 +308,30 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
|||||||
dict.readIfPresent("restartOnRestart", restartOnRestart_);
|
dict.readIfPresent("restartOnRestart", restartOnRestart_);
|
||||||
dict.readIfPresent("restartOnOutput", restartOnOutput_);
|
dict.readIfPresent("restartOnOutput", restartOnOutput_);
|
||||||
dict.readIfPresent("periodicRestart", periodicRestart_);
|
dict.readIfPresent("periodicRestart", periodicRestart_);
|
||||||
dict.readEntry("fields", faItems_);
|
|
||||||
|
|
||||||
for (auto& item : faItems_)
|
List<fieldAverageItem> faItems0;
|
||||||
|
dict.readEntry("fields", faItems0);
|
||||||
|
|
||||||
|
DynamicList<fieldAverageItem> faItems(faItems0.size());
|
||||||
|
|
||||||
|
wordHashSet names;
|
||||||
|
for (auto& item : faItems0)
|
||||||
|
{
|
||||||
|
if (names.insert(item.fieldName()))
|
||||||
{
|
{
|
||||||
item.setMeanFieldName(scopedName(item.meanFieldName()));
|
item.setMeanFieldName(scopedName(item.meanFieldName()));
|
||||||
item.setPrime2MeanFieldName(scopedName(item.prime2MeanFieldName()));
|
item.setPrime2MeanFieldName(scopedName(item.prime2MeanFieldName()));
|
||||||
|
faItems.push_back(item);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Duplicate entry found: " << item.fieldName()
|
||||||
|
<< " (ignored)" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
faItems_.transfer(faItems);
|
||||||
|
|
||||||
const scalar currentTime = obr().time().value();
|
const scalar currentTime = obr().time().value();
|
||||||
|
|
||||||
|
|||||||
@ -233,19 +233,19 @@ protected:
|
|||||||
|
|
||||||
//- Add mean average field to database
|
//- Add mean average field to database
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void addMeanFieldType(fieldAverageItem& item);
|
bool addMeanFieldType(fieldAverageItem& item);
|
||||||
|
|
||||||
//- Add mean average field to database
|
//- Add mean average field to database
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void addMeanField(fieldAverageItem& item);
|
bool addMeanField(fieldAverageItem& item);
|
||||||
|
|
||||||
//- Add prime-squared average field to database
|
//- Add prime-squared average field to database
|
||||||
template<class Type1, class Type2>
|
template<class Type1, class Type2>
|
||||||
void addPrime2MeanFieldType(fieldAverageItem& item);
|
bool addPrime2MeanFieldType(fieldAverageItem& item);
|
||||||
|
|
||||||
//- Add prime-squared average field to database
|
//- Add prime-squared average field to database
|
||||||
template<class Type1, class Type2>
|
template<class Type1, class Type2>
|
||||||
void addPrime2MeanField(fieldAverageItem& item);
|
bool addPrime2MeanField(fieldAverageItem& item);
|
||||||
|
|
||||||
|
|
||||||
// Calculation functions
|
// Calculation functions
|
||||||
@ -263,20 +263,20 @@ protected:
|
|||||||
|
|
||||||
//- Add mean-squared field value to prime-squared mean field
|
//- Add mean-squared field value to prime-squared mean field
|
||||||
template<class Type1, class Type2>
|
template<class Type1, class Type2>
|
||||||
void addMeanSqrToPrime2MeanType(const fieldAverageItem& item) const;
|
bool addMeanSqrToPrime2MeanType(const fieldAverageItem& item) const;
|
||||||
|
|
||||||
//- Add mean-squared field value to prime-squared mean field
|
//- Add mean-squared field value to prime-squared mean field
|
||||||
template<class Type1, class Type2>
|
template<class Type1, class Type2>
|
||||||
void addMeanSqrToPrime2Mean() const;
|
void addMeanSqrToPrime2Mean() const;
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void storeWindowFieldType(fieldAverageItem& item);
|
bool storeWindowFieldType(fieldAverageItem& item);
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void storeWindowFields();
|
void storeWindowFields();
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void restoreWindowFieldsType(const fieldAverageItem& item);
|
bool restoreWindowFieldsType(const fieldAverageItem& item);
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void restoreWindowFields(const fieldAverageItem& item);
|
void restoreWindowFields(const fieldAverageItem& item);
|
||||||
@ -288,7 +288,7 @@ protected:
|
|||||||
|
|
||||||
//- Write fields
|
//- Write fields
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeFieldType(const word& fieldName) const;
|
bool writeFieldType(const word& fieldName) const;
|
||||||
|
|
||||||
//- Write fields
|
//- Write fields
|
||||||
template<class Type>
|
template<class Type>
|
||||||
|
|||||||
@ -35,16 +35,16 @@ License
|
|||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::functionObjects::fieldAverage::addMeanFieldType
|
bool Foam::functionObjects::fieldAverage::addMeanFieldType
|
||||||
(
|
(
|
||||||
fieldAverageItem& item
|
fieldAverageItem& item
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const word& fieldName = item.fieldName();
|
const Type* fieldPtr = findObject<Type>(item.fieldName());
|
||||||
|
|
||||||
if (!foundObject<Type>(fieldName))
|
if (!fieldPtr)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field has been found, so set active flag to true
|
// Field has been found, so set active flag to true
|
||||||
@ -66,7 +66,7 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const Type& baseField = lookupObject<Type>(fieldName);
|
const Type& baseField = *fieldPtr;
|
||||||
|
|
||||||
// Store on registry
|
// Store on registry
|
||||||
obr().store
|
obr().store
|
||||||
@ -88,38 +88,51 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType
|
|||||||
1*baseField
|
1*baseField
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::functionObjects::fieldAverage::addMeanField
|
bool Foam::functionObjects::fieldAverage::addMeanField
|
||||||
(
|
(
|
||||||
fieldAverageItem& item
|
fieldAverageItem& item
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||||
|
typedef typename VolFieldType::Internal VolFieldInternalType;
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||||
typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
|
typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
|
||||||
|
|
||||||
|
bool added = false;
|
||||||
|
|
||||||
if (item.mean())
|
if (item.mean())
|
||||||
{
|
{
|
||||||
addMeanFieldType<VolFieldType>(item);
|
added =
|
||||||
addMeanFieldType<SurfaceFieldType>(item);
|
(
|
||||||
addMeanFieldType<SurfFieldType>(item);
|
addMeanFieldType<VolFieldType>(item)
|
||||||
|
|| addMeanFieldType<VolFieldInternalType>(item)
|
||||||
|
|| addMeanFieldType<SurfaceFieldType>(item)
|
||||||
|
|| addMeanFieldType<SurfFieldType>(item)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::functionObjects::fieldAverage::restoreWindowFieldsType
|
bool Foam::functionObjects::fieldAverage::restoreWindowFieldsType
|
||||||
(
|
(
|
||||||
const fieldAverageItem& item
|
const fieldAverageItem& item
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (restartOnOutput_)
|
if (restartOnOutput_)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const word& fieldName = item.fieldName();
|
const word& fieldName = item.fieldName();
|
||||||
@ -128,7 +141,7 @@ void Foam::functionObjects::fieldAverage::restoreWindowFieldsType
|
|||||||
|
|
||||||
if (!fieldPtr)
|
if (!fieldPtr)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FIFOStack<word>& fieldNames = item.windowFieldNames();
|
const FIFOStack<word>& fieldNames = item.windowFieldNames();
|
||||||
@ -160,6 +173,8 @@ void Foam::functionObjects::fieldAverage::restoreWindowFieldsType
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -170,29 +185,34 @@ void Foam::functionObjects::fieldAverage::restoreWindowFields
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||||
|
typedef typename VolFieldType::Internal VolFieldInternalType;
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||||
typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
|
typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
|
||||||
|
|
||||||
if (item.window() > 0)
|
if (item.window() > 0)
|
||||||
{
|
{
|
||||||
restoreWindowFieldsType<VolFieldType>(item);
|
(void)
|
||||||
restoreWindowFieldsType<SurfaceFieldType>(item);
|
(
|
||||||
restoreWindowFieldsType<SurfFieldType>(item);
|
restoreWindowFieldsType<VolFieldType>(item)
|
||||||
|
|| restoreWindowFieldsType<VolFieldInternalType>(item)
|
||||||
|
|| restoreWindowFieldsType<SurfaceFieldType>(item)
|
||||||
|
|| restoreWindowFieldsType<SurfFieldType>(item)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type1, class Type2>
|
template<class Type1, class Type2>
|
||||||
void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
|
bool Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
|
||||||
(
|
(
|
||||||
fieldAverageItem& item
|
fieldAverageItem& item
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const word& fieldName = item.fieldName();
|
const auto* baseFieldPtr = findObject<Type1>(item.fieldName());
|
||||||
|
|
||||||
if (!foundObject<Type1>(fieldName))
|
if (!baseFieldPtr)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const word& meanFieldName = item.meanFieldName();
|
const word& meanFieldName = item.meanFieldName();
|
||||||
@ -212,7 +232,7 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const Type1& baseField = lookupObject<Type1>(fieldName);
|
const auto& baseField = *baseFieldPtr;
|
||||||
const Type1& meanField = lookupObject<Type1>(meanFieldName);
|
const Type1& meanField = lookupObject<Type1>(meanFieldName);
|
||||||
|
|
||||||
// Store on registry
|
// Store on registry
|
||||||
@ -233,24 +253,32 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
|
|||||||
sqr(baseField) - sqr(meanField)
|
sqr(baseField) - sqr(meanField)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type1, class Type2>
|
template<class Type1, class Type2>
|
||||||
void Foam::functionObjects::fieldAverage::addPrime2MeanField
|
bool Foam::functionObjects::fieldAverage::addPrime2MeanField
|
||||||
(
|
(
|
||||||
fieldAverageItem& item
|
fieldAverageItem& item
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1;
|
typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1;
|
||||||
|
typedef typename VolFieldType1::Internal VolFieldInternalType1;
|
||||||
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1;
|
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1;
|
||||||
typedef DimensionedField<Type1, polySurfaceGeoMesh> SurfFieldType1;
|
typedef DimensionedField<Type1, polySurfaceGeoMesh> SurfFieldType1;
|
||||||
|
|
||||||
typedef GeometricField<Type2, fvPatchField, volMesh> VolFieldType2;
|
typedef GeometricField<Type2, fvPatchField, volMesh> VolFieldType2;
|
||||||
|
typedef typename VolFieldType2::Internal VolFieldInternalType2;
|
||||||
typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
|
typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
|
||||||
typedef DimensionedField<Type2, polySurfaceGeoMesh> SurfFieldType2;
|
typedef DimensionedField<Type2, polySurfaceGeoMesh> SurfFieldType2;
|
||||||
|
|
||||||
|
bool added = false;
|
||||||
|
|
||||||
if (item.prime2Mean())
|
if (item.prime2Mean())
|
||||||
{
|
{
|
||||||
if (!item.mean())
|
if (!item.mean())
|
||||||
@ -261,26 +289,34 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanField
|
|||||||
<< item.fieldName() << nl << exit(FatalError);
|
<< item.fieldName() << nl << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPrime2MeanFieldType<VolFieldType1, VolFieldType2>(item);
|
added =
|
||||||
addPrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>(item);
|
addPrime2MeanFieldType<VolFieldType1, VolFieldType2>(item)
|
||||||
addPrime2MeanFieldType<SurfFieldType1, SurfFieldType2>(item);
|
|| addPrime2MeanFieldType<VolFieldInternalType1, VolFieldInternalType2>
|
||||||
|
(
|
||||||
|
item
|
||||||
|
)
|
||||||
|
|| addPrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>(item)
|
||||||
|
|| addPrime2MeanFieldType<SurfFieldType1, SurfFieldType2>(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::functionObjects::fieldAverage::storeWindowFieldType
|
bool Foam::functionObjects::fieldAverage::storeWindowFieldType
|
||||||
(
|
(
|
||||||
fieldAverageItem& item
|
fieldAverageItem& item
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const word& fieldName = item.fieldName();
|
const auto* fPtr = findObject<Type>(item.fieldName());
|
||||||
if (!foundObject<Type>(fieldName))
|
|
||||||
|
if (!fPtr)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type& baseField = lookupObject<Type>(fieldName);
|
const Type& baseField = *fPtr;
|
||||||
|
|
||||||
const word windowFieldName = item.windowFieldName(this->name());
|
const word windowFieldName = item.windowFieldName(this->name());
|
||||||
|
|
||||||
@ -306,6 +342,8 @@ void Foam::functionObjects::fieldAverage::storeWindowFieldType
|
|||||||
DebugInfo << "Create and store: " << windowFieldName << endl;
|
DebugInfo << "Create and store: " << windowFieldName << endl;
|
||||||
|
|
||||||
item.addToWindow(windowFieldName, obr().time().deltaTValue());
|
item.addToWindow(windowFieldName, obr().time().deltaTValue());
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -313,6 +351,7 @@ template<class Type>
|
|||||||
void Foam::functionObjects::fieldAverage::storeWindowFields()
|
void Foam::functionObjects::fieldAverage::storeWindowFields()
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||||
|
typedef typename VolFieldType::Internal VolFieldInternalType;
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||||
typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
|
typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
|
||||||
|
|
||||||
@ -320,9 +359,13 @@ void Foam::functionObjects::fieldAverage::storeWindowFields()
|
|||||||
{
|
{
|
||||||
if (item.storeWindowFields())
|
if (item.storeWindowFields())
|
||||||
{
|
{
|
||||||
storeWindowFieldType<VolFieldType>(item);
|
(void)
|
||||||
storeWindowFieldType<SurfaceFieldType>(item);
|
(
|
||||||
storeWindowFieldType<SurfFieldType>(item);
|
storeWindowFieldType<VolFieldType>(item)
|
||||||
|
|| storeWindowFieldType<VolFieldInternalType>(item)
|
||||||
|
|| storeWindowFieldType<SurfaceFieldType>(item)
|
||||||
|
|| storeWindowFieldType<SurfFieldType>(item)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,14 +375,21 @@ template<class Type>
|
|||||||
void Foam::functionObjects::fieldAverage::calculateMeanFields() const
|
void Foam::functionObjects::fieldAverage::calculateMeanFields() const
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||||
|
typedef typename VolFieldType::Internal VolFieldInternalType;
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||||
typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
|
typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
|
||||||
|
|
||||||
|
const auto& obr = this->obr();
|
||||||
|
|
||||||
for (const fieldAverageItem& item : faItems_)
|
for (const fieldAverageItem& item : faItems_)
|
||||||
{
|
{
|
||||||
item.calculateMeanField<VolFieldType>(obr());
|
(void)
|
||||||
item.calculateMeanField<SurfaceFieldType>(obr());
|
(
|
||||||
item.calculateMeanField<SurfFieldType>(obr());
|
item.calculateMeanField<VolFieldType>(obr)
|
||||||
|
|| item.calculateMeanField<VolFieldInternalType>(obr)
|
||||||
|
|| item.calculateMeanField<SurfaceFieldType>(obr)
|
||||||
|
|| item.calculateMeanField<SurfFieldType>(obr)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,36 +398,41 @@ template<class Type1, class Type2>
|
|||||||
void Foam::functionObjects::fieldAverage::calculatePrime2MeanFields() const
|
void Foam::functionObjects::fieldAverage::calculatePrime2MeanFields() const
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1;
|
typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1;
|
||||||
|
typedef typename VolFieldType1::Internal VolFieldInternalType1;
|
||||||
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1;
|
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1;
|
||||||
typedef DimensionedField<Type1, polySurfaceGeoMesh> SurfFieldType1;
|
typedef DimensionedField<Type1, polySurfaceGeoMesh> SurfFieldType1;
|
||||||
|
|
||||||
typedef GeometricField<Type2, fvPatchField, volMesh> VolFieldType2;
|
typedef GeometricField<Type2, fvPatchField, volMesh> VolFieldType2;
|
||||||
|
typedef typename VolFieldType2::Internal VolFieldInternalType2;
|
||||||
typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
|
typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
|
||||||
typedef DimensionedField<Type2, polySurfaceGeoMesh> SurfFieldType2;
|
typedef DimensionedField<Type2, polySurfaceGeoMesh> SurfFieldType2;
|
||||||
|
|
||||||
|
const auto& obr = this->obr();
|
||||||
|
|
||||||
for (const fieldAverageItem& item : faItems_)
|
for (const fieldAverageItem& item : faItems_)
|
||||||
{
|
{
|
||||||
item.calculatePrime2MeanField<VolFieldType1, VolFieldType2>(obr());
|
(void)
|
||||||
item.calculatePrime2MeanField<SurfaceFieldType1, SurfaceFieldType2>
|
|
||||||
(
|
(
|
||||||
obr()
|
item.calculatePrime2MeanField<VolFieldType1, VolFieldType2>(obr)
|
||||||
|
|| item.calculatePrime2MeanField
|
||||||
|
<VolFieldInternalType1, VolFieldInternalType2>(obr)
|
||||||
|
|| item.calculatePrime2MeanField
|
||||||
|
<SurfaceFieldType1, SurfaceFieldType2>(obr)
|
||||||
|
|| item.calculatePrime2MeanField<SurfFieldType1, SurfFieldType2>(obr)
|
||||||
);
|
);
|
||||||
item.calculatePrime2MeanField<SurfFieldType1, SurfFieldType2>(obr());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type1, class Type2>
|
template<class Type1, class Type2>
|
||||||
void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2MeanType
|
bool Foam::functionObjects::fieldAverage::addMeanSqrToPrime2MeanType
|
||||||
(
|
(
|
||||||
const fieldAverageItem& item
|
const fieldAverageItem& item
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const word& fieldName = item.fieldName();
|
if (!foundObject<Type1>(item.fieldName()))
|
||||||
|
|
||||||
if (!foundObject<Type1>(fieldName))
|
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type1& meanField = lookupObject<Type1>(item.meanFieldName());
|
const Type1& meanField = lookupObject<Type1>(item.meanFieldName());
|
||||||
@ -385,6 +440,8 @@ void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2MeanType
|
|||||||
Type2& prime2MeanField = lookupObjectRef<Type2>(item.prime2MeanFieldName());
|
Type2& prime2MeanField = lookupObjectRef<Type2>(item.prime2MeanFieldName());
|
||||||
|
|
||||||
prime2MeanField += sqr(meanField);
|
prime2MeanField += sqr(meanField);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -392,10 +449,12 @@ template<class Type1, class Type2>
|
|||||||
void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2Mean() const
|
void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2Mean() const
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1;
|
typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1;
|
||||||
|
typedef typename VolFieldType1::Internal VolFieldInternalType1;
|
||||||
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1;
|
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1;
|
||||||
typedef DimensionedField<Type1, polySurfaceGeoMesh> SurfFieldType1;
|
typedef DimensionedField<Type1, polySurfaceGeoMesh> SurfFieldType1;
|
||||||
|
|
||||||
typedef GeometricField<Type2, fvPatchField, volMesh> VolFieldType2;
|
typedef GeometricField<Type2, fvPatchField, volMesh> VolFieldType2;
|
||||||
|
typedef typename VolFieldType2::Internal VolFieldInternalType2;
|
||||||
typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
|
typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
|
||||||
typedef DimensionedField<Type2, polySurfaceGeoMesh> SurfFieldType2;
|
typedef DimensionedField<Type2, polySurfaceGeoMesh> SurfFieldType2;
|
||||||
|
|
||||||
@ -403,28 +462,36 @@ void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2Mean() const
|
|||||||
{
|
{
|
||||||
if (item.prime2Mean())
|
if (item.prime2Mean())
|
||||||
{
|
{
|
||||||
addMeanSqrToPrime2MeanType<VolFieldType1, VolFieldType2>(item);
|
(void)
|
||||||
addMeanSqrToPrime2MeanType<SurfaceFieldType1, SurfaceFieldType2>
|
|
||||||
(
|
(
|
||||||
item
|
addMeanSqrToPrime2MeanType<VolFieldType1, VolFieldType2>(item)
|
||||||
|
|| addMeanSqrToPrime2MeanType
|
||||||
|
<VolFieldInternalType1, VolFieldInternalType2>(item)
|
||||||
|
|| addMeanSqrToPrime2MeanType
|
||||||
|
<SurfaceFieldType1, SurfaceFieldType2>(item)
|
||||||
|
|| addMeanSqrToPrime2MeanType
|
||||||
|
<SurfFieldType1, SurfFieldType2>(item)
|
||||||
);
|
);
|
||||||
addMeanSqrToPrime2MeanType<SurfFieldType1, SurfFieldType2>(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::functionObjects::fieldAverage::writeFieldType
|
bool Foam::functionObjects::fieldAverage::writeFieldType
|
||||||
(
|
(
|
||||||
const word& fieldName
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (foundObject<Type>(fieldName))
|
const auto* fPtr = findObject<Type>(fieldName);
|
||||||
|
|
||||||
|
if (fPtr)
|
||||||
{
|
{
|
||||||
const Type& f = lookupObject<Type>(fieldName);
|
DebugInfo<< "writing " << Type::typeName << ": " << fieldName << endl;
|
||||||
f.write();
|
return fPtr->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -432,6 +499,7 @@ template<class Type>
|
|||||||
void Foam::functionObjects::fieldAverage::writeFields() const
|
void Foam::functionObjects::fieldAverage::writeFields() const
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||||
|
typedef typename VolFieldType::Internal VolFieldInternalType;
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||||
typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
|
typedef DimensionedField<Type, polySurfaceGeoMesh> SurfFieldType;
|
||||||
|
|
||||||
@ -440,17 +508,27 @@ void Foam::functionObjects::fieldAverage::writeFields() const
|
|||||||
if (item.mean())
|
if (item.mean())
|
||||||
{
|
{
|
||||||
const word& fieldName = item.meanFieldName();
|
const word& fieldName = item.meanFieldName();
|
||||||
writeFieldType<VolFieldType>(fieldName);
|
|
||||||
writeFieldType<SurfaceFieldType>(fieldName);
|
(void)
|
||||||
writeFieldType<SurfFieldType>(fieldName);
|
(
|
||||||
|
writeFieldType<VolFieldType>(fieldName)
|
||||||
|
|| writeFieldType<VolFieldInternalType>(fieldName)
|
||||||
|
|| writeFieldType<SurfaceFieldType>(fieldName)
|
||||||
|
|| writeFieldType<SurfFieldType>(fieldName)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.prime2Mean())
|
if (item.prime2Mean())
|
||||||
{
|
{
|
||||||
const word& fieldName = item.prime2MeanFieldName();
|
const word& fieldName = item.prime2MeanFieldName();
|
||||||
writeFieldType<VolFieldType>(fieldName);
|
|
||||||
writeFieldType<SurfaceFieldType>(fieldName);
|
(void)
|
||||||
writeFieldType<SurfFieldType>(fieldName);
|
(
|
||||||
|
writeFieldType<VolFieldType>(fieldName)
|
||||||
|
|| writeFieldType<VolFieldInternalType>(fieldName)
|
||||||
|
|| writeFieldType<SurfaceFieldType>(fieldName)
|
||||||
|
|| writeFieldType<SurfFieldType>(fieldName)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.writeWindowFields())
|
if (item.writeWindowFields())
|
||||||
@ -459,9 +537,14 @@ void Foam::functionObjects::fieldAverage::writeFields() const
|
|||||||
forAllConstIters(fieldNames, fieldNameIter)
|
forAllConstIters(fieldNames, fieldNameIter)
|
||||||
{
|
{
|
||||||
const word& fieldName = fieldNameIter();
|
const word& fieldName = fieldNameIter();
|
||||||
writeFieldType<VolFieldType>(fieldName);
|
|
||||||
writeFieldType<SurfaceFieldType>(fieldName);
|
(void)
|
||||||
writeFieldType<SurfFieldType>(fieldName);
|
(
|
||||||
|
writeFieldType<VolFieldType>(fieldName)
|
||||||
|
|| writeFieldType<VolFieldInternalType>(fieldName)
|
||||||
|
|| writeFieldType<SurfaceFieldType>(fieldName)
|
||||||
|
|| writeFieldType<SurfFieldType>(fieldName)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user