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:
@ -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"
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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>());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user