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:
Henry Weller
2020-02-24 15:28:36 +00:00
parent b494e5a9c8
commit e01de98df0
3 changed files with 29 additions and 16 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -80,9 +80,18 @@ void Foam::functionObjects::fieldValues::volFieldValue::initialise
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;
@ -100,9 +109,14 @@ void Foam::functionObjects::fieldValues::volFieldValue::writeFileHeader
forAll(fields_, fieldi)
{
file()
<< tab << operationTypeNames_[operation_]
<< "(" << fields_[fieldi] << ")";
file() << tab << operationTypeNames_[operation_] << "(";
forAll(weightFieldNames_, i)
{
file() << weightFieldNames_[i] << ',';
}
file() << fields_[fieldi] << ")";
}
file() << endl;
@ -120,8 +134,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
:
fieldValue(name, runTime, dict, typeName),
volRegion(fieldValue::mesh_, dict),
operation_(operationTypeNames_.read(dict.lookup("operation"))),
weightFieldName_("none")
operation_(operationTypeNames_.read(dict.lookup("operation")))
{
read(dict);
}
@ -136,8 +149,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
:
fieldValue(name, obr, dict, typeName),
volRegion(fieldValue::mesh_, dict),
operation_(operationTypeNames_.read(dict.lookup("operation"))),
weightFieldName_("none")
operation_(operationTypeNames_.read(dict.lookup("operation")))
{
read(dict);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -65,6 +65,7 @@ Usage
name | Name of volRegion if required | no |
operation | Operation to perform | yes |
weightField | Name of field to apply weighting | no |
weightFields | Names of fields to apply weighting | no |
fields | List of fields to operate on | yes |
\endtable
@ -159,8 +160,8 @@ protected:
//- Operation to apply to values
operationType operation_;
//- Weight field name - only used for weighted modes
word weightFieldName_;
//- Weight field names - only used for weighted modes
wordList weightFieldNames_;
// Protected Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -179,9 +179,9 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
scalarField V(filterField(fieldValue::mesh_.V()));
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);