ENH: add check for isTimeDb() into objectRegistry

- add missing time() into pointMesh

STYLE: use static_cast instead of dynamic_cast for Time -> objectRegistry
This commit is contained in:
Mark Olesen
2021-11-17 19:51:22 +01:00
parent 1af0380edc
commit 39d244ad91
7 changed files with 33 additions and 14 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2018 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -146,6 +146,9 @@ int main(int argc, char *argv[])
const objectRegistry& db = (optMesh ? mesh.thisDb() : runTime); const objectRegistry& db = (optMesh ? mesh.thisDb() : runTime);
Info<<"## start ##" << nl; Info<<"## start ##" << nl;
Info<< "db isTime:" << db.isTimeDb() << " addr:" << Foam::name(&db)
<< " time: " << Foam::name(&(db.time())) << nl;
printRegistry(Info, db); printRegistry(Info, db);
Info<< nl; Info<< nl;

View File

@ -71,9 +71,9 @@ static label eraseImpl(objectRegistry& obr, InputIter first, InputIter last)
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::objectRegistry::parentNotTime() const bool Foam::objectRegistry::parentNotTime() const noexcept
{ {
return (&parent_ != dynamic_cast<const objectRegistry*>(&time_)); return (&parent_ != static_cast<const objectRegistry*>(&time_));
} }
@ -125,6 +125,12 @@ Foam::objectRegistry::~objectRegistry()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::objectRegistry::isTimeDb() const noexcept
{
return (this == &static_cast<const objectRegistry&>(time_));
}
Foam::HashTable<Foam::wordHashSet> Foam::objectRegistry::classes() const Foam::HashTable<Foam::wordHashSet> Foam::objectRegistry::classes() const
{ {
return classesImpl(*this, predicates::always()); return classesImpl(*this, predicates::always());

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -82,7 +82,7 @@ class objectRegistry
//- Is the objectRegistry parent_ different from time_ //- Is the objectRegistry parent_ different from time_
// Used to terminate searching within the ancestors // Used to terminate searching within the ancestors
bool parentNotTime() const; bool parentNotTime() const noexcept;
//- Templated implementation for count() //- Templated implementation for count()
// The number of items with a matching class // The number of items with a matching class
@ -169,17 +169,20 @@ public:
return *this; return *this;
} }
//- Return the parent objectRegistry
const objectRegistry& parent() const noexcept
{
return parent_;
}
//- Return time registry //- Return time registry
const Time& time() const noexcept const Time& time() const noexcept
{ {
return time_; return time_;
} }
//- Return the parent objectRegistry //- True if the registry is Time
const objectRegistry& parent() const noexcept bool isTimeDb() const noexcept;
{
return parent_;
}
//- Local directory path of this objectRegistry relative to the time //- Local directory path of this objectRegistry relative to the time
virtual const fileName& dbDir() const virtual const fileName& dbDir() const

View File

@ -94,7 +94,7 @@ bool Foam::pointMesh::movePoints()
{ {
if (debug) if (debug)
{ {
Pout<< "pointMesh::movePoints(const pointField&): " Pout<< "pointMesh::movePoints(): "
<< "Moving points." << endl; << "Moving points." << endl;
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -53,7 +54,7 @@ class pointMesh
public MeshObject<polyMesh, UpdateableMeshObject, pointMesh>, public MeshObject<polyMesh, UpdateableMeshObject, pointMesh>,
public GeoMesh<polyMesh> public GeoMesh<polyMesh>
{ {
// Permanent data // Permanent Data
//- Boundary mesh //- Boundary mesh
pointBoundaryMesh boundary_; pointBoundaryMesh boundary_;
@ -123,6 +124,12 @@ public:
return GeoMesh<polyMesh>::mesh_.thisDb(); return GeoMesh<polyMesh>::mesh_.thisDb();
} }
//- Return Time from polyMesh.
const Time& time() const
{
return GeoMesh<polyMesh>::mesh_.time();
}
// Mesh motion // Mesh motion

View File

@ -183,7 +183,7 @@ public:
IOobject IOobject
( (
"dSigma", "dSigma",
surfactConc.mesh().mesh().time().timeName(), surfactConc.mesh().time().timeName(),
surfactConc.mesh().mesh(), surfactConc.mesh().mesh(),
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -113,7 +113,7 @@ bool Foam::cyclicAMIPointPatch::coupled() const
{ {
return return
Pstream::parRun() Pstream::parRun()
|| !this->boundaryMesh().mesh().mesh().time().processorCase(); || !this->boundaryMesh().mesh().time().processorCase();
} }