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

View File

@ -71,9 +71,9 @@ static label eraseImpl(objectRegistry& obr, InputIter first, InputIter last)
// * * * * * * * * * * * * * 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 * * * * * * * * * * * * * //
bool Foam::objectRegistry::isTimeDb() const noexcept
{
return (this == &static_cast<const objectRegistry&>(time_));
}
Foam::HashTable<Foam::wordHashSet> Foam::objectRegistry::classes() const
{
return classesImpl(*this, predicates::always());

View File

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

View File

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

View File

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

View File

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

View File

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