functionObjects: Further simplification and rationalization using the fvMeshFunctionObject base-class

This commit is contained in:
Henry Weller
2016-08-10 12:29:19 +01:00
parent 8339b57255
commit 2da5570c92
35 changed files with 256 additions and 447 deletions

View File

@ -52,6 +52,18 @@ Foam::functionObjects::fvMeshFunctionObject::fvMeshFunctionObject
{} {}
Foam::functionObjects::fvMeshFunctionObject::fvMeshFunctionObject
(
const word& name,
const objectRegistry& obr,
const dictionary& dict
)
:
regionFunctionObject(name, obr, dict),
mesh_(refCast<const fvMesh>(obr_))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::fvMeshFunctionObject::~fvMeshFunctionObject() Foam::functionObjects::fvMeshFunctionObject::~fvMeshFunctionObject()

View File

@ -100,6 +100,14 @@ public:
const dictionary& dict const dictionary& dict
); );
//- Construct from the region objectRegistry and dictionary
fvMeshFunctionObject
(
const word& name,
const objectRegistry& obr,
const dictionary& dict
);
//- Destructor //- Destructor
virtual ~fvMeshFunctionObject(); virtual ~fvMeshFunctionObject();

View File

@ -103,18 +103,12 @@ Foam::functionObjects::fieldMinMax::fieldMinMax
const dictionary& dict const dictionary& dict
) )
: :
regionFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
logFiles(obr_, name), logFiles(obr_, name),
location_(true), location_(true),
mode_(mdMag), mode_(mdMag),
fieldSet_() fieldSet_()
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
resetName(typeName); resetName(typeName);
} }
@ -130,7 +124,7 @@ Foam::functionObjects::fieldMinMax::~fieldMinMax()
bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict) bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
{ {
regionFunctionObject::read(dict); fvMeshFunctionObject::read(dict);
location_ = dict.lookupOrDefault<Switch>("location", true); location_ = dict.lookupOrDefault<Switch>("location", true);

View File

@ -67,7 +67,7 @@ Usage
Output data is written to the file \<timeDir\>/fieldMinMax.dat Output data is written to the file \<timeDir\>/fieldMinMax.dat
See also See also
Foam::functionObjects::regionFunctionObject Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::logFiles Foam::functionObjects::logFiles
SourceFiles SourceFiles
@ -78,7 +78,7 @@ SourceFiles
#ifndef functionObjects_fieldMinMax_H #ifndef functionObjects_fieldMinMax_H
#define functionObjects_fieldMinMax_H #define functionObjects_fieldMinMax_H
#include "regionFunctionObject.H" #include "fvMeshFunctionObject.H"
#include "logFiles.H" #include "logFiles.H"
#include "vector.H" #include "vector.H"
@ -95,7 +95,7 @@ namespace functionObjects
class fieldMinMax class fieldMinMax
: :
public regionFunctionObject, public fvMeshFunctionObject,
public logFiles public logFiles
{ {
public: public:

View File

@ -109,10 +109,9 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
const label proci = Pstream::myProcNo(); const label proci = Pstream::myProcNo();
const fieldType& field = obr_.lookupObject<fieldType>(fieldName); const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
const fvMesh& mesh = field.mesh();
const volVectorField::Boundary& CfBoundary = const volVectorField::Boundary& CfBoundary =
mesh.C().boundaryField(); mesh_.C().boundaryField();
switch (mode) switch (mode)
{ {
@ -126,7 +125,7 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
List<vector> minCs(Pstream::nProcs()); List<vector> minCs(Pstream::nProcs());
label minProci = findMin(magField); label minProci = findMin(magField);
minVs[proci] = magField[minProci]; minVs[proci] = magField[minProci];
minCs[proci] = field.mesh().C()[minProci]; minCs[proci] = mesh_.C()[minProci];
labelList maxIs(Pstream::nProcs()); labelList maxIs(Pstream::nProcs());
@ -134,7 +133,7 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
List<vector> maxCs(Pstream::nProcs()); List<vector> maxCs(Pstream::nProcs());
label maxProci = findMax(magField); label maxProci = findMax(magField);
maxVs[proci] = magField[maxProci]; maxVs[proci] = magField[maxProci];
maxCs[proci] = field.mesh().C()[maxProci]; maxCs[proci] = mesh_.C()[maxProci];
forAll(magFieldBoundary, patchi) forAll(magFieldBoundary, patchi)
{ {
@ -198,7 +197,7 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
List<vector> minCs(Pstream::nProcs()); List<vector> minCs(Pstream::nProcs());
label minProci = findMin(field); label minProci = findMin(field);
minVs[proci] = field[minProci]; minVs[proci] = field[minProci];
minCs[proci] = field.mesh().C()[minProci]; minCs[proci] = mesh_.C()[minProci];
Pstream::gatherList(minVs); Pstream::gatherList(minVs);
Pstream::gatherList(minCs); Pstream::gatherList(minCs);
@ -207,7 +206,7 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
List<vector> maxCs(Pstream::nProcs()); List<vector> maxCs(Pstream::nProcs());
label maxProci = findMax(field); label maxProci = findMax(field);
maxVs[proci] = field[maxProci]; maxVs[proci] = field[maxProci];
maxCs[proci] = field.mesh().C()[maxProci]; maxCs[proci] = mesh_.C()[maxProci];
forAll(fieldBoundary, patchi) forAll(fieldBoundary, patchi)
{ {

View File

@ -49,7 +49,7 @@ Foam::functionObjects::fieldValue::fieldValue
const word& valueType const word& valueType
) )
: :
regionFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
logFiles(obr_, name), logFiles(obr_, name),
dict_(dict), dict_(dict),
regionName_(word::null), regionName_(word::null),
@ -68,7 +68,7 @@ Foam::functionObjects::fieldValue::fieldValue
const word& valueType const word& valueType
) )
: :
regionFunctionObject(name, obr, dict), fvMeshFunctionObject(name, obr, dict),
logFiles(obr_, name), logFiles(obr_, name),
dict_(dict), dict_(dict),
regionName_(word::null), regionName_(word::null),
@ -89,8 +89,12 @@ Foam::functionObjects::fieldValue::~fieldValue()
bool Foam::functionObjects::fieldValue::read(const dictionary& dict) bool Foam::functionObjects::fieldValue::read(const dictionary& dict)
{ {
dict_ = dict; if (dict != dict_)
regionFunctionObject::read(dict); {
dict_ = dict;
}
fvMeshFunctionObject::read(dict);
dict.lookup("fields") >> fields_; dict.lookup("fields") >> fields_;
dict.lookup("writeFields") >> writeFields_; dict.lookup("writeFields") >> writeFields_;

View File

@ -32,7 +32,7 @@ Description
See also See also
Foam::functionObject Foam::functionObject
Foam::functionObjects::regionFunctionObject Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::logFiles Foam::functionObjects::logFiles
SourceFiles SourceFiles
@ -43,7 +43,7 @@ SourceFiles
#ifndef functionObjects_fieldValue_H #ifndef functionObjects_fieldValue_H
#define functionObjects_fieldValue_H #define functionObjects_fieldValue_H
#include "regionFunctionObject.H" #include "fvMeshFunctionObject.H"
#include "logFiles.H" #include "logFiles.H"
#include "Switch.H" #include "Switch.H"
#include "Field.H" #include "Field.H"
@ -65,7 +65,7 @@ namespace functionObjects
class fieldValue class fieldValue
: :
public regionFunctionObject, public fvMeshFunctionObject,
public logFiles public logFiles
{ {
@ -169,9 +169,6 @@ public:
//- Return the output field values flag //- Return the output field values flag
inline const Switch& writeFields() const; 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 //- Return access to the latest set of results
inline const dictionary& resultDict() const; inline const dictionary& resultDict() const;

View File

@ -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& inline const Foam::dictionary&
Foam::functionObjects::fieldValue::resultDict() const Foam::functionObjects::fieldValue::resultDict() const
{ {

View File

@ -112,12 +112,6 @@ Foam::functionObjects::fieldValues::fieldValueDelta::fieldValueDelta
region1Ptr_(nullptr), region1Ptr_(nullptr),
region2Ptr_(nullptr) region2Ptr_(nullptr)
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
resetName(typeName); resetName(typeName);
} }

View File

@ -102,7 +102,7 @@ const Foam::NamedEnum
void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces() void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces()
{ {
label zoneId = mesh().faceZones().findZoneID(regionName_); label zoneId = mesh_.faceZones().findZoneID(regionName_);
if (zoneId < 0) if (zoneId < 0)
{ {
@ -110,11 +110,11 @@ void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces()
<< type() << " " << name() << ": " << type() << " " << name() << ": "
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):" << nl << regionTypeNames_[regionType_] << "(" << regionName_ << "):" << nl
<< " Unknown face zone name: " << regionName_ << " Unknown face zone name: " << regionName_
<< ". Valid face zones are: " << mesh().faceZones().names() << ". Valid face zones are: " << mesh_.faceZones().names()
<< nl << exit(FatalError); << nl << exit(FatalError);
} }
const faceZone& fZone = mesh().faceZones()[zoneId]; const faceZone& fZone = mesh_.faceZones()[zoneId];
DynamicList<label> faceIds(fZone.size()); DynamicList<label> faceIds(fZone.size());
DynamicList<label> facePatchIds(fZone.size()); DynamicList<label> facePatchIds(fZone.size());
@ -126,15 +126,15 @@ void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces()
label faceId = -1; label faceId = -1;
label facePatchId = -1; label facePatchId = -1;
if (mesh().isInternalFace(facei)) if (mesh_.isInternalFace(facei))
{ {
faceId = facei; faceId = facei;
facePatchId = -1; facePatchId = -1;
} }
else else
{ {
facePatchId = mesh().boundaryMesh().whichPatch(facei); facePatchId = mesh_.boundaryMesh().whichPatch(facei);
const polyPatch& pp = mesh().boundaryMesh()[facePatchId]; const polyPatch& pp = mesh_.boundaryMesh()[facePatchId];
if (isA<coupledPolyPatch>(pp)) if (isA<coupledPolyPatch>(pp))
{ {
if (refCast<const coupledPolyPatch>(pp).owner()) if (refCast<const coupledPolyPatch>(pp).owner())
@ -187,7 +187,7 @@ void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces()
void Foam::functionObjects::fieldValues::surfaceRegion::setPatchFaces() void Foam::functionObjects::fieldValues::surfaceRegion::setPatchFaces()
{ {
const label patchid = mesh().boundaryMesh().findPatchID(regionName_); const label patchid = mesh_.boundaryMesh().findPatchID(regionName_);
if (patchid < 0) if (patchid < 0)
{ {
@ -196,11 +196,11 @@ void Foam::functionObjects::fieldValues::surfaceRegion::setPatchFaces()
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):" << nl << regionTypeNames_[regionType_] << "(" << regionName_ << "):" << nl
<< " Unknown patch name: " << regionName_ << " Unknown patch name: " << regionName_
<< ". Valid patch names are: " << ". Valid patch names are: "
<< mesh().boundaryMesh().names() << nl << mesh_.boundaryMesh().names() << nl
<< exit(FatalError); << exit(FatalError);
} }
const polyPatch& pp = mesh().boundaryMesh()[patchid]; const polyPatch& pp = mesh_.boundaryMesh()[patchid];
label nFaces = pp.size(); label nFaces = pp.size();
if (isA<emptyPolyPatch>(pp)) if (isA<emptyPolyPatch>(pp))
@ -230,7 +230,7 @@ void Foam::functionObjects::fieldValues::surfaceRegion::sampledSurfaceFaces
surfacePtr_ = sampledSurface::New surfacePtr_ = sampledSurface::New
( (
name(), name(),
mesh(), mesh_,
dict.subDict("sampledSurfaceDict") dict.subDict("sampledSurfaceDict")
); );
surfacePtr_().update(); surfacePtr_().update();
@ -253,15 +253,15 @@ void Foam::functionObjects::fieldValues::surfaceRegion::combineMeshGeometry
if (facePatchId_[i] != -1) if (facePatchId_[i] != -1)
{ {
label patchi = facePatchId_[i]; 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 // Add local faces and points to the all* lists
indirectPrimitivePatch pp indirectPrimitivePatch pp
( (
IndirectList<face>(mesh().faces(), globalFacesIs), IndirectList<face>(mesh_.faces(), globalFacesIs),
mesh().points() mesh_.points()
); );
allFaces[Pstream::myProcNo()] = pp.localFaces(); allFaces[Pstream::myProcNo()] = pp.localFaces();
allPoints[Pstream::myProcNo()] = pp.localPoints(); allPoints[Pstream::myProcNo()] = pp.localPoints();
@ -372,7 +372,7 @@ void Foam::functionObjects::fieldValues::surfaceRegion::combineSurfaceGeometry
if (Pstream::parRun()) if (Pstream::parRun())
{ {
// Dimension as fraction of mesh bounding box // Dimension as fraction of mesh bounding box
scalar mergeDim = 1e-10*mesh().bounds().mag(); scalar mergeDim = 1e-10*mesh_.bounds().mag();
labelList pointsMap; labelList pointsMap;
@ -409,7 +409,7 @@ Foam::functionObjects::fieldValues::surfaceRegion::totalArea() const
} }
else else
{ {
totalArea = gSum(filterField(mesh().magSf(), false)); totalArea = gSum(filterField(mesh_.magSf(), false));
} }
return totalArea; return totalArea;
@ -664,12 +664,6 @@ Foam::functionObjects::fieldValues::surfaceRegion::surfaceRegion
facePatchId_(), facePatchId_(),
faceSign_() faceSign_()
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
} }
@ -694,12 +688,6 @@ Foam::functionObjects::fieldValues::surfaceRegion::surfaceRegion
facePatchId_(), facePatchId_(),
faceSign_() faceSign_()
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
} }

View File

@ -291,7 +291,7 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::writeValues
else else
{ {
// Get oriented Sf // Get oriented Sf
Sf = filterField(mesh().Sf(), true); Sf = filterField(mesh_.Sf(), true);
} }
// Combine onto master // Combine onto master

View File

@ -95,24 +95,24 @@ void Foam::functionObjects::fieldValues::volRegion::setCellZoneCells()
{ {
dict().lookup("name") >> regionName_; dict().lookup("name") >> regionName_;
label zoneId = mesh().cellZones().findZoneID(regionName_); label zoneId = mesh_.cellZones().findZoneID(regionName_);
if (zoneId < 0) if (zoneId < 0)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown cell zone name: " << regionName_ << "Unknown cell zone name: " << regionName_
<< ". Valid cell zones are: " << mesh().cellZones().names() << ". Valid cell zones are: " << mesh_.cellZones().names()
<< nl << exit(FatalError); << nl << exit(FatalError);
} }
cellId_ = mesh().cellZones()[zoneId]; cellId_ = mesh_.cellZones()[zoneId];
nCells_ = returnReduce(cellId_.size(), sumOp<label>()); nCells_ = returnReduce(cellId_.size(), sumOp<label>());
break; break;
} }
case stAll: case stAll:
{ {
cellId_ = identity(mesh().nCells()); cellId_ = identity(mesh_.nCells());
nCells_ = returnReduce(cellId_.size(), sumOp<label>()); nCells_ = returnReduce(cellId_.size(), sumOp<label>());
break; break;
} }
@ -134,7 +134,7 @@ void Foam::functionObjects::fieldValues::volRegion::setCellZoneCells()
Foam::scalar Foam::functionObjects::fieldValues::volRegion::volume() const 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"), weightFieldName_("none"),
writeVolume_(dict.lookupOrDefault("writeVolume", false)) writeVolume_(dict.lookupOrDefault("writeVolume", false))
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
} }
@ -243,12 +237,6 @@ Foam::functionObjects::fieldValues::volRegion::volRegion
weightFieldName_("none"), weightFieldName_("none"),
writeVolume_(dict.lookupOrDefault("writeVolume", false)) writeVolume_(dict.lookupOrDefault("writeVolume", false))
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
} }

View File

@ -165,7 +165,7 @@ bool Foam::functionObjects::fieldValues::volRegion::writeValues
if (ok) if (ok)
{ {
Field<Type> values(setFieldValues<Type>(fieldName)); Field<Type> values(setFieldValues<Type>(fieldName));
scalarField V(filterField(mesh().V())); scalarField V(filterField(mesh_.V()));
scalarField weightField(values.size(), 1.0); scalarField weightField(values.size(), 1.0);
if (weightFieldName_ != "none") if (weightFieldName_ != "none")

View File

@ -75,15 +75,9 @@ Foam::functionObjects::histogram::histogram
const dictionary& dict const dictionary& dict
) )
: :
regionFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
file_(obr_, name) file_(obr_, name)
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
} }
@ -120,8 +114,6 @@ bool Foam::functionObjects::histogram::write()
{ {
Log << type() << " " << name() << " write:" << nl; Log << type() << " " << name() << " write:" << nl;
const fvMesh& mesh = refCast<const fvMesh>(obr_);
autoPtr<volScalarField> fieldPtr; autoPtr<volScalarField> fieldPtr;
if (obr_.foundObject<volScalarField>(fieldName_)) if (obr_.foundObject<volScalarField>(fieldName_))
{ {
@ -137,12 +129,12 @@ bool Foam::functionObjects::histogram::write()
IOobject IOobject
( (
fieldName_, fieldName_,
mesh.time().timeName(), mesh_.time().timeName(),
mesh, mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh mesh_
) )
); );
} }
@ -166,7 +158,7 @@ bool Foam::functionObjects::histogram::write()
} }
scalarField volFrac(nBins_, 0); scalarField volFrac(nBins_, 0);
const scalarField& V = mesh.V(); const scalarField& V = mesh_.V();
forAll(field, celli) forAll(field, celli)
{ {

View File

@ -59,7 +59,7 @@ Usage
See also See also
Foam::functionObject Foam::functionObject
Foam::functionObjects::regionFunctionObject Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::writeFile Foam::functionObjects::writeFile
SourceFiles SourceFiles
@ -70,7 +70,7 @@ SourceFiles
#ifndef functionObjects_histogram_H #ifndef functionObjects_histogram_H
#define functionObjects_histogram_H #define functionObjects_histogram_H
#include "regionFunctionObject.H" #include "fvMeshFunctionObject.H"
#include "writeFile.H" #include "writeFile.H"
#include "writer.H" #include "writer.H"
@ -87,7 +87,7 @@ namespace functionObjects
class histogram class histogram
: :
public regionFunctionObject public fvMeshFunctionObject
{ {
// Private data // Private data

View File

@ -355,8 +355,6 @@ bool Foam::functionObjects::nearWallFields::write()
vtf_[i].write(); vtf_[i].write();
} }
Log << endl;
return true; return true;
} }

View File

@ -173,7 +173,6 @@ void Foam::functionObjects::regionSizeDistribution::writeAlphaFields
Foam::Map<Foam::label> Foam::Map<Foam::label>
Foam::functionObjects::regionSizeDistribution::findPatchRegions Foam::functionObjects::regionSizeDistribution::findPatchRegions
( (
const polyMesh& mesh,
const regionSplit& regions const regionSplit& regions
) const ) const
{ {
@ -181,19 +180,19 @@ Foam::functionObjects::regionSizeDistribution::findPatchRegions
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Count number of patch faces (just for initial sizing) // Count number of patch faces (just for initial sizing)
const labelHashSet patchIDs(mesh.boundaryMesh().patchSet(patchNames_)); const labelHashSet patchIDs(mesh_.boundaryMesh().patchSet(patchNames_));
label nPatchFaces = 0; label nPatchFaces = 0;
forAllConstIter(labelHashSet, patchIDs, iter) forAllConstIter(labelHashSet, patchIDs, iter)
{ {
nPatchFaces += mesh.boundaryMesh()[iter.key()].size(); nPatchFaces += mesh_.boundaryMesh()[iter.key()].size();
} }
Map<label> patchRegions(nPatchFaces); Map<label> patchRegions(nPatchFaces);
forAllConstIter(labelHashSet, patchIDs, iter) forAllConstIter(labelHashSet, patchIDs, iter)
{ {
const polyPatch& pp = mesh.boundaryMesh()[iter.key()]; const polyPatch& pp = mesh_.boundaryMesh()[iter.key()];
// Collect all regions on the patch // Collect all regions on the patch
const labelList& faceCells = pp.faceCells(); const labelList& faceCells = pp.faceCells();
@ -330,17 +329,11 @@ Foam::functionObjects::regionSizeDistribution::regionSizeDistribution
const dictionary& dict const dictionary& dict
) )
: :
regionFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
file_(obr_, name), file_(obr_, name),
alphaName_(dict.lookup("field")), alphaName_(dict.lookup("field")),
patchNames_(dict.lookup("patches")) patchNames_(dict.lookup("patches"))
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
} }
@ -389,8 +382,6 @@ bool Foam::functionObjects::regionSizeDistribution::write()
{ {
Info<< type() << " " << name() << " write:" << nl; Info<< type() << " " << name() << " write:" << nl;
const fvMesh& mesh = refCast<const fvMesh>(obr_);
autoPtr<volScalarField> alphaPtr; autoPtr<volScalarField> alphaPtr;
if (obr_.foundObject<volScalarField>(alphaName_)) if (obr_.foundObject<volScalarField>(alphaName_))
{ {
@ -406,12 +397,12 @@ bool Foam::functionObjects::regionSizeDistribution::write()
IOobject IOobject
( (
alphaName_, alphaName_,
mesh.time().timeName(), mesh_.time().timeName(),
mesh, mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh mesh_
) )
); );
} }
@ -428,7 +419,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
<< fvc::domainIntegrate(alpha).value() << fvc::domainIntegrate(alpha).value()
<< endl; << endl;
const scalar meshVol = gSum(mesh.V()); const scalar meshVol = gSum(mesh_.V());
const scalar maxDropletVol = 1.0/6.0*pow(maxDiam_, 3); const scalar maxDropletVol = 1.0/6.0*pow(maxDiam_, 3);
const scalar delta = (maxDiam_-minDiam_)/nBins_; const scalar delta = (maxDiam_-minDiam_)/nBins_;
@ -438,14 +429,14 @@ bool Foam::functionObjects::regionSizeDistribution::write()
// Determine blocked faces // Determine blocked faces
boolList blockedFace(mesh.nFaces(), false); boolList blockedFace(mesh_.nFaces(), false);
label nBlocked = 0; label nBlocked = 0;
{ {
for (label facei = 0; facei < mesh.nInternalFaces(); facei++) for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
{ {
scalar ownVal = alpha[mesh.faceOwner()[facei]]; scalar ownVal = alpha[mesh_.faceOwner()[facei]];
scalar neiVal = alpha[mesh.faceNeighbour()[facei]]; scalar neiVal = alpha[mesh_.faceNeighbour()[facei]];
if if
( (
@ -491,7 +482,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
} }
regionSplit regions(mesh, blockedFace); regionSplit regions(mesh_, blockedFace);
Info<< " Determined " << regions.nRegions() Info<< " Determined " << regions.nRegions()
<< " disconnected regions" << endl; << " disconnected regions" << endl;
@ -504,12 +495,12 @@ bool Foam::functionObjects::regionSizeDistribution::write()
IOobject IOobject
( (
"region", "region",
mesh.time().timeName(), mesh_.time().timeName(),
mesh, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh, mesh_,
dimensionedScalar("zero", dimless, 0) dimensionedScalar("zero", dimless, 0)
); );
Info<< " Dumping region as volScalarField to " << region.name() Info<< " Dumping region as volScalarField to " << region.name()
@ -525,20 +516,19 @@ bool Foam::functionObjects::regionSizeDistribution::write()
// Determine regions connected to supplied patches // Determine regions connected to supplied patches
Map<label> patchRegions(findPatchRegions(mesh, regions)); Map<label> patchRegions(findPatchRegions(regions));
// Sum all regions // Sum all regions
const scalarField alphaVol(alpha.primitiveField()*mesh.V()); const scalarField alphaVol(alpha.primitiveField()*mesh_.V());
Map<scalar> allRegionVolume(regionSum(regions, mesh.V())); Map<scalar> allRegionVolume(regionSum(regions, mesh_.V()));
Map<scalar> allRegionAlphaVolume(regionSum(regions, alphaVol)); Map<scalar> allRegionAlphaVolume(regionSum(regions, alphaVol));
Map<label> allRegionNumCells Map<label> allRegionNumCells
( (
regionSum regionSum
( (
regions, regions,
labelField(mesh.nCells(), 1.0) labelField(mesh_.nCells(), 1.0)
) )
); );

View File

@ -96,7 +96,7 @@ Usage
See also See also
Foam::functionObject Foam::functionObject
Foam::functionObjects::regionFunctionObject Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::writeFile Foam::functionObjects::writeFile
SourceFiles SourceFiles
@ -107,7 +107,7 @@ SourceFiles
#ifndef functionObjects_regionSizeDistribution_H #ifndef functionObjects_regionSizeDistribution_H
#define functionObjects_regionSizeDistribution_H #define functionObjects_regionSizeDistribution_H
#include "regionFunctionObject.H" #include "fvMeshFunctionObject.H"
#include "writeFile.H" #include "writeFile.H"
#include "writer.H" #include "writer.H"
#include "Map.H" #include "Map.H"
@ -132,7 +132,7 @@ namespace functionObjects
class regionSizeDistribution class regionSizeDistribution
: :
public regionFunctionObject public fvMeshFunctionObject
{ {
// Private data // Private data
@ -194,7 +194,7 @@ class regionSizeDistribution
) const; ) const;
//- Mark all regions starting at patches //- Mark all regions starting at patches
Map<label> findPatchRegions(const polyMesh&, const regionSplit&) const; Map<label> findPatchRegions(const regionSplit&) const;
//- Helper: divide if denom != 0 //- Helper: divide if denom != 0
static tmp<scalarField> divide(const scalarField&, const scalarField&); static tmp<scalarField> divide(const scalarField&, const scalarField&);

View File

@ -26,7 +26,6 @@ License
#include "Pstream.H" #include "Pstream.H"
#include "functionObjectList.H" #include "functionObjectList.H"
#include "streamLine.H" #include "streamLine.H"
#include "fvMesh.H"
#include "streamLineParticleCloud.H" #include "streamLineParticleCloud.H"
#include "ReadFields.H" #include "ReadFields.H"
#include "meshSearch.H" #include "meshSearch.H"
@ -55,9 +54,7 @@ namespace functionObjects
Foam::autoPtr<Foam::indirectPrimitivePatch> Foam::autoPtr<Foam::indirectPrimitivePatch>
Foam::functionObjects::streamLine::wallPatch() const Foam::functionObjects::streamLine::wallPatch() const
{ {
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const polyBoundaryMesh& patches = mesh.boundaryMesh();
label nFaces = 0; label nFaces = 0;
@ -92,10 +89,10 @@ Foam::functionObjects::streamLine::wallPatch() const
( (
IndirectList<face> IndirectList<face>
( (
mesh.faces(), mesh_.faces(),
addressing addressing
), ),
mesh.points() mesh_.points()
) )
); );
} }
@ -103,12 +100,10 @@ Foam::functionObjects::streamLine::wallPatch() const
void Foam::functionObjects::streamLine::track() void Foam::functionObjects::streamLine::track()
{ {
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
IDLList<streamLineParticle> initialParticles; IDLList<streamLineParticle> initialParticles;
streamLineParticleCloud particles streamLineParticleCloud particles
( (
mesh, mesh_,
cloudName_, cloudName_,
initialParticles initialParticles
); );
@ -121,7 +116,7 @@ void Foam::functionObjects::streamLine::track()
( (
new streamLineParticle new streamLineParticle
( (
mesh, mesh_,
seedPoints[i], seedPoints[i],
seedPoints.cells()[i], seedPoints.cells()[i],
lifeTime_ lifeTime_
@ -146,11 +141,11 @@ void Foam::functionObjects::streamLine::track()
forAll(fields_, i) forAll(fields_, i)
{ {
if (mesh.foundObject<volScalarField>(fields_[i])) if (mesh_.foundObject<volScalarField>(fields_[i]))
{ {
nScalar++; nScalar++;
} }
else if (mesh.foundObject<volVectorField>(fields_[i])) else if (mesh_.foundObject<volVectorField>(fields_[i]))
{ {
nVector++; nVector++;
} }
@ -159,9 +154,9 @@ void Foam::functionObjects::streamLine::track()
FatalErrorInFunction FatalErrorInFunction
<< "Cannot find field " << fields_[i] << nl << "Cannot find field " << fields_[i] << nl
<< "Valid scalar fields are:" << "Valid scalar fields are:"
<< mesh.names(volScalarField::typeName) << nl << mesh_.names(volScalarField::typeName) << nl
<< "Valid vector fields are:" << "Valid vector fields are:"
<< mesh.names(volVectorField::typeName) << mesh_.names(volVectorField::typeName)
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -172,9 +167,9 @@ void Foam::functionObjects::streamLine::track()
forAll(fields_, i) forAll(fields_, i)
{ {
if (mesh.foundObject<volScalarField>(fields_[i])) if (mesh_.foundObject<volScalarField>(fields_[i]))
{ {
const volScalarField& f = mesh.lookupObject<volScalarField> const volScalarField& f = mesh_.lookupObject<volScalarField>
( (
fields_[i] fields_[i]
); );
@ -188,9 +183,9 @@ void Foam::functionObjects::streamLine::track()
) )
); );
} }
else if (mesh.foundObject<volVectorField>(fields_[i])) else if (mesh_.foundObject<volVectorField>(fields_[i]))
{ {
const volVectorField& f = mesh.lookupObject<volVectorField> const volVectorField& f = mesh_.lookupObject<volVectorField>
( (
fields_[i] fields_[i]
); );
@ -290,23 +285,10 @@ Foam::functionObjects::streamLine::streamLine
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), fvMeshFunctionObject(name, runTime, dict),
obr_
(
runTime.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
),
dict_(dict), dict_(dict),
nSubCycle_(0) nSubCycle_(0)
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict_); read(dict_);
} }
@ -321,6 +303,11 @@ Foam::functionObjects::streamLine::~streamLine()
bool Foam::functionObjects::streamLine::read(const dictionary& dict) bool Foam::functionObjects::streamLine::read(const dictionary& dict)
{ {
if (dict != dict_)
{
dict_ = dict;
}
Info<< type() << " " << name() << ":" << nl; Info<< type() << " " << name() << ":" << nl;
dict.lookup("fields") >> fields_; dict.lookup("fields") >> fields_;
@ -402,15 +389,13 @@ bool Foam::functionObjects::streamLine::read(const dictionary& dict)
cloudName_ = dict.lookupOrDefault<word>("cloudName", "streamLine"); cloudName_ = dict.lookupOrDefault<word>("cloudName", "streamLine");
dict.lookup("seedSampleSet") >> seedSet_; dict.lookup("seedSampleSet") >> seedSet_;
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); meshSearchPtr_.reset(new meshSearch(mesh_));
meshSearchPtr_.reset(new meshSearch(mesh));
const dictionary& coeffsDict = dict.subDict(seedSet_ + "Coeffs"); const dictionary& coeffsDict = dict.subDict(seedSet_ + "Coeffs");
sampledSetPtr_ = sampledSet::New sampledSetPtr_ = sampledSet::New
( (
seedSet_, seedSet_,
mesh, mesh_,
meshSearchPtr_(), meshSearchPtr_(),
coeffsDict coeffsDict
); );
@ -434,8 +419,6 @@ bool Foam::functionObjects::streamLine::write()
Info<< type() << " " << name() << " write:" << nl; Info<< type() << " " << name() << " write:" << nl;
const Time& runTime = obr_.time(); const Time& runTime = obr_.time();
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
// Do all injection and tracking // Do all injection and tracking
track(); track();
@ -562,11 +545,11 @@ bool Foam::functionObjects::streamLine::write()
? runTime.path()/".."/"postProcessing"/"sets"/name() ? runTime.path()/".."/"postProcessing"/"sets"/name()
: runTime.path()/"postProcessing"/"sets"/name() : runTime.path()/"postProcessing"/"sets"/name()
); );
if (mesh.name() != fvMesh::defaultRegion) if (mesh_.name() != fvMesh::defaultRegion)
{ {
vtkPath = vtkPath/mesh.name(); vtkPath = vtkPath/mesh_.name();
} }
vtkPath = vtkPath/mesh.time().timeName(); vtkPath = vtkPath/mesh_.time().timeName();
mkDir(vtkPath); mkDir(vtkPath);
@ -674,8 +657,6 @@ bool Foam::functionObjects::streamLine::write()
void Foam::functionObjects::streamLine::updateMesh(const mapPolyMesh& mpm) void Foam::functionObjects::streamLine::updateMesh(const mapPolyMesh& mpm)
{ {
const fvMesh& mesh_ = dynamic_cast<const fvMesh&>(obr_);
if (&mpm.mesh() == &mesh_) if (&mpm.mesh() == &mesh_)
{ {
read(dict_); read(dict_);
@ -685,8 +666,6 @@ void Foam::functionObjects::streamLine::updateMesh(const mapPolyMesh& mpm)
void Foam::functionObjects::streamLine::movePoints(const polyMesh& mesh) void Foam::functionObjects::streamLine::movePoints(const polyMesh& mesh)
{ {
const fvMesh& mesh_ = dynamic_cast<const fvMesh&>(obr_);
if (&mesh == &mesh_) if (&mesh == &mesh_)
{ {
// Moving mesh affects the search tree // Moving mesh affects the search tree

View File

@ -102,7 +102,7 @@ SourceFiles
#ifndef functionObjects_streamLine_H #ifndef functionObjects_streamLine_H
#define functionObjects_streamLine_H #define functionObjects_streamLine_H
#include "functionObject.H" #include "fvMeshFunctionObject.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
#include "DynamicList.H" #include "DynamicList.H"
#include "scalarList.H" #include "scalarList.H"
@ -116,7 +116,6 @@ namespace Foam
{ {
// Forward declaration of classes // Forward declaration of classes
class objectRegistry;
class meshSearch; class meshSearch;
class sampledSet; class sampledSet;
@ -129,13 +128,10 @@ namespace functionObjects
class streamLine class streamLine
: :
public functionObject public fvMeshFunctionObject
{ {
// Private data // Private data
//- Database this class is registered to
const objectRegistry& obr_;
//- Input dictionary //- Input dictionary
dictionary dict_; dictionary dict_;

View File

@ -63,9 +63,7 @@ namespace functionObjects
Foam::autoPtr<Foam::indirectPrimitivePatch> Foam::autoPtr<Foam::indirectPrimitivePatch>
Foam::functionObjects::wallBoundedStreamLine::wallPatch() const Foam::functionObjects::wallBoundedStreamLine::wallPatch() const
{ {
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const polyBoundaryMesh& patches = mesh.boundaryMesh();
label nFaces = 0; label nFaces = 0;
@ -102,10 +100,10 @@ Foam::functionObjects::wallBoundedStreamLine::wallPatch() const
( (
IndirectList<face> IndirectList<face>
( (
mesh.faces(), mesh_.faces(),
addressing addressing
), ),
mesh.points() mesh_.points()
) )
); );
} }
@ -118,9 +116,7 @@ Foam::tetIndices Foam::functionObjects::wallBoundedStreamLine::findNearestTet
const label celli const label celli
) const ) const
{ {
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); const cell& cFaces = mesh_.cells()[celli];
const cell& cFaces = mesh.cells()[celli];
label minFacei = -1; label minFacei = -1;
label minTetPtI = -1; label minTetPtI = -1;
@ -132,16 +128,16 @@ Foam::tetIndices Foam::functionObjects::wallBoundedStreamLine::findNearestTet
if (isWallPatch[facei]) if (isWallPatch[facei])
{ {
const face& f = mesh.faces()[facei]; const face& f = mesh_.faces()[facei];
const label fp0 = mesh.tetBasePtIs()[facei]; const label fp0 = mesh_.tetBasePtIs()[facei];
const point& basePoint = mesh.points()[f[fp0]]; const point& basePoint = mesh_.points()[f[fp0]];
label fp = f.fcIndex(fp0); label fp = f.fcIndex(fp0);
for (label i = 2; i < f.size(); i++) for (label i = 2; i < f.size(); i++)
{ {
const point& thisPoint = mesh.points()[f[fp]]; const point& thisPoint = mesh_.points()[f[fp]];
label nextFp = f.fcIndex(fp); label nextFp = f.fcIndex(fp);
const point& nextPoint = mesh.points()[f[nextFp]]; const point& nextPoint = mesh_.points()[f[nextFp]];
const triPointRef tri(basePoint, thisPoint, nextPoint); const triPointRef tri(basePoint, thisPoint, nextPoint);
@ -163,22 +159,19 @@ Foam::tetIndices Foam::functionObjects::wallBoundedStreamLine::findNearestTet
celli, celli,
minFacei, minFacei,
minTetPtI, minTetPtI,
mesh mesh_
); );
} }
void Foam::functionObjects::wallBoundedStreamLine::track() void Foam::functionObjects::wallBoundedStreamLine::track()
{ {
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
// Determine the 'wall' patches // Determine the 'wall' patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// These are the faces that need to be followed // These are the faces that need to be followed
autoPtr<indirectPrimitivePatch> boundaryPatch(wallPatch()); autoPtr<indirectPrimitivePatch> boundaryPatch(wallPatch());
PackedBoolList isWallPatch(mesh.nFaces()); PackedBoolList isWallPatch(mesh_.nFaces());
forAll(boundaryPatch().addressing(), i) forAll(boundaryPatch().addressing(), i)
{ {
isWallPatch[boundaryPatch().addressing()[i]] = 1; isWallPatch[boundaryPatch().addressing()[i]] = 1;
@ -192,7 +185,7 @@ void Foam::functionObjects::wallBoundedStreamLine::track()
IDLList<wallBoundedStreamLineParticle> initialParticles; IDLList<wallBoundedStreamLineParticle> initialParticles;
wallBoundedStreamLineParticleCloud particles wallBoundedStreamLineParticleCloud particles
( (
mesh, mesh_,
cloudName_, cloudName_,
initialParticles initialParticles
); );
@ -216,16 +209,16 @@ void Foam::functionObjects::wallBoundedStreamLine::track()
//Pout<< "Seeding particle :" << nl //Pout<< "Seeding particle :" << nl
// << " seedPt:" << seedPt << nl // << " seedPt:" << seedPt << nl
// << " face :" << ids.face() << nl // << " face :" << ids.face() << nl
// << " at :" << mesh.faceCentres()[ids.face()] << nl // << " at :" << mesh_.faceCentres()[ids.face()] << nl
// << " cell :" << mesh.cellCentres()[ids.cell()] << nl // << " cell :" << mesh_.cellCentres()[ids.cell()] << nl
// << endl; // << endl;
particles.addParticle particles.addParticle
( (
new wallBoundedStreamLineParticle new wallBoundedStreamLineParticle
( (
mesh, mesh_,
ids.faceTri(mesh).centre(), ids.faceTri(mesh_).centre(),
ids.cell(), ids.cell(),
ids.face(), // tetFace ids.face(), // tetFace
ids.tetPt(), ids.tetPt(),
@ -262,11 +255,11 @@ void Foam::functionObjects::wallBoundedStreamLine::track()
forAll(fields_, i) forAll(fields_, i)
{ {
if (mesh.foundObject<volScalarField>(fields_[i])) if (mesh_.foundObject<volScalarField>(fields_[i]))
{ {
nScalar++; nScalar++;
} }
else if (mesh.foundObject<volVectorField>(fields_[i])) else if (mesh_.foundObject<volVectorField>(fields_[i]))
{ {
nVector++; nVector++;
} }
@ -275,9 +268,9 @@ void Foam::functionObjects::wallBoundedStreamLine::track()
FatalErrorInFunction FatalErrorInFunction
<< "Cannot find field " << fields_[i] << endl << "Cannot find field " << fields_[i] << endl
<< "Valid scalar fields are:" << "Valid scalar fields are:"
<< mesh.names(volScalarField::typeName) << endl << mesh_.names(volScalarField::typeName) << endl
<< "Valid vector fields are:" << "Valid vector fields are:"
<< mesh.names(volVectorField::typeName) << mesh_.names(volVectorField::typeName)
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -289,9 +282,9 @@ void Foam::functionObjects::wallBoundedStreamLine::track()
forAll(fields_, i) forAll(fields_, i)
{ {
if (mesh.foundObject<volScalarField>(fields_[i])) if (mesh_.foundObject<volScalarField>(fields_[i]))
{ {
const volScalarField& f = mesh.lookupObject<volScalarField> const volScalarField& f = mesh_.lookupObject<volScalarField>
( (
fields_[i] fields_[i]
); );
@ -305,9 +298,9 @@ void Foam::functionObjects::wallBoundedStreamLine::track()
) )
); );
} }
else if (mesh.foundObject<volVectorField>(fields_[i])) else if (mesh_.foundObject<volVectorField>(fields_[i]))
{ {
const volVectorField& f = mesh.lookupObject<volVectorField> const volVectorField& f = mesh_.lookupObject<volVectorField>
( (
fields_[i] fields_[i]
); );
@ -409,22 +402,9 @@ Foam::functionObjects::wallBoundedStreamLine::wallBoundedStreamLine
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), fvMeshFunctionObject(name, runTime, dict),
obr_
(
runTime.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
),
dict_(dict) dict_(dict)
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict_); read(dict_);
} }
@ -439,7 +419,13 @@ Foam::functionObjects::wallBoundedStreamLine::~wallBoundedStreamLine()
bool Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict) bool Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict)
{ {
//dict_ = dict; if (dict != dict_)
{
dict_ = dict;
}
Info<< type() << " " << name() << ":" << nl;
dict.lookup("fields") >> fields_; dict.lookup("fields") >> fields_;
if (dict.found("U")) if (dict.found("U"))
{ {
@ -502,15 +488,13 @@ bool Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict)
); );
dict.lookup("seedSampleSet") >> seedSet_; dict.lookup("seedSampleSet") >> seedSet_;
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
const dictionary& coeffsDict = dict.subDict(seedSet_ + "Coeffs"); const dictionary& coeffsDict = dict.subDict(seedSet_ + "Coeffs");
sampledSetPtr_ = sampledSet::New sampledSetPtr_ = sampledSet::New
( (
seedSet_, seedSet_,
mesh, mesh_,
meshSearchMeshObject::New(mesh), meshSearchMeshObject::New(mesh_),
coeffsDict coeffsDict
); );
coeffsDict.lookup("axis") >> sampledSetAxis_; coeffsDict.lookup("axis") >> sampledSetAxis_;
@ -523,12 +507,12 @@ bool Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict)
if (debug) if (debug)
{ {
// 1. positive volume decomposition tets // 1. positive volume decomposition tets
faceSet faces(mesh, "lowQualityTetFaces", mesh.nFaces()/100+1); faceSet faces(mesh_, "lowQualityTetFaces", mesh_.nFaces()/100+1);
if if
( (
polyMeshTetDecomposition::checkFaceTets polyMeshTetDecomposition::checkFaceTets
( (
mesh, mesh_,
polyMeshTetDecomposition::minTetQuality, polyMeshTetDecomposition::minTetQuality,
true, true,
&faces &faces
@ -546,16 +530,16 @@ bool Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict)
// 2. all edges on a cell having two faces // 2. all edges on a cell having two faces
EdgeMap<label> numFacesPerEdge; EdgeMap<label> numFacesPerEdge;
forAll(mesh.cells(), celli) forAll(mesh_.cells(), celli)
{ {
const cell& cFaces = mesh.cells()[celli]; const cell& cFaces = mesh_.cells()[celli];
numFacesPerEdge.clear(); numFacesPerEdge.clear();
forAll(cFaces, cFacei) forAll(cFaces, cFacei)
{ {
label facei = cFaces[cFacei]; label facei = cFaces[cFacei];
const face& f = mesh.faces()[facei]; const face& f = mesh_.faces()[facei];
forAll(f, fp) forAll(f, fp)
{ {
const edge e(f[fp], f.nextLabel(fp)); const edge e(f[fp], f.nextLabel(fp));
@ -597,8 +581,6 @@ bool Foam::functionObjects::wallBoundedStreamLine::execute()
bool Foam::functionObjects::wallBoundedStreamLine::write() bool Foam::functionObjects::wallBoundedStreamLine::write()
{ {
const Time& runTime = obr_.time(); const Time& runTime = obr_.time();
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
// Do all injection and tracking // Do all injection and tracking
track(); track();
@ -724,11 +706,11 @@ bool Foam::functionObjects::wallBoundedStreamLine::write()
? runTime.path()/".."/"postProcessing"/"sets"/name() ? runTime.path()/".."/"postProcessing"/"sets"/name()
: runTime.path()/"postProcessing"/"sets"/name() : runTime.path()/"postProcessing"/"sets"/name()
); );
if (mesh.name() != fvMesh::defaultRegion) if (mesh_.name() != fvMesh::defaultRegion)
{ {
vtkPath = vtkPath/mesh.name(); vtkPath = vtkPath/mesh_.name();
} }
vtkPath = vtkPath/mesh.time().timeName(); vtkPath = vtkPath/mesh_.time().timeName();
mkDir(vtkPath); mkDir(vtkPath);
@ -839,8 +821,6 @@ void Foam::functionObjects::wallBoundedStreamLine::updateMesh
const mapPolyMesh& mpm const mapPolyMesh& mpm
) )
{ {
const fvMesh& mesh_ = dynamic_cast<const fvMesh&>(obr_);
if (&mpm.mesh() == &mesh_) if (&mpm.mesh() == &mesh_)
{ {
read(dict_); read(dict_);
@ -853,8 +833,6 @@ void Foam::functionObjects::wallBoundedStreamLine::movePoints
const polyMesh& mesh const polyMesh& mesh
) )
{ {
const fvMesh& mesh_ = dynamic_cast<const fvMesh&>(obr_);
if (&mesh == &mesh_) if (&mesh == &mesh_)
{ {
// Moving mesh affects the search tree // Moving mesh affects the search tree

View File

@ -94,7 +94,7 @@ Note
option should be used option should be used
See also See also
Foam::functionObject Foam::fvMeshFunctionObject
Foam::functionObjects::timeControl Foam::functionObjects::timeControl
Foam::sampledSet Foam::sampledSet
Foam::streamLine Foam::streamLine
@ -107,7 +107,7 @@ SourceFiles
#ifndef functionObjects_wallBoundedStreamLine_H #ifndef functionObjects_wallBoundedStreamLine_H
#define functionObjects_wallBoundedStreamLine_H #define functionObjects_wallBoundedStreamLine_H
#include "functionObject.H" #include "fvMeshFunctionObject.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
#include "DynamicList.H" #include "DynamicList.H"
#include "scalarList.H" #include "scalarList.H"
@ -122,7 +122,6 @@ namespace Foam
{ {
// Forward declaration of classes // Forward declaration of classes
class objectRegistry;
class meshSearch; class meshSearch;
class sampledSet; class sampledSet;
@ -135,13 +134,10 @@ namespace functionObjects
class wallBoundedStreamLine class wallBoundedStreamLine
: :
public functionObject public fvMeshFunctionObject
{ {
// Private data // Private data
//- Database this class is registered to
const objectRegistry& obr_;
//- Input dictionary //- Input dictionary
dictionary dict_; dictionary dict_;

View File

@ -102,18 +102,10 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
const dictionary& dict const dictionary& dict
) )
: :
regionFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
logFiles(obr_, name), logFiles(obr_, name),
patchSet_() patchSet_()
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volScalarField* wallHeatFluxPtr volScalarField* wallHeatFluxPtr
( (
new volScalarField new volScalarField
@ -121,17 +113,17 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
IOobject IOobject
( (
type(), type(),
mesh.time().timeName(), mesh_.time().timeName(),
mesh, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh, mesh_,
dimensionedScalar("0", dimMass/pow3(dimTime), 0) dimensionedScalar("0", dimMass/pow3(dimTime), 0)
) )
); );
mesh.objectRegistry::store(wallHeatFluxPtr); mesh_.objectRegistry::store(wallHeatFluxPtr);
read(dict); read(dict);
resetName(typeName); resetName(typeName);
@ -148,13 +140,12 @@ Foam::functionObjects::wallHeatFlux::~wallHeatFlux()
bool Foam::functionObjects::wallHeatFlux::read(const dictionary& dict) bool Foam::functionObjects::wallHeatFlux::read(const dictionary& dict)
{ {
regionFunctionObject::read(dict); fvMeshFunctionObject::read(dict);
const fvMesh& mesh = refCast<const fvMesh>(obr_); const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
patchSet_ = patchSet_ =
mesh.boundaryMesh().patchSet mesh_.boundaryMesh().patchSet
( (
wordReList(dict.lookupOrDefault("patches", wordReList())) wordReList(dict.lookupOrDefault("patches", wordReList()))
); );
@ -248,11 +239,10 @@ bool Foam::functionObjects::wallHeatFlux::write()
wallHeatFlux.write(); wallHeatFlux.write();
const fvMesh& mesh = refCast<const fvMesh>(obr_); const fvPatchList& patches = mesh_.boundary();
const fvPatchList& patches = mesh.boundary();
const surfaceScalarField::Boundary& magSf = const surfaceScalarField::Boundary& magSf =
mesh.magSf().boundaryField(); mesh_.magSf().boundaryField();
forAllConstIter(labelHashSet, patchSet_, iter) forAllConstIter(labelHashSet, patchSet_, iter)
{ {
@ -268,7 +258,8 @@ bool Foam::functionObjects::wallHeatFlux::write()
if (Pstream::master()) if (Pstream::master())
{ {
file() << mesh.time().value() file()
<< mesh_.time().value()
<< token::TAB << pp.name() << token::TAB << pp.name()
<< token::TAB << minHfp << token::TAB << minHfp
<< token::TAB << maxHfp << token::TAB << maxHfp

View File

@ -54,7 +54,7 @@ Usage
See also See also
Foam::functionObject Foam::functionObject
Foam::functionObjects::regionFunctionObject Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::logFiles Foam::functionObjects::logFiles
Foam::functionObjects::pressureTools Foam::functionObjects::pressureTools
Foam::functionObjects::timeControl Foam::functionObjects::timeControl
@ -67,7 +67,7 @@ SourceFiles
#ifndef functionObjects_wallHeatFlux_H #ifndef functionObjects_wallHeatFlux_H
#define functionObjects_wallHeatFlux_H #define functionObjects_wallHeatFlux_H
#include "regionFunctionObject.H" #include "fvMeshFunctionObject.H"
#include "logFiles.H" #include "logFiles.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
#include "surfaceFieldsFwd.H" #include "surfaceFieldsFwd.H"
@ -78,10 +78,6 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes
class fvMesh;
namespace functionObjects namespace functionObjects
{ {
@ -91,7 +87,7 @@ namespace functionObjects
class wallHeatFlux class wallHeatFlux
: :
public regionFunctionObject, public fvMeshFunctionObject,
public logFiles public logFiles
{ {

View File

@ -59,7 +59,6 @@ void Foam::functionObjects::wallShearStress::writeFileHeader(const label i)
void Foam::functionObjects::wallShearStress::calcShearStress void Foam::functionObjects::wallShearStress::calcShearStress
( (
const fvMesh& mesh,
const volSymmTensorField& Reff, const volSymmTensorField& Reff,
volVectorField& shearStress volVectorField& shearStress
) )
@ -71,8 +70,8 @@ void Foam::functionObjects::wallShearStress::calcShearStress
label patchi = iter.key(); label patchi = iter.key();
vectorField& ssp = shearStress.boundaryFieldRef()[patchi]; vectorField& ssp = shearStress.boundaryFieldRef()[patchi];
const vectorField& Sfp = mesh.Sf().boundaryField()[patchi]; const vectorField& Sfp = mesh_.Sf().boundaryField()[patchi];
const scalarField& magSfp = mesh.magSf().boundaryField()[patchi]; const scalarField& magSfp = mesh_.magSf().boundaryField()[patchi];
const symmTensorField& Reffp = Reff.boundaryField()[patchi]; const symmTensorField& Reffp = Reff.boundaryField()[patchi];
ssp = (-Sfp/magSfp) & Reffp; ssp = (-Sfp/magSfp) & Reffp;
@ -89,18 +88,10 @@ Foam::functionObjects::wallShearStress::wallShearStress
const dictionary& dict const dictionary& dict
) )
: :
regionFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
logFiles(obr_, name), logFiles(obr_, name),
patchSet_() patchSet_()
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volVectorField* wallShearStressPtr volVectorField* wallShearStressPtr
( (
new volVectorField new volVectorField
@ -108,12 +99,12 @@ Foam::functionObjects::wallShearStress::wallShearStress
IOobject IOobject
( (
type(), type(),
mesh.time().timeName(), mesh_.time().timeName(),
mesh, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh, mesh_,
dimensionedVector dimensionedVector
( (
"0", "0",
@ -123,7 +114,7 @@ Foam::functionObjects::wallShearStress::wallShearStress
) )
); );
mesh.objectRegistry::store(wallShearStressPtr); mesh_.objectRegistry::store(wallShearStressPtr);
read(dict); read(dict);
resetName(typeName); resetName(typeName);
@ -140,13 +131,12 @@ Foam::functionObjects::wallShearStress::~wallShearStress()
bool Foam::functionObjects::wallShearStress::read(const dictionary& dict) bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
{ {
regionFunctionObject::read(dict); fvMeshFunctionObject::read(dict);
const fvMesh& mesh = refCast<const fvMesh>(obr_); const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
patchSet_ = patchSet_ =
mesh.boundaryMesh().patchSet mesh_.boundaryMesh().patchSet
( (
wordReList(dict.lookupOrDefault("patches", wordReList())) wordReList(dict.lookupOrDefault("patches", wordReList()))
); );
@ -199,26 +189,24 @@ bool Foam::functionObjects::wallShearStress::execute()
typedef compressible::turbulenceModel cmpModel; typedef compressible::turbulenceModel cmpModel;
typedef incompressible::turbulenceModel icoModel; typedef incompressible::turbulenceModel icoModel;
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volVectorField& wallShearStress = volVectorField& wallShearStress =
const_cast<volVectorField&> const_cast<volVectorField&>
( (
mesh.lookupObject<volVectorField>(type()) mesh_.lookupObject<volVectorField>(type())
); );
tmp<volSymmTensorField> Reff; tmp<volSymmTensorField> Reff;
if (mesh.foundObject<cmpModel>(turbulenceModel::propertiesName)) if (mesh_.foundObject<cmpModel>(turbulenceModel::propertiesName))
{ {
const cmpModel& model = const cmpModel& model =
mesh.lookupObject<cmpModel>(turbulenceModel::propertiesName); mesh_.lookupObject<cmpModel>(turbulenceModel::propertiesName);
Reff = model.devRhoReff(); Reff = model.devRhoReff();
} }
else if (mesh.foundObject<icoModel>(turbulenceModel::propertiesName)) else if (mesh_.foundObject<icoModel>(turbulenceModel::propertiesName))
{ {
const icoModel& model = const icoModel& model =
mesh.lookupObject<icoModel>(turbulenceModel::propertiesName); mesh_.lookupObject<icoModel>(turbulenceModel::propertiesName);
Reff = model.devReff(); Reff = model.devReff();
} }
@ -229,7 +217,7 @@ bool Foam::functionObjects::wallShearStress::execute()
<< "database" << exit(FatalError); << "database" << exit(FatalError);
} }
calcShearStress(mesh, Reff(), wallShearStress); calcShearStress(Reff(), wallShearStress);
return true; return true;
} }
@ -247,8 +235,7 @@ bool Foam::functionObjects::wallShearStress::write()
wallShearStress.write(); wallShearStress.write();
const fvMesh& mesh = refCast<const fvMesh>(obr_); const fvPatchList& patches = mesh_.boundary();
const fvPatchList& patches = mesh.boundary();
forAllConstIter(labelHashSet, patchSet_, iter) forAllConstIter(labelHashSet, patchSet_, iter)
{ {
@ -262,7 +249,7 @@ bool Foam::functionObjects::wallShearStress::write()
if (Pstream::master()) if (Pstream::master())
{ {
file() << mesh.time().value() file() << mesh_.time().value()
<< token::TAB << pp.name() << token::TAB << pp.name()
<< token::TAB << minSsp << token::TAB << minSsp
<< token::TAB << maxSsp << token::TAB << maxSsp

View File

@ -65,7 +65,7 @@ Usage
See also See also
Foam::functionObject Foam::functionObject
Foam::functionObjects::regionFunctionObject Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::logFiles Foam::functionObjects::logFiles
Foam::functionObjects::pressureTools Foam::functionObjects::pressureTools
Foam::functionObjects::timeControl Foam::functionObjects::timeControl
@ -78,7 +78,7 @@ SourceFiles
#ifndef functionObjects_wallShearStress_H #ifndef functionObjects_wallShearStress_H
#define functionObjects_wallShearStress_H #define functionObjects_wallShearStress_H
#include "regionFunctionObject.H" #include "fvMeshFunctionObject.H"
#include "logFiles.H" #include "logFiles.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
#include "HashSet.H" #include "HashSet.H"
@ -87,10 +87,6 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes
class fvMesh;
namespace functionObjects namespace functionObjects
{ {
@ -100,7 +96,7 @@ namespace functionObjects
class wallShearStress class wallShearStress
: :
public regionFunctionObject, public fvMeshFunctionObject,
public logFiles public logFiles
{ {
@ -120,7 +116,6 @@ protected:
//- Calculate the shear-stress //- Calculate the shear-stress
void calcShearStress void calcShearStress
( (
const fvMesh& mesh,
const volSymmTensorField& Reff, const volSymmTensorField& Reff,
volVectorField& shearStress volVectorField& shearStress
); );

View File

@ -65,11 +65,10 @@ void Foam::functionObjects::yPlus::writeFileHeader(const label i)
void Foam::functionObjects::yPlus::calcYPlus void Foam::functionObjects::yPlus::calcYPlus
( (
const turbulenceModel& turbModel, const turbulenceModel& turbModel,
const fvMesh& mesh,
volScalarField& yPlus volScalarField& yPlus
) )
{ {
volScalarField::Boundary d = nearWallDist(mesh).y(); volScalarField::Boundary d = nearWallDist(mesh_).y();
const volScalarField::Boundary nutBf = const volScalarField::Boundary nutBf =
turbModel.nut()().boundaryField(); turbModel.nut()().boundaryField();
@ -80,7 +79,7 @@ void Foam::functionObjects::yPlus::calcYPlus
const volScalarField::Boundary nuBf = const volScalarField::Boundary nuBf =
turbModel.nu()().boundaryField(); turbModel.nu()().boundaryField();
const fvPatchList& patches = mesh.boundary(); const fvPatchList& patches = mesh_.boundary();
volScalarField::Boundary& yPlusBf = yPlus.boundaryFieldRef(); volScalarField::Boundary& yPlusBf = yPlus.boundaryFieldRef();
@ -121,17 +120,9 @@ Foam::functionObjects::yPlus::yPlus
const dictionary& dict const dictionary& dict
) )
: :
regionFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
logFiles(obr_, name) logFiles(obr_, name)
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volScalarField* yPlusPtr volScalarField* yPlusPtr
( (
new volScalarField new volScalarField
@ -139,17 +130,17 @@ Foam::functionObjects::yPlus::yPlus
IOobject IOobject
( (
type(), type(),
mesh.time().timeName(), mesh_.time().timeName(),
mesh, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
mesh, mesh_,
dimensionedScalar("0", dimless, 0.0) dimensionedScalar("0", dimless, 0.0)
) )
); );
mesh.objectRegistry::store(yPlusPtr); mesh_.objectRegistry::store(yPlusPtr);
resetName(typeName); resetName(typeName);
} }
@ -165,7 +156,7 @@ Foam::functionObjects::yPlus::~yPlus()
bool Foam::functionObjects::yPlus::read(const dictionary& dict) bool Foam::functionObjects::yPlus::read(const dictionary& dict)
{ {
regionFunctionObject::read(dict); fvMeshFunctionObject::read(dict);
return true; return true;
} }
@ -173,20 +164,20 @@ bool Foam::functionObjects::yPlus::read(const dictionary& dict)
bool Foam::functionObjects::yPlus::execute() bool Foam::functionObjects::yPlus::execute()
{ {
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volScalarField& yPlus = volScalarField& yPlus =
const_cast<volScalarField&> const_cast<volScalarField&>
( (
mesh.lookupObject<volScalarField>(type()) mesh_.lookupObject<volScalarField>(type())
); );
if (mesh.foundObject<turbulenceModel>(turbulenceModel::propertiesName)) if (mesh_.foundObject<turbulenceModel>(turbulenceModel::propertiesName))
{ {
const turbulenceModel& model = const turbulenceModel& model = mesh_.lookupObject<turbulenceModel>
mesh.lookupObject<turbulenceModel>(turbulenceModel::propertiesName); (
turbulenceModel::propertiesName
);
calcYPlus(model, mesh, yPlus); calcYPlus(model, yPlus);
} }
else else
{ {
@ -212,9 +203,7 @@ bool Foam::functionObjects::yPlus::write()
logFiles::write(); logFiles::write();
const volScalarField::Boundary& yPlusBf = yPlus.boundaryField(); const volScalarField::Boundary& yPlusBf = yPlus.boundaryField();
const fvPatchList& patches = mesh_.boundary();
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const fvPatchList& patches = mesh.boundary();
forAll(patches, patchi) forAll(patches, patchi)
{ {
@ -236,7 +225,7 @@ bool Foam::functionObjects::yPlus::write()
writeTime(file()); writeTime(file());
file() file()
<< token::TAB << patch.name() << token::TAB << patch.name()
<< token::TAB << minYplus << token::TAB << minYplus
<< token::TAB << maxYplus << token::TAB << maxYplus
<< token::TAB << avgYplus << token::TAB << avgYplus

View File

@ -33,7 +33,7 @@ Description
See also See also
Foam::functionObject Foam::functionObject
Foam::functionObjects::regionFunctionObject Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::logFiles Foam::functionObjects::logFiles
Foam::functionObjects::timeControl Foam::functionObjects::timeControl
@ -45,7 +45,7 @@ SourceFiles
#ifndef functionObjects_yPlus_H #ifndef functionObjects_yPlus_H
#define functionObjects_yPlus_H #define functionObjects_yPlus_H
#include "regionFunctionObject.H" #include "fvMeshFunctionObject.H"
#include "logFiles.H" #include "logFiles.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
@ -55,7 +55,6 @@ namespace Foam
{ {
// Forward declaration of classes // Forward declaration of classes
class fvMesh;
class turbulenceModel; class turbulenceModel;
namespace functionObjects namespace functionObjects
@ -67,7 +66,7 @@ namespace functionObjects
class yPlus class yPlus
: :
public regionFunctionObject, public fvMeshFunctionObject,
public logFiles public logFiles
{ {
// Private Member Functions // Private Member Functions
@ -79,7 +78,6 @@ class yPlus
void calcYPlus void calcYPlus
( (
const turbulenceModel& turbModel, const turbulenceModel& turbModel,
const fvMesh& mesh,
volScalarField& yPlus volScalarField& yPlus
); );

View File

@ -315,8 +315,6 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::forces::rho() const
{ {
if (rhoName_ == "rhoInf") if (rhoName_ == "rhoInf")
{ {
const fvMesh& mesh = refCast<const fvMesh>(obr_);
return tmp<volScalarField> return tmp<volScalarField>
( (
new volScalarField new volScalarField
@ -324,10 +322,10 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::forces::rho() const
IOobject IOobject
( (
"rho", "rho",
mesh.time().timeName(), mesh_.time().timeName(),
mesh mesh_
), ),
mesh, mesh_,
dimensionedScalar("rho", dimDensity, rhoRef_) dimensionedScalar("rho", dimDensity, rhoRef_)
) )
); );
@ -529,7 +527,7 @@ Foam::functionObjects::forces::forces
const dictionary& dict const dictionary& dict
) )
: :
regionFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
logFiles(obr_, name), logFiles(obr_, name),
force_(3), force_(3),
moment_(3), moment_(3),
@ -552,12 +550,6 @@ Foam::functionObjects::forces::forces
binCumulative_(true), binCumulative_(true),
initialised_(false) initialised_(false)
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
resetNames(createFileNames(dict)); resetNames(createFileNames(dict));
} }
@ -570,7 +562,7 @@ Foam::functionObjects::forces::forces
const dictionary& dict const dictionary& dict
) )
: :
regionFunctionObject(name, obr, dict), fvMeshFunctionObject(name, obr, dict),
logFiles(obr_, name), logFiles(obr_, name),
force_(3), force_(3),
moment_(3), moment_(3),
@ -593,12 +585,6 @@ Foam::functionObjects::forces::forces
binCumulative_(true), binCumulative_(true),
initialised_(false) initialised_(false)
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
resetNames(createFileNames(dict)); resetNames(createFileNames(dict));
} }
@ -614,7 +600,7 @@ Foam::functionObjects::forces::~forces()
bool Foam::functionObjects::forces::read(const dictionary& dict) bool Foam::functionObjects::forces::read(const dictionary& dict)
{ {
regionFunctionObject::read(dict); fvMeshFunctionObject::read(dict);
initialised_ = false; initialised_ = false;
@ -622,8 +608,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
directForceDensity_ = dict.lookupOrDefault("directForceDensity", false); directForceDensity_ = dict.lookupOrDefault("directForceDensity", false);
const fvMesh& mesh = refCast<const fvMesh>(obr_); const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
patchSet_ = pbm.patchSet(wordReList(dict.lookup("patches"))); patchSet_ = pbm.patchSet(wordReList(dict.lookup("patches")));
@ -763,10 +748,8 @@ void Foam::functionObjects::forces::calcForcesMoment()
{ {
const volVectorField& fD = obr_.lookupObject<volVectorField>(fDName_); const volVectorField& fD = obr_.lookupObject<volVectorField>(fDName_);
const fvMesh& mesh = fD.mesh();
const surfaceVectorField::Boundary& Sfb = const surfaceVectorField::Boundary& Sfb =
mesh.Sf().boundaryField(); mesh_.Sf().boundaryField();
forAllConstIter(labelHashSet, patchSet_, iter) forAllConstIter(labelHashSet, patchSet_, iter)
{ {
@ -774,7 +757,7 @@ void Foam::functionObjects::forces::calcForcesMoment()
vectorField Md vectorField Md
( (
mesh.C().boundaryField()[patchi] - coordSys_.origin() mesh_.C().boundaryField()[patchi] - coordSys_.origin()
); );
scalarField sA(mag(Sfb[patchi])); scalarField sA(mag(Sfb[patchi]));
@ -794,18 +777,15 @@ void Foam::functionObjects::forces::calcForcesMoment()
//- Porous force //- Porous force
vectorField fP(Md.size(), Zero); vectorField fP(Md.size(), Zero);
applyBins(Md, fN, fT, fP, mesh.C().boundaryField()[patchi]); applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[patchi]);
} }
} }
else else
{ {
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
const volScalarField& p = obr_.lookupObject<volScalarField>(pName_); const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
const fvMesh& mesh = U.mesh();
const surfaceVectorField::Boundary& Sfb = const surfaceVectorField::Boundary& Sfb =
mesh.Sf().boundaryField(); mesh_.Sf().boundaryField();
tmp<volSymmTensorField> tdevRhoReff = devRhoReff(); tmp<volSymmTensorField> tdevRhoReff = devRhoReff();
const volSymmTensorField::Boundary& devRhoReffb const volSymmTensorField::Boundary& devRhoReffb
@ -820,7 +800,7 @@ void Foam::functionObjects::forces::calcForcesMoment()
vectorField Md vectorField Md
( (
mesh.C().boundaryField()[patchi] - coordSys_.origin() mesh_.C().boundaryField()[patchi] - coordSys_.origin()
); );
vectorField fN vectorField fN
@ -832,7 +812,7 @@ void Foam::functionObjects::forces::calcForcesMoment()
vectorField fP(Md.size(), Zero); vectorField fP(Md.size(), Zero);
applyBins(Md, fN, fT, fP, mesh.C().boundaryField()[patchi]); applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[patchi]);
} }
} }
@ -842,8 +822,6 @@ void Foam::functionObjects::forces::calcForcesMoment()
const volScalarField rho(this->rho()); const volScalarField rho(this->rho());
const volScalarField mu(this->mu()); const volScalarField mu(this->mu());
const fvMesh& mesh = U.mesh();
const HashTable<const porosityModel*> models = const HashTable<const porosityModel*> models =
obr_.lookupClass<porosityModel>(); obr_.lookupClass<porosityModel>();
@ -867,9 +845,9 @@ void Foam::functionObjects::forces::calcForcesMoment()
forAll(cellZoneIDs, i) forAll(cellZoneIDs, i)
{ {
label zoneI = cellZoneIDs[i]; label zoneI = cellZoneIDs[i];
const cellZone& cZone = mesh.cellZones()[zoneI]; const cellZone& cZone = mesh_.cellZones()[zoneI];
const vectorField d(mesh.C(), cZone); const vectorField d(mesh_.C(), cZone);
const vectorField fP(fPTot, cZone); const vectorField fP(fPTot, cZone);
const vectorField Md(d - coordSys_.origin()); const vectorField Md(d - coordSys_.origin());

View File

@ -101,7 +101,7 @@ Note
See also See also
Foam::functionObject Foam::functionObject
Foam::functionObjects::regionFunctionObject Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::logFiles Foam::functionObjects::logFiles
Foam::functionObjects::timeControl Foam::functionObjects::timeControl
Foam::forceCoeffs Foam::forceCoeffs
@ -114,7 +114,7 @@ SourceFiles
#ifndef functionObjects_forces_H #ifndef functionObjects_forces_H
#define functionObjects_forces_H #define functionObjects_forces_H
#include "regionFunctionObject.H" #include "fvMeshFunctionObject.H"
#include "logFiles.H" #include "logFiles.H"
#include "coordinateSystem.H" #include "coordinateSystem.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
@ -133,7 +133,7 @@ namespace functionObjects
class forces class forces
: :
public regionFunctionObject, public fvMeshFunctionObject,
public logFiles public logFiles
{ {

View File

@ -59,21 +59,8 @@ Foam::functionObjects::dsmcFields::dsmcFields
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), fvMeshFunctionObject(name, runTime, dict)
obr_
(
runTime.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
)
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
} }
@ -215,13 +202,11 @@ bool Foam::functionObjects::dsmcFields::write()
physicoChemical::k.value()*rhoNMean*translationalT physicoChemical::k.value()*rhoNMean*translationalT
); );
const fvMesh& mesh = fDMean.mesh();
volScalarField::Boundary& pBf = p.boundaryFieldRef(); volScalarField::Boundary& pBf = p.boundaryFieldRef();
forAll(mesh.boundaryMesh(), i) forAll(mesh_.boundaryMesh(), i)
{ {
const polyPatch& patch = mesh.boundaryMesh()[i]; const polyPatch& patch = mesh_.boundaryMesh()[i];
if (isA<wallPolyPatch>(patch)) if (isA<wallPolyPatch>(patch))
{ {

View File

@ -35,6 +35,9 @@ Description
- overallT - overallT
from averaged extensive fields from a DSMC calculation. from averaged extensive fields from a DSMC calculation.
See also
Foam::functionObjects::fvMeshFunctionObject
SourceFiles SourceFiles
dsmcFields.C dsmcFields.C
@ -43,16 +46,12 @@ SourceFiles
#ifndef functionObjects_dsmcFields_H #ifndef functionObjects_dsmcFields_H
#define functionObjects_dsmcFields_H #define functionObjects_dsmcFields_H
#include "functionObject.H" #include "fvMeshFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// Forward declaration of classes
class objectRegistry;
namespace functionObjects namespace functionObjects
{ {
@ -62,13 +61,8 @@ namespace functionObjects
class dsmcFields class dsmcFields
: :
public functionObject public fvMeshFunctionObject
{ {
// Private data
const objectRegistry& obr_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct

View File

@ -53,16 +53,10 @@ Foam::functionObjects::residuals::residuals
const dictionary& dict const dictionary& dict
) )
: :
regionFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
logFiles(obr_, name), logFiles(obr_, name),
fieldSet_() fieldSet_()
{ {
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict); read(dict);
resetName(typeName); resetName(typeName);
} }
@ -78,7 +72,7 @@ Foam::functionObjects::residuals::~residuals()
bool Foam::functionObjects::residuals::read(const dictionary& dict) bool Foam::functionObjects::residuals::read(const dictionary& dict)
{ {
regionFunctionObject::read(dict); fvMeshFunctionObject::read(dict);
dict.lookup("fields") >> fieldSet_; dict.lookup("fields") >> fieldSet_;

View File

@ -51,7 +51,7 @@ Description
See also See also
Foam::functionObject Foam::functionObject
Foam::functionObjects::regionFunctionObject Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::logFiles Foam::functionObjects::logFiles
Foam::functionObjects::timeControl Foam::functionObjects::timeControl
@ -63,7 +63,7 @@ SourceFiles
#ifndef functionObjects_residuals_H #ifndef functionObjects_residuals_H
#define functionObjects_residuals_H #define functionObjects_residuals_H
#include "regionFunctionObject.H" #include "fvMeshFunctionObject.H"
#include "logFiles.H" #include "logFiles.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -79,7 +79,7 @@ namespace functionObjects
class residuals class residuals
: :
public regionFunctionObject, public fvMeshFunctionObject,
public logFiles public logFiles
{ {
protected: protected:

View File

@ -36,12 +36,9 @@ void Foam::functionObjects::residuals::writeFileHeader(const word& fieldName)
if (obr_.foundObject<fieldType>(fieldName)) if (obr_.foundObject<fieldType>(fieldName))
{ {
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
const fvMesh& mesh = field.mesh();
typename pTraits<Type>::labelType validComponents typename pTraits<Type>::labelType validComponents
( (
mesh.validComponents<Type>() mesh_.validComponents<Type>()
); );
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
@ -66,9 +63,7 @@ void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
if (obr_.foundObject<fieldType>(fieldName)) if (obr_.foundObject<fieldType>(fieldName))
{ {
const fieldType& field = obr_.lookupObject<fieldType>(fieldName); const Foam::dictionary& solverDict = mesh_.solverPerformanceDict();
const fvMesh& mesh = field.mesh();
const Foam::dictionary& solverDict = mesh.solverPerformanceDict();
if (solverDict.found(fieldName)) if (solverDict.found(fieldName))
{ {
@ -81,7 +76,7 @@ void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
typename pTraits<Type>::labelType validComponents typename pTraits<Type>::labelType validComponents
( (
mesh.validComponents<Type>() mesh_.validComponents<Type>()
); );
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)