mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
functionObjects: Further simplification and rationalization using the fvMeshFunctionObject base-class
This commit is contained in:
@ -49,7 +49,7 @@ Foam::functionObjects::fieldValue::fieldValue
|
||||
const word& valueType
|
||||
)
|
||||
:
|
||||
regionFunctionObject(name, runTime, dict),
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
logFiles(obr_, name),
|
||||
dict_(dict),
|
||||
regionName_(word::null),
|
||||
@ -68,7 +68,7 @@ Foam::functionObjects::fieldValue::fieldValue
|
||||
const word& valueType
|
||||
)
|
||||
:
|
||||
regionFunctionObject(name, obr, dict),
|
||||
fvMeshFunctionObject(name, obr, dict),
|
||||
logFiles(obr_, name),
|
||||
dict_(dict),
|
||||
regionName_(word::null),
|
||||
@ -89,8 +89,12 @@ Foam::functionObjects::fieldValue::~fieldValue()
|
||||
|
||||
bool Foam::functionObjects::fieldValue::read(const dictionary& dict)
|
||||
{
|
||||
dict_ = dict;
|
||||
regionFunctionObject::read(dict);
|
||||
if (dict != dict_)
|
||||
{
|
||||
dict_ = dict;
|
||||
}
|
||||
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fields_;
|
||||
dict.lookup("writeFields") >> writeFields_;
|
||||
|
||||
@ -32,7 +32,7 @@ Description
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::regionFunctionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::logFiles
|
||||
|
||||
SourceFiles
|
||||
@ -43,7 +43,7 @@ SourceFiles
|
||||
#ifndef functionObjects_fieldValue_H
|
||||
#define functionObjects_fieldValue_H
|
||||
|
||||
#include "regionFunctionObject.H"
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "logFiles.H"
|
||||
#include "Switch.H"
|
||||
#include "Field.H"
|
||||
@ -65,7 +65,7 @@ namespace functionObjects
|
||||
|
||||
class fieldValue
|
||||
:
|
||||
public regionFunctionObject,
|
||||
public fvMeshFunctionObject,
|
||||
public logFiles
|
||||
{
|
||||
|
||||
@ -169,9 +169,6 @@ public:
|
||||
//- Return the output field values flag
|
||||
inline const Switch& writeFields() const;
|
||||
|
||||
//- Helper function to return the reference to the mesh
|
||||
inline const fvMesh& mesh() const;
|
||||
|
||||
//- Return access to the latest set of results
|
||||
inline const dictionary& resultDict() const;
|
||||
|
||||
|
||||
@ -53,12 +53,6 @@ Foam::functionObjects::fieldValue::writeFields() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::fvMesh& Foam::functionObjects::fieldValue::mesh() const
|
||||
{
|
||||
return refCast<const fvMesh>(obr_);
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::dictionary&
|
||||
Foam::functionObjects::fieldValue::resultDict() const
|
||||
{
|
||||
|
||||
@ -112,12 +112,6 @@ Foam::functionObjects::fieldValues::fieldValueDelta::fieldValueDelta
|
||||
region1Ptr_(nullptr),
|
||||
region2Ptr_(nullptr)
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
resetName(typeName);
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ const Foam::NamedEnum
|
||||
|
||||
void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces()
|
||||
{
|
||||
label zoneId = mesh().faceZones().findZoneID(regionName_);
|
||||
label zoneId = mesh_.faceZones().findZoneID(regionName_);
|
||||
|
||||
if (zoneId < 0)
|
||||
{
|
||||
@ -110,11 +110,11 @@ void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces()
|
||||
<< type() << " " << name() << ": "
|
||||
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):" << nl
|
||||
<< " Unknown face zone name: " << regionName_
|
||||
<< ". Valid face zones are: " << mesh().faceZones().names()
|
||||
<< ". Valid face zones are: " << mesh_.faceZones().names()
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
const faceZone& fZone = mesh().faceZones()[zoneId];
|
||||
const faceZone& fZone = mesh_.faceZones()[zoneId];
|
||||
|
||||
DynamicList<label> faceIds(fZone.size());
|
||||
DynamicList<label> facePatchIds(fZone.size());
|
||||
@ -126,15 +126,15 @@ void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces()
|
||||
|
||||
label faceId = -1;
|
||||
label facePatchId = -1;
|
||||
if (mesh().isInternalFace(facei))
|
||||
if (mesh_.isInternalFace(facei))
|
||||
{
|
||||
faceId = facei;
|
||||
facePatchId = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
facePatchId = mesh().boundaryMesh().whichPatch(facei);
|
||||
const polyPatch& pp = mesh().boundaryMesh()[facePatchId];
|
||||
facePatchId = mesh_.boundaryMesh().whichPatch(facei);
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[facePatchId];
|
||||
if (isA<coupledPolyPatch>(pp))
|
||||
{
|
||||
if (refCast<const coupledPolyPatch>(pp).owner())
|
||||
@ -187,7 +187,7 @@ void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces()
|
||||
|
||||
void Foam::functionObjects::fieldValues::surfaceRegion::setPatchFaces()
|
||||
{
|
||||
const label patchid = mesh().boundaryMesh().findPatchID(regionName_);
|
||||
const label patchid = mesh_.boundaryMesh().findPatchID(regionName_);
|
||||
|
||||
if (patchid < 0)
|
||||
{
|
||||
@ -196,11 +196,11 @@ void Foam::functionObjects::fieldValues::surfaceRegion::setPatchFaces()
|
||||
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):" << nl
|
||||
<< " Unknown patch name: " << regionName_
|
||||
<< ". Valid patch names are: "
|
||||
<< mesh().boundaryMesh().names() << nl
|
||||
<< mesh_.boundaryMesh().names() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const polyPatch& pp = mesh().boundaryMesh()[patchid];
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[patchid];
|
||||
|
||||
label nFaces = pp.size();
|
||||
if (isA<emptyPolyPatch>(pp))
|
||||
@ -230,7 +230,7 @@ void Foam::functionObjects::fieldValues::surfaceRegion::sampledSurfaceFaces
|
||||
surfacePtr_ = sampledSurface::New
|
||||
(
|
||||
name(),
|
||||
mesh(),
|
||||
mesh_,
|
||||
dict.subDict("sampledSurfaceDict")
|
||||
);
|
||||
surfacePtr_().update();
|
||||
@ -253,15 +253,15 @@ void Foam::functionObjects::fieldValues::surfaceRegion::combineMeshGeometry
|
||||
if (facePatchId_[i] != -1)
|
||||
{
|
||||
label patchi = facePatchId_[i];
|
||||
globalFacesIs[i] += mesh().boundaryMesh()[patchi].start();
|
||||
globalFacesIs[i] += mesh_.boundaryMesh()[patchi].start();
|
||||
}
|
||||
}
|
||||
|
||||
// Add local faces and points to the all* lists
|
||||
indirectPrimitivePatch pp
|
||||
(
|
||||
IndirectList<face>(mesh().faces(), globalFacesIs),
|
||||
mesh().points()
|
||||
IndirectList<face>(mesh_.faces(), globalFacesIs),
|
||||
mesh_.points()
|
||||
);
|
||||
allFaces[Pstream::myProcNo()] = pp.localFaces();
|
||||
allPoints[Pstream::myProcNo()] = pp.localPoints();
|
||||
@ -372,7 +372,7 @@ void Foam::functionObjects::fieldValues::surfaceRegion::combineSurfaceGeometry
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Dimension as fraction of mesh bounding box
|
||||
scalar mergeDim = 1e-10*mesh().bounds().mag();
|
||||
scalar mergeDim = 1e-10*mesh_.bounds().mag();
|
||||
|
||||
labelList pointsMap;
|
||||
|
||||
@ -409,7 +409,7 @@ Foam::functionObjects::fieldValues::surfaceRegion::totalArea() const
|
||||
}
|
||||
else
|
||||
{
|
||||
totalArea = gSum(filterField(mesh().magSf(), false));
|
||||
totalArea = gSum(filterField(mesh_.magSf(), false));
|
||||
}
|
||||
|
||||
return totalArea;
|
||||
@ -664,12 +664,6 @@ Foam::functionObjects::fieldValues::surfaceRegion::surfaceRegion
|
||||
facePatchId_(),
|
||||
faceSign_()
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -694,12 +688,6 @@ Foam::functionObjects::fieldValues::surfaceRegion::surfaceRegion
|
||||
facePatchId_(),
|
||||
faceSign_()
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
@ -291,7 +291,7 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::writeValues
|
||||
else
|
||||
{
|
||||
// Get oriented Sf
|
||||
Sf = filterField(mesh().Sf(), true);
|
||||
Sf = filterField(mesh_.Sf(), true);
|
||||
}
|
||||
|
||||
// Combine onto master
|
||||
|
||||
@ -95,24 +95,24 @@ void Foam::functionObjects::fieldValues::volRegion::setCellZoneCells()
|
||||
{
|
||||
dict().lookup("name") >> regionName_;
|
||||
|
||||
label zoneId = mesh().cellZones().findZoneID(regionName_);
|
||||
label zoneId = mesh_.cellZones().findZoneID(regionName_);
|
||||
|
||||
if (zoneId < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown cell zone name: " << regionName_
|
||||
<< ". Valid cell zones are: " << mesh().cellZones().names()
|
||||
<< ". Valid cell zones are: " << mesh_.cellZones().names()
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
cellId_ = mesh().cellZones()[zoneId];
|
||||
cellId_ = mesh_.cellZones()[zoneId];
|
||||
nCells_ = returnReduce(cellId_.size(), sumOp<label>());
|
||||
break;
|
||||
}
|
||||
|
||||
case stAll:
|
||||
{
|
||||
cellId_ = identity(mesh().nCells());
|
||||
cellId_ = identity(mesh_.nCells());
|
||||
nCells_ = returnReduce(cellId_.size(), sumOp<label>());
|
||||
break;
|
||||
}
|
||||
@ -134,7 +134,7 @@ void Foam::functionObjects::fieldValues::volRegion::setCellZoneCells()
|
||||
|
||||
Foam::scalar Foam::functionObjects::fieldValues::volRegion::volume() const
|
||||
{
|
||||
return gSum(filterField(mesh().V()));
|
||||
return gSum(filterField(mesh_.V()));
|
||||
}
|
||||
|
||||
|
||||
@ -218,12 +218,6 @@ Foam::functionObjects::fieldValues::volRegion::volRegion
|
||||
weightFieldName_("none"),
|
||||
writeVolume_(dict.lookupOrDefault("writeVolume", false))
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -243,12 +237,6 @@ Foam::functionObjects::fieldValues::volRegion::volRegion
|
||||
weightFieldName_("none"),
|
||||
writeVolume_(dict.lookupOrDefault("writeVolume", false))
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
@ -165,7 +165,7 @@ bool Foam::functionObjects::fieldValues::volRegion::writeValues
|
||||
if (ok)
|
||||
{
|
||||
Field<Type> values(setFieldValues<Type>(fieldName));
|
||||
scalarField V(filterField(mesh().V()));
|
||||
scalarField V(filterField(mesh_.V()));
|
||||
scalarField weightField(values.size(), 1.0);
|
||||
|
||||
if (weightFieldName_ != "none")
|
||||
|
||||
Reference in New Issue
Block a user