STYLE: make IOobject time() noexcept. Use explicit REGISTER/NO_REGISTER

This commit is contained in:
Mark Olesen
2023-01-13 12:44:16 +01:00
parent 1f5a75c3c2
commit 8a70c898ae
25 changed files with 101 additions and 100 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -285,7 +285,7 @@ Foam::word Foam::IOobject::group(const word& name)
if (i == std::string::npos || i == 0) if (i == std::string::npos || i == 0)
{ {
return word::null; return word();
} }
return name.substr(i+1); return name.substr(i+1);
@ -307,6 +307,16 @@ Foam::word Foam::IOobject::member(const word& name)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IOobject::IOobject(const objectRegistry& registry, IOobjectOption ioOpt)
:
IOobjectOption(ioOpt),
objState_(objectState::GOOD),
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
db_(registry)
{}
Foam::IOobject::IOobject Foam::IOobject::IOobject
( (
const word& name, const word& name,
@ -315,19 +325,11 @@ Foam::IOobject::IOobject
IOobjectOption ioOpt IOobjectOption ioOpt
) )
: :
IOobjectOption(ioOpt), IOobject(registry, ioOpt)
objState_(objectState::GOOD),
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
name_(name),
headerClassName_(),
note_(),
instance_(instance),
local_(),
db_(registry)
{ {
name_ = name;
instance_ = instance;
if (objectRegistry::debug) if (objectRegistry::debug)
{ {
InfoInFunction InfoInFunction
@ -345,19 +347,12 @@ Foam::IOobject::IOobject
IOobjectOption ioOpt IOobjectOption ioOpt
) )
: :
IOobjectOption(ioOpt), IOobject(registry, ioOpt)
objState_(objectState::GOOD),
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
name_(name),
headerClassName_(),
note_(),
instance_(instance),
local_(local),
db_(registry)
{ {
name_ = name;
instance_ = instance;
local_ = local;
if (objectRegistry::debug) if (objectRegistry::debug)
{ {
InfoInFunction InfoInFunction
@ -373,18 +368,7 @@ Foam::IOobject::IOobject
IOobjectOption ioOpt IOobjectOption ioOpt
) )
: :
IOobjectOption(ioOpt), IOobject(registry, ioOpt)
objState_(objectState::GOOD),
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
name_(),
headerClassName_(),
note_(),
instance_(),
local_(),
db_(registry)
{ {
if (!fileNameComponents(path, instance_, local_, name_)) if (!fileNameComponents(path, instance_, local_, name_))
{ {
@ -451,7 +435,7 @@ const Foam::objectRegistry& Foam::IOobject::db() const noexcept
} }
const Foam::Time& Foam::IOobject::time() const const Foam::Time& Foam::IOobject::time() const noexcept
{ {
return db_.time(); return db_.time();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -186,6 +186,12 @@ private:
const objectRegistry& db_; const objectRegistry& db_;
// Private Member Functions
//- Construct from registry, io options. Without name, instance, local
IOobject(const objectRegistry& registry, IOobjectOption ioOpt);
protected: protected:
// Protected Member Functions // Protected Member Functions
@ -450,7 +456,7 @@ public:
const objectRegistry& db() const noexcept; const objectRegistry& db() const noexcept;
//- Return Time associated with the objectRegistry //- Return Time associated with the objectRegistry
const Time& time() const; const Time& time() const noexcept;
//- Return the object name //- Return the object name
inline const word& name() const noexcept; inline const word& name() const noexcept;

View File

@ -279,7 +279,7 @@ void Foam::Time::setControls()
*this, *this,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
); );
@ -440,7 +440,7 @@ Foam::Time::Time
*this, *this,
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
), ),
@ -506,7 +506,7 @@ Foam::Time::Time
*this, *this,
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
), ),
@ -589,7 +589,7 @@ Foam::Time::Time
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
dict dict
), ),
@ -666,7 +666,7 @@ Foam::Time::Time
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
), ),
@ -1006,7 +1006,7 @@ void Foam::Time::setTime(const instant& inst, const label newIndex)
*this, *this,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
); );

View File

@ -526,7 +526,7 @@ bool Foam::Time::writeTimeDict() const
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
); );

View File

