diff --git a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C index 12e04eb3e3..6a6e0cfce1 100644 --- a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C +++ b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C @@ -64,13 +64,13 @@ namespace Foam // Hack to do zones which have Lists in them. See above. -bool writeZones(const word& name, Time& runTime) +bool writeZones(const word& name, const fileName& meshDir, Time& runTime) { IOobject io ( name, runTime.timeName(), - polyMesh::meshSubDir, + meshDir, runTime, IOobject::MUST_READ, IOobject::NO_WRITE, @@ -144,8 +144,20 @@ bool writeZones(const word& name, Time& runTime) int main(int argc, char *argv[]) { timeSelector::addOptions(); +# include "addRegionOption.H" # include "setRootCase.H" # include "createTime.H" + + fileName meshDir = polyMesh::meshSubDir; + fileName regionPrefix = ""; + word regionName = polyMesh::defaultRegion; + if (args.optionReadIfPresent("region", regionName)) + { + Info<< "Using region " << regionName << nl << endl; + regionPrefix = regionName; + meshDir = regionName/polyMesh::meshSubDir; + } + Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); forAll(timeDirs, timeI) @@ -154,27 +166,32 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << endl; // Convert all the standard mesh files - writeMeshObject("cells", runTime); - writeMeshObject("owner", runTime); - writeMeshObject("neighbour", runTime); - writeMeshObject("faces", runTime); - writeMeshObject("points", runTime); - writeMeshObject("pointProcAddressing", runTime); - writeMeshObject("faceProcAddressing", runTime); - writeMeshObject("cellProcAddressing", runTime); - writeMeshObject("boundaryProcAddressing", runTime); + writeMeshObject("cells", meshDir, runTime); + writeMeshObject("owner", meshDir, runTime); + writeMeshObject("neighbour", meshDir, runTime); + writeMeshObject("faces", meshDir, runTime); + writeMeshObject("points", meshDir, runTime); + writeMeshObject("pointProcAddressing", meshDir, runTime); + writeMeshObject("faceProcAddressing", meshDir, runTime); + writeMeshObject("cellProcAddressing", meshDir, runTime); + writeMeshObject + ( + "boundaryProcAddressing", + meshDir, + runTime + ); if (runTime.writeFormat() == IOstream::ASCII) { // Only do zones when converting from binary to ascii // The other way gives problems since working on dictionary level. - writeZones("cellZones", runTime); - writeZones("faceZones", runTime); - writeZones("pointZones", runTime); + writeZones("cellZones", meshDir, runTime); + writeZones("faceZones", meshDir, runTime); + writeZones("pointZones", meshDir, runTime); } // Get list of objects from the database - IOobjectList objects(runTime, runTime.timeName()); + IOobjectList objects(runTime, runTime.timeName(), regionPrefix); forAllConstIter(IOobjectList, objects, iter) { diff --git a/applications/utilities/miscellaneous/foamFormatConvert/writeMeshObject.H b/applications/utilities/miscellaneous/foamFormatConvert/writeMeshObject.H index 390c76ca03..717f5f4c02 100644 --- a/applications/utilities/miscellaneous/foamFormatConvert/writeMeshObject.H +++ b/applications/utilities/miscellaneous/foamFormatConvert/writeMeshObject.H @@ -40,13 +40,18 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -inline bool writeMeshObject(const word& name, Time& runTime) +inline bool writeMeshObject +( + const word& name, + const fileName& meshDir, + Time& runTime +) { IOobject io ( name, runTime.timeName(), - polyMesh::meshSubDir, + meshDir, runTime, IOobject::MUST_READ, IOobject::NO_WRITE,