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

@ -1,4 +1,4 @@
IOobject phiBHeader typeIOobject<surfaceScalarField> phiBHeader
( (
"phiB", "phiB",
runTime.timeName(), runTime.timeName(),
@ -9,7 +9,7 @@ IOobject phiBHeader
surfaceScalarField* phiBPtr = nullptr; surfaceScalarField* phiBPtr = nullptr;
if (phiBHeader.typeHeaderOk<surfaceScalarField>(true)) if (phiBHeader.headerOk())
{ {
Info<< "Reading face flux "; Info<< "Reading face flux ";

View File

@ -56,7 +56,7 @@ volScalarField mu
Info<< "Constructing clouds" << endl; Info<< "Constructing clouds" << endl;
parcelCloudList clouds(rhoInf, U, mu, g); parcelCloudList clouds(rhoInf, U, mu, g);
IOobject Hheader typeIOobject<volVectorField> Hheader
( (
"H", "H",
runTime.timeName(), runTime.timeName(),
@ -67,14 +67,14 @@ IOobject Hheader
autoPtr<volVectorField> HPtr; autoPtr<volVectorField> HPtr;
if (Hheader.typeHeaderOk<volVectorField>(true)) if (Hheader.headerOk())
{ {
Info<< "\nReading field H\n" << endl; Info<< "\nReading field H\n" << endl;
HPtr.reset(new volVectorField (Hheader, mesh)); HPtr.reset(new volVectorField (Hheader, mesh));
} }
IOobject HdotGradHheader typeIOobject<volVectorField> HdotGradHheader
( (
"HdotGradH", "HdotGradH",
runTime.timeName(), runTime.timeName(),
@ -85,7 +85,7 @@ IOobject HdotGradHheader
autoPtr<volVectorField> HdotGradHPtr; autoPtr<volVectorField> HdotGradHPtr;
if (HdotGradHheader.typeHeaderOk<volVectorField>(true)) if (HdotGradHheader.headerOk())
{ {
Info<< "Reading field HdotGradH" << endl; Info<< "Reading field HdotGradH" << endl;

View File

@ -1,6 +1,6 @@
Info<< "Reading non-inertial frame fields" << endl; Info<< "Reading non-inertial frame fields" << endl;
IOobject linearAccelerationHeader typeIOobject<uniformDimensionedVectorField> linearAccelerationHeader
( (
"linearAcceleration", "linearAcceleration",
runTime.timeName(), runTime.timeName(),
@ -11,13 +11,7 @@
autoPtr<uniformDimensionedVectorField> linearAccelerationPtr; autoPtr<uniformDimensionedVectorField> linearAccelerationPtr;
if if (linearAccelerationHeader.headerOk())
(
linearAccelerationHeader.typeHeaderOk<uniformDimensionedVectorField>
(
true
)
)
{ {
Info<< " Reading " << linearAccelerationHeader.name() << endl; Info<< " Reading " << linearAccelerationHeader.name() << endl;
@ -28,7 +22,7 @@
} }
IOobject angularVelocityHeader typeIOobject<uniformDimensionedVectorField> angularVelocityHeader
( (
"angularVelocity", "angularVelocity",
runTime.timeName(), runTime.timeName(),
@ -39,7 +33,7 @@
autoPtr<uniformDimensionedVectorField> angularVelocityPtr; autoPtr<uniformDimensionedVectorField> angularVelocityPtr;
if (angularVelocityHeader.typeHeaderOk<uniformDimensionedVectorField>(true)) if (angularVelocityHeader.headerOk())
{ {
Info<< " Reading " << angularVelocityHeader.name() << endl; Info<< " Reading " << angularVelocityHeader.name() << endl;
@ -50,7 +44,7 @@
} }
IOobject angularAccelerationHeader typeIOobject<uniformDimensionedVectorField> angularAccelerationHeader
( (
"angularAcceleration", "angularAcceleration",
runTime.timeName(), runTime.timeName(),
@ -61,13 +55,7 @@
autoPtr<uniformDimensionedVectorField> angularAccelerationPtr; autoPtr<uniformDimensionedVectorField> angularAccelerationPtr;
if if (angularAccelerationHeader.headerOk())
(
angularAccelerationHeader.typeHeaderOk<uniformDimensionedVectorField>
(
true
)
)
{ {
Info<< " Reading " << angularAccelerationHeader.name() << endl; Info<< " Reading " << angularAccelerationHeader.name() << endl;
@ -78,7 +66,7 @@
} }
IOobject centreOfRotationHeader typeIOobject<uniformDimensionedVectorField> centreOfRotationHeader
( (
"centreOfRotation", "centreOfRotation",
runTime.timeName(), runTime.timeName(),
@ -89,13 +77,7 @@
autoPtr<uniformDimensionedVectorField> centreOfRotationPtr; autoPtr<uniformDimensionedVectorField> centreOfRotationPtr;
if if (centreOfRotationHeader.headerOk())
(
centreOfRotationHeader.typeHeaderOk<uniformDimensionedVectorField>
(
true
)
)
{ {
Info<< " Reading " << centreOfRotationHeader.name() << endl; Info<< " Reading " << centreOfRotationHeader.name() << endl;

View File

@ -46,7 +46,7 @@ Foam::IOobject Foam::twoPhaseChangeModel::createIOobject
const compressibleTwoPhaseMixture& mixture const compressibleTwoPhaseMixture& mixture
) const ) const
{ {
IOobject io typeIOobject<IOdictionary> io
( (
phaseChangePropertiesName, phaseChangePropertiesName,
mixture.alpha1().mesh().time().constant(), mixture.alpha1().mesh().time().constant(),
@ -55,7 +55,7 @@ Foam::IOobject Foam::twoPhaseChangeModel::createIOobject
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
io.readOpt() = IOobject::MUST_READ_IF_MODIFIED; io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
return io; return io;

View File

@ -32,7 +32,7 @@ Foam::autoPtr<Foam::twoPhaseChangeModel> Foam::twoPhaseChangeModel::New
const compressibleTwoPhaseMixture& mixture const compressibleTwoPhaseMixture& mixture
) )
{ {
IOobject twoPhaseChangeModelIO typeIOobject<IOdictionary> twoPhaseChangeModelIO
( (
IOobject IOobject
( (
@ -47,7 +47,7 @@ Foam::autoPtr<Foam::twoPhaseChangeModel> Foam::twoPhaseChangeModel::New
word modelType(twoPhaseChangeModels::noPhaseChange::typeName); word modelType(twoPhaseChangeModels::noPhaseChange::typeName);
if (twoPhaseChangeModelIO.typeHeaderOk<IOdictionary>(false)) if (twoPhaseChangeModelIO.headerOk())
{ {
IOdictionary(twoPhaseChangeModelIO).lookup IOdictionary(twoPhaseChangeModelIO).lookup
( (

View File

@ -44,7 +44,7 @@ Foam::MovingPhaseModel<BasePhaseModel>::phi(const volVectorField& U) const
{ {
word phiName(IOobject::groupName("phi", this->name())); word phiName(IOobject::groupName("phi", this->name()));
IOobject phiHeader typeIOobject<surfaceScalarField> phiHeader
( (
phiName, phiName,
U.mesh().time().timeName(), U.mesh().time().timeName(),
@ -52,7 +52,7 @@ Foam::MovingPhaseModel<BasePhaseModel>::phi(const volVectorField& U) const
IOobject::NO_READ IOobject::NO_READ
); );
if (phiHeader.typeHeaderOk<surfaceScalarField>(true)) if (phiHeader.headerOk())
{ {
Info<< "Reading face flux field " << phiName << endl; Info<< "Reading face flux field " << phiName << endl;

View File

@ -639,7 +639,7 @@ int main(int argc, char *argv[])
Info<< "Checking for motionProperties\n" << endl; Info<< "Checking for motionProperties\n" << endl;
IOobject motionObj typeIOobject<IOdictionary> motionObj
( (
"motionProperties", "motionProperties",
runTime.constant(), runTime.constant(),
@ -651,7 +651,7 @@ int main(int argc, char *argv[])
// corrector for mesh motion // corrector for mesh motion
twoDPointCorrector* correct2DPtr = nullptr; twoDPointCorrector* correct2DPtr = nullptr;
if (motionObj.typeHeaderOk<IOdictionary>(true)) if (motionObj.headerOk())
{ {
Info<< "Reading " << runTime.constant() / "motionProperties" Info<< "Reading " << runTime.constant() / "motionProperties"
<< endl << endl; << endl << endl;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -230,7 +230,7 @@ int main(int argc, char *argv[])
// Refinement level // Refinement level
IOobject refHeader typeIOobject<labelIOList> refHeader
( (
"refinementLevel", "refinementLevel",
runTime.timeName(), runTime.timeName(),
@ -238,7 +238,7 @@ int main(int argc, char *argv[])
runTime runTime
); );
if (!readLevel && refHeader.typeHeaderOk<labelIOList>(true)) if (!readLevel && refHeader.headerOk())
{ {
WarningInFunction WarningInFunction
<< "Detected " << refHeader.name() << " file in " << "Detected " << refHeader.name() << " file in "

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -74,7 +74,7 @@ Foam::edgeStats::edgeStats(const polyMesh& mesh)
mesh_(mesh), mesh_(mesh),
normalDir_(3) normalDir_(3)
{ {
IOobject motionObj typeIOobject<IOdictionary> motionObj
( (
"motionProperties", "motionProperties",
mesh.time().constant(), mesh.time().constant(),
@ -83,7 +83,7 @@ Foam::edgeStats::edgeStats(const polyMesh& mesh)
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (motionObj.typeHeaderOk<IOdictionary>(true)) if (motionObj.headerOk())
{ {
Info<< "Reading " << mesh.time().constant() / "motionProperties" Info<< "Reading " << mesh.time().constant() / "motionProperties"
<< endl << endl; << endl << endl;

View File

@ -8,7 +8,7 @@
&& runTime.timeName() != "0" && runTime.timeName() != "0"
) )
{ {
IOobject io typeIOobject<IOdictionary> io
( (
"time", "time",
runTime.timeName(), runTime.timeName(),
@ -19,7 +19,7 @@
false false
); );
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
IOdictionary timeObject IOdictionary timeObject
( (

View File

@ -8,7 +8,7 @@
&& runTime.timeName() != "0" && runTime.timeName() != "0"
) )
{ {
IOobject io typeIOobject<IOdictionary> io
( (
"time", "time",
runTime.timeName(), runTime.timeName(),
@ -19,7 +19,7 @@
false false
); );
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
IOdictionary timeObject IOdictionary timeObject
( (

View File

@ -149,9 +149,12 @@ int main(int argc, char *argv[])
} }
} }
IOobject meshDictIO(systemDictIO(dictName, args, runTime, regionName)); typeIOobject<IOdictionary> meshDictIO
(
systemDictIO(dictName, args, runTime, regionName)
);
if (!meshDictIO.typeHeaderOk<IOdictionary>(true)) if (!meshDictIO.headerOk())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Cannot find file " << meshDictIO.relativeObjectPath() << "Cannot find file " << meshDictIO.relativeObjectPath()

View File

@ -84,7 +84,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
{ {
// Create dummy system/fv* // Create dummy system/fv*
{ {
IOobject io typeIOobject<IOdictionary> io
( (
"fvSchemes", "fvSchemes",
mesh.time().system(), mesh.time().system(),
@ -95,9 +95,9 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
false false
); );
Info<< "Testing:" << io.objectPath<IOdictionary>() << endl; Info<< "Testing:" << io.objectPath() << endl;
if (!io.typeHeaderOk<IOdictionary>(false)) if (!io.headerOk())
{ {
Info<< "Writing dummy " << regionName/io.name() << endl; Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict; dictionary dummyDict;
@ -112,7 +112,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
} }
} }
{ {
IOobject io typeIOobject<IOdictionary> io
( (
"fvSolution", "fvSolution",
mesh.time().system(), mesh.time().system(),
@ -123,7 +123,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
false false
); );
if (!io.typeHeaderOk<IOdictionary>(false)) if (!io.headerOk())
{ {
Info<< "Writing dummy " << regionName/io.name() << endl; Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict; dictionary dummyDict;

View File

@ -342,7 +342,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
{ {
// Create dummy system/fv* // Create dummy system/fv*
{ {
IOobject io typeIOobject<IOdictionary> io
( (
"fvSchemes", "fvSchemes",
mesh.time().system(), mesh.time().system(),
@ -353,9 +353,9 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
false 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; Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict; dictionary dummyDict;
@ -370,7 +370,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
} }
} }
{ {
IOobject io typeIOobject<IOdictionary> io
( (
"fvSolution", "fvSolution",
mesh.time().system(), mesh.time().system(),
@ -381,7 +381,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
false false
); );
if (!io.typeHeaderOk<IOdictionary>(true)) if (!io.headerOk())
{ {
Info<< "Writing dummy " << regionName/io.name() << endl; Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict; dictionary dummyDict;
@ -2492,7 +2492,7 @@ int main(int argc, char *argv[])
{ {
autoPtr<pointIOField> patchFaceCentresPtr; autoPtr<pointIOField> patchFaceCentresPtr;
IOobject io typeIOobject<pointIOField> io
( (
"patchFaceCentres", "patchFaceCentres",
mesh.pointsInstance(), mesh.pointsInstance(),
@ -2500,7 +2500,8 @@ int main(int argc, char *argv[])
mesh, mesh,
IOobject::MUST_READ IOobject::MUST_READ
); );
if (io.typeHeaderOk<pointIOField>(true))
if (io.headerOk())
{ {
// Read patchFaceCentres and patchEdgeCentres // Read patchFaceCentres and patchEdgeCentres
Info<< "Reading patch face,edge centres : " Info<< "Reading patch face,edge centres : "

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -65,7 +65,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
IOobject Uheader typeIOobject<volVectorField> Uheader
( (
"U", "U",
runTime.timeName(), runTime.timeName(),
@ -74,7 +74,7 @@ int main(int argc, char *argv[])
); );
// Check U exists // Check U exists
if (Uheader.typeHeaderOk<volVectorField>(true)) if (Uheader.headerOk())
{ {
Info<< " Reading U" << endl; Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh); volVectorField U(Uheader, mesh);

View File

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

View File

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

View File

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

View File

@ -89,7 +89,7 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
bool writeOk = false; bool writeOk = false;
if (io.typeHeaderOk<meshCellZones>(false)) if (io.headerOk())
{ {
Info<< " Reading " << io.headerClassName() Info<< " Reading " << io.headerClassName()
<< " : " << name << endl; << " : " << name << endl;
@ -199,7 +199,7 @@ bool writeOptionalMeshObject
bool writeOk = false; bool writeOk = false;
bool haveFile = io.typeHeaderOk<IOField<label>>(false); bool haveFile = io.headerOk();
// Make sure all know if there is a valid class name // Make sure all know if there is a valid class name
stringList classNames(1, io.headerClassName()); stringList classNames(1, io.headerClassName());

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -48,7 +48,7 @@ inline bool writeMeshObject
bool disableHeaderChecking = false bool disableHeaderChecking = false
) )
{ {
IOobject io typeIOobject<CheckType> io
( (
name, name,
runTime.timeName(), runTime.timeName(),
@ -61,11 +61,7 @@ inline bool writeMeshObject
bool writeOk = false; bool writeOk = false;
if if (io.headerOk())
(
io.typeHeaderOk<Type>(false)
&& io.headerClassName() == CheckType::typeName
)
{ {
Info<< " Reading " << io.headerClassName() Info<< " Reading " << io.headerClassName()
<< " : " << name << endl; << " : " << name << endl;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -106,7 +106,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ IOobject::MUST_READ
); );
if (obj.typeHeaderOk<volScalarField>(false)) if (obj.headerOk())
{ {
addToFieldList(vsf, obj, objI, mesh); addToFieldList(vsf, obj, objI, mesh);
addToFieldList(vvf, obj, objI, mesh); addToFieldList(vvf, obj, objI, mesh);

View File

@ -382,7 +382,7 @@ int main(int argc, char *argv[])
label nProcs = fileHandler().nProcs(runTime.path(), regionDir); label nProcs = fileHandler().nProcs(runTime.path(), regionDir);
// Get the dictionary IO // Get the dictionary IO
const IOobject dictIO const typeIOobject<IOdictionary> dictIO
( (
systemDictIO(dictName, args, runTime, regionName) systemDictIO(dictName, args, runTime, regionName)
); );
@ -432,13 +432,13 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
dictIO.objectPath<domainDecomposition>() dictIO.objectPath()
); );
// Decompose the mesh // Decompose the mesh
if (!decomposeFieldsOnly) if (!decomposeFieldsOnly)
{ {
mesh.decomposeMesh(dictIO.objectPath<domainDecomposition>()); mesh.decomposeMesh(dictIO.objectPath());
mesh.writeDecomposition(decomposeSets); mesh.writeDecomposition(decomposeSets);

View File

@ -331,9 +331,8 @@ int main(int argc, char *argv[])
// Problem: faceCompactIOList recognises both 'faceList' and // Problem: faceCompactIOList recognises both 'faceList' and
// 'faceCompactList' so we should be lenient when doing // 'faceCompactList' so we cannot check the type
// typeHeaderOk if (!facesIO.headerOk())
if (!facesIO.typeHeaderOk<faceCompactIOList>(false))
{ {
Info<< "No mesh." << nl << endl; Info<< "No mesh." << nl << endl;
continue; continue;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -586,13 +586,13 @@ double* Foam::vtkPVFoam::findTimes(int& nTimeSteps)
if if
( (
IOobject typeIOobject<pointIOField>
( (
"points", "points",
timeName, timeName,
meshDir_, meshDir_,
runTime runTime
).typeHeaderOk<pointIOField>(true) ).headerOk()
) )
{ {
break; break;

View File

@ -120,7 +120,7 @@ void Foam::vtkPVFoam::convertFields(vtkMultiBlockDataSet* output)
forAllConstIter(IOobjectList, objects, iter) forAllConstIter(IOobjectList, objects, iter)
{ {
Info<< " " << iter()->name() Info<< " " << iter()->name()
<< " == " << iter()->objectPath<volScalarField>() << nl; << " == " << iter()->objectPath(false) << nl;
} }
printMemory(); printMemory();
} }

View File

@ -124,7 +124,7 @@ Foam::wordList Foam::vtkPVFoam::getZoneNames(const word& zoneType) const
false false
); );
if (ioObj.typeHeaderOk<meshCellZones>(false)) if (ioObj.headerOk())
{ {
zonesEntries zones(ioObj); zonesEntries zones(ioObj);
@ -321,7 +321,7 @@ void Foam::vtkPVFoam::updateInfoPatches
{ {
// Mesh not loaded - read from file // Mesh not loaded - read from file
// but this could fail if we've supplied a bad region name // but this could fail if we've supplied a bad region name
IOobject ioObj typeIOobject<polyBoundaryMesh> ioObj
( (
"boundary", "boundary",
dbPtr_().findInstance dbPtr_().findInstance
@ -338,7 +338,7 @@ void Foam::vtkPVFoam::updateInfoPatches
); );
// This should only ever fail if the mesh region doesn't exist // This should only ever fail if the mesh region doesn't exist
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true)) if (ioObj.headerOk())
{ {
polyBoundaryMeshEntries patchEntries(ioObj); polyBoundaryMeshEntries patchEntries(ioObj);

View File

@ -171,7 +171,7 @@ int USERD_set_filenames
false false
); );
if (sprayHeader.typeHeaderOk<Cloud<passiveParticle>>(false)) if (sprayHeader.headerOk())
{ {
Info<< "[Found lagrangian]" << endl; Info<< "[Found lagrangian]" << endl;

View File

@ -1,10 +1,9 @@
if (nVar >= Num_variables - nSprayVariables) if (nVar >= Num_variables - nSprayVariables)
{ {
return Z_UNDEF; return Z_UNDEF;
} }
IOobject fieldObjectPtr typeIOobject<volScalarField> fieldObjectPtr
( (
fieldNames[var2field[nVar]], fieldNames[var2field[nVar]],
runTime.timeName(), runTime.timeName(),
@ -12,7 +11,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ IOobject::NO_READ
); );
if (!fieldObjectPtr.typeHeaderOk<volScalarField>(true)) if (!fieldObjectPtr.headerOk())
{ {
return Z_UNDEF; return Z_UNDEF;
} }

View File

@ -4,7 +4,7 @@ if (nVar >= Num_variables - nSprayVariables)
} }
IOobject fieldObjectPtr typeIOobject<volTensorField> fieldObjectPtr
( (
fieldNames[var2field[nVar]], fieldNames[var2field[nVar]],
runTime.timeName(), runTime.timeName(),
@ -12,7 +12,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ IOobject::NO_READ
); );
if (!fieldObjectPtr.typeHeaderOk<volTensorField>(true)) if (!fieldObjectPtr.headerOk())
{ {
return Z_UNDEF; return Z_UNDEF;
} }

View File

@ -4,7 +4,7 @@ if (nVar >= Num_variables - nSprayVariables)
} }
IOobject fieldObjectPtr typeIOobject<volVectorField> fieldObjectPtr
( (
fieldNames[var2field[nVar]], fieldNames[var2field[nVar]],
runTime.timeName(), runTime.timeName(),
@ -12,7 +12,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ IOobject::NO_READ
); );
if (!fieldObjectPtr.typeHeaderOk<volVectorField>(true)) if (!fieldObjectPtr.headerOk())
{ {
return Z_UNDEF; return Z_UNDEF;
} }

View File

@ -5,7 +5,7 @@ if (nVar >= Num_variables - nSprayVariables)
return Z_UNDEF; return Z_UNDEF;
} }
IOobject fieldObjectPtr typeIOobject<volScalarField> fieldObjectPtr
( (
fieldNames[var2field[nVar]], fieldNames[var2field[nVar]],
runTime.timeName(), runTime.timeName(),
@ -13,7 +13,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ IOobject::NO_READ
); );
if (!fieldObjectPtr.typeHeaderOk<volScalarField>(true)) if (!fieldObjectPtr.headerOk())
{ {
return Z_UNDEF; return Z_UNDEF;
} }

View File

@ -5,7 +5,7 @@ if (nVar >= Num_variables - nSprayVariables)
return Z_UNDEF; return Z_UNDEF;
} }
IOobject fieldObjectPtr typeIOobject<volTensorField> fieldObjectPtr
( (
fieldNames[var2field[nVar]], fieldNames[var2field[nVar]],
runTime.timeName(), runTime.timeName(),
@ -13,7 +13,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ IOobject::NO_READ
); );
if (!fieldObjectPtr.typeHeaderOk<volTensorField>(true)) if (!fieldObjectPtr.headerOk())
{ {
return Z_UNDEF; return Z_UNDEF;
} }

View File

@ -5,7 +5,7 @@ if (nVar >= Num_variables - nSprayVariables)
return Z_UNDEF; return Z_UNDEF;
} }
IOobject fieldObjectPtr typeIOobject<volVectorField> fieldObjectPtr
( (
fieldNames[var2field[nVar]], fieldNames[var2field[nVar]],
runTime.timeName(), runTime.timeName(),
@ -13,7 +13,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ IOobject::NO_READ
); );
if (!fieldObjectPtr.typeHeaderOk<volVectorField>(true)) if (!fieldObjectPtr.headerOk())
{ {
return Z_UNDEF; return Z_UNDEF;
} }

View File

@ -1,4 +1,4 @@
IOobject UMeanHeader typeIOobject<volVectorField> UMeanHeader
( (
"UMean", "UMean",
runTime.timeName(), runTime.timeName(),
@ -6,7 +6,7 @@
IOobject::MUST_READ IOobject::MUST_READ
); );
if (!UMeanHeader.typeHeaderOk<volVectorField>(true)) if (!UMeanHeader.headerOk())
{ {
Info<< " No UMean field" << endl; Info<< " No UMean field" << endl;
continue; continue;

View File

@ -174,7 +174,7 @@ int main(int argc, char *argv[])
epsilon.write(); epsilon.write();
// Turbulence omega // Turbulence omega
IOobject omegaHeader typeIOobject<volScalarField> omegaHeader
( (
"omega", "omega",
runTime.timeName(), runTime.timeName(),
@ -184,7 +184,7 @@ int main(int argc, char *argv[])
false false
); );
if (omegaHeader.typeHeaderOk<volScalarField>(true)) if (omegaHeader.headerOk())
{ {
volScalarField omega(omegaHeader, mesh); volScalarField omega(omegaHeader, mesh);
@ -202,7 +202,7 @@ int main(int argc, char *argv[])
} }
// Turbulence nuTilda // Turbulence nuTilda
IOobject nuTildaHeader typeIOobject<volScalarField> nuTildaHeader
( (
"nuTilda", "nuTilda",
runTime.timeName(), runTime.timeName(),
@ -212,7 +212,7 @@ int main(int argc, char *argv[])
false false
); );
if (nuTildaHeader.typeHeaderOk<volScalarField>(true)) if (nuTildaHeader.headerOk())
{ {
volScalarField nuTilda(nuTildaHeader, mesh); volScalarField nuTilda(nuTildaHeader, mesh);
nuTilda = nut; nuTilda = nut;

View File

@ -1,4 +1,4 @@
EXE_INC = \ EXE_INC = -ggdb3 \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -59,7 +59,7 @@ void MapConsistentVolFields
// Read field // Read field
fieldType fieldSource(*fieldIter(), meshSource); fieldType fieldSource(*fieldIter(), meshSource);
IOobject fieldTargetIOobject typeIOobject<fieldType> fieldTargetIOobject
( (
fieldIter()->name(), fieldIter()->name(),
meshTarget.time().timeName(), meshTarget.time().timeName(),
@ -68,7 +68,7 @@ void MapConsistentVolFields
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
); );
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true)) if (fieldTargetIOobject.headerOk())
{ {
// Read fieldTarget // Read fieldTarget
fieldType fieldTarget fieldType fieldTarget

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -53,7 +53,7 @@ void MapVolFields
forAllIter(IOobjectList, fields, fieldIter) forAllIter(IOobjectList, fields, fieldIter)
{ {
IOobject fieldTargetIOobject typeIOobject<fieldType> fieldTargetIOobject
( (
fieldIter()->name(), fieldIter()->name(),
meshTarget.time().timeName(), meshTarget.time().timeName(),
@ -62,7 +62,7 @@ void MapVolFields
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
); );
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true)) if (fieldTargetIOobject.headerOk())
{ {
Info<< " interpolating " << fieldIter()->name() << endl; Info<< " interpolating " << fieldIter()->name() << endl;

View File

@ -41,7 +41,7 @@ void UnMapped(const IOobjectList& objects)
forAllConstIter(IOobjectList, fields, fieldIter) forAllConstIter(IOobjectList, fields, fieldIter)
{ {
mvBak(fieldIter()->objectPath<Type>(), "unmapped"); mvBak(fieldIter()->objectPath(false), "unmapped");
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -141,7 +141,7 @@ void MapVolFields
{ {
const fieldType fieldSource(*fieldIter(), meshSource); const fieldType fieldSource(*fieldIter(), meshSource);
IOobject targetIO typeIOobject<fieldType> targetIO
( (
fieldName, fieldName,
meshTarget.time().timeName(), meshTarget.time().timeName(),
@ -149,7 +149,7 @@ void MapVolFields
IOobject::MUST_READ IOobject::MUST_READ
); );
if (targetIO.typeHeaderOk<fieldType>(true)) if (targetIO.headerOk())
{ {
Info<< " interpolating onto existing field " Info<< " interpolating onto existing field "
<< fieldName << endl; << fieldName << endl;

View File

@ -41,7 +41,7 @@ void UnMapped(const IOobjectList& objects)
forAllConstIter(IOobjectList, fields, fieldIter) forAllConstIter(IOobjectList, fields, fieldIter)
{ {
mvBak(fieldIter()->objectPath<Type>(), "unmapped"); mvBak(fieldIter()->objectPath(false), "unmapped");
} }
} }

View File

@ -58,7 +58,7 @@ bool setCellFieldType
word fieldName(fieldValueStream); word fieldName(fieldValueStream);
// Check the current time directory // Check the current time directory
IOobject fieldHeader typeIOobject<fieldType> fieldHeader
( (
fieldName, fieldName,
mesh.time().timeName(), mesh.time().timeName(),
@ -67,9 +67,9 @@ bool setCellFieldType
); );
// Check the "constant" directory // Check the "constant" directory
if (!fieldHeader.typeHeaderOk<fieldType>(true)) if (!fieldHeader.headerOk())
{ {
fieldHeader = IOobject fieldHeader = typeIOobject<fieldType>
( (
fieldName, fieldName,
mesh.time().constant(), mesh.time().constant(),
@ -79,7 +79,7 @@ bool setCellFieldType
} }
// Check field exists // Check field exists
if (fieldHeader.typeHeaderOk<fieldType>(true)) if (fieldHeader.headerOk())
{ {
Info<< " Setting internal values of " Info<< " Setting internal values of "
<< fieldHeader.headerClassName() << fieldHeader.headerClassName()
@ -204,7 +204,7 @@ bool setFaceFieldType
word fieldName(fieldValueStream); word fieldName(fieldValueStream);
// Check the current time directory // Check the current time directory
IOobject fieldHeader typeIOobject<fieldType> fieldHeader
( (
fieldName, fieldName,
mesh.time().timeName(), mesh.time().timeName(),
@ -213,9 +213,9 @@ bool setFaceFieldType
); );
// Check the "constant" directory // Check the "constant" directory
if (!fieldHeader.typeHeaderOk<fieldType>(true)) if (!fieldHeader.headerOk())
{ {
fieldHeader = IOobject fieldHeader = typeIOobject<fieldType>
( (
fieldName, fieldName,
mesh.time().constant(), mesh.time().constant(),
@ -225,7 +225,7 @@ bool setFaceFieldType
} }
// Check field exists // Check field exists
if (fieldHeader.typeHeaderOk<fieldType>(true)) if (fieldHeader.headerOk())
{ {
Info<< " Setting patchField values of " Info<< " Setting patchField values of "
<< fieldHeader.headerClassName() << fieldHeader.headerClassName()

View File

@ -156,7 +156,7 @@ int main(int argc, char *argv[])
Pstream::scatterList(meshBb); Pstream::scatterList(meshBb);
} }
IOobject io typeIOobject<searchableSurface> io
( (
surfFileName, surfFileName,
runTime.constant(), runTime.constant(),
@ -167,7 +167,7 @@ int main(int argc, char *argv[])
); );
// Look for file (using searchableSurface rules) // Look for file (using searchableSurface rules)
const fileName actualPath(typeFilePath<searchableSurface>(io)); const fileName actualPath(io.filePath());
fileName localPath(actualPath); fileName localPath(actualPath);
localPath.replace(runTime.rootPath() + '/', ""); localPath.replace(runTime.rootPath() + '/', "");

View File

@ -159,7 +159,7 @@ Maxwell<BasicMomentumTransportModel>::Maxwell
forAll(sigmas_, modei) forAll(sigmas_, modei)
{ {
IOobject header typeIOobject<volSymmTensorField> header
( (
IOobject::groupName("sigma" + name(modei), alphaRhoPhi.group()), IOobject::groupName("sigma" + name(modei), alphaRhoPhi.group()),
this->runTime_.timeName(), this->runTime_.timeName(),
@ -168,7 +168,7 @@ Maxwell<BasicMomentumTransportModel>::Maxwell
); );
// Check if mode field exists and can be read // Check if mode field exists and can be read
if (header.typeHeaderOk<volSymmTensorField>(true)) if (header.headerOk())
{ {
Info<< " Reading mode stress field " Info<< " Reading mode stress field "
<< header.name() << endl; << header.name() << endl;

View File

@ -45,7 +45,7 @@ Foam::IOdictionary Foam::momentumTransportModel::readModelDict
bool registerObject bool registerObject
) )
{ {
IOobject momentumTransport typeIOobject<IOdictionary> momentumTransport
( (
IOobject::groupName(typeName, group), IOobject::groupName(typeName, group),
obr.time().constant(), obr.time().constant(),
@ -55,13 +55,13 @@ Foam::IOdictionary Foam::momentumTransportModel::readModelDict
registerObject registerObject
); );
if (momentumTransport.typeHeaderOk<IOdictionary>(true)) if (momentumTransport.headerOk())
{ {
return momentumTransport; return momentumTransport;
} }
else else
{ {
IOobject turbulenceProperties typeIOobject<IOdictionary> turbulenceProperties
( (
IOobject::groupName("turbulenceProperties", group), IOobject::groupName("turbulenceProperties", group),
obr.time().constant(), obr.time().constant(),
@ -71,7 +71,7 @@ Foam::IOdictionary Foam::momentumTransportModel::readModelDict
registerObject registerObject
); );
if (turbulenceProperties.typeHeaderOk<IOdictionary>(true)) if (turbulenceProperties.headerOk())
{ {
return turbulenceProperties; return turbulenceProperties;
} }

View File

@ -61,6 +61,13 @@ Description
- \par NO_WRITE - \par NO_WRITE
No automatic write on destruction but can be written explicitly No automatic write on destruction but can be written explicitly
Class
Foam::typeIOobject
Description
Templated form of IOobject providing type information for file reading and
header type checking.
SourceFiles SourceFiles
IOobject.C IOobject.C
IOobjectReadHeader.C IOobjectReadHeader.C
@ -134,6 +141,7 @@ public:
static const NamedEnum<fileCheckTypes, 4> fileCheckTypesNames; static const NamedEnum<fileCheckTypes, 4> fileCheckTypesNames;
private: private:
// Private Data // Private Data
@ -176,6 +184,11 @@ protected:
//- Set the object state to bad //- Set the object state to bad
void setBad(const string&); void setBad(const string&);
//- Read header using typeGlobalFile to find file
// and optionally check the headerClassName against Type
template<class Type>
bool typeHeaderOk(const bool checkType);
public: public:
@ -411,11 +424,6 @@ public:
return path(global)/name(); return path(global)/name();
} }
//- Return complete path + object name including the processor
// sub-directory for a parallel run if globalFile is false for Type
template<class Type>
inline fileName objectPath() const;
//- Return the path relative to the case directory //- Return the path relative to the case directory
fileName relativePath() const; fileName relativePath() const;
@ -438,10 +446,9 @@ public:
//- Read header //- Read header
bool readHeader(Istream&); bool readHeader(Istream&);
//- Read header (uses typeFilePath to find file) and check header //- Read header of local object without type-checking
// info. Optionally checks headerClassName against type // Mainly used to create IOobjectLists
template<class Type> bool headerOk();
bool typeHeaderOk(const bool checkType = true);
//- Helper: warn that type does not support re-reading //- Helper: warn that type does not support re-reading
template<class Type> template<class Type>
@ -516,19 +523,6 @@ inline bool typeGlobalFile()
return typeGlobal<Type>(); return typeGlobal<Type>();
} }
//- Template function for obtaining filePath
template<class Type>
inline fileName typeFilePath(const IOobject& io)
{
return io.filePath(Type::typeName, typeGlobalFile<Type>());
}
template<class Type>
inline fileName IOobject::objectPath() const
{
return objectPath(typeGlobalFile<Type>());
}
inline IOobject unregister(const IOobject& io) inline IOobject unregister(const IOobject& io)
{ {
IOobject uio(io); IOobject uio(io);
@ -537,6 +531,53 @@ inline IOobject unregister(const IOobject& io)
} }
/*---------------------------------------------------------------------------*\
Class typeIOobject Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class typeIOobject
:
public IOobject
{
public:
// Constructors
using IOobject::IOobject;
typeIOobject(const IOobject& io)
:
IOobject(io)
{}
// Member Functions
// Reading
//- Read header (uses typeGlobalFile to find file) and check
bool headerOk();
using IOobject::objectPath;
//- Return the object path for this Type
inline fileName objectPath() const
{
return objectPath(typeGlobalFile<Type>());
}
using IOobject::filePath;
//- Return the path for the file for this Type
inline fileName filePath() const
{
return filePath(Type::typeName, typeGlobalFile<Type>());
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -28,6 +28,12 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool Foam::IOobject::headerOk()
{
return typeHeaderOk<IOobject>(false);
}
bool Foam::IOobject::readHeader(Istream& is) bool Foam::IOobject::readHeader(Istream& is)
{ {
if (IOobject::debug) if (IOobject::debug)

View File

@ -49,7 +49,10 @@ bool Foam::IOobject::typeHeaderOk(const bool checkType)
// Determine local status // Determine local status
if (!masterOnly || Pstream::master()) if (!masterOnly || Pstream::master())
{ {
const fileName fName(typeFilePath<Type>(*this)); const fileName fName
(
filePath(Type::typeName, typeGlobalFile<Type>())
);
ok = fp.readHeader(*this, fName, Type::typeName); ok = fp.readHeader(*this, fName, Type::typeName);
if (ok && checkType && headerClassName_ != Type::typeName) if (ok && checkType && headerClassName_ != Type::typeName)
@ -88,4 +91,11 @@ void Foam::IOobject::warnNoRereading() const
} }
template<class Type>
bool Foam::typeIOobject<Type>::headerOk()
{
return typeHeaderOk<Type>(true);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -26,7 +26,6 @@ License
#include "IOobjectList.H" #include "IOobjectList.H"
#include "Time.H" #include "Time.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "IOList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -57,7 +56,6 @@ Foam::IOobjectList::IOobjectList
newInstance newInstance
); );
forAll(ObjectNames, i) forAll(ObjectNames, i)
{ {
IOobject* objectPtr = new IOobject IOobject* objectPtr = new IOobject
@ -72,7 +70,7 @@ Foam::IOobjectList::IOobjectList
); );
// Use object with local scope // Use object with local scope
if (objectPtr->typeHeaderOk<IOList<label>>(false)) if (objectPtr->headerOk())
{ {
insert(ObjectNames[i], objectPtr); insert(ObjectNames[i], objectPtr);
} }

View File

@ -421,15 +421,15 @@ Foam::fileName Foam::regIOobject::filePath() const
bool Foam::regIOobject::headerOk() bool Foam::regIOobject::headerOk()
{ {
// Note: Should be consistent with IOobject::typeHeaderOk(false) // Note: Should be consistent with typeIOobject<Type>::headerOk()
bool ok = true; bool ok = true;
fileName fName(filePath()); const fileName fName(filePath());
ok = Foam::fileHandler().readHeader(*this, fName, type()); ok = Foam::fileHandler().readHeader(*this, fName, type());
if (!ok && IOobject::debug) if (IOobject::debug && (!ok || headerClassName() != type()))
{ {
IOWarningInFunction(fName) IOWarningInFunction(fName)
<< "failed to read header of file " << objectPath() << "failed to read header of file " << objectPath()

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -110,10 +110,7 @@ bool Foam::GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
else if else if
( (
this->readOpt() == IOobject::READ_IF_PRESENT this->readOpt() == IOobject::READ_IF_PRESENT
&& this->template typeHeaderOk<GeometricField<Type, PatchField, GeoMesh>> && this->headerOk()
(
true
)
) )
{ {
readFields(); readFields();
@ -141,7 +138,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
bool Foam::GeometricField<Type, PatchField, GeoMesh>::readOldTimeIfPresent() bool Foam::GeometricField<Type, PatchField, GeoMesh>::readOldTimeIfPresent()
{ {
// Read the old time field if present // Read the old time field if present
IOobject field0 typeIOobject<GeometricField<Type, PatchField, GeoMesh>> field0
( (
this->name() + "_0", this->name() + "_0",
this->time().timeName(), this->time().timeName(),
@ -151,13 +148,7 @@ bool Foam::GeometricField<Type, PatchField, GeoMesh>::readOldTimeIfPresent()
this->registerObject() this->registerObject()
); );
if if (field0.headerOk())
(
field0.template typeHeaderOk<GeometricField<Type, PatchField, GeoMesh>>
(
true
)
)
{ {
if (debug) if (debug)
{ {

View File

@ -370,9 +370,8 @@ bool Foam::fileOperation::exists(IOobject& io) const
} }
else else
{ {
ok = // IOobject::headerOk assumes local scope
isFile(objPath) ok = isFile(objPath) && io.headerOk();
&& io.typeHeaderOk<IOList<label>>(false);// object with local scope
} }
if (!ok) if (!ok)
@ -389,9 +388,8 @@ bool Foam::fileOperation::exists(IOobject& io) const
} }
else else
{ {
ok = // IOobject::headerOk assumes local scope
isFile(originalPath) ok = isFile(originalPath) && io.headerOk();
&& io.typeHeaderOk<IOList<label>>(false);
} }
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -1858,7 +1858,7 @@ const Foam::labelList& Foam::globalMeshData::sharedPointGlobalLabels() const
); );
labelList& sharedPointGlobalLabels = sharedPointGlobalLabelsPtr_(); labelList& sharedPointGlobalLabels = sharedPointGlobalLabelsPtr_();
IOobject addrHeader typeIOobject<labelIOList> addrHeader
( (
"pointProcAddressing", "pointProcAddressing",
mesh_.facesInstance()/mesh_.meshSubDir, mesh_.facesInstance()/mesh_.meshSubDir,
@ -1866,7 +1866,7 @@ const Foam::labelList& Foam::globalMeshData::sharedPointGlobalLabels() const
IOobject::MUST_READ IOobject::MUST_READ
); );
if (addrHeader.typeHeaderOk<labelIOList>(true)) if (addrHeader.headerOk())
{ {
// There is a pointProcAddressing file so use it to get labels // There is a pointProcAddressing file so use it to get labels
// on the original mesh // on the original mesh

View File

@ -137,7 +137,7 @@ void Foam::polyMesh::calcDirections() const
Foam::autoPtr<Foam::labelIOList> Foam::polyMesh::readTetBasePtIs() const Foam::autoPtr<Foam::labelIOList> Foam::polyMesh::readTetBasePtIs() const
{ {
IOobject io typeIOobject<labelIOList> io
( (
"tetBasePtIs", "tetBasePtIs",
instance(), instance(),
@ -147,7 +147,7 @@ Foam::autoPtr<Foam::labelIOList> Foam::polyMesh::readTetBasePtIs() const
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (io.typeHeaderOk<labelIOList>()) if (io.headerOk())
{ {
return autoPtr<labelIOList>(new labelIOList(io)); return autoPtr<labelIOList>(new labelIOList(io));
} }
@ -1250,7 +1250,7 @@ Foam::IOobject Foam::polyMesh::points0IO
{ {
// Check that points0 are actually in constant directory // Check that points0 are actually in constant directory
IOobject io typeIOobject<pointIOField> io
( (
"points0", "points0",
instance, instance,
@ -1261,7 +1261,7 @@ Foam::IOobject Foam::polyMesh::points0IO
false false
); );
if (io.typeHeaderOk<pointIOField>()) if (io.headerOk())
{ {
return io; return io;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,7 +46,7 @@ void Foam::preservePatchTypes
// Read boundary file as single dictionary // Read boundary file as single dictionary
{ {
IOobject patchEntriesHeader typeIOobject<polyBoundaryMeshEntries> patchEntriesHeader
( (
"boundary", "boundary",
meshInstance, meshInstance,
@ -57,7 +57,7 @@ void Foam::preservePatchTypes
false false
); );
if (patchEntriesHeader.typeHeaderOk<polyBoundaryMesh>(true)) if (patchEntriesHeader.headerOk())
{ {
// Create a list of entries from the boundary file. // Create a list of entries from the boundary file.
polyBoundaryMeshEntries patchEntries(patchEntriesHeader); polyBoundaryMeshEntries patchEntries(patchEntriesHeader);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -82,7 +82,7 @@ Foam::laminarThermophysicalTransportModel
const thermoModel& thermo const thermoModel& thermo
) )
{ {
IOobject header typeIOobject<IOdictionary> header
( (
IOobject::groupName IOobject::groupName
( (
@ -96,7 +96,7 @@ Foam::laminarThermophysicalTransportModel
false false
); );
if (header.typeHeaderOk<IOdictionary>(true)) if (header.headerOk())
{ {
IOdictionary modelDict(header); IOdictionary modelDict(header);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -82,7 +82,7 @@ Foam::LESThermophysicalTransportModel
const thermoModel& thermo const thermoModel& thermo
) )
{ {
IOobject header typeIOobject<IOdictionary> header
( (
IOobject::groupName IOobject::groupName
( (
@ -96,7 +96,7 @@ Foam::LESThermophysicalTransportModel
false false
); );
if (header.typeHeaderOk<IOdictionary>(true)) if (header.headerOk())
{ {
IOdictionary modelDict(header); IOdictionary modelDict(header);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -82,7 +82,7 @@ Foam::RASThermophysicalTransportModel
const thermoModel& thermo const thermoModel& thermo
) )
{ {
IOobject header typeIOobject<IOdictionary> header
( (
IOobject::groupName IOobject::groupName
( (
@ -96,7 +96,7 @@ Foam::RASThermophysicalTransportModel
false false
); );
if (header.typeHeaderOk<IOdictionary>(true)) if (header.headerOk())
{ {
IOdictionary modelDict(header); IOdictionary modelDict(header);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -47,7 +47,7 @@ Foam::IOobject Foam::combustionModel::createIOobject
const word& combustionProperties const word& combustionProperties
) const ) const
{ {
IOobject io typeIOobject<IOdictionary> io
( (
thermo.phasePropertyName(combustionProperties), thermo.phasePropertyName(combustionProperties),
thermo.T().mesh().time().constant(), thermo.T().mesh().time().constant(),
@ -56,7 +56,7 @@ Foam::IOobject Foam::combustionModel::createIOobject
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
io.readOpt() = IOobject::MUST_READ_IF_MODIFIED; io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
return io; return io;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -35,7 +35,7 @@ Foam::autoPtr<Foam::combustionModel> Foam::combustionModel::New
const word& combustionProperties const word& combustionProperties
) )
{ {
IOobject combIO typeIOobject<IOdictionary> combIO
( (
IOobject IOobject
( (
@ -49,7 +49,7 @@ Foam::autoPtr<Foam::combustionModel> Foam::combustionModel::New
); );
word modelType(combustionModels::noCombustion::typeName); word modelType(combustionModels::noCombustion::typeName);
if (combIO.typeHeaderOk<IOdictionary>(false)) if (combIO.headerOk())
{ {
IOdictionary(combIO).lookup(combustionModel::typeName) >> modelType; IOdictionary(combIO).lookup(combustionModel::typeName) >> modelType;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,9 +30,9 @@ License
Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io) Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
{ {
IOobject dictHeader(dynamicMeshDictIOobject(io)); typeIOobject<IOdictionary> dictHeader(dynamicMeshDictIOobject(io));
if (dictHeader.typeHeaderOk<IOdictionary>(true)) if (dictHeader.headerOk())
{ {
IOdictionary dict(dictHeader); IOdictionary dict(dictHeader);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -111,19 +111,16 @@ Foam::componentDisplacementMotionSolver::componentDisplacementMotionSolver
<< "Number of points in mesh " << mesh.nPoints() << "Number of points in mesh " << mesh.nPoints()
<< " differs from number of points " << points0_.size() << " differs from number of points " << points0_.size()
<< " read from file " << " read from file "
<< typeFilePath<pointIOField> << typeIOobject<pointIOField>
( (
IOobject "points",
( mesh.time().constant(),
"points", polyMesh::meshSubDir,
mesh.time().constant(), mesh,
polyMesh::meshSubDir, IOobject::MUST_READ,
mesh, IOobject::NO_WRITE,
IOobject::MUST_READ, false
IOobject::NO_WRITE, ).filePath()
false
)
)
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -51,19 +51,16 @@ Foam::points0MotionSolver::points0MotionSolver
<< "Number of points in mesh " << mesh.nPoints() << "Number of points in mesh " << mesh.nPoints()
<< " differs from number of points " << points0_.size() << " differs from number of points " << points0_.size()
<< " read from file " << " read from file "
<< typeFilePath<pointIOField> << typeIOobject<pointIOField>
( (
IOobject "points",
( mesh.time().constant(),
"points", polyMesh::meshSubDir,
mesh.time().constant(), mesh,
polyMesh::meshSubDir, IOobject::MUST_READ,
mesh, IOobject::NO_WRITE,
IOobject::MUST_READ, false
IOobject::NO_WRITE, ).filePath()
false
)
)
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -52,7 +52,7 @@ Foam::dynamicMeshPointInterpolator::dynamicMeshPointInterpolator
forAll(allTimes, i) forAll(allTimes, i)
{ {
IOobject io typeIOobject<pointVectorField> io
( (
fieldName_, fieldName_,
allTimes[i].name(), allTimes[i].name(),
@ -61,7 +61,8 @@ Foam::dynamicMeshPointInterpolator::dynamicMeshPointInterpolator
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
); );
if (io.typeHeaderOk<pointVectorField>(false))
if (io.headerOk())
{ {
names.append(allTimes[i].name()); names.append(allTimes[i].name());
values.append(allTimes[i].value()); values.append(allTimes[i].value());

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,11 +39,11 @@ License
Foam::hexRef8Data::hexRef8Data(const IOobject& io) Foam::hexRef8Data::hexRef8Data(const IOobject& io)
{ {
{ {
IOobject rio(io); typeIOobject<labelIOList> rio(io);
rio.rename("cellLevel"); rio.rename("cellLevel");
bool haveFile = returnReduce bool haveFile = returnReduce
( (
rio.typeHeaderOk<labelIOList>(true), rio.headerOk(),
orOp<bool>() orOp<bool>()
); );
if (haveFile) if (haveFile)
@ -53,11 +53,11 @@ Foam::hexRef8Data::hexRef8Data(const IOobject& io)
} }
} }
{ {
IOobject rio(io); typeIOobject<labelIOList> rio(io);
rio.rename("pointLevel"); rio.rename("pointLevel");
bool haveFile = returnReduce bool haveFile = returnReduce
( (
rio.typeHeaderOk<labelIOList>(true), rio.headerOk(),
orOp<bool>() orOp<bool>()
); );
if (haveFile) if (haveFile)
@ -67,11 +67,11 @@ Foam::hexRef8Data::hexRef8Data(const IOobject& io)
} }
} }
{ {
IOobject rio(io); typeIOobject<uniformDimensionedScalarField> rio(io);
rio.rename("level0Edge"); rio.rename("level0Edge");
bool haveFile = returnReduce bool haveFile = returnReduce
( (
rio.typeHeaderOk<uniformDimensionedScalarField>(true), rio.headerOk(),
orOp<bool>() orOp<bool>()
); );
if (haveFile) if (haveFile)
@ -81,11 +81,11 @@ Foam::hexRef8Data::hexRef8Data(const IOobject& io)
} }
} }
{ {
IOobject rio(io); typeIOobject<refinementHistory> rio(io);
rio.rename("refinementHistory"); rio.rename("refinementHistory");
bool haveFile = returnReduce bool haveFile = returnReduce
( (
rio.typeHeaderOk<refinementHistory>(true), rio.headerOk(),
orOp<bool>() orOp<bool>()
); );
if (haveFile) if (haveFile)

View File

@ -470,4 +470,10 @@ fvConstraints = $(general)/fvConstraints
$(fvConstraints)/fvConstraint.C $(fvConstraints)/fvConstraint.C
$(fvConstraints)/fvConstraints.C $(fvConstraints)/fvConstraints.C
cellSources = sets/cellSources
$(cellSources)/fieldToCell/fieldToCell.C
faceSources = sets/faceSources
$(faceSources)/patchFluxToFace/patchFluxToFace.C
LIB = $(FOAM_LIBBIN)/libfiniteVolume LIB = $(FOAM_LIBBIN)/libfiniteVolume

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,7 +34,7 @@ Foam::IOobject Foam::IOMRFZoneList::createIOobject
const fvMesh& mesh const fvMesh& mesh
) const ) const
{ {
IOobject io typeIOobject<IOdictionary> io
( (
"MRFProperties", "MRFProperties",
mesh.time().constant(), mesh.time().constant(),
@ -43,7 +43,7 @@ Foam::IOobject Foam::IOMRFZoneList::createIOobject
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
Info<< "Creating MRF zone list from " << io.name() << endl; Info<< "Creating MRF zone list from " << io.name() << endl;

View File

@ -42,7 +42,7 @@ Foam::IOobject Foam::fvConstraints::createIOobject
const fvMesh& mesh const fvMesh& mesh
) const ) const
{ {
IOobject io typeIOobject<IOdictionary> io
( (
typeName, typeName,
mesh.time().system(), mesh.time().system(),
@ -51,7 +51,7 @@ Foam::IOobject Foam::fvConstraints::createIOobject
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
Info<< "Creating fvConstraints from " Info<< "Creating fvConstraints from "
<< io.instance()/io.name() << nl << io.instance()/io.name() << nl
@ -66,7 +66,7 @@ Foam::IOobject Foam::fvConstraints::createIOobject
// check if the fvOptions file is in system // check if the fvOptions file is in system
io.rename("fvOptions"); io.rename("fvOptions");
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
Warning Warning
<< "Creating fvConstraints from " << "Creating fvConstraints from "
@ -82,7 +82,7 @@ Foam::IOobject Foam::fvConstraints::createIOobject
// check if the fvOptions file is in constant // check if the fvOptions file is in constant
io.instance() = mesh.time().constant(); io.instance() = mesh.time().constant();
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
Warning Warning
<< "Creating fvConstraints from " << "Creating fvConstraints from "

View File

@ -42,7 +42,7 @@ Foam::IOobject Foam::fvModels::createIOobject
const fvMesh& mesh const fvMesh& mesh
) const ) const
{ {
IOobject io typeIOobject<IOdictionary> io
( (
typeName, typeName,
mesh.time().constant(), mesh.time().constant(),
@ -51,7 +51,7 @@ Foam::IOobject Foam::fvModels::createIOobject
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
Info<< "Creating fvModels from " Info<< "Creating fvModels from "
<< io.instance()/io.name() << nl << io.instance()/io.name() << nl
@ -66,7 +66,7 @@ Foam::IOobject Foam::fvModels::createIOobject
// check if the fvOptions file is in constant // check if the fvOptions file is in constant
io.rename("fvOptions"); io.rename("fvOptions");
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
Warning Warning
<< "Creating fvModels from " << "Creating fvModels from "
@ -82,7 +82,7 @@ Foam::IOobject Foam::fvModels::createIOobject
// check if the fvOptions file is in system // check if the fvOptions file is in system
io.instance() = mesh.time().system(); io.instance() = mesh.time().system();
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
Warning Warning
<< "Creating fvModels from " << "Creating fvModels from "

View File

@ -1,6 +1,6 @@
if (!mesh.foundObject<IOdictionary>("radiationProperties")) if (!mesh.foundObject<IOdictionary>("radiationProperties"))
{ {
IOobject radiationProperties typeIOobject<IOdictionary> radiationProperties
( (
"radiationProperties", "radiationProperties",
runTime.constant(), runTime.constant(),
@ -10,7 +10,7 @@ if (!mesh.foundObject<IOdictionary>("radiationProperties"))
false false
); );
if (radiationProperties.typeHeaderOk<IOdictionary>(false)) if (radiationProperties.headerOk())
{ {
const word modelType const word modelType
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,7 +34,7 @@ Foam::IOobject Foam::IOporosityModelList::createIOobject
const fvMesh& mesh const fvMesh& mesh
) const ) const
{ {
IOobject io typeIOobject<IOdictionary> io
( (
"porosityProperties", "porosityProperties",
mesh.time().constant(), mesh.time().constant(),
@ -43,7 +43,7 @@ Foam::IOobject Foam::IOporosityModelList::createIOobject
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (io.typeHeaderOk<IOdictionary>(true)) if (io.headerOk())
{ {
Info<< "Creating porosity model list from " << io.name() << nl << endl; Info<< "Creating porosity model list from " << io.name() << nl << endl;

View File

@ -120,12 +120,12 @@ CrankNicolsonDdtScheme<Type>::ddt0_
runTime.timeIndex() == runTime.startTimeIndex() runTime.timeIndex() == runTime.startTimeIndex()
|| runTime.timeIndex() == runTime.startTimeIndex() + 1 || runTime.timeIndex() == runTime.startTimeIndex() + 1
) )
&& IOobject && typeIOobject<DDt0Field<GeoField>>
( (
name, name,
startTimeName, startTimeName,
mesh() mesh()
).typeHeaderOk<DDt0Field<GeoField>>() ).headerOk()
) )
{ {
regIOobject::store regIOobject::store

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -29,6 +29,7 @@ License
#include "Time.H" #include "Time.H"
#include "IFstream.H" #include "IFstream.H"
#include "fieldDictionary.H" #include "fieldDictionary.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -125,8 +126,7 @@ void Foam::fieldToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
// Try to load field typeIOobject<volScalarField> fieldObject
IOobject fieldObject
( (
fieldName_, fieldName_,
mesh().time().timeName(), mesh().time().timeName(),
@ -136,41 +136,68 @@ void Foam::fieldToCell::applyToSet
false false
); );
// Note: should check for volScalarField but that introduces dependency if (!fieldObject.IOobject::headerOk())
// on volMesh so just use another type with processor-local scope
if (!fieldObject.typeHeaderOk<labelIOList>(false))
{ {
WarningInFunction WarningInFunction
<< "Cannot read field " << fieldName_ << "Cannot read field " << fieldName_
<< " from time " << mesh().time().timeName() << endl; << " from time " << mesh().time().timeName() << endl;
} }
else if (fieldObject.headerClassName() == "volScalarField") else if (fieldObject.IOobject::headerOk())
{ {
IFstream str(typeFilePath<labelIOList>(fieldObject)); IFstream str(fieldObject.filePath());
// Read dictionary // Read dictionary
fieldDictionary fieldDict(fieldObject, fieldObject.headerClassName()); const fieldDictionary fieldDict
(
fieldObject,
volScalarField::typeName
);
scalarField internalVals("internalField", fieldDict, mesh().nCells()); const scalarField internalVals
(
"internalField",
fieldDict, mesh().nCells()
);
applyToSet(action, internalVals, set); applyToSet(action, internalVals, set);
} }
else if (fieldObject.headerClassName() == "volVectorField")
{
IFstream str(typeFilePath<labelIOList>(fieldObject));
// Read dictionary
fieldDictionary fieldDict(fieldObject, fieldObject.headerClassName());
vectorField internalVals("internalField", fieldDict, mesh().nCells());
applyToSet(action, mag(internalVals), set);
}
else else
{ {
WarningInFunction typeIOobject<volVectorField> fieldObject
(
fieldName_,
mesh().time().timeName(),
mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE,
false
);
if (fieldObject.IOobject::headerOk())
{
IFstream str(fieldObject.filePath());
// Read dictionary
const fieldDictionary fieldDict
(
fieldObject,
volVectorField::typeName
);
const vectorField internalVals
(
"internalField",
fieldDict, mesh().nCells()
);
applyToSet(action, mag(internalVals), set);
}
else
{
WarningInFunction
<< "Cannot handle fields of type " << fieldObject.headerClassName() << "Cannot handle fields of type " << fieldObject.headerClassName()
<< endl; << endl;
}
} }
} }

View File

@ -29,6 +29,7 @@ License
#include "Time.H" #include "Time.H"
#include "IFstream.H" #include "IFstream.H"
#include "fieldDictionary.H" #include "fieldDictionary.H"
#include "surfaceFields.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -132,8 +133,7 @@ void Foam::patchFluxToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
// Try to load field typeIOobject<surfaceScalarField> fieldObject
IOobject fieldObject
( (
fieldName_, fieldName_,
mesh().time().timeName(), mesh().time().timeName(),
@ -143,17 +143,9 @@ void Foam::patchFluxToFace::applyToSet
false false
); );
// Note: should check for surfaceScalarField but that introduces dependency if (fieldObject.headerOk())
// on volMesh so just use another type with processor-local scope
if (!fieldObject.typeHeaderOk<labelIOList>(false))
{ {
WarningInFunction IFstream str(fieldObject.filePath());
<< "Cannot read flux field " << fieldName_
<< " from time " << mesh().time().timeName() << endl;
}
else if (fieldObject.headerClassName() == "surfaceScalarField")
{
IFstream str(typeFilePath<labelIOList>(fieldObject));
// Read dictionary // Read dictionary
const fieldDictionary fieldDict const fieldDictionary fieldDict
@ -174,8 +166,8 @@ void Foam::patchFluxToFace::applyToSet
else else
{ {
WarningInFunction WarningInFunction
<< "Incorrect flux field type " << fieldObject.headerClassName() << "Cannot read flux field " << fieldName_
<< endl; << " from time " << mesh().time().timeName() << endl;
} }
} }

View File

@ -243,7 +243,7 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
} }
else else
{ {
IOobject propsDictHeader typeIOobject<timeIOdictionary> propsDictHeader
( (
name() + "Properties", name() + "Properties",
obr_.time().timeName(obr_.time().startTime().value()), obr_.time().timeName(obr_.time().startTime().value()),
@ -254,7 +254,7 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
false false
); );
if (!propsDictHeader.typeHeaderOk<timeIOdictionary>()) if (!propsDictHeader.headerOk())
{ {
Log << " Starting averaging at time " Log << " Starting averaging at time "
<< obr_.time().timeName() << nl; << obr_.time().timeName() << nl;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -79,7 +79,7 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
} }
else else
{ {
IOobject fieldHeader typeIOobject<VolFieldType> fieldHeader
( (
fieldName, fieldName,
mesh_.time().timeName(), mesh_.time().timeName(),
@ -88,11 +88,7 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if if (fieldHeader.headerOk())
(
fieldHeader.typeHeaderOk<VolFieldType>(false)
&& fieldHeader.headerClassName() == VolFieldType::typeName
)
{ {
DebugInfo DebugInfo
<< type() << ": Field " << fieldName << " read from file" << type() << ": Field " << fieldName << " read from file"
@ -103,20 +99,28 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
mesh_.lookupObject<VolFieldType>(fieldName) mesh_.lookupObject<VolFieldType>(fieldName)
); );
} }
else if else
(
fieldHeader.typeHeaderOk<SurfaceFieldType>(false)
&& fieldHeader.headerClassName() == SurfaceFieldType::typeName
)
{ {
DebugInfo typeIOobject<SurfaceFieldType> fieldHeader
<< type() << ": Field " << fieldName << " read from file"
<< endl;
transformField<SurfaceFieldType>
( (
mesh_.lookupObject<SurfaceFieldType>(fieldName) fieldName,
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
); );
if (fieldHeader.headerOk())
{
DebugInfo
<< type() << ": Field " << fieldName << " read from file"
<< endl;
transformField<SurfaceFieldType>
(
mesh_.lookupObject<SurfaceFieldType>(fieldName)
);
}
} }
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,7 +55,7 @@ void Foam::functionObjects::readFields::loadField
} }
else else
{ {
IOobject fieldHeader typeIOobject<VolFieldType> fieldHeader
( (
fieldName, fieldName,
mesh_.time().timeName(), mesh_.time().timeName(),
@ -64,11 +64,7 @@ void Foam::functionObjects::readFields::loadField
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if if (fieldHeader.headerOk())
(
fieldHeader.typeHeaderOk<VolFieldType>(false)
&& fieldHeader.headerClassName() == VolFieldType::typeName
)
{ {
// Store field locally // Store field locally
Log << " Reading " << fieldName << endl; Log << " Reading " << fieldName << endl;
@ -77,18 +73,26 @@ void Foam::functionObjects::readFields::loadField
vflds.setSize(sz+1); vflds.setSize(sz+1);
vflds.set(sz, new VolFieldType(fieldHeader, mesh_)); vflds.set(sz, new VolFieldType(fieldHeader, mesh_));
} }
else if else
(
fieldHeader.typeHeaderOk<SurfaceFieldType>(false)
&& fieldHeader.headerClassName() == SurfaceFieldType::typeName
)
{ {
// Store field locally typeIOobject<SurfaceFieldType> fieldHeader
Log << " Reading " << fieldName << endl; (
fieldName,
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
label sz = sflds.size(); if (fieldHeader.headerOk())
sflds.setSize(sz+1); {
sflds.set(sz, new SurfaceFieldType(fieldHeader, mesh_)); // Store field locally
Log << " Reading " << fieldName << endl;
label sz = sflds.size();
sflds.setSize(sz+1);
sflds.set(sz, new SurfaceFieldType(fieldHeader, mesh_));
}
} }
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -56,7 +56,7 @@ bool Foam::functionObjects::writeDictionary::tryDirectory
bool& firstDict bool& firstDict
) )
{ {
IOobject dictIO typeIOobject<IOdictionary> dictIO
( (
dictNames_[dictI], dictNames_[dictI],
location, location,
@ -66,7 +66,7 @@ bool Foam::functionObjects::writeDictionary::tryDirectory
false false
); );
if (dictIO.typeHeaderOk<IOdictionary>(true)) if (dictIO.headerOk())
{ {
IOdictionary dict(dictIO); IOdictionary dict(dictIO);

View File

@ -47,7 +47,7 @@ namespace heatTransferModels
void Foam::fv::heatTransferModels::constant::readCoeffs() void Foam::fv::heatTransferModels::constant::readCoeffs()
{ {
IOobject htcIO typeIOobject<volScalarField> htcIO
( (
"htc", "htc",
mesh().time().constant(), mesh().time().constant(),
@ -67,7 +67,7 @@ void Foam::fv::heatTransferModels::constant::readCoeffs()
); );
htcPtr_.clear(); htcPtr_.clear();
} }
else if (htcIO.typeHeaderOk<volScalarField>(false)) else if (htcIO.headerOk())
{ {
htc_ = dimensionedScalar("htc", dimPower/dimTemperature/dimArea, NaN); htc_ = dimensionedScalar("htc", dimPower/dimTemperature/dimArea, NaN);
htcPtr_.set(new volScalarField(htcIO, mesh())); htcPtr_.set(new volScalarField(htcIO, mesh()));
@ -77,7 +77,7 @@ void Foam::fv::heatTransferModels::constant::readCoeffs()
FatalIOErrorInFunction(coeffs()) FatalIOErrorInFunction(coeffs())
<< "Heat transfer coefficient (htc) not found. A uniform htc " << "Heat transfer coefficient (htc) not found. A uniform htc "
<< "value should be specified, or a non-uniform field should " << "value should be specified, or a non-uniform field should "
<< "exist at " << htcIO.objectPath<volScalarField>() << "exist at " << htcIO.objectPath()
<< exit(FatalIOError); << exit(FatalIOError);
} }
} }

View File

@ -42,7 +42,7 @@ namespace fv
void Foam::fv::heatTransferModel::readCoeffs() void Foam::fv::heatTransferModel::readCoeffs()
{ {
IOobject AoVIO typeIOobject<volScalarField> AoVIO
( (
"AoV", "AoV",
mesh().time().constant(), mesh().time().constant(),
@ -56,7 +56,7 @@ void Foam::fv::heatTransferModel::readCoeffs()
AoV_ = dimensionedScalar("AoV", dimless/dimLength, coeffs()); AoV_ = dimensionedScalar("AoV", dimless/dimLength, coeffs());
AoVPtr_.clear(); AoVPtr_.clear();
} }
else if (AoVIO.typeHeaderOk<volScalarField>(false)) else if (AoVIO.headerOk())
{ {
AoV_ = dimensionedScalar("AoV", dimless/dimLength, NaN); AoV_ = dimensionedScalar("AoV", dimless/dimLength, NaN);
AoVPtr_.set(new volScalarField(AoVIO, mesh())); AoVPtr_.set(new volScalarField(AoVIO, mesh()));
@ -66,7 +66,7 @@ void Foam::fv::heatTransferModel::readCoeffs()
FatalIOErrorInFunction(coeffs()) FatalIOErrorInFunction(coeffs())
<< "Area per unit volume (AoV) not found. A uniform AoV " << "Area per unit volume (AoV) not found. A uniform AoV "
<< "value should be specified, or a non-uniform field should " << "value should be specified, or a non-uniform field should "
<< "exist at " << AoVIO.objectPath<volScalarField>() << "exist at " << AoVIO.objectPath()
<< exit(FatalIOError); << exit(FatalIOError);
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -88,7 +88,7 @@ Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver
: -1 : -1
) )
{ {
IOobject io typeIOobject<pointVectorField> io
( (
"pointLocation", "pointLocation",
fvMesh_.time().timeName(), fvMesh_.time().timeName(),
@ -105,7 +105,7 @@ Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver
} }
if (io.typeHeaderOk<pointVectorField>(true)) if (io.headerOk())
{ {
pointLocation_.reset pointLocation_.reset
( (

View File

@ -39,7 +39,7 @@ Foam::word Foam::Cloud<ParticleType>::cloudPropertiesName("cloudProperties");
template<class ParticleType> template<class ParticleType>
void Foam::Cloud<ParticleType>::readCloudUniformProperties() void Foam::Cloud<ParticleType>::readCloudUniformProperties()
{ {
IOobject dictObj typeIOobject<timeIOdictionary> dictObj
( (
cloudPropertiesName, cloudPropertiesName,
time().timeName(), time().timeName(),
@ -50,7 +50,7 @@ void Foam::Cloud<ParticleType>::readCloudUniformProperties()
false false
); );
if (dictObj.typeHeaderOk<timeIOdictionary>(true)) if (dictObj.headerOk())
{ {
const timeIOdictionary uniformPropsDict(dictObj); const timeIOdictionary uniformPropsDict(dictObj);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -44,9 +44,12 @@ void Foam::particle::readFields(TrackCloudType& c)
{ {
bool valid = c.size(); bool valid = c.size();
IOobject procIO(c.fieldIOobject("origProcId", IOobject::MUST_READ)); typeIOobject<IOField<label>> procIO
(
c.fieldIOobject("origProcId", IOobject::MUST_READ)
);
bool haveFile = procIO.typeHeaderOk<IOField<label>>(true); bool haveFile = procIO.headerOk();
IOField<label> origProcId(procIO, valid && haveFile); IOField<label> origProcId(procIO, valid && haveFile);
c.checkFieldIOobject(c, origProcId); c.checkFieldIOobject(c, origProcId);

View File

@ -41,7 +41,7 @@ void Foam::parcelCloudList::initialise
const Args& ... args const Args& ... args
) )
{ {
IOobject cloudsIO typeIOobject<wordGlobalIOList> cloudsIO
( (
cloudsName, cloudsName,
mesh_.time().constant(), mesh_.time().constant(),
@ -50,7 +50,7 @@ void Foam::parcelCloudList::initialise
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (cloudsIO.typeHeaderOk<wordGlobalIOList>(false)) if (cloudsIO.headerOk())
{ {
wordGlobalIOList cloudNames(cloudsIO); wordGlobalIOList cloudNames(cloudsIO);
@ -63,7 +63,7 @@ void Foam::parcelCloudList::initialise
} }
else else
{ {
IOobject cloudIO typeIOobject<IOdictionary> cloudIO
( (
"cloudProperties", "cloudProperties",
mesh_.time().constant(), mesh_.time().constant(),
@ -72,7 +72,7 @@ void Foam::parcelCloudList::initialise
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (cloudIO.typeHeaderOk<IOdictionary>(false)) if (cloudIO.headerOk())
{ {
this->setSize(1); this->setSize(1);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -101,7 +101,7 @@ Foam::PatchCollisionDensity<CloudType>::PatchCollisionDensity
collisionDensity_ == 0; collisionDensity_ == 0;
collisionDensity0_ == 0; collisionDensity0_ == 0;
IOobject io typeIOobject<volScalarField> io
( (
this->owner().name() + ":collisionDensity", this->owner().name() + ":collisionDensity",
this->owner().mesh().time().timeName(), this->owner().mesh().time().timeName(),
@ -110,7 +110,7 @@ Foam::PatchCollisionDensity<CloudType>::PatchCollisionDensity
IOobject::NO_WRITE IOobject::NO_WRITE
); );
if (io.typeHeaderOk<volScalarField>()) if (io.headerOk())
{ {
const volScalarField collisionDensity(io, this->owner().mesh()); const volScalarField collisionDensity(io, this->owner().mesh());
collisionDensity_ == collisionDensity.boundaryField(); collisionDensity_ == collisionDensity.boundaryField();

View File

@ -46,7 +46,7 @@ void Foam::refinementFeatures::read
// Try reading extendedEdgeMesh first // Try reading extendedEdgeMesh first
IOobject extFeatObj typeIOobject<extendedFeatureEdgeMesh> extFeatObj
( (
featFileName, // name featFileName, // name
io.time().constant(), // instance io.time().constant(), // instance
@ -57,7 +57,7 @@ void Foam::refinementFeatures::read
false false
); );
const fileName fName(typeFilePath<extendedFeatureEdgeMesh>(extFeatObj)); const fileName fName(extFeatObj.filePath());
if (!fName.empty() && extendedEdgeMesh::canRead(fName)) if (!fName.empty() && extendedEdgeMesh::canRead(fName))
{ {
@ -77,7 +77,7 @@ void Foam::refinementFeatures::read
{ {
// Try reading edgeMesh // Try reading edgeMesh
IOobject featObj typeIOobject<featureEdgeMesh> featObj
( (
featFileName, featFileName,
io.time().constant(), io.time().constant(),
@ -88,7 +88,7 @@ void Foam::refinementFeatures::read
false false
); );
const fileName fName(typeFilePath<featureEdgeMesh>(featObj)); const fileName fName(featObj.filePath());
if (fName.empty()) if (fName.empty())
{ {
@ -96,7 +96,7 @@ void Foam::refinementFeatures::read
( (
dict dict
) << "Could not open " ) << "Could not open "
<< featObj.objectPath<featureEdgeMesh>() << featObj.objectPath()
<< exit(FatalIOError); << exit(FatalIOError);
} }

View File

@ -128,9 +128,8 @@ $(topoSets)/pointZoneSet.C
sets/topoSetSource/topoSetSource.C sets/topoSetSource/topoSetSource.C
cellSources = sets/cellSources cellSources = sets/cellSources
$(cellSources)/faceToCell/faceToCell.C $(cellSources)/faceToCell/faceToCell.C
$(cellSources)/fieldToCell/fieldToCell.C
$(cellSources)/pointToCell/pointToCell.C $(cellSources)/pointToCell/pointToCell.C
$(cellSources)/shapeToCell/shapeToCell.C $(cellSources)/shapeToCell/shapeToCell.C
$(cellSources)/boxToCell/boxToCell.C $(cellSources)/boxToCell/boxToCell.C
@ -154,15 +153,14 @@ $(faceSources)/faceToFace/faceToFace.C
$(faceSources)/labelToFace/labelToFace.C $(faceSources)/labelToFace/labelToFace.C
$(faceSources)/cellToFace/cellToFace.C $(faceSources)/cellToFace/cellToFace.C
$(faceSources)/normalToFace/normalToFace.C $(faceSources)/normalToFace/normalToFace.C
$(faceSources)/pointToFace/pointToFace.C
$(faceSources)/patchToFace/patchToFace.C $(faceSources)/patchToFace/patchToFace.C
$(faceSources)/pointToFace/pointToFace.C
$(faceSources)/boundaryToFace/boundaryToFace.C $(faceSources)/boundaryToFace/boundaryToFace.C
$(faceSources)/zoneToFace/zoneToFace.C $(faceSources)/zoneToFace/zoneToFace.C
$(faceSources)/boxToFace/boxToFace.C $(faceSources)/boxToFace/boxToFace.C
$(faceSources)/regionToFace/regionToFace.C $(faceSources)/regionToFace/regionToFace.C
$(faceSources)/cylinderToFace/cylinderToFace.C $(faceSources)/cylinderToFace/cylinderToFace.C
$(faceSources)/cylinderAnnulusToFace/cylinderAnnulusToFace.C $(faceSources)/cylinderAnnulusToFace/cylinderAnnulusToFace.C
$(faceSources)/patchFluxToFace/patchFluxToFace.C
pointSources = sets/pointSources pointSources = sets/pointSources
$(pointSources)/labelToPoint/labelToPoint.C $(pointSources)/labelToPoint/labelToPoint.C

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -66,7 +66,7 @@ bool Foam::fileFormats::edgeMeshFormat::read
// Construct IOobject to re-use the headerOk & readHeader // Construct IOobject to re-use the headerOk & readHeader
// (so we can read ascii and binary) // (so we can read ascii and binary)
IOobject io typeIOobject<featureEdgeMesh> io
( (
filename, filename,
dummyTime, dummyTime,
@ -75,14 +75,14 @@ bool Foam::fileFormats::edgeMeshFormat::read
false false
); );
if (!io.typeHeaderOk<featureEdgeMesh>(false)) if (!io.headerOk())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Cannot read file " << filename << "Cannot read file " << filename
<< exit(FatalError); << exit(FatalError);
} }
const fileName fName(typeFilePath<featureEdgeMesh>(io)); const fileName fName(io.filePath());
autoPtr<IFstream> isPtr(new IFstream(fName)); autoPtr<IFstream> isPtr(new IFstream(fName));
bool ok = false; bool ok = false;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -64,7 +64,7 @@ bool Foam::fileFormats::extendedEdgeMeshFormat::read
// Construct IOobject to re-use the headerOk & readHeader // Construct IOobject to re-use the headerOk & readHeader
// (so we can read ascii and binary) // (so we can read ascii and binary)
IOobject io typeIOobject<extendedFeatureEdgeMesh> io
( (
filename, filename,
dummyTime, dummyTime,
@ -73,14 +73,14 @@ bool Foam::fileFormats::extendedEdgeMeshFormat::read
false false
); );
if (!io.typeHeaderOk<extendedFeatureEdgeMesh>(false)) if (!io.headerOk())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Cannot read file " << filename << "Cannot read file " << filename
<< exit(FatalError); << exit(FatalError);
} }
const fileName fName(typeFilePath<extendedFeatureEdgeMesh>(io)); const fileName fName(io.filePath());
autoPtr<IFstream> isPtr(new IFstream(fName)); autoPtr<IFstream> isPtr(new IFstream(fName));
bool ok = false; bool ok = false;

Some files were not shown because too many files have changed in this diff Show More