@ -115,7 +115,8 @@ Foam::codedBase::codeDict
obr.time().system(), obr.time().system(),
obr, obr,
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE IOobject::NO_WRITE,
IOobject::REGISTER
) )
); );

View File

@ -113,7 +113,8 @@ void Foam::functionObjectList::createPropertiesDict() const
"uniform"/word("functionObjects"), "uniform"/word("functionObjects"),
time_, time_,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE IOobject::NO_WRITE,
IOobject::REGISTER
) )
) )
); );
@ -132,7 +133,8 @@ void Foam::functionObjectList::createOutputRegistry() const
time_.timeName(), time_.timeName(),
time_, time_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE,
IOobject::REGISTER
) )
) )
); );
@ -453,7 +455,9 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
( (
args["dict"], args["dict"],
runTime, runTime,
IOobject::MUST_READ_IF_MODIFIED IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
IOobject::REGISTER
) )
) )
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd. Copyright (C) 2015-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -88,9 +88,9 @@ Foam::objectRegistry::objectRegistry(const Time& t, const label nObjects)
word::validate(t.caseName()), word::validate(t.caseName()),
t.path(), t.path(),
t, t,
IOobject::NO_READ, IOobjectOption::NO_READ,
IOobject::AUTO_WRITE, IOobjectOption::AUTO_WRITE,
false IOobjectOption::NO_REGISTER
), ),
true // to flag that this is the top-level regIOobject true // to flag that this is the top-level regIOobject
), ),
@ -207,8 +207,9 @@ const Foam::objectRegistry& Foam::objectRegistry::subRegistry
name, name,
time().constant(), time().constant(),
*this, *this,
IOobject::NO_READ, IOobjectOption::NO_READ,
IOobject::NO_WRITE IOobjectOption::NO_WRITE,
IOobjectOption::REGISTER
) )
); );
subObr->store(); subObr->store();

View File

@ -59,7 +59,7 @@ Foam::expressions::exprResultGlobals::exprResultGlobals
obr.time(), obr.time(),
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE, IOobject::AUTO_WRITE,
true // register IOobject::REGISTER
) )
), ),
variables_(), variables_(),

View File

@ -85,7 +85,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::readFields()
this->db(), this->db(),
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
typeName typeName
); );

View File

@ -236,7 +236,8 @@ void Foam::ReadFields
timeName, timeName,
fieldsCache, fieldsCache,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE,
IOobject::REGISTER
) )
); );
timeCachePtr->store(); timeCachePtr->store();
@ -261,7 +262,7 @@ void Foam::ReadFields
mesh.thisDb(), mesh.thisDb(),
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false // do not register IOobject::NO_REGISTER
), ),
mesh mesh
); );
@ -275,7 +276,8 @@ void Foam::ReadFields
timeName, timeName,
timeCache, timeCache,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE,
IOobject::REGISTER
), ),
loadedFld loadedFld
); );
@ -347,7 +349,8 @@ void Foam::readFields
io.local(), io.local(),
io.db(), io.db(),
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE,
IOobject::REGISTER
), ),
mesh mesh
); );
@ -402,7 +405,8 @@ void Foam::readUniformFields
io.local(), io.local(),
io.db(), io.db(),
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE,
IOobject::REGISTER
) )
); );
fieldPtr->store(); fieldPtr->store();

View File

@ -94,7 +94,8 @@ Foam::uniformInterpolationTable<Type>::uniformInterpolationTable
db, db,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false // if used in BCs, could be used by multiple patches IOobject::NO_REGISTER
// No register: could be used by multiple patches if used in BCs
), ),
List<scalar>(2, Zero), List<scalar>(2, Zero),
x0_(dict.get<scalar>("x0")), x0_(dict.get<scalar>("x0")),

View File

@ -114,7 +114,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
*this, *this,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
); );
@ -128,7 +128,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
*this, *this,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
); );
@ -142,7 +142,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
*this, *this,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
); );
@ -156,7 +156,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
*this, *this,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
); );
@ -171,7 +171,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
*this, *this,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
*this *this
); );
@ -256,7 +256,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
*this, *this,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
); );
@ -291,7 +291,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
*this, *this,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
*this *this
); );
@ -328,7 +328,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
*this, *this,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
*this *this
); );
@ -369,7 +369,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
*this, *this,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
*this *this
); );
@ -426,7 +426,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
*this, *this,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
) )
); );

