functionObjects::volFieldValue: Added support for a list of weighting fields
This is particularly useful for multiphase simulations for which integrating the
density weighted phase properties also requires the phase fraction to be
including in the weighting.
A single weight field can be specified as before:
weightField rho;
or a list specified by:
weightFields (alpha.water rho.water);
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -80,9 +80,18 @@ void Foam::functionObjects::fieldValues::volFieldValue::initialise
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (dict.readIfPresent("weightField", weightFieldName_))
|
if (dict.readIfPresent("weightFields", weightFieldNames_))
|
||||||
{
|
{
|
||||||
Info<< " weight field = " << weightFieldName_;
|
Info<< name() << " " << operationTypeNames_[operation_]
|
||||||
|
<< " weight fields " << weightFieldNames_;
|
||||||
|
}
|
||||||
|
else if (dict.found("weightField"))
|
||||||
|
{
|
||||||
|
weightFieldNames_.setSize(1);
|
||||||
|
dict.lookup("weightField") >> weightFieldNames_[0];
|
||||||
|
|
||||||
|
Info<< name() << " " << operationTypeNames_[operation_]
|
||||||
|
<< " weight field " << weightFieldNames_[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< nl << endl;
|
Info<< nl << endl;
|
||||||
@ -100,9 +109,14 @@ void Foam::functionObjects::fieldValues::volFieldValue::writeFileHeader
|
|||||||
|
|
||||||
forAll(fields_, fieldi)
|
forAll(fields_, fieldi)
|
||||||
{
|
{
|
||||||
file()
|
file() << tab << operationTypeNames_[operation_] << "(";
|
||||||
<< tab << operationTypeNames_[operation_]
|
|
||||||
<< "(" << fields_[fieldi] << ")";
|
forAll(weightFieldNames_, i)
|
||||||
|
{
|
||||||
|
file() << weightFieldNames_[i] << ',';
|
||||||
|
}
|
||||||
|
|
||||||
|
file() << fields_[fieldi] << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
file() << endl;
|
file() << endl;
|
||||||
@ -120,8 +134,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
|
|||||||
:
|
:
|
||||||
fieldValue(name, runTime, dict, typeName),
|
fieldValue(name, runTime, dict, typeName),
|
||||||
volRegion(fieldValue::mesh_, dict),
|
volRegion(fieldValue::mesh_, dict),
|
||||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
operation_(operationTypeNames_.read(dict.lookup("operation")))
|
||||||
weightFieldName_("none")
|
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
}
|
}
|
||||||
@ -136,8 +149,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
|
|||||||
:
|
:
|
||||||
fieldValue(name, obr, dict, typeName),
|
fieldValue(name, obr, dict, typeName),
|
||||||
volRegion(fieldValue::mesh_, dict),
|
volRegion(fieldValue::mesh_, dict),
|
||||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
operation_(operationTypeNames_.read(dict.lookup("operation")))
|
||||||
weightFieldName_("none")
|
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -65,6 +65,7 @@ Usage
|
|||||||
name | Name of volRegion if required | no |
|
name | Name of volRegion if required | no |
|
||||||
operation | Operation to perform | yes |
|
operation | Operation to perform | yes |
|
||||||
weightField | Name of field to apply weighting | no |
|
weightField | Name of field to apply weighting | no |
|
||||||
|
weightFields | Names of fields to apply weighting | no |
|
||||||
fields | List of fields to operate on | yes |
|
fields | List of fields to operate on | yes |
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
@ -159,8 +160,8 @@ protected:
|
|||||||
//- Operation to apply to values
|
//- Operation to apply to values
|
||||||
operationType operation_;
|
operationType operation_;
|
||||||
|
|
||||||
//- Weight field name - only used for weighted modes
|
//- Weight field names - only used for weighted modes
|
||||||
word weightFieldName_;
|
wordList weightFieldNames_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -179,9 +179,9 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
|
|||||||
scalarField V(filterField(fieldValue::mesh_.V()));
|
scalarField V(filterField(fieldValue::mesh_.V()));
|
||||||
scalarField weightField(values.size(), 1.0);
|
scalarField weightField(values.size(), 1.0);
|
||||||
|
|
||||||
if (weightFieldName_ != "none")
|
forAll(weightFieldNames_, i)
|
||||||
{
|
{
|
||||||
weightField = setFieldValues<scalar>(weightFieldName_, true);
|
weightField *= setFieldValues<scalar>(weightFieldNames_[i], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type result = processValues(values, V, weightField);
|
Type result = processValues(values, V, weightField);
|
||||||
|
|||||||
Reference in New Issue
Block a user