diff --git a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C index c367fe9171..5694c82b27 100644 --- a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C +++ b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.C @@ -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); } diff --git a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.H b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.H index cc22044bb8..ad355cfe52 100644 --- a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.H +++ b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValue.H @@ -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 diff --git a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValueTemplates.C b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValueTemplates.C index 5e3658243f..88ba9f458c 100644 --- a/src/functionObjects/field/fieldValues/volFieldValue/volFieldValueTemplates.C +++ b/src/functionObjects/field/fieldValues/volFieldValue/volFieldValueTemplates.C @@ -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(weightFieldName_, true); + weightField *= setFieldValues(weightFieldNames_[i], true); } Type result = processValues(values, V, weightField);