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 |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
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)
{
return word::null;
return word();
}
return name.substr(i+1);
@ -307,6 +307,16 @@ Foam::word Foam::IOobject::member(const word& name)
// * * * * * * * * * * * * * * * * 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
(
const word& name,
@ -315,19 +325,11 @@ Foam::IOobject::IOobject
IOobjectOption ioOpt
)
:
IOobjectOption(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)
IOobject(registry, ioOpt)
{
name_ = name;
instance_ = instance;
if (objectRegistry::debug)
{
InfoInFunction
@ -345,19 +347,12 @@ Foam::IOobject::IOobject
IOobjectOption ioOpt
)
:
IOobjectOption(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)
IOobject(registry, ioOpt)
{
name_ = name;
instance_ = instance;
local_ = local;
if (objectRegistry::debug)
{
InfoInFunction
@ -373,18 +368,7 @@ Foam::IOobject::IOobject
IOobjectOption ioOpt
)
:
IOobjectOption(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)
IOobject(registry, ioOpt)
{
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();
}

View File

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

View File

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

View File

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

View File

@ -115,7 +115,8 @@ Foam::codedBase::codeDict
obr.time().system(),
obr,
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"),
time_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
IOobject::NO_WRITE,
IOobject::REGISTER
)
)
);
@ -132,7 +133,8 @@ void Foam::functionObjectList::createOutputRegistry() const
time_.timeName(),
time_,
IOobject::NO_READ,
IOobject::NO_WRITE
IOobject::NO_WRITE,
IOobject::REGISTER
)
)
);
@ -453,7 +455,9 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
(
args["dict"],
runTime,
IOobject::MUST_READ_IF_MODIFIED
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
IOobject::REGISTER
)
)
);

View File

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

View File

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

View File

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

View File

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

View File

@ -94,7 +94,8 @@ Foam::uniformInterpolationTable<Type>::uniformInterpolationTable
db,
IOobject::NO_READ,
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),
x0_(dict.get<scalar>("x0")),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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