mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added average option to fieldValueDelta function object
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -38,15 +38,16 @@ namespace Foam
|
||||
|
||||
template<>
|
||||
const char*
|
||||
NamedEnum<fieldValues::fieldValueDelta::operationType, 4>::names[] =
|
||||
NamedEnum<fieldValues::fieldValueDelta::operationType, 5>::names[] =
|
||||
{
|
||||
"add",
|
||||
"subtract",
|
||||
"min",
|
||||
"max"
|
||||
"max",
|
||||
"average"
|
||||
};
|
||||
|
||||
const NamedEnum<fieldValues::fieldValueDelta::operationType, 4>
|
||||
const NamedEnum<fieldValues::fieldValueDelta::operationType, 5>
|
||||
fieldValues::fieldValueDelta::operationTypeNames_;
|
||||
}
|
||||
|
||||
@ -158,7 +159,7 @@ void Foam::fieldValues::fieldValueDelta::write()
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " output:" << endl;
|
||||
Info<< type() << " " << name_ << " output:" << endl;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
@ -179,10 +180,8 @@ void Foam::fieldValues::fieldValueDelta::write()
|
||||
{
|
||||
Info<< " none" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,6 +37,8 @@ Description
|
||||
{
|
||||
type fieldValueDelta;
|
||||
functionObjectLibs ("libfieldFunctionObjects.so");
|
||||
operation subtract;
|
||||
|
||||
fieldValue1
|
||||
{
|
||||
...
|
||||
@ -54,6 +56,15 @@ Description
|
||||
type | type name: fieldValueDelta | yes |
|
||||
\endtable
|
||||
|
||||
\linebreak
|
||||
The \c operation is one of:
|
||||
\plaintable
|
||||
add | add
|
||||
subtract | subtract
|
||||
min | minimum
|
||||
max | maximum
|
||||
average | average
|
||||
\endplaintable
|
||||
SeeAlso
|
||||
Foam::fieldValue
|
||||
|
||||
@ -92,11 +103,12 @@ public:
|
||||
opAdd,
|
||||
opSubtract,
|
||||
opMin,
|
||||
opMax
|
||||
opMax,
|
||||
opAverage
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 4> operationTypeNames_;
|
||||
static const NamedEnum<operationType, 5> operationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,6 +25,7 @@ License
|
||||
|
||||
#include "GeometricField.H"
|
||||
#include "volMesh.H"
|
||||
#include "surfaceMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -59,6 +60,11 @@ Type Foam::fieldValues::fieldValueDelta::applyOperation
|
||||
result = max(value1, value2);
|
||||
break;
|
||||
}
|
||||
case opAverage:
|
||||
{
|
||||
result = 0.5*(value1 + value2);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorIn
|
||||
@ -83,6 +89,7 @@ template<class Type>
|
||||
void Foam::fieldValues::fieldValueDelta::processFields(bool& found)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
||||
|
||||
const wordList& fields1 = source1Ptr_->fields();
|
||||
|
||||
@ -95,7 +102,12 @@ void Foam::fieldValues::fieldValueDelta::processFields(bool& found)
|
||||
forAll(fields1, i)
|
||||
{
|
||||
const word& fieldName = fields1[i];
|
||||
if (obr_.foundObject<vf>(fieldName) && results2.found(fieldName))
|
||||
|
||||
if
|
||||
(
|
||||
(obr_.foundObject<vf>(fieldName) || obr_.foundObject<sf>(fieldName))
|
||||
&& results2.found(fieldName)
|
||||
)
|
||||
{
|
||||
results1.lookup(fieldName) >> r1;
|
||||
results2.lookup(fieldName) >> r2;
|
||||
|
||||
Reference in New Issue
Block a user