diff --git a/applications/utilities/mesh/generation/blockMesh/Make/files b/applications/utilities/mesh/generation/blockMesh/Make/files index af92bf759c..81f5f36749 100644 --- a/applications/utilities/mesh/generation/blockMesh/Make/files +++ b/applications/utilities/mesh/generation/blockMesh/Make/files @@ -26,6 +26,6 @@ blockPoints.C blockCells.C blockBoundary.C -genBlockMesh.C +blockMeshApp.C EXE = $(FOAM_APPBIN)/blockMesh diff --git a/applications/utilities/mesh/generation/blockMesh/genBlockMesh.C b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C similarity index 77% rename from applications/utilities/mesh/generation/blockMesh/genBlockMesh.C rename to applications/utilities/mesh/generation/blockMesh/blockMeshApp.C index c13d906392..fbfbaa289c 100644 --- a/applications/utilities/mesh/generation/blockMesh/genBlockMesh.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C @@ -22,14 +22,35 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +Application + blockMesh + Description A multi-block mesh generator. + The @a constant/blockMeshDict (or @a constant/\/blockMeshDict) + is used. + + For backwards compatibility, @a constant/polyMesh/blockMeshDict + (or @a constant/\/polyMesh/blockMeshDict) can also be used + if the previous search failed. + +Usage + + - blockMesh [OPTION] + + @param -blockTopology \n + Write the topology as a set of edges in OBJ format. + + @param -region \\n + Specify an alternative mesh region + \*---------------------------------------------------------------------------*/ #include "Time.H" #include "IOdictionary.H" #include "IOPtrList.H" +#include "autoPtr.H" #include "blockMesh.H" #include "attachPolyTopoChanger.H" @@ -60,47 +81,89 @@ int main(int argc, char *argv[]) word regionName; fileName polyMeshDir; + fileName constantDir; + autoPtr meshDictPtr; if (args.options().found("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; polyMeshDir = polyMesh::meshSubDir; + constantDir = runTime.constant(); + + // try constant/blockMeshDict + meshDictPtr.reset + ( + new IOobject + ( + "blockMeshDict", + runTime.constant(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); } + // not found, fallback to polyMesh directory + if (!meshDictPtr->headerOk()) + { + meshDictPtr.reset + ( + new IOobject + ( + "blockMeshDict", + runTime.constant(), + polyMeshDir, + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + } - Info<< nl << "Reading block mesh description dictionary" << endl; - - IOobject meshDescriptionIOobject - ( - "blockMeshDict", - runTime.constant(), - polyMeshDir, - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ); - - if (!meshDescriptionIOobject.headerOk()) + if (!meshDictPtr->headerOk()) { FatalErrorIn(args.executable()) << "Cannot open mesh description file " << nl - << runTime.constant()/polyMeshDir/"blockMeshDict" << nl + << constantDir/"blockMeshDict" << nl + << "or "<< nl + << constantDir/polyMeshDir/polyMesh::meshSubDir/"blockMeshDict" + << nl << exit(FatalError); } - IOdictionary meshDescription(meshDescriptionIOobject); + Info<< nl << "Reading mesh description file" << endl; + + IOdictionary blockMeshDict(meshDictPtr()); Info<< nl << "Creating block mesh" << endl; - blockMesh blocks(meshDescription); + blockMesh blocks(blockMeshDict); if (writeTopo) @@ -145,7 +208,6 @@ int main(int argc, char *argv[]) } - Info<< nl << "Creating mesh from block mesh" << endl; wordList patchNames = blocks.patchNames(); @@ -186,11 +248,11 @@ int main(int argc, char *argv[]) // Read in a list of dictionaries for the merge patch pairs - if (meshDescription.found("mergePatchPairs")) + if (blockMeshDict.found("mergePatchPairs")) { List > mergePatchPairs ( - meshDescription.lookup("mergePatchPairs") + blockMeshDict.lookup("mergePatchPairs") ); if (mergePatchPairs.size()) @@ -296,7 +358,7 @@ int main(int argc, char *argv[]) // Set the precision of the points data to 10 IOstream::defaultPrecision(10); - Info << nl << "Writing polyMesh" << endl; + Info<< nl << "Writing polyMesh" << endl; mesh.removeFiles(mesh.instance()); if (!mesh.write()) {