WIP: fieldStatistics: add volume-weighted average to the options
This commit is contained in:
parent
5f2d55e07b
commit
40eda57389
@ -50,6 +50,16 @@ Foam::functionObjects::fieldStatistics::modeTypeNames_
|
|||||||
{ modeType::mdCmpt, "component" },
|
{ modeType::mdCmpt, "component" },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const Foam::Enum
|
||||||
|
<
|
||||||
|
Foam::functionObjects::fieldStatistics::meanType
|
||||||
|
>
|
||||||
|
Foam::functionObjects::fieldStatistics::meanTypeNames_
|
||||||
|
({
|
||||||
|
{ meanType::ARITHMETIC, "arithmetic" },
|
||||||
|
{ meanType::VOLUMETRIC, "volumetric" },
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -156,6 +166,7 @@ bool Foam::functionObjects::fieldStatistics::read(const dictionary& dict)
|
|||||||
internal_ = dict.getOrDefault("internal", false);
|
internal_ = dict.getOrDefault("internal", false);
|
||||||
|
|
||||||
mode_ = modeTypeNames_.getOrDefault("mode", dict, modeType::mdMag);
|
mode_ = modeTypeNames_.getOrDefault("mode", dict, modeType::mdMag);
|
||||||
|
mean_ = meanTypeNames_.getOrDefault("mean", dict, meanType::ARITHMETIC);
|
||||||
|
|
||||||
// Reset and reprepare the input field names
|
// Reset and reprepare the input field names
|
||||||
fieldSet_.clear();
|
fieldSet_.clear();
|
||||||
|
@ -53,6 +53,7 @@ Usage
|
|||||||
// Optional entries
|
// Optional entries
|
||||||
mode <word>;
|
mode <word>;
|
||||||
internal <bool>;
|
internal <bool>;
|
||||||
|
mean <word>;
|
||||||
|
|
||||||
// Inherited entries
|
// Inherited entries
|
||||||
...
|
...
|
||||||
@ -69,6 +70,7 @@ Usage
|
|||||||
mode | Output format of the statistical results | word | no | magnitude
|
mode | Output format of the statistical results | word | no | magnitude
|
||||||
internal | Flag to use internal fields only in computing statistics <!--
|
internal | Flag to use internal fields only in computing statistics <!--
|
||||||
--> | bool | no | false
|
--> | bool | no | false
|
||||||
|
mean | Type of the mean operation | word | no | arithmetic
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
Available statistics of the operand field through the \c statistics entry:
|
Available statistics of the operand field through the \c statistics entry:
|
||||||
@ -85,6 +87,12 @@ Usage
|
|||||||
component | Output statistics separately for each component
|
component | Output statistics separately for each component
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Options for the \c meanType entry:
|
||||||
|
\verbatim
|
||||||
|
arithmetic | Arithmetic mean (average)
|
||||||
|
volumetric | Volume-weighted arithmetic mean
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
The inherited entries are elaborated in:
|
The inherited entries are elaborated in:
|
||||||
- \link functionObject.H \endlink
|
- \link functionObject.H \endlink
|
||||||
- \link writeFile.H \endlink
|
- \link writeFile.H \endlink
|
||||||
@ -133,6 +141,17 @@ class fieldStatistics
|
|||||||
static const Enum<modeType> modeTypeNames_;
|
static const Enum<modeType> modeTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
|
//- Options for the mean type of the specified fields
|
||||||
|
enum meanType : char
|
||||||
|
{
|
||||||
|
ARITHMETIC = 0, //!< "Arithmetic mean (average)"
|
||||||
|
VOLUMETRIC //!< "Volume-weighted arithmetic mean"
|
||||||
|
};
|
||||||
|
|
||||||
|
//- Names for meanType
|
||||||
|
static const Enum<meanType> meanTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
// Private Classes
|
// Private Classes
|
||||||
|
|
||||||
//- Type-safe union for input field types
|
//- Type-safe union for input field types
|
||||||
@ -172,6 +191,9 @@ class fieldStatistics
|
|||||||
//- Output-format mode - only applicable for tensor ranks > 0
|
//- Output-format mode - only applicable for tensor ranks > 0
|
||||||
modeType mode_;
|
modeType mode_;
|
||||||
|
|
||||||
|
//- Type of the mean of the specified fields
|
||||||
|
meanType mean_;
|
||||||
|
|
||||||
//- Operand fields on which statistics are computed
|
//- Operand fields on which statistics are computed
|
||||||
volFieldSelection fieldSet_;
|
volFieldSelection fieldSet_;
|
||||||
|
|
||||||
|
@ -108,6 +108,12 @@ bool Foam::functionObjects::fieldStatistics::calcStat(const word& fieldName)
|
|||||||
template<class T>
|
template<class T>
|
||||||
T Foam::functionObjects::fieldStatistics::calcMean(const Field<T>& field)
|
T Foam::functionObjects::fieldStatistics::calcMean(const Field<T>& field)
|
||||||
{
|
{
|
||||||
|
if (internal_ && (mean_ == VOLUMETRIC))
|
||||||
|
{
|
||||||
|
const auto& V = mesh_.V();
|
||||||
|
return (gSum(V*field)/gSum(V));
|
||||||
|
}
|
||||||
|
|
||||||
return gAverage(field);
|
return gAverage(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user