From f1d7955e45335d34fc6c960ecedd1e2bc540b48a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 29 Jul 2008 09:11:11 +0200 Subject: [PATCH] BUGFIX - blockMeshApp should now handle paths properly --- .../mesh/generation/blockMesh/blockMeshApp.C | 51 ++++++++++++------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C index 57e006d3df..e73a5262b9 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C @@ -80,57 +80,70 @@ int main(int argc, char *argv[]) word regionName; fileName polyMeshDir; + word dictName("blockMeshDict"); + fileName dictPath(runTime.constant()); if (args.options().found("region")) { - regionName = args.options()["region"]; + // constant//polyMesh/blockMeshDict + regionName = args.options()["region"]; polyMeshDir = regionName/polyMesh::meshSubDir; Info<< nl << "Generating mesh for region " << regionName << endl; } else { - regionName = polyMesh::defaultRegion; + // constant/polyMesh/blockMeshDict + regionName = polyMesh::defaultRegion; polyMeshDir = polyMesh::meshSubDir; } - word dictName("blockMeshDict"); - fileName dictPath(runTime.constant()/polyMeshDir); + fileName dictLocal = polyMeshDir; if (args.options().found("dict")) { - fileName userDict(args.options()["dict"]); + wordList elems(fileName(args.options()["dict"]).components()); + dictName = elems[elems.size()-1]; + dictPath = elems[0]; + dictLocal = ""; - dictName = userDict.name(); - dictPath = userDict.path(); + if (elems.size() == 1) + { + dictPath = "."; + } + else if (elems.size() > 2) + { + dictLocal = fileName(SubList(elems, elems.size()-2, 1)); + } } - Info<< nl << "Reading block mesh description dictionary" << endl; - IOobject meshDescriptionIOobject + IOobject meshDictIo ( dictName, dictPath, + dictLocal, runTime, IOobject::MUST_READ, IOobject::NO_WRITE, false ); - if (!meshDescriptionIOobject.headerOk()) + if (!meshDictIo.headerOk()) { FatalErrorIn(args.executable()) - << "Cannot open mesh description file: " << nl - << dictPath/dictName << nl + << "Cannot open mesh description file\n " + << meshDictIo.objectPath() + << nl << exit(FatalError); } - IOdictionary meshDescription(meshDescriptionIOobject); + Info<< nl << "Creating block mesh from\n " + << meshDictIo.objectPath() << endl; - Info<< nl << "Creating block mesh" << endl; - - blockMesh blocks(meshDescription); + IOdictionary meshDict(meshDictIo); + blockMesh blocks(meshDict); if (writeTopo) { @@ -187,7 +200,7 @@ int main(int argc, char *argv[]) ( runTime, runTime.constant(), - polyMeshDir, //polyMesh::meshSubDir + polyMeshDir, patchNames, patchTypes, defaultFacesName, @@ -215,11 +228,11 @@ int main(int argc, char *argv[]) // Read in a list of dictionaries for the merge patch pairs - if (meshDescription.found("mergePatchPairs")) + if (meshDict.found("mergePatchPairs")) { List > mergePatchPairs ( - meshDescription.lookup("mergePatchPairs") + meshDict.lookup("mergePatchPairs") ); if (mergePatchPairs.size())