Commit 5265a872 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: regionModel - simplified construction of regionMesh - now owned by time db

parent 179d9fd6
......@@ -46,11 +46,9 @@ namespace regionModels
void Foam::regionModels::regionModel::constructMeshObjects()
{
// construct region mesh
if (!time_.foundObject<fvMesh>(regionName_))
{
regionMeshPtr_.reset
(
fvMesh* regionMeshPtr =
new fvMesh
(
IOobject
......@@ -60,8 +58,9 @@ void Foam::regionModels::regionModel::constructMeshObjects()
time_,
IOobject::MUST_READ
)
)
);
);
regionMeshPtr->objectRegistry::store();
}
}
......@@ -364,7 +363,6 @@ Foam::regionModels::regionModel::regionModel
active_(false),
infoOutput_(false),
modelName_("none"),
regionMeshPtr_(nullptr),
coeffs_(dictionary::null),
outputPropertiesPtr_(nullptr),
primaryPatchIDs_(),
......@@ -400,7 +398,6 @@ Foam::regionModels::regionModel::regionModel
active_(get<Switch>("active")),
infoOutput_(true),
modelName_(modelName),
regionMeshPtr_(nullptr),
coeffs_(subOrEmptyDict(modelName + "Coeffs")),
outputPropertiesPtr_(nullptr),
primaryPatchIDs_(),
......@@ -448,7 +445,6 @@ Foam::regionModels::regionModel::regionModel
active_(dict.get<Switch>("active")),
infoOutput_(false),
modelName_(modelName),
regionMeshPtr_(nullptr),
coeffs_(dict.subOrEmptyDict(modelName + "Coeffs")),
outputPropertiesPtr_(nullptr),
primaryPatchIDs_(),
......@@ -469,12 +465,6 @@ Foam::regionModels::regionModel::regionModel
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::regionModels::regionModel::~regionModel()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::regionModels::regionModel::evolve()
......
......@@ -99,9 +99,6 @@ protected:
//- Model name
const word modelName_;
//- Pointer to the region mesh database
autoPtr<fvMesh> regionMeshPtr_;
//- Model coefficients dictionary
dictionary coeffs_;
......@@ -185,7 +182,7 @@ public:
//- Destructor
virtual ~regionModel();
virtual ~regionModel() = default;
// Member Functions
......
......@@ -62,19 +62,15 @@ inline const Foam::word& Foam::regionModels::regionModel::modelName() const
inline const Foam::fvMesh& Foam::regionModels::regionModel::regionMesh() const
{
const fvMesh* regionPtr = time_.findObject<fvMesh>(regionName_);
const fvMesh* regionPtr = time_.getObjectPtr<fvMesh>(regionName_);
  • Should actually have been fine to leave this as findObject or even cfindObject. The getObjectPtr just adds a const_cast to the call.

    Edited by Mark Olesen
  • done for symmetry with the non-const version - too many options for this kind of thing at the moment

Please register or sign in to reply
if (regionPtr)
{
return *regionPtr;
}
else if (!regionMeshPtr_.valid())
if (!regionPtr)
{
FatalErrorInFunction
<< "Region mesh not available" << abort(FatalError);
}
return *regionMeshPtr_;
return *regionPtr;
}
......@@ -82,17 +78,13 @@ inline Foam::fvMesh& Foam::regionModels::regionModel::regionMesh()
{
fvMesh* regionPtr = time_.getObjectPtr<fvMesh>(regionName_);
if (regionPtr)
{
return *regionPtr;
}
else if (!regionMeshPtr_.valid())
if (!regionPtr)
{
FatalErrorInFunction
<< "Region mesh not available" << abort(FatalError);
}
return *regionMeshPtr_;
return *regionPtr;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment