functionObjects::volRegion: Replaced with fvCellSet
Replacing volRegion removes unnecessary functionality duplication and ensures
cell set selection is consistent between functionObjects, fvModels and
fvConstraints for user convenience and reducing the code maintenance overhead.
Description
General cell set selection class for models that apply to sub-sets
of the mesh.
Currently supports cell selection from a set of points, a specified cellSet
or cellZone or all of the cells. The selection method can either be
specified explicitly using the \c select entry or inferred from the
presence of either a \c cellSet, \c cellZone or \c points entry. The \c
select entry is required to select \c all cells.
Usage
Examples:
\verbatim
// Apply everywhere
select all;
// Apply within a given cellSet
select cellSet; // Optional
cellSet rotor;
// Apply within a given cellZone
select cellZone; // Optional
cellZone rotor;
// Apply in cells containing a list of points
select points; // Optional
points
(
(2.25 0.5 0)
(2.75 0.5 0)
);
\endverbatim
This commit is contained in:
@ -92,7 +92,7 @@ const Foam::NamedEnum
|
||||
<
|
||||
Foam::functionObjects::fieldValues::surfaceFieldValue::selectionTypes,
|
||||
3
|
||||
> Foam::functionObjects::fieldValues::surfaceFieldValue::selectionTypeNames_;
|
||||
> Foam::functionObjects::fieldValues::surfaceFieldValue::selectionTypeNames;
|
||||
|
||||
const Foam::NamedEnum
|
||||
<
|
||||
@ -111,7 +111,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< selectionTypeNames_[selectionType_]
|
||||
<< selectionTypeNames[selectionType_]
|
||||
<< "(" << selectionName_ << "):" << nl
|
||||
<< " Unknown face zone name: " << selectionName_
|
||||
<< ". Valid face zones are: " << mesh_.faceZones().names()
|
||||
@ -182,7 +182,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchFaces()
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< selectionTypeNames_[selectionType_]
|
||||
<< selectionTypeNames[selectionType_]
|
||||
<< "(" << selectionName_ << "):" << nl
|
||||
<< " Unknown patch name: " << selectionName_
|
||||
<< ". Valid patch names are: "
|
||||
@ -441,10 +441,10 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< selectionTypeNames_[selectionType_]
|
||||
<< selectionTypeNames[selectionType_]
|
||||
<< "(" << selectionName_ << "):" << nl
|
||||
<< " Unknown selection type. Valid selection types are:"
|
||||
<< selectionTypeNames_.sortedToc() << nl << exit(FatalError);
|
||||
<< selectionTypeNames.sortedToc() << nl << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< selectionTypeNames_[selectionType_]
|
||||
<< selectionTypeNames[selectionType_]
|
||||
<< "(" << selectionName_ << "):" << nl
|
||||
<< " selection has no faces" << exit(FatalError);
|
||||
}
|
||||
@ -512,7 +512,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::writeFileHeader
|
||||
{
|
||||
writeCommented(file(), "Selection type : ");
|
||||
file()
|
||||
<< selectionTypeNames_[selectionType_] << " "
|
||||
<< selectionTypeNames[selectionType_] << " "
|
||||
<< selectionName_ << endl;
|
||||
writeCommented(file(), "Faces : ");
|
||||
file() << nFaces_ << endl;
|
||||
@ -661,7 +661,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
||||
surfaceWriterPtr_(nullptr),
|
||||
selectionType_
|
||||
(
|
||||
selectionTypeNames_.read
|
||||
selectionTypeNames.read
|
||||
(
|
||||
dict.lookupBackwardsCompatible({"select", "regionType"})
|
||||
)
|
||||
@ -691,7 +691,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::surfaceFieldValue
|
||||
surfaceWriterPtr_(nullptr),
|
||||
selectionType_
|
||||
(
|
||||
selectionTypeNames_.read
|
||||
selectionTypeNames.read
|
||||
(
|
||||
dict.lookupBackwardsCompatible({"select", "regionType"})
|
||||
)
|
||||
@ -777,7 +777,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
|
||||
surfaceWriterPtr_->write
|
||||
(
|
||||
outputDir(),
|
||||
selectionTypeNames_[selectionType_] + ("_" + selectionName_),
|
||||
selectionTypeNames[selectionType_] + ("_" + selectionName_),
|
||||
points,
|
||||
faces
|
||||
);
|
||||
|
||||
@ -197,7 +197,7 @@ public:
|
||||
};
|
||||
|
||||
//- Selection type names
|
||||
static const NamedEnum<selectionTypes, 3> selectionTypeNames_;
|
||||
static const NamedEnum<selectionTypes, 3> selectionTypeNames;
|
||||
|
||||
|
||||
//- Operation type enumeration
|
||||
|
||||
@ -320,7 +320,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
||||
(
|
||||
outputDir(),
|
||||
fieldName
|
||||
+ '_' + selectionTypeNames_[selectionType_]
|
||||
+ '_' + selectionTypeNames[selectionType_]
|
||||
+ '_' + selectionName_,
|
||||
points,
|
||||
faces,
|
||||
@ -424,7 +424,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< selectionTypeNames_[selectionType_]
|
||||
<< selectionTypeNames[selectionType_]
|
||||
<< "(" << selectionName_ << "):"
|
||||
<< nl
|
||||
<< " Unable to process internal faces for volume field "
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -26,6 +26,7 @@ License
|
||||
#include "volFieldValue.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "writeFile.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -150,7 +151,7 @@ void Foam::functionObjects::fieldValues::volFieldValue::writeFileHeader
|
||||
const label i
|
||||
)
|
||||
{
|
||||
volRegion::writeFileHeader(*this, file());
|
||||
fvCellSet::writeFileHeader(*this, file());
|
||||
|
||||
writeCommented(file(), "Time");
|
||||
|
||||
@ -230,7 +231,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
|
||||
)
|
||||
:
|
||||
fieldValue(name, runTime, dict, typeName),
|
||||
volRegion(fieldValue::mesh_, dict),
|
||||
fvCellSet(fieldValue::mesh_, dict),
|
||||
writeLocation_(false),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
scaleFactor_(1)
|
||||
@ -247,7 +248,7 @@ Foam::functionObjects::fieldValues::volFieldValue::volFieldValue
|
||||
)
|
||||
:
|
||||
fieldValue(name, obr, dict, typeName),
|
||||
volRegion(fieldValue::mesh_, dict),
|
||||
fvCellSet(fieldValue::mesh_, dict),
|
||||
writeLocation_(false),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
scaleFactor_(1)
|
||||
@ -288,11 +289,7 @@ bool Foam::functionObjects::fieldValues::volFieldValue::write()
|
||||
}
|
||||
|
||||
// Construct the weight field and the volumes
|
||||
scalarField weights
|
||||
(
|
||||
isNull(cellIDs()) ? fieldValue::mesh_.nCells() : cellIDs().size(),
|
||||
1
|
||||
);
|
||||
scalarField weights(nCells(), 1);
|
||||
forAll(weightFieldNames_, i)
|
||||
{
|
||||
weights *= getFieldValues<scalar>(weightFieldNames_[i]);
|
||||
|
||||
@ -25,9 +25,9 @@ Class
|
||||
Foam::functionObjects::fieldValues::volFieldValue
|
||||
|
||||
Description
|
||||
Provides a 'volRegion' specialisation of the fieldValue function object.
|
||||
Provides a 'fvCellSet' specialisation of the fieldValue function object.
|
||||
|
||||
Given a list of user-specified fields and a 'volRegion', a number of
|
||||
Given a list of user-specified fields and a 'fvCellSet', a number of
|
||||
operations can be performed, such as sums, averages and integrations.
|
||||
|
||||
Example of function object specification:
|
||||
@ -62,8 +62,8 @@ Usage
|
||||
log | Write data to standard output | no | no
|
||||
writeFields | Write the region field values | yes |
|
||||
writeLocation| Write the location (if available) | no | no
|
||||
select | volRegion type: see below | yes |
|
||||
name | Name of volRegion if required | no |
|
||||
select | fvCellSet type: see below | yes |
|
||||
name | Name of fvCellSet if required | no |
|
||||
operation | Operation to perform | yes |
|
||||
weightField | Name of field to apply weighting | no |
|
||||
weightFields | Names of fields to apply weighting | no |
|
||||
@ -93,7 +93,7 @@ Usage
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fieldValues::fieldValue
|
||||
Foam::functionObjects::volRegion
|
||||
Foam::Foam::fvCellSet
|
||||
Foam::functionObject
|
||||
|
||||
SourceFiles
|
||||
@ -105,7 +105,7 @@ SourceFiles
|
||||
#define functionObjects_volFieldValue_H
|
||||
|
||||
#include "fieldValue.H"
|
||||
#include "volRegion.H"
|
||||
#include "fvCellSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -123,7 +123,7 @@ namespace fieldValues
|
||||
class volFieldValue
|
||||
:
|
||||
public fieldValue,
|
||||
public volRegion
|
||||
public fvCellSet
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@ -81,7 +81,7 @@ void Foam::functionObjects::fieldValues::volFieldValue::compareScalars
|
||||
}
|
||||
|
||||
result.value = values[i];
|
||||
result.celli = isNull(cellIDs()) ? i : cellIDs()[i];
|
||||
result.celli = celli(i);
|
||||
result.proci = Pstream::parRun() ? Pstream::myProcNo() : -1;
|
||||
result.cc = fieldValue::mesh_.C()[result.celli];
|
||||
|
||||
@ -250,8 +250,8 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName + '_' + selectionTypeNames_[selectionType_]
|
||||
+ '-' + volRegion::cellZoneName_,
|
||||
fieldName + '_' + selectionTypeNames[selectionType()]
|
||||
+ '-' + cellSetName(),
|
||||
obr_.time().name(),
|
||||
obr_,
|
||||
IOobject::NO_READ,
|
||||
@ -318,7 +318,7 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
|
||||
file() << tab << result.value;
|
||||
|
||||
Log << " " << operationTypeNames_[operation_]
|
||||
<< "(" << volRegion::cellZoneName_ << ") of " << fieldName
|
||||
<< "(" << cellSetName() << ") of " << fieldName
|
||||
<< " = " << result.value;
|
||||
|
||||
if (result.celli != -1)
|
||||
@ -356,13 +356,13 @@ Foam::functionObjects::fieldValues::volFieldValue::filterField
|
||||
const Field<Type>& field
|
||||
) const
|
||||
{
|
||||
if (isNull(cellIDs()))
|
||||
if (all())
|
||||
{
|
||||
return field;
|
||||
}
|
||||
else
|
||||
{
|
||||
return tmp<Field<Type>>(new Field<Type>(field, cellIDs()));
|
||||
return tmp<Field<Type>>(new Field<Type>(field, cells()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user