mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
regionFunctionObject: Moved the field/object maintenance functions from fvMeshFunctionObject into regionFunctionObject
This commit is contained in:
@ -38,6 +38,59 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::regionFunctionObject::writeObject
|
||||
(
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
if (obr_.foundObject<regIOobject>(fieldName))
|
||||
{
|
||||
const regIOobject& field = obr_.lookupObject<regIOobject>(fieldName);
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< "functionObjects::" << type() << " " << name()
|
||||
<< " writing field: " << field.name() << endl;
|
||||
}
|
||||
|
||||
field.write();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::regionFunctionObject::clearObject
|
||||
(
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
if (foundObject<regIOobject>(fieldName))
|
||||
{
|
||||
const regIOobject& resultObject = lookupObject<regIOobject>(fieldName);
|
||||
|
||||
if (resultObject.ownedByRegistry())
|
||||
{
|
||||
return const_cast<regIOobject&>(resultObject).checkOut();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::regionFunctionObject::regionFunctionObject
|
||||
|
||||
@ -76,6 +76,32 @@ protected:
|
||||
Switch log_;
|
||||
|
||||
|
||||
// Protected member functions
|
||||
|
||||
//- Find field in the objectRegistry
|
||||
template<class ObjectType>
|
||||
bool foundObject(const word& fieldName) const;
|
||||
|
||||
//- Lookup field from the objectRegistry
|
||||
template<class ObjectType>
|
||||
const ObjectType& lookupObject(const word& fieldName) const;
|
||||
|
||||
//- Store the given field in the objectRegistry under the given name
|
||||
template<class ObjectType>
|
||||
bool store
|
||||
(
|
||||
word& fieldName,
|
||||
const tmp<ObjectType>& tfield,
|
||||
bool cacheable = false
|
||||
);
|
||||
|
||||
//- Write field if present in objectRegistry
|
||||
bool writeObject(const word& fieldName);
|
||||
|
||||
//- Clear field from the objectRegistry if present
|
||||
bool clearObject(const word& fieldName);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
@ -132,6 +158,12 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "regionFunctionObjectTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -23,36 +23,36 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "volFields.H"
|
||||
#include "regionFunctionObject.H"
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
template<class FieldType>
|
||||
bool Foam::functionObjects::fvMeshFunctionObject::foundField
|
||||
template<class ObjectType>
|
||||
bool Foam::functionObjects::regionFunctionObject::foundObject
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
return mesh_.foundObject<FieldType>(fieldName);
|
||||
return obr_.foundObject<ObjectType>(fieldName);
|
||||
}
|
||||
|
||||
|
||||
template<class FieldType>
|
||||
const FieldType& Foam::functionObjects::fvMeshFunctionObject::lookupField
|
||||
template<class ObjectType>
|
||||
const ObjectType& Foam::functionObjects::regionFunctionObject::lookupObject
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
return mesh_.lookupObject<FieldType>(fieldName);
|
||||
return obr_.lookupObject<ObjectType>(fieldName);
|
||||
}
|
||||
|
||||
|
||||
template<class FieldType>
|
||||
bool Foam::functionObjects::fvMeshFunctionObject::store
|
||||
template<class ObjectType>
|
||||
bool Foam::functionObjects::regionFunctionObject::store
|
||||
(
|
||||
word& fieldName,
|
||||
const tmp<FieldType>& tfield,
|
||||
const tmp<ObjectType>& tfield,
|
||||
bool cacheable
|
||||
)
|
||||
{
|
||||
@ -71,12 +71,12 @@ bool Foam::functionObjects::fvMeshFunctionObject::store
|
||||
if
|
||||
(
|
||||
fieldName.size()
|
||||
&& mesh_.foundObject<FieldType>(fieldName)
|
||||
&& obr_.foundObject<ObjectType>(fieldName)
|
||||
)
|
||||
{
|
||||
const FieldType& field =
|
||||
const ObjectType& field =
|
||||
(
|
||||
mesh_.lookupObject<FieldType>(fieldName)
|
||||
obr_.lookupObject<ObjectType>(fieldName)
|
||||
);
|
||||
|
||||
// If there is a result field already registered assign to the new
|
||||
@ -84,11 +84,11 @@ bool Foam::functionObjects::fvMeshFunctionObject::store
|
||||
// the object registry
|
||||
if (&field != &tfield())
|
||||
{
|
||||
const_cast<FieldType&>(field) = tfield;
|
||||
const_cast<ObjectType&>(field) = tfield;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh_.objectRegistry::store(tfield.ptr());
|
||||
obr_.objectRegistry::store(tfield.ptr());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -102,7 +102,7 @@ bool Foam::functionObjects::fvMeshFunctionObject::store
|
||||
fieldName = tfield().name();
|
||||
}
|
||||
|
||||
mesh_.objectRegistry::store(tfield.ptr());
|
||||
obr_.objectRegistry::store(tfield.ptr());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -37,6 +37,7 @@ SourceFiles
|
||||
#ifndef fvcSurfaceIntegrate_H
|
||||
#define fvcSurfaceIntegrate_H
|
||||
|
||||
#include "primitiveFieldsFwd.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
|
||||
|
||||
@ -38,59 +38,6 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fvMeshFunctionObject::writeField
|
||||
(
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
if (mesh_.foundObject<regIOobject>(fieldName))
|
||||
{
|
||||
const regIOobject& field = mesh_.lookupObject<regIOobject>(fieldName);
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< "functionObjects::" << type() << " " << name()
|
||||
<< " writing field: " << field.name() << endl;
|
||||
}
|
||||
|
||||
field.write();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fvMeshFunctionObject::clearField
|
||||
(
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
if (foundField<regIOobject>(fieldName))
|
||||
{
|
||||
const regIOobject& resultField = lookupField<regIOobject>(fieldName);
|
||||
|
||||
if (resultField.ownedByRegistry())
|
||||
{
|
||||
return const_cast<regIOobject&>(resultField).checkOut();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fvMeshFunctionObject::fvMeshFunctionObject
|
||||
|
||||
@ -73,32 +73,6 @@ protected:
|
||||
const fvMesh& mesh_;
|
||||
|
||||
|
||||
// Protected member functions
|
||||
|
||||
//- Find field in the objectRegistry
|
||||
template<class FieldType>
|
||||
bool foundField(const word& fieldName) const;
|
||||
|
||||
//- Lookup field from the objectRegistry
|
||||
template<class FieldType>
|
||||
const FieldType& lookupField(const word& fieldName) const;
|
||||
|
||||
//- Store the given field in the objectRegistry under the given name
|
||||
template<class FieldType>
|
||||
bool store
|
||||
(
|
||||
word& fieldName,
|
||||
const tmp<FieldType>& tfield,
|
||||
bool cacheable = false
|
||||
);
|
||||
|
||||
//- Write field if present in objectRegistry
|
||||
bool writeField(const word& fieldName);
|
||||
|
||||
//- Clear field from the objectRegistry if present
|
||||
bool clearField(const word& fieldName);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
@ -139,12 +113,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "fvMeshFunctionObjectTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -68,10 +68,10 @@ Foam::functionObjects::CourantNo::byRho
|
||||
|
||||
bool Foam::functionObjects::CourantNo::calc()
|
||||
{
|
||||
if (foundField<surfaceScalarField>(phiName_))
|
||||
if (foundObject<surfaceScalarField>(phiName_))
|
||||
{
|
||||
const surfaceScalarField& phi =
|
||||
lookupField<surfaceScalarField>(phiName_);
|
||||
lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
tmp<volScalarField::Internal> Coi
|
||||
(
|
||||
@ -83,13 +83,13 @@ bool Foam::functionObjects::CourantNo::calc()
|
||||
)
|
||||
);
|
||||
|
||||
if (foundField<volScalarField>(resultName_))
|
||||
if (foundObject<volScalarField>(resultName_))
|
||||
{
|
||||
volScalarField& Co
|
||||
(
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
lookupField<volScalarField>(resultName_)
|
||||
lookupObject<volScalarField>(resultName_)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -49,9 +49,9 @@ namespace functionObjects
|
||||
|
||||
bool Foam::functionObjects::Lambda2::calc()
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
if (foundObject<volVectorField>(fieldName_))
|
||||
{
|
||||
const volVectorField& U = lookupField<volVectorField>(fieldName_);
|
||||
const volVectorField& U = lookupObject<volVectorField>(fieldName_);
|
||||
const tmp<volTensorField> tgradU(fvc::grad(U));
|
||||
const volTensorField& gradU = tgradU();
|
||||
|
||||
|
||||
@ -51,14 +51,14 @@ bool Foam::functionObjects::MachNo::calc()
|
||||
{
|
||||
if
|
||||
(
|
||||
foundField<volVectorField>(fieldName_)
|
||||
foundObject<volVectorField>(fieldName_)
|
||||
&& mesh_.foundObject<fluidThermo>(fluidThermo::dictName)
|
||||
)
|
||||
{
|
||||
const fluidThermo& thermo =
|
||||
mesh_.lookupObject<fluidThermo>(fluidThermo::dictName);
|
||||
|
||||
const volVectorField& U = lookupField<volVectorField>(fieldName_);
|
||||
const volVectorField& U = lookupObject<volVectorField>(fieldName_);
|
||||
|
||||
return store
|
||||
(
|
||||
|
||||
@ -50,7 +50,7 @@ namespace functionObjects
|
||||
|
||||
bool Foam::functionObjects::PecletNo::calc()
|
||||
{
|
||||
if (foundField<surfaceScalarField>(phiName_))
|
||||
if (foundObject<surfaceScalarField>(phiName_))
|
||||
{
|
||||
tmp<volScalarField> nuEff
|
||||
(
|
||||
|
||||
@ -49,9 +49,9 @@ namespace functionObjects
|
||||
|
||||
bool Foam::functionObjects::Q::calc()
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
if (foundObject<volVectorField>(fieldName_))
|
||||
{
|
||||
const volVectorField& U = lookupField<volVectorField>(fieldName_);
|
||||
const volVectorField& U = lookupObject<volVectorField>(fieldName_);
|
||||
const tmp<volTensorField> tgradU(fvc::grad(U));
|
||||
const volTensorField& gradU = tgradU();
|
||||
|
||||
|
||||
@ -34,17 +34,17 @@ bool Foam::functionObjects::blendingFactor::calcBF()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
|
||||
|
||||
if (!foundField<FieldType>(fieldName_))
|
||||
if (!foundObject<FieldType>(fieldName_))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const FieldType& field = lookupField<FieldType>(fieldName_);
|
||||
const FieldType& field = lookupObject<FieldType>(fieldName_);
|
||||
|
||||
const word divScheme("div(" + phiName_ + ',' + fieldName_ + ')');
|
||||
ITstream& its = mesh_.divScheme(divScheme);
|
||||
|
||||
const surfaceScalarField& phi = lookupField<surfaceScalarField>(phiName_);
|
||||
const surfaceScalarField& phi = lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
tmp<fv::convectionScheme<Type>> cs =
|
||||
fv::convectionScheme<Type>::New(mesh_, phi, its);
|
||||
|
||||
@ -30,12 +30,12 @@ License
|
||||
template<class FieldType>
|
||||
bool Foam::functionObjects::div::calcDiv()
|
||||
{
|
||||
if (foundField<FieldType>(fieldName_))
|
||||
if (foundObject<FieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::div(lookupField<FieldType>(fieldName_))
|
||||
fvc::div(lookupObject<FieldType>(fieldName_))
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@ -49,12 +49,12 @@ namespace functionObjects
|
||||
|
||||
bool Foam::functionObjects::enstrophy::calc()
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
if (foundObject<volVectorField>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
0.5*magSqr(fvc::curl(lookupField<volVectorField>(fieldName_)))
|
||||
0.5*magSqr(fvc::curl(lookupObject<volVectorField>(fieldName_)))
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@ -124,7 +124,7 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::write
|
||||
{
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
fvMeshFunctionObject::writeField(transformFieldName(fieldSet_[fieldi]));
|
||||
writeObject(transformFieldName(fieldSet_[fieldi]));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldExpression.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -112,13 +113,13 @@ bool Foam::functionObjects::fieldExpression::execute(const bool postProcess)
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::write(const bool postProcess)
|
||||
{
|
||||
return writeField(resultName_);
|
||||
return writeObject(resultName_);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::clear()
|
||||
{
|
||||
return clearField(resultName_);
|
||||
return clearObject(resultName_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -49,9 +49,9 @@ namespace functionObjects
|
||||
|
||||
bool Foam::functionObjects::flowType::calc()
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
if (foundObject<volVectorField>(fieldName_))
|
||||
{
|
||||
const volVectorField& U = lookupField<volVectorField>(fieldName_);
|
||||
const volVectorField& U = lookupObject<volVectorField>(fieldName_);
|
||||
const tmp<volTensorField> tgradU(fvc::grad(U));
|
||||
const volTensorField& gradU = tgradU();
|
||||
|
||||
|
||||
@ -33,21 +33,21 @@ bool Foam::functionObjects::grad::calcGrad()
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (foundField<VolFieldType>(fieldName_))
|
||||
if (foundObject<VolFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::grad(lookupField<VolFieldType>(fieldName_)),
|
||||
fvc::grad(lookupObject<VolFieldType>(fieldName_)),
|
||||
true
|
||||
);
|
||||
}
|
||||
else if (foundField<SurfaceFieldType>(fieldName_))
|
||||
else if (foundObject<SurfaceFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::grad(lookupField<SurfaceFieldType>(fieldName_)),
|
||||
fvc::grad(lookupObject<SurfaceFieldType>(fieldName_)),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@ -34,20 +34,20 @@ bool Foam::functionObjects::mag::calcMag()
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (foundField<VolFieldType>(fieldName_))
|
||||
if (foundObject<VolFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
Foam::mag(lookupField<VolFieldType>(fieldName_))
|
||||
Foam::mag(lookupObject<VolFieldType>(fieldName_))
|
||||
);
|
||||
}
|
||||
else if (foundField<SurfaceFieldType>(fieldName_))
|
||||
else if (foundObject<SurfaceFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
Foam::mag(lookupField<SurfaceFieldType>(fieldName_))
|
||||
Foam::mag(lookupObject<SurfaceFieldType>(fieldName_))
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@ -87,7 +87,7 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::rhoScale
|
||||
{
|
||||
if (p.dimensions() == dimPressure)
|
||||
{
|
||||
return lookupField<volScalarField>(rhoName_)*tsf;
|
||||
return lookupObject<volScalarField>(rhoName_)*tsf;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -122,7 +122,7 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::pDyn
|
||||
{
|
||||
return
|
||||
tp
|
||||
+ rhoScale(p, 0.5*magSqr(lookupField<volVectorField>(UName_)));
|
||||
+ rhoScale(p, 0.5*magSqr(lookupObject<volVectorField>(UName_)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -163,9 +163,9 @@ Foam::functionObjects::pressure::coeff
|
||||
|
||||
bool Foam::functionObjects::pressure::calc()
|
||||
{
|
||||
if (foundField<volScalarField>(fieldName_))
|
||||
if (foundObject<volScalarField>(fieldName_))
|
||||
{
|
||||
const volScalarField& p = lookupField<volScalarField>(fieldName_);
|
||||
const volScalarField& p = lookupObject<volScalarField>(fieldName_);
|
||||
|
||||
return store
|
||||
(
|
||||
|
||||
@ -49,12 +49,12 @@ namespace functionObjects
|
||||
|
||||
bool Foam::functionObjects::vorticity::calc()
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
if (foundObject<volVectorField>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::curl(lookupField<volVectorField>(fieldName_))
|
||||
fvc::curl(lookupObject<volVectorField>(fieldName_))
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user