mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
functionObjects: Simply functionObjects requiring access to the fvMesh using fvMeshFunctionObject
This commit is contained in:
@ -131,10 +131,10 @@ bool Foam::functionObjects::div::execute(const bool postProcess)
|
||||
|
||||
bool Foam::functionObjects::div::write(const bool postProcess)
|
||||
{
|
||||
if (obr_.foundObject<regIOobject>(resultName_))
|
||||
if (mesh_.foundObject<regIOobject>(resultName_))
|
||||
{
|
||||
const regIOobject& field =
|
||||
obr_.lookupObject<regIOobject>(resultName_);
|
||||
mesh_.lookupObject<regIOobject>(resultName_);
|
||||
|
||||
Info<< type() << " " << name() << " output:" << nl
|
||||
<< " writing field " << field.name() << nl << endl;
|
||||
|
||||
@ -32,6 +32,9 @@ Description
|
||||
limited to surfaceScalarFields and volVectorFields, and the output is a
|
||||
volScalarField.
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
div.C
|
||||
|
||||
@ -62,7 +65,7 @@ class div
|
||||
:
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
// Private data
|
||||
// Private member data
|
||||
|
||||
//- Name of field to process
|
||||
word fieldName_;
|
||||
|
||||
@ -32,6 +32,9 @@ Description
|
||||
limited to scalar and vector volume or surface fields, and the output is a
|
||||
volume vector or tensor field.
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
grad.C
|
||||
|
||||
|
||||
@ -32,6 +32,9 @@ Description
|
||||
can be applied to any volume or surface fieldsm and the output is a
|
||||
volume or surface scalar field.
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
mag.C
|
||||
|
||||
|
||||
@ -46,14 +46,12 @@ namespace functionObjects
|
||||
|
||||
void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
// Count number of faces
|
||||
label nPatchFaces = 0;
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
{
|
||||
label patchi = iter.key();
|
||||
nPatchFaces += mesh.boundary()[patchi].size();
|
||||
nPatchFaces += mesh_.boundary()[patchi].size();
|
||||
}
|
||||
|
||||
// Global indexing
|
||||
@ -65,7 +63,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
}
|
||||
|
||||
// Construct cloud
|
||||
Cloud<findCellParticle> cloud(mesh, IDLList<findCellParticle>());
|
||||
Cloud<findCellParticle> cloud(mesh_, IDLList<findCellParticle>());
|
||||
|
||||
// Add particles to track to sample locations
|
||||
nPatchFaces = 0;
|
||||
@ -73,7 +71,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
{
|
||||
label patchi = iter.key();
|
||||
const fvPatch& patch = mesh.boundary()[patchi];
|
||||
const fvPatch& patch = mesh_.boundary()[patchi];
|
||||
|
||||
vectorField nf(patch.nf());
|
||||
vectorField faceCellCentres(patch.patch().faceCellCentres());
|
||||
@ -88,7 +86,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
(
|
||||
mappedPatchBase::facePoint
|
||||
(
|
||||
mesh,
|
||||
mesh_,
|
||||
meshFacei,
|
||||
polyMesh::FACE_DIAG_TRIS
|
||||
)
|
||||
@ -112,14 +110,14 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
label celli = -1;
|
||||
label tetFacei = -1;
|
||||
label tetPtI = -1;
|
||||
mesh.findCellFacePt(start, celli, tetFacei, tetPtI);
|
||||
mesh_.findCellFacePt(start, celli, tetFacei, tetPtI);
|
||||
|
||||
// Add to cloud. Add originating face as passive data
|
||||
cloud.addParticle
|
||||
(
|
||||
new findCellParticle
|
||||
(
|
||||
mesh,
|
||||
mesh_,
|
||||
start,
|
||||
celli,
|
||||
tetFacei,
|
||||
@ -140,8 +138,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
// Dump particles
|
||||
OBJstream str
|
||||
(
|
||||
mesh.time().path()
|
||||
/"wantedTracks_" + mesh.time().timeName() + ".obj"
|
||||
mesh_.time().path()
|
||||
/"wantedTracks_" + mesh_.time().timeName() + ".obj"
|
||||
);
|
||||
InfoInFunction << "Dumping tracks to " << str.name() << endl;
|
||||
|
||||
@ -155,14 +153,14 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
|
||||
|
||||
// Per cell: empty or global wall index and end location
|
||||
cellToWalls_.setSize(mesh.nCells());
|
||||
cellToSamples_.setSize(mesh.nCells());
|
||||
cellToWalls_.setSize(mesh_.nCells());
|
||||
cellToSamples_.setSize(mesh_.nCells());
|
||||
|
||||
// Database to pass into findCellParticle::move
|
||||
findCellParticle::trackingData td(cloud, cellToWalls_, cellToSamples_);
|
||||
|
||||
// Track all particles to their end position.
|
||||
scalar maxTrackLen = 2.0*mesh.bounds().mag();
|
||||
scalar maxTrackLen = 2.0*mesh_.bounds().mag();
|
||||
|
||||
|
||||
//Debug: collect start points
|
||||
@ -202,8 +200,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
{
|
||||
OBJstream str
|
||||
(
|
||||
mesh.time().path()
|
||||
/"obtainedTracks_" + mesh.time().timeName() + ".obj"
|
||||
mesh_.time().path()
|
||||
/"obtainedTracks_" + mesh_.time().timeName() + ".obj"
|
||||
);
|
||||
InfoInFunction << "Dumping obtained to " << str.name() << endl;
|
||||
|
||||
@ -230,22 +228,9 @@ Foam::functionObjects::nearWallFields::nearWallFields
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
obr_
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
),
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldSet_()
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -270,11 +255,9 @@ bool Foam::functionObjects::nearWallFields::read(const dictionary& dict)
|
||||
InfoInFunction << endl;
|
||||
}
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
patchSet_ =
|
||||
mesh.boundaryMesh().patchSet(wordReList(dict.lookup("patches")));
|
||||
mesh_.boundaryMesh().patchSet(wordReList(dict.lookup("patches")));
|
||||
distance_ = readScalar(dict.lookup("distance"));
|
||||
|
||||
|
||||
@ -343,7 +326,7 @@ bool Foam::functionObjects::nearWallFields::execute(const bool postProcess)
|
||||
|
||||
Info<< type() << " " << name() << " output:" << nl;
|
||||
|
||||
Info<< " Sampling fields to " << obr_.time().timeName()
|
||||
Info<< " Sampling fields to " << time_.timeName()
|
||||
<< endl;
|
||||
|
||||
sampleFields(vsf_);
|
||||
@ -363,7 +346,7 @@ bool Foam::functionObjects::nearWallFields::write(const bool postProcess)
|
||||
InfoInFunction << endl;
|
||||
}
|
||||
|
||||
Info<< " Writing sampled fields to " << obr_.time().timeName()
|
||||
Info<< " Writing sampled fields to " << time_.timeName()
|
||||
<< endl;
|
||||
|
||||
forAll(vsf_, i)
|
||||
|
||||
@ -61,7 +61,7 @@ Description
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
nearWallFields.C
|
||||
@ -71,7 +71,7 @@ SourceFiles
|
||||
#ifndef functionObjects_nearWallFields_H
|
||||
#define functionObjects_nearWallFields_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "volFields.H"
|
||||
#include "Tuple2.H"
|
||||
#include "interpolationCellPoint.H"
|
||||
@ -80,10 +80,6 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
@ -93,14 +89,11 @@ namespace functionObjects
|
||||
|
||||
class nearWallFields
|
||||
:
|
||||
public functionObject
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
// Protected member data
|
||||
|
||||
// Read from dictionary
|
||||
|
||||
|
||||
@ -48,25 +48,10 @@ Foam::functionObjects::processorField::processorField
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
obr_
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
)
|
||||
fvMeshFunctionObject(name, runTime, dict)
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField* procFieldPtr
|
||||
(
|
||||
new volScalarField
|
||||
@ -74,17 +59,17 @@ Foam::functionObjects::processorField::processorField
|
||||
IOobject
|
||||
(
|
||||
"processorID",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
mesh_,
|
||||
dimensionedScalar("0", dimless, 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(procFieldPtr);
|
||||
mesh_.objectRegistry::store(procFieldPtr);
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +90,7 @@ bool Foam::functionObjects::processorField::read(const dictionary& dict)
|
||||
bool Foam::functionObjects::processorField::execute(const bool postProcess)
|
||||
{
|
||||
const volScalarField& procField =
|
||||
obr_.lookupObject<volScalarField>("processorID");
|
||||
mesh_.lookupObject<volScalarField>("processorID");
|
||||
|
||||
const_cast<volScalarField&>(procField) ==
|
||||
dimensionedScalar("proci", dimless, Pstream::myProcNo());
|
||||
@ -117,7 +102,7 @@ bool Foam::functionObjects::processorField::execute(const bool postProcess)
|
||||
bool Foam::functionObjects::processorField::write(const bool postProcess)
|
||||
{
|
||||
const volScalarField& procField =
|
||||
obr_.lookupObject<volScalarField>("processorID");
|
||||
mesh_.lookupObject<volScalarField>("processorID");
|
||||
|
||||
procField.write();
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ Description
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
processorField.C
|
||||
@ -58,16 +58,12 @@ SourceFiles
|
||||
#ifndef functionObjects_processorField_H
|
||||
#define functionObjects_processorField_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "fvMeshFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
@ -77,18 +73,8 @@ namespace functionObjects
|
||||
|
||||
class processorField
|
||||
:
|
||||
public functionObject
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
|
||||
@ -49,22 +49,9 @@ Foam::functionObjects::readFields::readFields
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
obr_
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
),
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldSet_()
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ Description
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
|
||||
SourceFiles
|
||||
readFields.C
|
||||
@ -64,7 +64,7 @@ SourceFiles
|
||||
#ifndef functionObjects_readFields_H
|
||||
#define functionObjects_readFields_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
|
||||
@ -72,10 +72,6 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
@ -85,15 +81,12 @@ namespace functionObjects
|
||||
|
||||
class readFields
|
||||
:
|
||||
public functionObject
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Fields to load
|
||||
wordList fieldSet_;
|
||||
|
||||
|
||||
@ -59,13 +59,11 @@ void Foam::functionObjects::readFields::loadField
|
||||
}
|
||||
else
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
@ -80,7 +78,7 @@ void Foam::functionObjects::readFields::loadField
|
||||
Info<< " Reading " << fieldName << endl;
|
||||
label sz = vflds.size();
|
||||
vflds.setSize(sz+1);
|
||||
vflds.set(sz, new vfType(fieldHeader, mesh));
|
||||
vflds.set(sz, new vfType(fieldHeader, mesh_));
|
||||
}
|
||||
else if
|
||||
(
|
||||
@ -92,7 +90,7 @@ void Foam::functionObjects::readFields::loadField
|
||||
Info<< " Reading " << fieldName << endl;
|
||||
label sz = sflds.size();
|
||||
sflds.setSize(sz+1);
|
||||
sflds.set(sz, new sfType(fieldHeader, mesh));
|
||||
sflds.set(sz, new sfType(fieldHeader, mesh_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user