diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 3bf63435bc..d67b35953c 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -223,6 +223,7 @@ db/functionObjects/writeFile/writeFile.C db/functionObjects/writeFiles/writeFiles.C db/functionObjects/timeControl/timeControl.C db/functionObjects/timeControl/timeControlFunctionObject.C +db/functionObjects/regionFunctionObject/regionFunctionObject.C Time = db/Time $(Time)/TimePaths.C diff --git a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C new file mode 100644 index 0000000000..94da686f17 --- /dev/null +++ b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.C @@ -0,0 +1,81 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "regionFunctionObject.H" +#include "Time.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(regionFunctionObject, 0); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::regionFunctionObject::regionFunctionObject +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + functionObject(name), + time_(runTime), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) +{} + + +Foam::functionObjects::regionFunctionObject::regionFunctionObject +( + const word& name, + const objectRegistry& obr, + const dictionary& dict +) +: + functionObject(name), + time_(obr.time()), + obr_(obr) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::regionFunctionObject::~regionFunctionObject() +{} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H new file mode 100644 index 0000000000..4f7fab0b7f --- /dev/null +++ b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::functionObjects::regionFunctionObject + +Description + Specialization of Foam::functionObject for a region and providing a + reference to the region Foam::objectRegistry. + +SeeAlso + Foam::functionObject + +SourceFiles + regionFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_regionFunctionObject_H +#define functionObjects_regionFunctionObject_H + +#include "functionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; + +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class regionFunctionObject Declaration +\*---------------------------------------------------------------------------*/ + +class regionFunctionObject +: + public functionObject +{ + +protected: + + // Protected member data + + //- Reference to the Time + const Time& time_; + + //- Reference to the region objectRegistry + const objectRegistry& obr_; + + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + regionFunctionObject(const regionFunctionObject&); + + //- Disallow default bitwise assignment + void operator=(const regionFunctionObject&); + + +public: + + //- Runtime type information + TypeName("regionFunctionObject"); + + + // Constructors + + //- Construct from Time and dictionary. + // The region objectRegistry is looked-up runTime with the name + // looked-up from the dictionary (defaults to polyMesh::defaultRegion) + regionFunctionObject + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- Construct from the region objectRegistry and dictionary + regionFunctionObject + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict + ); + + + //- Destructor + virtual ~regionFunctionObject(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index b2434f0cbf..61107dea0d 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -100,20 +100,12 @@ Foam::Omanip Foam::functionObjects::writeFile::valueWidth Foam::functionObjects::writeFile::writeFile ( const word& name, - const Time& t, + const Time& runTime, const dictionary& dict, const word& prefix ) : - functionObject(name), - time_(t), - obr_ - ( - time_.lookupObject - ( - dict.lookupOrDefault("region", polyMesh::defaultRegion) - ) - ), + regionFunctionObject(name, runTime, dict), prefix_(prefix), log_(true) {} @@ -127,9 +119,7 @@ Foam::functionObjects::writeFile::writeFile const word& prefix ) : - functionObject(name), - time_(obr.time()), - obr_(obr), + regionFunctionObject(name, obr, dict), prefix_(prefix), log_(true) {} diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H index 5c5f2df6e5..c0431f07d5 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H @@ -28,8 +28,8 @@ Description functionObject base class for writing single files See Also + Foam::regionFunctionObject Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles functionObjectFile.C @@ -39,7 +39,7 @@ SourceFiles #ifndef functionObjects_writeFile_H #define functionObjects_writeFile_H -#include "functionObject.H" +#include "regionFunctionObject.H" #include "Time.H" #include "IOmanip.H" @@ -56,19 +56,13 @@ namespace functionObjects class writeFile : - public functionObject + public regionFunctionObject { protected: // Protected data - //- Reference to the Time - const Time& time_; - - //- Reference to the objectRegistry - const objectRegistry& obr_; - //- Prefix const word prefix_; diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 7c64e76cff..7862b70de2 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -91,6 +91,7 @@ $(faceToCell)/extendedFaceToCellStencil.C $(faceToCell)/extendedCentredFaceToCellStencil.C $(faceToCell)/MeshObjects/centredCFCFaceToCellStencilObject.C +fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C fvPatchFields = fields/fvPatchFields $(fvPatchFields)/fvPatchField/fvPatchFields.C diff --git a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C new file mode 100644 index 0000000000..f5e0b45852 --- /dev/null +++ b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "fvMeshFunctionObject.H" +#include "Time.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(fvMeshFunctionObject, 0); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::fvMeshFunctionObject::fvMeshFunctionObject +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + regionFunctionObject(name, runTime, dict), + mesh_(refCast(obr_)) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::fvMeshFunctionObject::~fvMeshFunctionObject() +{} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H new file mode 100644 index 0000000000..6e2477fc47 --- /dev/null +++ b/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::functionObjects::fvMeshFunctionObject + +Description + Specialization of Foam::functionObject for an Foam::fvMesh, providing a + reference to the Foam::fvMesh. + + If the selected region is not an Foam::fvMesh a Foam::FatalError will be + generated. + +SeeAlso + Foam::regionFunctionObject + Foam::functionObject + +SourceFiles + fvMeshFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_fvMeshFunctionObject_H +#define functionObjects_fvMeshFunctionObject_H + +#include "regionFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class fvMesh; + +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class fvMeshFunctionObject Declaration +\*---------------------------------------------------------------------------*/ + +class fvMeshFunctionObject +: + public regionFunctionObject +{ + +protected: + + // Protected member data + + //- Reference to the fvMesh + const fvMesh& mesh_; + + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + fvMeshFunctionObject(const fvMeshFunctionObject&); + + //- Disallow default bitwise assignment + void operator=(const fvMeshFunctionObject&); + + +public: + + //- Runtime type information + TypeName("fvMeshFunctionObject"); + + + // Constructors + + //- Construct from Time and dictionary + fvMeshFunctionObject + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + + //- Destructor + virtual ~fvMeshFunctionObject(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/div/div.C b/src/postProcessing/functionObjects/field/div/div.C index 691ff862c8..a91ffffcdf 100644 --- a/src/postProcessing/functionObjects/field/div/div.C +++ b/src/postProcessing/functionObjects/field/div/div.C @@ -47,9 +47,7 @@ Foam::volScalarField& Foam::functionObjects::div::divField const dimensionSet& dims ) { - const fvMesh& mesh = refCast(obr_); - - if (!mesh.foundObject(divName)) + if (!mesh_.foundObject(divName)) { volScalarField* divFieldPtr ( @@ -58,20 +56,20 @@ Foam::volScalarField& Foam::functionObjects::div::divField IOobject ( divName, - mesh.time().timeName(), - mesh, + mesh_.time().timeName(), + mesh_, IOobject::NO_READ, IOobject::NO_WRITE ), - mesh, + mesh_, dimensionedScalar("zero", dims/dimLength, 0.0) ) ); - mesh.objectRegistry::store(divFieldPtr); + mesh_.objectRegistry::store(divFieldPtr); } - const volScalarField& field = mesh.lookupObject(divName); + const volScalarField& field = mesh_.lookupObject(divName); return const_cast(field); } @@ -86,23 +84,8 @@ Foam::functionObjects::div::div const dictionary& dict ) : - functionObject(name), - obr_ - ( - runTime.lookupObject - ( - dict.lookupOrDefault("region", polyMesh::defaultRegion) - ) - ), - fieldName_("undefined-fieldName"), - resultName_("undefined-resultName") + fvMeshFunctionObject(name, runTime, dict) { - if (!isA(obr_)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - read(dict); } diff --git a/src/postProcessing/functionObjects/field/div/div.H b/src/postProcessing/functionObjects/field/div/div.H index 5d1df72c42..17e53c26d6 100644 --- a/src/postProcessing/functionObjects/field/div/div.H +++ b/src/postProcessing/functionObjects/field/div/div.H @@ -40,7 +40,7 @@ SourceFiles #ifndef functionObjects_div_H #define functionObjects_div_H -#include "functionObject.H" +#include "fvMeshFunctionObject.H" #include "volFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,7 +49,6 @@ namespace Foam { // Forward declaration of classes -class objectRegistry; class dimensionSet; namespace functionObjects @@ -61,13 +60,10 @@ namespace functionObjects class div : - public functionObject + public fvMeshFunctionObject { // Private data - //- Reference to the objectRegistry - const objectRegistry& obr_; - //- Name of field to process word fieldName_; diff --git a/src/postProcessing/functionObjects/field/div/divTemplates.C b/src/postProcessing/functionObjects/field/div/divTemplates.C index 8cae12aa60..bdfea97710 100644 --- a/src/postProcessing/functionObjects/field/div/divTemplates.C +++ b/src/postProcessing/functionObjects/field/div/divTemplates.C @@ -36,11 +36,9 @@ void Foam::functionObjects::div::calcDiv bool& processed ) { - const fvMesh& mesh = refCast(obr_); - - if (mesh.foundObject(fieldName)) + if (mesh_.foundObject(fieldName)) { - const FieldType& vf = mesh.lookupObject(fieldName); + const FieldType& vf = mesh_.lookupObject(fieldName); volScalarField& field = divField(resultName, vf.dimensions()); diff --git a/src/postProcessing/functionObjects/field/grad/grad.C b/src/postProcessing/functionObjects/field/grad/grad.C index 05e0b509b4..4736c4c04d 100644 --- a/src/postProcessing/functionObjects/field/grad/grad.C +++ b/src/postProcessing/functionObjects/field/grad/grad.C @@ -48,23 +48,8 @@ Foam::functionObjects::grad::grad const dictionary& dict ) : - functionObject(name), - obr_ - ( - runTime.lookupObject - ( - dict.lookupOrDefault("region", polyMesh::defaultRegion) - ) - ), - fieldName_("undefined-fieldName"), - resultName_("undefined-resultName") + fvMeshFunctionObject(name, runTime, dict) { - if (!isA(obr_)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - read(dict); } diff --git a/src/postProcessing/functionObjects/field/grad/grad.H b/src/postProcessing/functionObjects/field/grad/grad.H index 2d092f320a..43e6cef3d5 100644 --- a/src/postProcessing/functionObjects/field/grad/grad.H +++ b/src/postProcessing/functionObjects/field/grad/grad.H @@ -40,7 +40,7 @@ SourceFiles #ifndef functionObjects_grad_H #define functionObjects_grad_H -#include "functionObject.H" +#include "fvMeshFunctionObject.H" #include "volFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,7 +49,6 @@ namespace Foam { // Forward declaration of classes -class objectRegistry; class dimensionSet; namespace functionObjects @@ -61,13 +60,10 @@ namespace functionObjects class grad : - public functionObject + public fvMeshFunctionObject { // Private data - //- Reference to the objectRegistry - const objectRegistry& obr_; - //- Name of field to process word fieldName_; diff --git a/src/postProcessing/functionObjects/field/grad/gradTemplates.C b/src/postProcessing/functionObjects/field/grad/gradTemplates.C index c54c0a490c..0c06b01c61 100644 --- a/src/postProcessing/functionObjects/field/grad/gradTemplates.C +++ b/src/postProcessing/functionObjects/field/grad/gradTemplates.C @@ -46,9 +46,7 @@ Foam::functionObjects::grad::gradField typedef typename outerProduct::type gradType; typedef GeometricField vfGradType; - const fvMesh& mesh = refCast(obr_); - - if (!mesh.foundObject(gradName)) + if (!mesh_.foundObject(gradName)) { vfGradType* gradFieldPtr ( @@ -57,12 +55,12 @@ Foam::functionObjects::grad::gradField IOobject ( gradName, - mesh.time().timeName(), - mesh, + mesh_.time().timeName(), + mesh_, IOobject::NO_READ, IOobject::NO_WRITE ), - mesh, + mesh_, dimensioned ( "zero", @@ -72,10 +70,10 @@ Foam::functionObjects::grad::gradField ) ); - mesh.objectRegistry::store(gradFieldPtr); + mesh_.objectRegistry::store(gradFieldPtr); } - const vfGradType& field = mesh.lookupObject(gradName); + const vfGradType& field = mesh_.lookupObject(gradName); return const_cast(field); } @@ -95,12 +93,9 @@ void Foam::functionObjects::grad::calcGrad typedef typename outerProduct::type gradType; typedef GeometricField vfGradType; - const fvMesh& mesh = refCast(obr_); - - - if (mesh.foundObject(fieldName)) + if (mesh_.foundObject(fieldName)) { - const vfType& vf = mesh.lookupObject(fieldName); + const vfType& vf = mesh_.lookupObject(fieldName); vfGradType& field = gradField(resultName, vf.dimensions()); @@ -109,9 +104,9 @@ void Foam::functionObjects::grad::calcGrad processed = true; } - else if (mesh.foundObject(fieldName)) + else if (mesh_.foundObject(fieldName)) { - const sfType& sf = mesh.lookupObject(fieldName); + const sfType& sf = mesh_.lookupObject(fieldName); vfGradType& field = gradField(resultName, sf.dimensions()); diff --git a/src/postProcessing/functionObjects/field/mag/mag.C b/src/postProcessing/functionObjects/field/mag/mag.C index a51aad91ae..ac8e426e9c 100644 --- a/src/postProcessing/functionObjects/field/mag/mag.C +++ b/src/postProcessing/functionObjects/field/mag/mag.C @@ -48,23 +48,8 @@ Foam::functionObjects::mag::mag const dictionary& dict ) : - functionObject(name), - obr_ - ( - runTime.lookupObject - ( - dict.lookupOrDefault("region", polyMesh::defaultRegion) - ) - ), - fieldName_("undefined-fieldName"), - resultName_("undefined-resultName") + fvMeshFunctionObject(name, runTime, dict) { - if (!isA(obr_)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - read(dict); } diff --git a/src/postProcessing/functionObjects/field/mag/mag.H b/src/postProcessing/functionObjects/field/mag/mag.H index dd4dc1f4f5..be1c6fe86f 100644 --- a/src/postProcessing/functionObjects/field/mag/mag.H +++ b/src/postProcessing/functionObjects/field/mag/mag.H @@ -40,7 +40,7 @@ SourceFiles #ifndef functionObjects_mag_H #define functionObjects_mag_H -#include "functionObject.H" +#include "fvMeshFunctionObject.H" #include "volFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,7 +49,6 @@ namespace Foam { // Forward declaration of classes -class objectRegistry; class dimensionSet; namespace functionObjects @@ -61,13 +60,10 @@ namespace functionObjects class mag : - public functionObject + public fvMeshFunctionObject { // Private data - //- Reference to the objectRegistry - const objectRegistry& obr_; - //- Name of field to process word fieldName_; diff --git a/src/postProcessing/functionObjects/field/mag/magTemplates.C b/src/postProcessing/functionObjects/field/mag/magTemplates.C index 1a2e107b73..49386a701b 100644 --- a/src/postProcessing/functionObjects/field/mag/magTemplates.C +++ b/src/postProcessing/functionObjects/field/mag/magTemplates.C @@ -35,9 +35,7 @@ FieldType& Foam::functionObjects::mag::magField const dimensionSet& dims ) { - const fvMesh& mesh = refCast(obr_); - - if (!mesh.foundObject(magName)) + if (!mesh_.foundObject(magName)) { FieldType* magFieldPtr ( @@ -46,20 +44,20 @@ FieldType& Foam::functionObjects::mag::magField IOobject ( magName, - mesh.time().timeName(), - mesh, + mesh_.time().timeName(), + mesh_, IOobject::NO_READ, IOobject::NO_WRITE ), - mesh, + mesh_, dimensionedScalar("zero", dims, 0.0) ) ); - mesh.objectRegistry::store(magFieldPtr); + mesh_.objectRegistry::store(magFieldPtr); } - const FieldType& f = mesh.lookupObject(magName); + const FieldType& f = mesh_.lookupObject(magName); return const_cast(f); } @@ -78,11 +76,9 @@ void Foam::functionObjects::mag::calc typedef GeometricField vfType; typedef GeometricField sfType; - const fvMesh& mesh = refCast(obr_); - - if (mesh.foundObject(fieldName)) + if (mesh_.foundObject(fieldName)) { - const vfType& vf = mesh.lookupObject(fieldName); + const vfType& vf = mesh_.lookupObject(fieldName); volScalarField& field = magField(resultName_, vf.dimensions()); @@ -91,9 +87,9 @@ void Foam::functionObjects::mag::calc processed = true; } - else if (mesh.foundObject(fieldName)) + else if (mesh_.foundObject(fieldName)) { - const sfType& sf = mesh.lookupObject(fieldName); + const sfType& sf = mesh_.lookupObject(fieldName); surfaceScalarField& field = magField(resultName_, sf.dimensions()); diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C index e57156c53c..411ad032cc 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C +++ b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C @@ -48,23 +48,8 @@ Foam::functionObjects::blendingFactor::blendingFactor const dictionary& dict ) : - functionObject(name), - obr_ - ( - runTime.lookupObject - ( - dict.lookupOrDefault("region", polyMesh::defaultRegion) - ) - ), - phiName_("unknown-phiName"), - fieldName_("unknown-fieldName") + fvMeshFunctionObject(name, runTime, dict) { - if (!isA(obr_)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - read(dict); } diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H index f47fc08061..33e1fd1c85 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H +++ b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H @@ -32,6 +32,10 @@ Description the bended convection schemes. The output is a volume field (cells) whose value is calculated via the maximum blending factor for any cell face. +SeeAlso + Foam::fvMeshFunctionObject + Foam::functionObject + SourceFiles blendingFactor.C @@ -40,7 +44,7 @@ SourceFiles #ifndef functionObjects_blendingFactor_H #define functionObjects_blendingFactor_H -#include "functionObject.H" +#include "fvMeshFunctionObject.H" #include "volFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,13 +64,10 @@ namespace functionObjects class blendingFactor : - public functionObject + public fvMeshFunctionObject { // Private data - //- Reference to the objectRegistry - const objectRegistry& obr_; - //- Name of flux field, default is "phi" word phiName_;