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

@ -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
@ -65,7 +65,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << endl;
IOobject Uheader
typeIOobject<volVectorField> Uheader
(
"U",
runTime.timeName(),
@ -74,7 +74,7 @@ int main(int argc, char *argv[])
);
// Check U exists
if (Uheader.typeHeaderOk<volVectorField>(true))
if (Uheader.headerOk())
{
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);

View File

@ -189,11 +189,11 @@ int main(int argc, char *argv[])
// Dictionary to control refinement
const word dictName("refineMeshDict");
IOobject dictIO(systemDictIO(dictName, args, runTime));
typeIOobject<IOdictionary> dictIO(systemDictIO(dictName, args, runTime));
dictionary refineDict;
if (readDict)
{
if (dictIO.typeHeaderOk<IOdictionary>(true))
if (dictIO.headerOk())
{
Info<< "Refining according to "
<< dictIO.path(typeGlobalFile<IOdictionary>()) << nl << endl;
@ -209,7 +209,7 @@ int main(int argc, char *argv[])
}
else if (!refineAllCells)
{
if (dictIO.typeHeaderOk<IOdictionary>(true))
if (dictIO.headerOk())
{
Info<< "Refining according to "
<< dictIO.path(typeGlobalFile<IOdictionary>()) << nl << endl;

View File

@ -575,7 +575,7 @@ autoPtr<mapPolyMesh> createRegionMesh
{
// Create dummy system/fv*
{
IOobject io
typeIOobject<IOdictionary> io
(
"fvSchemes",
mesh.time().system(),
@ -586,9 +586,9 @@ autoPtr<mapPolyMesh> createRegionMesh
false
);
Info<< "Testing:" << io.objectPath<IOdictionary>() << endl;
Info<< "Testing:" << io.objectPath() << endl;
if (!io.typeHeaderOk<IOdictionary>(true))
if (!io.headerOk())
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
@ -603,7 +603,7 @@ autoPtr<mapPolyMesh> createRegionMesh
}
}
{
IOobject io
typeIOobject<IOdictionary> io
(
"fvSolution",
mesh.time().system(),
@ -614,8 +614,7 @@ autoPtr<mapPolyMesh> createRegionMesh
false
);
if (!io.typeHeaderOk<IOdictionary>(true))
// if (!exists(io.objectPath()))
if (!io.headerOk())
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;

View File

@ -2,4 +2,5 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools