BUG: missing unit-normal weighting for surfaceFieldValue (fixes #2273)

- when using a vector field for weighting, it either used mag()
  or mag * area, but did not have a unit-normal projection version
This commit is contained in:
Mark Olesen
2021-11-22 15:59:46 +01:00
parent ccb0fd9cf0
commit 55af2fc2c6
11 changed files with 343 additions and 163 deletions

View File

@ -114,7 +114,7 @@ bool Foam::functionObjects::fieldValue::execute()
bool Foam::functionObjects::fieldValue::write()
{
Log << type() << " " << name() << " write:" << nl;
Log << type() << ' ' << name() << " write:" << nl;
return true;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -186,16 +186,16 @@ public:
// Member Functions
//- Return the reference to the construction dictionary
inline const dictionary& dict() const;
inline const dictionary& dict() const noexcept;
//- Return the region name
inline const word& regionName() const;
inline const word& regionName() const noexcept;
//- Return the list of field names
inline const wordList& fields() const;
inline const wordList& fields() const noexcept;
//- Return the output field values flag
inline bool writeFields() const;
inline bool writeFields() const noexcept;
//- Read from dictionary
virtual bool read(const dictionary& dict);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,25 +28,28 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::dictionary& Foam::functionObjects::fieldValue::dict() const
inline const Foam::dictionary& Foam::functionObjects::fieldValue::dict()
const noexcept
{
return dict_;
}
inline const Foam::word& Foam::functionObjects::fieldValue::regionName() const
inline const Foam::word& Foam::functionObjects::fieldValue::regionName()
const noexcept
{
return regionName_;
}
inline const Foam::wordList& Foam::functionObjects::fieldValue::fields() const
inline const Foam::wordList& Foam::functionObjects::fieldValue::fields()
const noexcept
{
return fields_;
}
inline bool Foam::functionObjects::fieldValue::writeFields() const
inline bool Foam::functionObjects::fieldValue::writeFields() const noexcept
{
return writeFields_;
}

View File

@ -543,9 +543,10 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::functionObjects::fieldValues::surfaceFieldValue::usesSf() const
bool Foam::functionObjects::fieldValues::surfaceFieldValue::usesSf()
const noexcept
{
// Only a few operations do not require the Sf field
// Few operations do not require the Sf field
switch (operation_)
{
case opNone:
@ -554,14 +555,11 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::usesSf() const
case opSum:
case opSumMag:
case opAverage:
{
return false;
}
default:
{
return true;
}
}
}
@ -703,11 +701,14 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
scalar mean, numer;
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
// Weighted quantity = (Weight * phi * dA)
tmp<scalarField> weight(weightingFactor(weightField));
tmp<scalarField> weight
(
weightingFactor(weightField, is_magOp())
);
// Mean weighted value (area-averaged)
mean = gSum(weight()*areaVal()) / areaTotal;
@ -786,11 +787,14 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
scalar mean, numer;
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
// Weighted quantity = (Weight * phi . dA)
tmp<scalarField> weight(weightingFactor(weightField));
tmp<scalarField> weight
(
weightingFactor(weightField, is_magOp())
);
// Mean weighted value (area-averaged)
mean = gSum(weight()*areaVal()) / areaTotal;
@ -824,14 +828,17 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<>
Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
(
const Field<scalar>& weightField
) const
const Field<scalar>& weightField,
const bool useMag
)
{
if (usesMag())
if (useMag)
{
return mag(weightField);
}
@ -846,17 +853,48 @@ Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
(
const Field<scalar>& weightField,
const vectorField& Sf
) const
const vectorField& Sf,
const bool useMag
)
{
// scalar * unit-normal
// Can skip this check - already used canWeight()
/// if (returnReduce(weightField.empty(), andOp<bool>()))
/// {
/// // No weight field - revert to unweighted form?
/// return tmp<scalarField>::New(Sf.size(), scalar(1));
/// }
if (useMag)
{
return mag(weightField);
}
// pass through
return weightField;
}
template<>
Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::areaWeightingFactor
(
const Field<scalar>& weightField,
const vectorField& Sf,
const bool useMag
)
{
// scalar * Area
if (returnReduce(weightField.empty(), andOp<bool>()))
{
// No weight field - revert to unweighted form
return mag(Sf);
}
else if (usesMag())
// Can skip this check - already used canWeight()
/// if (returnReduce(weightField.empty(), andOp<bool>()))
/// {
/// // No weight field - revert to unweighted form
/// return mag(Sf);
/// }
if (useMag)
{
return mag(weightField * mag(Sf));
}
@ -870,17 +908,61 @@ Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
(
const Field<vector>& weightField,
const vectorField& Sf
) const
const vectorField& Sf,
const bool useMag
)
{
// vector (dot) unit-normal
// Can skip this check - already used canWeight()
/// if (returnReduce(weightField.empty(), andOp<bool>()))
/// {
/// // No weight field - revert to unweighted form
/// return tmp<scalarField>::New(Sf.size(), scalar(1));
/// }
const label len = weightField.size();
auto tresult = tmp<scalarField>::New(weightField.size());
auto& result = tresult.ref();
for (label facei=0; facei < len; ++facei)
{
const vector unitNormal(normalised(Sf[facei]));
result[facei] = (weightField[facei] & unitNormal);
}
if (useMag)
{
for (scalar& val : result)
{
val = mag(val);
}
}
return tresult;
}
template<>
Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::areaWeightingFactor
(
const Field<vector>& weightField,
const vectorField& Sf,
const bool useMag
)
{
// vector (dot) Area
if (returnReduce(weightField.empty(), andOp<bool>()))
{
// No weight field - revert to unweighted form
return mag(Sf);
}
else if (usesMag())
// Can skip this check - already used canWeight()
/// if (returnReduce(weightField.empty(), andOp<bool>()))
/// {
/// // No weight field - revert to unweighted form
/// return mag(Sf);
/// }
if (useMag)
{
return mag(weightField & Sf);
}
@ -959,6 +1041,13 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// Needs completed sampledSurface, surfaceWriter
Foam::functionObjects::fieldValues::surfaceFieldValue::~surfaceFieldValue()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::fieldValues::surfaceFieldValue::read
@ -1048,7 +1137,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::read
Info<< operationTypeNames_[operation_] << nl;
}
if (usesWeight())
if (is_weightedOp())
{
// Can have "weightFields" or "weightField"

View File

@ -435,6 +435,40 @@ protected:
autoPtr<surfaceWriter> surfaceWriterPtr_;
// Static Member Functions
//- Weighting factor.
// Possibly applies mag() depending on the operation type.
template<class WeightType>
static tmp<scalarField> weightingFactor
(
const Field<WeightType>& weightField,
const bool useMag
);
//- Weighting factor, weight field projected onto unit-normal.
// Possibly applies mag() depending on the operation type.
// Reverts to 'one' if the weight field is unavailable.
template<class WeightType>
static tmp<scalarField> weightingFactor
(
const Field<WeightType>& weightField,
const vectorField& Sf,
const bool useMag
);
//- Weighting factor, weight field with area factor.
// Possibly applies mag() depending on the operation type.
// Reverts to mag(Sf) if the weight field is unavailable.
template<class WeightType>
static tmp<scalarField> areaWeightingFactor
(
const Field<WeightType>& weightField,
const vectorField& Sf,
const bool useMag
);
// Protected Member Functions
//- The volume mesh or surface registry being used
@ -444,30 +478,29 @@ protected:
inline bool withSurfaceFields() const;
//- Can use mesh topological merge?
inline bool withTopologicalMerge() const;
inline bool withTopologicalMerge() const noexcept;
//- Return the local list of face IDs
inline const labelList& faceId() const;
inline const labelList& faceId() const noexcept;
//- Return the local list of patch ID per face
inline const labelList& facePatch() const;
inline const labelList& facePatch() const noexcept;
//- Return the local true/false list representing the face flip map
inline const boolList& faceFlip() const;
inline const boolList& faceFlip() const noexcept;
//- True if the operation needs a surface Sf
bool usesSf() const;
bool usesSf() const noexcept;
//- True if the operation variant uses mag
inline bool usesMag() const;
inline bool is_magOp() const noexcept;
//- True if the operation variant uses a weight-field
inline bool usesWeight() const;
inline bool is_weightedOp() const noexcept;
//- True if operation variant uses a weight-field that is available.
// Checks for availability on any processor.
//- True if field is non-empty on any processor.
template<class WeightType>
inline bool canWeight(const Field<WeightType>& weightField) const;
inline bool canWeight(const Field<WeightType>& fld) const;
//- Update the surface and surface information as required.
// Do nothing (and return false) if no update was required
@ -519,26 +552,6 @@ protected:
const GeometricField<Type, fvPatchField, volMesh>& field
) const;
//- Weighting factor.
// Possibly applies mag() depending on the operation type.
template<class WeightType>
tmp<scalarField> weightingFactor
(
const Field<WeightType>& weightField
) const;
//- Weighting factor, weight field with the area.
// Possibly applies mag() depending on the operation type.
// Reverts to mag(Sf) if the weight field is not available.
template<class WeightType>
tmp<scalarField> weightingFactor
(
const Field<WeightType>& weightField,
const vectorField& Sf
) const;
//- Templated helper function to output field values
template<class WeightType>
label writeAll
@ -597,13 +610,13 @@ public:
//- Destructor
virtual ~surfaceFieldValue() = default;
virtual ~surfaceFieldValue();
// Member Functions
//- Return the region type
inline regionTypes regionType() const;
inline regionTypes regionType() const noexcept;
//- Return the output directory
inline fileName outputDir() const;
@ -646,26 +659,46 @@ vector surfaceFieldValue::processValues
template<>
tmp<scalarField> surfaceFieldValue::weightingFactor
(
const Field<scalar>& weightField
) const;
const Field<scalar>& weightField,
const bool useMag
);
//- Specialisation for scalar - scalar * Area
//- Specialisation for scalar - pass through
template<>
tmp<scalarField> surfaceFieldValue::weightingFactor
(
const Field<scalar>& weightField,
const vectorField& Sf
) const;
const vectorField& Sf /* unused */,
const bool useMag
);
//- Specialisation for scalar - scalar * Area
template<>
tmp<scalarField> surfaceFieldValue::areaWeightingFactor
(
const Field<scalar>& weightField,
const vectorField& Sf,
const bool useMag
);
//- Specialisation for vector - vector (dot) Area
//- Specialisation for vector - vector (dot) unit-normal
template<>
tmp<scalarField> surfaceFieldValue::weightingFactor
(
const Field<vector>& weightField,
const vectorField& Sf
) const;
const vectorField& Sf,
const bool useMag
);
//- Specialisation for vector - vector (dot) Area
template<>
tmp<scalarField> surfaceFieldValue::areaWeightingFactor
(
const Field<vector>& weightField,
const vectorField& Sf,
const bool useMag
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -44,28 +44,31 @@ withSurfaceFields() const
inline bool Foam::functionObjects::fieldValues::surfaceFieldValue::
withTopologicalMerge() const
withTopologicalMerge() const noexcept
{
return (stFaceZone == regionType_ || stPatch == regionType_);
}
inline const Foam::labelList&
Foam::functionObjects::fieldValues::surfaceFieldValue::faceId() const
Foam::functionObjects::fieldValues::surfaceFieldValue::faceId()
const noexcept
{
return faceId_;
}
inline const Foam::labelList&
Foam::functionObjects::fieldValues::surfaceFieldValue::facePatch() const
Foam::functionObjects::fieldValues::surfaceFieldValue::facePatch()
const noexcept
{
return facePatchId_;
}
inline const Foam::boolList&
Foam::functionObjects::fieldValues::surfaceFieldValue::faceFlip() const
Foam::functionObjects::fieldValues::surfaceFieldValue::faceFlip()
const noexcept
{
return faceFlip_;
}
@ -73,16 +76,17 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::faceFlip() const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool
Foam::functionObjects::fieldValues::surfaceFieldValue::usesMag() const
inline bool Foam::functionObjects::fieldValues::surfaceFieldValue::
is_magOp()
const noexcept
{
// Operation specifically tagged to use mag
return (operation_ & typeAbsolute);
}
inline bool
Foam::functionObjects::fieldValues::surfaceFieldValue::usesWeight() const
inline bool Foam::functionObjects::fieldValues::surfaceFieldValue::
is_weightedOp() const noexcept
{
// Operation specifically tagged to require a weight field
return (operation_ & typeWeighted);
@ -90,7 +94,8 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::usesWeight() const
inline Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypes
Foam::functionObjects::fieldValues::surfaceFieldValue::regionType() const
Foam::functionObjects::fieldValues::surfaceFieldValue::regionType()
const noexcept
{
return regionType_;
}

View File

@ -35,19 +35,32 @@ License
#include "interpolationCell.H"
#include "interpolationCellPoint.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class WeightType>
Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
(
const Field<WeightType>& weightField,
const bool useMag /* ignore */
)
{
// The scalar form is specialized.
// Other types: use mag() to generate a scalar field.
return mag(weightField);
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class WeightType>
inline bool Foam::functionObjects::fieldValues::surfaceFieldValue::canWeight
(
const Field<WeightType>& weightField
const Field<WeightType>& fld
) const
{
return
(
usesWeight()
&& returnReduce(!weightField.empty(), orOp<bool>()) // On some processor
);
// Non-empty on some processor
return returnReduce(!fld.empty(), orOp<bool>());
}
@ -156,9 +169,13 @@ processSameTypeValues
case opWeightedSum:
case opAbsWeightedSum:
{
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
tmp<scalarField> weight(weightingFactor(weightField));
tmp<scalarField> weight
(
weightingFactor(weightField, Sf, is_magOp())
);
result = gSum(weight*values);
}
else
@ -183,9 +200,12 @@ processSameTypeValues
case opWeightedAverage:
case opAbsWeightedAverage:
{
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
const scalarField factor(weightingFactor(weightField));
const scalarField factor
(
weightingFactor(weightField, Sf, is_magOp())
);
result = gSum(factor*values)/(gSum(factor) + ROOTVSMALL);
}
@ -193,6 +213,7 @@ processSameTypeValues
{
// Unweighted form
const label n = returnReduce(values.size(), sumOp<label>());
result = gSum(values)/(scalar(n) + ROOTVSMALL);
}
break;
@ -201,9 +222,12 @@ processSameTypeValues
case opWeightedAreaAverage:
case opAbsWeightedAreaAverage:
{
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
const scalarField factor(weightingFactor(weightField, Sf));
const scalarField factor
(
areaWeightingFactor(weightField, Sf, is_magOp())
);
result = gSum(factor*values)/gSum(factor + ROOTVSMALL);
}
@ -211,7 +235,8 @@ processSameTypeValues
{
// Unweighted form
const scalarField factor(mag(Sf));
result = gSum(factor*values)/gSum(factor);
result = gSum(factor*values)/gSum(factor + ROOTVSMALL);
}
break;
}
@ -219,15 +244,20 @@ processSameTypeValues
case opWeightedAreaIntegrate:
case opAbsWeightedAreaIntegrate:
{
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
tmp<scalarField> factor(weightingFactor(weightField, Sf));
tmp<scalarField> factor
(
areaWeightingFactor(weightField, Sf, is_magOp())
);
result = gSum(factor*values);
}
else
{
// Unweighted form
tmp<scalarField> factor(mag(Sf));
result = gSum(factor*values);
}
break;
@ -264,14 +294,14 @@ processSameTypeValues
case opWeightedUniformity:
case opAbsWeightedUniformity:
{
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
// Change weighting from vector -> scalar and dispatch again
return processValues<Type, scalar>
(
values,
Sf,
weightingFactor(weightField)
weightingFactor(weightField, is_magOp())
);
}
@ -295,19 +325,6 @@ Type Foam::functionObjects::fieldValues::surfaceFieldValue::processValues
}
template<class WeightType>
Foam::tmp<Foam::scalarField>
Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
(
const Field<WeightType>& weightField
) const
{
// The scalar form is specialized.
// For other types always need mag() to generate a scalar field.
return mag(weightField);
}
template<class WeightType>
Foam::label Foam::functionObjects::fieldValues::surfaceFieldValue::writeAll
(

View File

@ -84,9 +84,10 @@ Foam::functionObjects::fieldValues::volFieldValue::postOperationTypeNames_
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::functionObjects::fieldValues::volFieldValue::usesVol() const
bool Foam::functionObjects::fieldValues::volFieldValue::usesVol()
const noexcept
{
// Only a few operations require the cell volume
// Few operations require the cell volume
switch (operation_)
{
case opVolAverage:
@ -102,33 +103,6 @@ bool Foam::functionObjects::fieldValues::volFieldValue::usesVol() const
}
bool Foam::functionObjects::fieldValues::volFieldValue::usesMag() const
{
// Operation specifically tagged to use mag
return (operation_ & typeAbsolute);
}
bool Foam::functionObjects::fieldValues::volFieldValue::usesWeight() const
{
// Operation specifically tagged to require a weight field
return (operation_ & typeWeighted);
}
bool Foam::functionObjects::fieldValues::volFieldValue::canWeight
(
const scalarField& weightField
) const
{
return
(
usesWeight()
&& returnReduce(!weightField.empty(), orOp<bool>()) // On some processor
);
}
void Foam::functionObjects::fieldValues::volFieldValue::writeFileHeader
(
Ostream& os
@ -260,7 +234,7 @@ bool Foam::functionObjects::fieldValues::volFieldValue::read
weightFieldNames_.clear();
if (usesWeight())
if (is_weightedOp())
{
// Can have "weightFields" or "weightField"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -222,17 +222,16 @@ protected:
// Protected Member Functions
//- True if the operation needs the cell-volume
bool usesVol() const;
bool usesVol() const noexcept;
//- True if the operation variant uses mag
bool usesMag() const;
inline bool is_magOp() const noexcept;
//- True if the operation variant uses a weight-field
bool usesWeight() const;
inline bool is_weightedOp() const noexcept;
//- True if operation variant uses a weight-field that is available.
// Checks for availability on any processor.
inline bool canWeight(const scalarField& weightField) const;
//- True if field is non-empty on any processor.
inline bool canWeight(const scalarField& fld) const;
//- Return true if the field name is valid
template<class Type>
@ -332,6 +331,10 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "volFieldValueI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "volFieldValueTemplates.C"
#endif

View File

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
inline bool Foam::functionObjects::fieldValues::volFieldValue::is_magOp()
const noexcept
{
// Operation tagged to use mag
return (operation_ & typeAbsolute);
}
inline bool Foam::functionObjects::fieldValues::volFieldValue::is_weightedOp()
const noexcept
{
// Operation tagged to require a weight field
return (operation_ & typeWeighted);
}
inline bool Foam::functionObjects::fieldValues::volFieldValue::canWeight
(
const scalarField& fld
) const
{
// Non-empty on some processor
return returnReduce(!fld.empty(), orOp<bool>());
}
// ************************************************************************* //

View File

@ -112,7 +112,7 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
case opSum:
case opWeightedSum:
{
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
result = gSum(weightField*values);
}
@ -126,7 +126,7 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
case opAverage:
case opWeightedAverage:
{
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
result =
gSum(weightField*values)/(gSum(weightField) + ROOTVSMALL);
@ -142,7 +142,7 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
case opVolAverage:
case opWeightedVolAverage:
{
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
result = gSum(weightField*V*values)
/(gSum(weightField*V) + ROOTVSMALL);
@ -157,7 +157,7 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
case opVolIntegrate:
case opWeightedVolIntegrate:
{
if (canWeight(weightField))
if (is_weightedOp() && canWeight(weightField))
{
result = gSum(weightField*V*values);
}