mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Exposed weightField to all face/cell source function object operations
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -55,9 +55,9 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
"none",
|
"none",
|
||||||
"sum",
|
"sum",
|
||||||
|
"average",
|
||||||
"volAverage",
|
"volAverage",
|
||||||
"volIntegrate",
|
"volIntegrate",
|
||||||
"weightedAverage",
|
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max",
|
||||||
"CoV"
|
"CoV"
|
||||||
@ -143,9 +143,8 @@ void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
|
|||||||
<< " total volume = " << gSum(filterField(mesh().V()))
|
<< " total volume = " << gSum(filterField(mesh().V()))
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
|
|
||||||
if (operation_ == opWeightedAverage)
|
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||||
{
|
{
|
||||||
dict.lookup("weightField") >> weightFieldName_;
|
|
||||||
Info<< " weight field = " << weightFieldName_;
|
Info<< " weight field = " << weightFieldName_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -39,6 +39,7 @@ Description
|
|||||||
source cellZone; // Type of cell source
|
source cellZone; // Type of cell source
|
||||||
sourceName c0;
|
sourceName c0;
|
||||||
operation volAverage;
|
operation volAverage;
|
||||||
|
weightField alpha1; // optional weight field
|
||||||
fields
|
fields
|
||||||
(
|
(
|
||||||
p
|
p
|
||||||
@ -49,9 +50,9 @@ Description
|
|||||||
where operation is one of:
|
where operation is one of:
|
||||||
- none
|
- none
|
||||||
- sum
|
- sum
|
||||||
|
- average
|
||||||
- volAverage
|
- volAverage
|
||||||
- volIntegrate
|
- volIntegrate
|
||||||
- weightedAverage
|
|
||||||
- CoV (Coefficient of variation: standard deviation/mean)
|
- CoV (Coefficient of variation: standard deviation/mean)
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -103,9 +104,9 @@ public:
|
|||||||
{
|
{
|
||||||
opNone,
|
opNone,
|
||||||
opSum,
|
opSum,
|
||||||
|
opAverage,
|
||||||
opVolAverage,
|
opVolAverage,
|
||||||
opVolIntegrate,
|
opVolIntegrate,
|
||||||
opWeightedAverage,
|
|
||||||
opMin,
|
opMin,
|
||||||
opMax,
|
opMax,
|
||||||
opCoV
|
opCoV
|
||||||
@ -168,8 +169,7 @@ protected:
|
|||||||
Type processValues
|
Type processValues
|
||||||
(
|
(
|
||||||
const Field<Type>& values,
|
const Field<Type>& values,
|
||||||
const scalarField& V,
|
const scalarField& V
|
||||||
const scalarField& weightField
|
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Output file header information
|
//- Output file header information
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -78,8 +78,7 @@ template<class Type>
|
|||||||
Type Foam::fieldValues::cellSource::processValues
|
Type Foam::fieldValues::cellSource::processValues
|
||||||
(
|
(
|
||||||
const Field<Type>& values,
|
const Field<Type>& values,
|
||||||
const scalarField& V,
|
const scalarField& V
|
||||||
const scalarField& weightField
|
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
Type result = pTraits<Type>::zero;
|
Type result = pTraits<Type>::zero;
|
||||||
@ -90,6 +89,11 @@ Type Foam::fieldValues::cellSource::processValues
|
|||||||
result = sum(values);
|
result = sum(values);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case opAverage:
|
||||||
|
{
|
||||||
|
result = sum(values)/values.size();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case opVolAverage:
|
case opVolAverage:
|
||||||
{
|
{
|
||||||
result = sum(values*V)/sum(V);
|
result = sum(values*V)/sum(V);
|
||||||
@ -100,11 +104,6 @@ Type Foam::fieldValues::cellSource::processValues
|
|||||||
result = sum(values*V);
|
result = sum(values*V);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case opWeightedAverage:
|
|
||||||
{
|
|
||||||
result = sum(values*weightField)/sum(weightField);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case opMin:
|
case opMin:
|
||||||
{
|
{
|
||||||
result = min(values);
|
result = min(values);
|
||||||
@ -152,23 +151,25 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
|
|||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
Field<Type> values(setFieldValues<Type>(fieldName));
|
Field<Type> values(setFieldValues<Type>(fieldName));
|
||||||
combineFields(values);
|
|
||||||
|
|
||||||
scalarField V(filterField(mesh().V()));
|
scalarField V(filterField(mesh().V()));
|
||||||
combineFields(V);
|
scalarField weightField(values.size(), 1.0);
|
||||||
|
|
||||||
scalarField weightField;
|
if (weightFieldName_ != "none")
|
||||||
|
|
||||||
if (operation_ == opWeightedAverage)
|
|
||||||
{
|
{
|
||||||
weightField = setFieldValues<scalar>(weightFieldName_, true);
|
weightField = setFieldValues<scalar>(weightFieldName_, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Combine onto master
|
||||||
|
combineFields(values);
|
||||||
|
combineFields(V);
|
||||||
combineFields(weightField);
|
combineFields(weightField);
|
||||||
|
|
||||||
|
// apply weight field
|
||||||
|
values *= weightField;
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
Type result = processValues(values, V, weightField);
|
Type result = processValues(values, V);
|
||||||
|
|
||||||
if (valueOutput_)
|
if (valueOutput_)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -58,9 +58,9 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
"none",
|
"none",
|
||||||
"sum",
|
"sum",
|
||||||
|
"average",
|
||||||
"areaAverage",
|
"areaAverage",
|
||||||
"areaIntegrate",
|
"areaIntegrate",
|
||||||
"weightedAverage",
|
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max",
|
||||||
"CoV"
|
"CoV"
|
||||||
@ -282,9 +282,8 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
|||||||
<< " total area = " << totalArea
|
<< " total area = " << totalArea
|
||||||
<< nl;
|
<< nl;
|
||||||
|
|
||||||
if (operation_ == opWeightedAverage)
|
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||||
{
|
{
|
||||||
dict.lookup("weightField") >> weightFieldName_;
|
|
||||||
Info<< " weight field = " << weightFieldName_;
|
Info<< " weight field = " << weightFieldName_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +325,7 @@ Foam::fieldValues::faceSource::faceSource
|
|||||||
fieldValue(name, obr, dict, loadFromFiles),
|
fieldValue(name, obr, dict, loadFromFiles),
|
||||||
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
||||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||||
weightFieldName_("undefinedWeightedFieldName"),
|
weightFieldName_("none"),
|
||||||
nFaces_(0),
|
nFaces_(0),
|
||||||
faceId_(),
|
faceId_(),
|
||||||
facePatchId_(),
|
facePatchId_(),
|
||||||
|
|||||||
@ -40,6 +40,7 @@ Description
|
|||||||
// faceZone,patch,sampledSurface
|
// faceZone,patch,sampledSurface
|
||||||
sourceName f0; // faceZone name, see below
|
sourceName f0; // faceZone name, see below
|
||||||
operation sum;
|
operation sum;
|
||||||
|
weightField alpha1; // optional weight field
|
||||||
fields
|
fields
|
||||||
(
|
(
|
||||||
p
|
p
|
||||||
@ -57,19 +58,20 @@ Description
|
|||||||
operation is one of:
|
operation is one of:
|
||||||
- none
|
- none
|
||||||
- sum
|
- sum
|
||||||
|
- average
|
||||||
- areaAverage
|
- areaAverage
|
||||||
- areaIntegrate
|
- areaIntegrate
|
||||||
- weightedAverage
|
|
||||||
- min
|
- min
|
||||||
- max
|
- max
|
||||||
- CoV (Coefficient of variation: standard deviation/mean)
|
- CoV (Coefficient of variation: standard deviation/mean)
|
||||||
|
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
- faces on empty patches get ignored
|
- faces on empty patches get ignored
|
||||||
- if the field is a volField the faceZone can only consist of boundary
|
- if the field is a volField the faceZone can only consist of boundary
|
||||||
faces.
|
faces.
|
||||||
- all fields get oriented according to the faceZone (so you might e.g. see
|
- all fields get oriented according to the faceZone (so you might e.g. see
|
||||||
negative pressure)
|
negative pressure)
|
||||||
- using sampledSurfaces:
|
- using sampledSurfaces:
|
||||||
- they do not do surface fields
|
- they do not do surface fields
|
||||||
- they use cell values - they do not do any interpolation.
|
- they use cell values - they do not do any interpolation.
|
||||||
@ -129,9 +131,9 @@ public:
|
|||||||
{
|
{
|
||||||
opNone,
|
opNone,
|
||||||
opSum,
|
opSum,
|
||||||
|
opAverage,
|
||||||
opAreaAverage,
|
opAreaAverage,
|
||||||
opAreaIntegrate,
|
opAreaIntegrate,
|
||||||
opWeightedAverage,
|
|
||||||
opMin,
|
opMin,
|
||||||
opMax,
|
opMax,
|
||||||
opCoV
|
opCoV
|
||||||
@ -165,7 +167,7 @@ protected:
|
|||||||
//- Operation to apply to values
|
//- Operation to apply to values
|
||||||
operationType operation_;
|
operationType operation_;
|
||||||
|
|
||||||
//- Weight field name - only used for opWeightedAverage mode
|
//- Weight field name - optional
|
||||||
word weightFieldName_;
|
word weightFieldName_;
|
||||||
|
|
||||||
//- Global number of faces
|
//- Global number of faces
|
||||||
@ -213,8 +215,7 @@ protected:
|
|||||||
Type processValues
|
Type processValues
|
||||||
(
|
(
|
||||||
const Field<Type>& values,
|
const Field<Type>& values,
|
||||||
const scalarField& magSf,
|
const scalarField& magSf
|
||||||
const scalarField& weightField
|
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Output file header information
|
//- Output file header information
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -97,8 +97,7 @@ template<class Type>
|
|||||||
Type Foam::fieldValues::faceSource::processValues
|
Type Foam::fieldValues::faceSource::processValues
|
||||||
(
|
(
|
||||||
const Field<Type>& values,
|
const Field<Type>& values,
|
||||||
const scalarField& magSf,
|
const scalarField& magSf
|
||||||
const scalarField& weightField
|
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
Type result = pTraits<Type>::zero;
|
Type result = pTraits<Type>::zero;
|
||||||
@ -109,6 +108,11 @@ Type Foam::fieldValues::faceSource::processValues
|
|||||||
result = sum(values);
|
result = sum(values);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case opAverage:
|
||||||
|
{
|
||||||
|
result = sum(values)/values.size();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case opAreaAverage:
|
case opAreaAverage:
|
||||||
{
|
{
|
||||||
result = sum(values*magSf)/sum(magSf);
|
result = sum(values*magSf)/sum(magSf);
|
||||||
@ -119,11 +123,6 @@ Type Foam::fieldValues::faceSource::processValues
|
|||||||
result = sum(values*magSf);
|
result = sum(values*magSf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case opWeightedAverage:
|
|
||||||
{
|
|
||||||
result = sum(values*weightField)/sum(weightField);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case opMin:
|
case opMin:
|
||||||
{
|
{
|
||||||
result = min(values);
|
result = min(values);
|
||||||
@ -173,9 +172,9 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
|
|||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
Field<Type> values(getFieldValues<Type>(fieldName));
|
Field<Type> values(getFieldValues<Type>(fieldName));
|
||||||
scalarField weightField;
|
scalarField weightField(values.size(), 1.0);
|
||||||
|
|
||||||
if (operation_ == opWeightedAverage)
|
if (weightFieldName_ != "none")
|
||||||
{
|
{
|
||||||
weightField = getFieldValues<scalar>(weightFieldName_, true);
|
weightField = getFieldValues<scalar>(weightFieldName_, true);
|
||||||
}
|
}
|
||||||
@ -198,10 +197,13 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
|
|||||||
combineFields(magSf);
|
combineFields(magSf);
|
||||||
combineFields(weightField);
|
combineFields(weightField);
|
||||||
|
|
||||||
|
// apply weight field
|
||||||
|
values *= weightField;
|
||||||
|
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
Type result = processValues(values, magSf, weightField);
|
Type result = processValues(values, magSf);
|
||||||
|
|
||||||
if (valueOutput_)
|
if (valueOutput_)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user