View File

@ -56,7 +56,7 @@ void Foam::preservePatchTypes
obr, obr,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
); );
if (patchEntriesHeader.typeHeaderOk<polyBoundaryMesh>(true)) if (patchEntriesHeader.typeHeaderOk<polyBoundaryMesh>(true))

View File

@ -72,7 +72,7 @@ bool Foam::functionObjects::ObukhovLength::calcOL()
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
mesh_, mesh_,
dimLength, dimLength,
@ -90,7 +90,7 @@ bool Foam::functionObjects::ObukhovLength::calcOL()
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
mesh_, mesh_,
dimVelocity, dimVelocity,

View File

@ -61,7 +61,7 @@ Foam::extrudePatchMesh::extrudePatchMesh
mesh, mesh,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
Zero, Zero,
false false

View File

@ -61,7 +61,7 @@ void Foam::fvMesh::makeSf() const
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
*this, *this,
dimArea, dimArea,
@ -98,7 +98,7 @@ void Foam::fvMesh::makeMagSf() const
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
mag(Sf()) + dimensionedScalar("vs", dimArea, VSMALL) mag(Sf()) + dimensionedScalar("vs", dimArea, VSMALL)
); );
@ -130,7 +130,7 @@ void Foam::fvMesh::makeC() const
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
*this, *this,
dimLength, dimLength,
@ -165,7 +165,7 @@ void Foam::fvMesh::makeCf() const
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
*this, *this,
dimLength, dimLength,
@ -192,7 +192,7 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V() const
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
*this, *this,
dimVolume, dimVolume,
@ -245,7 +245,7 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V00() const
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
V0() V0()
); );
@ -364,7 +364,7 @@ Foam::tmp<Foam::surfaceVectorField> Foam::fvMesh::delta() const
*this, *this,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false IOobject::NO_REGISTER
), ),
*this, *this,
dimLength dimLength

View File

@ -88,7 +88,7 @@ static bool calc_rhoU
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
mesh, mesh,
(dimDensity * dimVelocity) (dimDensity * dimVelocity)
@ -142,7 +142,7 @@ static bool calc_pTotal
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
mesh, mesh,
dimPressure dimPressure

View File

@ -64,7 +64,7 @@ Foam::lumpedPointIOMovement::New
obr, obr,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true // register object IOobject::REGISTER
), ),
ownerId // tag this patch as owner too ownerId // tag this patch as owner too
); );

View File

@ -59,7 +59,7 @@ objectiveManager::objectiveManager
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true //register object IOobject::REGISTER
) )
), ),
mesh_(mesh), mesh_(mesh),

View File

@ -51,7 +51,7 @@ Foam::optimisationManager::optimisationManager(fvMesh& mesh)
mesh, mesh,
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
) )
), ),
mesh_(mesh), mesh_(mesh),

View File

@ -56,7 +56,7 @@ Foam::adjointSolverManager::adjointSolverManager
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true //register object IOobject::REGISTER
) )
), ),
mesh_(mesh), mesh_(mesh),

View File

@ -433,7 +433,7 @@ Foam::regionModels::regionModel::regionModel
mesh.time(), mesh.time(),
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
dict dict
), ),

View File

@ -93,7 +93,7 @@ Foam::polySurface::polySurface(const IOobject& io, bool doCheckIn)
io.db(), io.db(),
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
) )
), ),
MeshReference(faceList(), pointField()), MeshReference(faceList(), pointField()),
@ -124,7 +124,7 @@ Foam::polySurface::polySurface
obr, obr,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
doCheckIn doCheckIn
) )

View File

@ -119,7 +119,7 @@ void Foam::polySurface::storeField
fieldDb, fieldDb,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
*this, *this,
dims, dims,
@ -160,7 +160,7 @@ void Foam::polySurface::storeField
fieldDb, fieldDb,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
*this, *this,
dims, dims,

View File

@ -58,7 +58,7 @@ void Foam::surfMesh::storeField
fieldDb, fieldDb,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
*this, *this,
dims, dims,
@ -98,7 +98,7 @@ void Foam::surfMesh::storeField
fieldDb, fieldDb,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
true IOobject::REGISTER
), ),
*this, *this,
dims, dims,