ENH: 'mag' postOperation for surfaceFieldValue (#1622)

- support postOperation for volFieldValue as well
This commit is contained in:
Mark Olesen
2020-03-11 10:51:14 +01:00
parent 18e53c3c06
commit 2c4b639e1f
7 changed files with 210 additions and 65 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -109,6 +109,7 @@ const Foam::Enum
Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationTypeNames_
({
{ postOperationType::postOpNone, "none" },
{ postOperationType::postOpMag, "mag" },
{ postOperationType::postOpSqrt, "sqrt" },
});
@ -564,6 +565,8 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::writeFileHeader
os << tab << "Area";
}
// TBD: add in postOperation information?
for (const word& fieldName : fields_)
{
os << tab << operationTypeNames_[operation_]
@ -755,6 +758,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
) const
{
// scalar * Area
if (returnReduce(weightField.empty(), andOp<bool>()))
{
// No weight field - revert to unweighted form
@ -778,6 +782,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::weightingFactor
) const
{
// vector (dot) Area
if (returnReduce(weightField.empty(), andOp<bool>()))
{
// No weight field - revert to unweighted form
@ -806,7 +811,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
operation_(operationTypeNames_.get("operation", dict)),
postOperation_
(
postOperationTypeNames_.lookupOrDefault
postOperationTypeNames_.getOrDefault
(
"postOperation",
dict,
@ -839,7 +844,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
operation_(operationTypeNames_.get("operation", dict)),
postOperation_
(
postOperationTypeNames_.lookupOrDefault
postOperationTypeNames_.getOrDefault
(
"postOperation",
dict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -131,6 +131,13 @@ Usage
absWeightedUniformity | uniformity index using absolute weighting
\endplaintable
The \c postOperation is one of:
\plaintable
none | No additional operation after calculation
mag | Component-wise \c mag() after normal operation
sqrt | Component-wise \c sqrt() after normal operation
\endplaintable
Note
- The values reported by the areaNormalAverage and areaNormalIntegrate
operations are written as the first component of a field with the same
@ -193,7 +200,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
// Forward Declarations
class sampledSurface;
class surfaceWriter;
@ -311,7 +318,8 @@ public:
enum postOperationType
{
postOpNone, //!< No additional operation after calculation
postOpSqrt //!< Perform sqrt after normal operation
postOpMag, //!< Component-wise mag after normal operation
postOpSqrt //!< Component-wise sqrt after normal operation
};
//- Operation type names
@ -526,7 +534,7 @@ protected:
public:
//- Run-time type information
//- Declare type-name, virtual type (with debug switch)
TypeName("surfaceFieldValue");
@ -553,7 +561,7 @@ public:
virtual ~surfaceFieldValue() = default;
// Public Member Functions
// Member Functions
//- Return the region type
inline regionTypes regionType() const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -407,9 +407,19 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
{
break;
}
case postOpMag:
{
// mag: component-wise - does not change the type
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{
setComponent(result, d)
= mag(component(result, d));
}
break;
}
case postOpSqrt:
{
// sqrt: component-wise - doesn't change the type
// sqrt: component-wise - does not change the type
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{
setComponent(result, d)
@ -442,6 +452,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
Log << " " << prefix << regionName_ << suffix
<< " of " << fieldName << " = ";
// Operation tagged that it always returns scalar?
const bool alwaysScalar(operation_ & typeScalar);