diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkData.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkData.H index 50e78e781c8ef9a70ae7e8553d9d272a91793df4..73a0e17417114b1520ae62d8a8d28fd4c03b9df6 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkData.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkData.H @@ -18,8 +18,10 @@ if (!fieldsToUse.found(fieldName)) fieldName, timeDirs[n1].name(), mesh, - IOobject::NO_READ - ).typeHeaderOk<volScalarField>(false) + IOobject::NO_READ, + IOobject::NO_WRITE, + false // no register + ).typeHeaderOk<volScalarField>(false, false) ); if (variableGood) diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H index 912f48b28ac7d8b9c653d0d1e03fe31f08117ee1..9c0c612ed7fc5fe68233c257509dec635e45d517 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H @@ -7,8 +7,6 @@ if (timeDirs.size() > 1 && Pstream::master()) // We already loaded a mesh (usually from constant). // See if any other "polyMesh/points" files exist too. - const fileName& baseDir = mesh.time().path(); - Info<< "Search for moving mesh ... " << flush; forAll(timeDirs, timeI) { @@ -17,7 +15,6 @@ if (timeDirs.size() > 1 && Pstream::master()) meshMoving = ( timeName != mesh.pointsInstance() - && isDir(baseDir/timeName/polyMesh::meshSubDir) && IOobject ( "points", @@ -27,7 +24,7 @@ if (timeDirs.size() > 1 && Pstream::master()) IOobject::NO_READ, IOobject::NO_WRITE, false // no register - ).typeHeaderOk<pointIOField>(true) + ).typeHeaderOk<pointIOField>(true, false) ); if (meshMoving) diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkMeshMoving.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkMeshMoving.H index 51c7a11e7337648272c889c477630eea44bd44a4..8155d920cbc9a109d288d1381e485938c473b5b7 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkMeshMoving.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/checkMeshMoving.H @@ -8,15 +8,12 @@ if (timeDirs.size() > 1 && Pstream::master()) // We already loaded a mesh (usually from constant). // See if any other "polyMesh/points" files exist too. - const fileName& baseDir = mesh.time().path(); - Info<< "Search for moving mesh ... " << flush; forAll(timeDirs, timeI) { meshMoving = ( - isDir(baseDir/timeDirs[timeI].name()/polyMesh::meshSubDir) - && IOobject + IOobject ( "points", timeDirs[timeI].name(), @@ -25,7 +22,7 @@ if (timeDirs.size() > 1 && Pstream::master()) IOobject::NO_READ, IOobject::NO_WRITE, false // no register - ).typeHeaderOk<pointIOField>(true) + ).typeHeaderOk<pointIOField>(true, false) ); if (meshMoving) diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/getTimeIndex.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/getTimeIndex.H index a55e44e136420eafff0c92454fe786c2cfecc07b..91c718994f16c21fe2d336039b046049852551dc 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/getTimeIndex.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/getTimeIndex.H @@ -21,10 +21,10 @@ runTime, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, - false + false // no register ); - if (io.typeHeaderOk<IOdictionary>(true)) + if (io.typeHeaderOk<IOdictionary>(true, false)) { io.readOpt() = IOobject::MUST_READ_IF_MODIFIED; IOdictionary timeObject(io); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/moveMesh.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/moveMesh.H index f894e2c136a03f990341b20fe2c96094f3d85b94..8e3f53ce966bf42adcfdb062f2daea02b28e5306 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/moveMesh.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/moveMesh.H @@ -4,10 +4,13 @@ "points", runTime.timeName(), polyMesh::meshSubDir, - mesh + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false // no register ); - if (io.typeHeaderOk<pointIOField>(true)) + if (io.typeHeaderOk<pointIOField>(true, false)) { // Read new points io.readOpt() = IOobject::MUST_READ; diff --git a/applications/utilities/postProcessing/dataConversion/foamToGMV/moveMesh.H b/applications/utilities/postProcessing/dataConversion/foamToGMV/moveMesh.H index c1a1f8dee71ee7676da95d69acfde3bd015d9910..50db68176cec8c8d66ac0279d57b7d5f42071f8c 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToGMV/moveMesh.H +++ b/applications/utilities/postProcessing/dataConversion/foamToGMV/moveMesh.H @@ -1,27 +1,20 @@ -IOobject ioPoints -( - "points", - runTime.timeName(), - mesh.name(), - mesh -); - -if (ioPoints.typeHeaderOk<pointIOField>(true)) { - Info<< "new points available" << endl; - // Reading new points - pointIOField newPoints + IOobject io ( - IOobject - ( - "points", - runTime.timeName(), - mesh.name(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) + "points", + runTime.timeName(), + mesh.name(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false // no register ); - mesh.movePoints(newPoints); + if (io.typeHeaderOk<pointIOField>(true, false)) + { + Info<< "new points available" << endl; + // Read new points + io.readOpt() = IOobject::MUST_READ; + mesh.movePoints(pointIOField(io)); + } } diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index 50f4f56627f91003a04a04fd71a9f3b55f52ae64..b08b3bb66179314b7281c70b971ff4241512fba5 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -425,10 +425,16 @@ public: //- Read header bool readHeader(Istream&); - //- Read header (uses typeFilePath to find file) and check header - // info. Optionally checks headerClassName against type + //- Read header (uses typeFilePath to find file) and check its info. + // Optionally checks headerClassName against the type-name. + // When search is false, simply use the current instance, + // otherwise search previous instances. template<class Type> - bool typeHeaderOk(const bool checkType = true); + bool typeHeaderOk + ( + const bool checkType = true, + const bool search = true + ); //- Helper: warn that type does not support re-reading template<class Type> @@ -489,18 +495,23 @@ template<> Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip); -//- Template function for obtaining global status +//- Template function for obtaining global vs. local status template<class T> inline bool typeGlobal() { return false; } -//- Template function for obtaining filePath +//- Template function for obtaining local or global filePath template<class T> -inline fileName typeFilePath(const IOobject& io) +inline fileName typeFilePath(const IOobject& io, const bool search=true) { - return (typeGlobal<T>() ? io.globalFilePath() : io.localFilePath()); + return + ( + typeGlobal<T>() + ? io.globalFilePath(search) + : io.localFilePath(search) + ); } diff --git a/src/OpenFOAM/db/IOobject/IOobjectTemplates.C b/src/OpenFOAM/db/IOobject/IOobjectTemplates.C index 1ef06e3415e7902bfc452126f4c54fe71c339701..f93384bf8cc00fd49d773b34f04f03e433a5f4f0 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectTemplates.C +++ b/src/OpenFOAM/db/IOobject/IOobjectTemplates.C @@ -32,7 +32,11 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -bool Foam::IOobject::typeHeaderOk(const bool checkType) +bool Foam::IOobject::typeHeaderOk +( + const bool checkType, + const bool search +) { bool ok = true; @@ -48,7 +52,7 @@ bool Foam::IOobject::typeHeaderOk(const bool checkType) // Determine local status if (!masterOnly || Pstream::master()) { - Istream* isPtr = objectStream(typeFilePath<Type>(*this)); + Istream* isPtr = objectStream(typeFilePath<Type>(*this, search)); // If the stream has failed return if (!isPtr) diff --git a/src/OpenFOAM/db/IOobjects/IOMap/IOMapName.C b/src/OpenFOAM/db/IOobjects/IOMap/IOMapName.C index 894dd2cfc603c0a7f6825f9b282185886491df05..9ee8cb061ae9279d025f522925a0e955ae2741f5 100644 --- a/src/OpenFOAM/db/IOobjects/IOMap/IOMapName.C +++ b/src/OpenFOAM/db/IOobjects/IOMap/IOMapName.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,11 +30,11 @@ namespace Foam { defineTemplateTypeNameAndDebug(IOMap<dictionary>, 0); - //- Template specialisation for obtaining filePath + //- Template specialization for global status template<> - fileName typeFilePath<IOMap<dictionary>>(const IOobject& io) + bool typeGlobal<IOMap<dictionary>>() { - return io.globalFilePath(); + return true; } }