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