typeIOobject: Template typed form of IOobject for type-checked object file and header reading

used to check the existence of and open an object file, read and check the
header without constructing the object.

'typeIOobject' operates in an equivalent and consistent manner to 'regIOobject'
but the type information is provided by the template argument rather than via
virtual functions for which the derived object would need to be constructed,
which is the case for 'regIOobject'.

'typeIOobject' replaces the previous separate functions 'typeHeaderOk' and
'typeFilePath' with a single consistent interface.
This commit is contained in:
Henry Weller
2021-08-12 10:12:03 +01:00
parent 0a3a6312e5
commit b9123328fb
114 changed files with 514 additions and 475 deletions

View File

@ -16,6 +16,6 @@ for (label n1=0; n1<Times.size() && variableGood; ++n1)
Times[n1].name(),
mesh,
IOobject::NO_READ
).typeHeaderOk<volScalarField>(false);
).headerOk();
}
}

View File

@ -9,7 +9,7 @@ if (Times.size() > 1)
{
if (Times[timeI].name() != mesh.pointsInstance())
{
IOobject io
typeIOobject<pointIOField> io
(
"points",
Times[timeI].name(),
@ -17,7 +17,8 @@ if (Times.size() > 1)
mesh,
IOobject::NO_READ
);
if (io.typeHeaderOk<pointIOField>(true))
if (io.headerOk())
{
meshMoving = true;
break;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -584,10 +584,8 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
bool fieldExists = fieldObject.typeHeaderOk<IOField<scalar>>
(
false
);
bool fieldExists = fieldObject.headerOk();
if (fieldType == scalarIOField::typeName)
{
ensightCloudField<scalar>

View File

@ -6,13 +6,13 @@ if (timeDirs.size() > 1)
hasMovingMesh = true;
for (label i=0; i < timeDirs.size() && hasMovingMesh; ++i)
{
hasMovingMesh = IOobject
hasMovingMesh = typeIOobject<pointIOField>
(
"points",
timeDirs[i].name(),
polyMesh::meshSubDir,
mesh,
IOobject::NO_READ
).typeHeaderOk<pointIOField>(true);
).headerOk();
}
}

View File

@ -13,7 +13,7 @@
&& runTime.timeName() != "0"
)
{
IOobject io
typeIOobject<IOdictionary> io
(
"time",
runTime.timeName(),
@ -24,7 +24,7 @@
false
);
if (io.typeHeaderOk<IOdictionary>(true))
if (io.headerOk())
{
io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
IOdictionary timeObject(io);
@ -34,7 +34,7 @@
else
{
Info<< "skip ... missing entry "
<< io.objectPath<IOdictionary>() << endl;
<< io.objectPath() << endl;
continue;
}
}

View File

@ -1,5 +1,5 @@
{
IOobject io
typeIOobject<pointIOField> io
(
"points",
runTime.timeName(),
@ -7,7 +7,7 @@
mesh
);
if (io.typeHeaderOk<pointIOField>(true))
if (io.headerOk())
{
// Read new points
io.readOpt() = IOobject::MUST_READ;

View File

@ -71,13 +71,7 @@ for (label i=0; i < nTypes; i++)
IOobject::NO_READ
);
if
(
lagrangianHeader.typeHeaderOk<IOPosition<Cloud<passiveParticle>>>
(
false
)
)
if (lagrangianHeader.headerOk())
{
Cloud<passiveParticle> particles(mesh, cloud::defaultName);

View File

@ -1,4 +1,4 @@
IOobject ioPoints
typeIOobject<pointIOField> ioPoints
(
"points",
runTime.timeName(),
@ -6,7 +6,7 @@ IOobject ioPoints
mesh
);
if (ioPoints.typeHeaderOk<pointIOField>(true))
if (ioPoints.headerOk())
{
Info<< "new points available" << endl;
// Reading new points