diff --git a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C index de4fc8bce3..fbfbaa289c 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C @@ -28,12 +28,12 @@ Application Description A multi-block mesh generator. - A @a constant/polyMesh/blockMeshDict - (or @a constant/\/polyMesh/blockMeshDict) is used. + The @a constant/blockMeshDict (or @a constant/\/blockMeshDict) + is used. - For people who like to accidentally remove their entire - @a constant/polyMesh/, the path @a constant/blockMeshDict - (or @a constant/\/blockMeshDict) will also be checked. + For backwards compatibility, @a constant/polyMesh/blockMeshDict + (or @a constant/\/polyMesh/blockMeshDict) can also be used + if the previous search failed. Usage @@ -86,83 +86,77 @@ int main(int argc, char *argv[]) if (args.options().found("region")) { - regionName = args.options()["region"]; + regionName = args.options()["region"]; polyMeshDir = regionName/polyMesh::meshSubDir; constantDir = runTime.constant()/regionName; Info<< nl << "Generating mesh for region " << regionName << endl; + + // try constant//blockMeshDict + meshDictPtr.reset + ( + new IOobject + ( + "blockMeshDict", + runTime.constant(), + regionName, + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); } else { - regionName = polyMesh::defaultRegion; + regionName = polyMesh::defaultRegion; polyMeshDir = polyMesh::meshSubDir; constantDir = runTime.constant(); + + // try constant/blockMeshDict + meshDictPtr.reset + ( + new IOobject + ( + "blockMeshDict", + runTime.constant(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); } - // check constant/polyMesh or constant/polyMesh// - meshDictPtr.reset - ( - new IOobject + // not found, fallback to polyMesh directory + if (!meshDictPtr->headerOk()) + { + meshDictPtr.reset ( - "blockMeshDict", - runTime.constant(), - polyMeshDir, - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); + new IOobject + ( + "blockMeshDict", + runTime.constant(), + polyMeshDir, + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + } if (!meshDictPtr->headerOk()) { - // not found, failsafe checks - if (args.options().found("region")) - { - // try constant//blockMeshDict - meshDictPtr.reset - ( - new IOobject - ( - "blockMeshDict", - runTime.constant(), - regionName, - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - } - else - { - // try constant/blockMeshDict - meshDictPtr.reset - ( - new IOobject - ( - "blockMeshDict", - runTime.constant(), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - } - - if (!meshDictPtr->headerOk()) - { - FatalErrorIn(args.executable()) - << "Cannot open mesh description file\n " - << constantDir/polyMeshDir/"blockMeshDict" - << "\n (or " << constantDir/"blockMeshDict" << ")" << nl - << nl - << exit(FatalError); - } + FatalErrorIn(args.executable()) + << "Cannot open mesh description file " << nl + << constantDir/"blockMeshDict" << nl + << "or "<< nl + << constantDir/polyMeshDir/polyMesh::meshSubDir/"blockMeshDict" + << nl + << exit(FatalError); } - Info<< nl << "Reading mesh description file" << endl; IOdictionary blockMeshDict(meshDictPtr());