Skip to content
Snippets Groups Projects
Commit 0da8c186 authored by mattijs's avatar mattijs
Browse files

ENH: Have -region argument to foamFormatConvert

parent 626ce2bb
No related merge requests found
......@@ -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<cellIOList>("cells", runTime);
writeMeshObject<labelIOList>("owner", runTime);
writeMeshObject<labelIOList>("neighbour", runTime);
writeMeshObject<faceIOList>("faces", runTime);
writeMeshObject<pointIOField>("points", runTime);
writeMeshObject<labelIOList>("pointProcAddressing", runTime);
writeMeshObject<labelIOList>("faceProcAddressing", runTime);
writeMeshObject<labelIOList>("cellProcAddressing", runTime);
writeMeshObject<labelIOList>("boundaryProcAddressing", runTime);
writeMeshObject<cellIOList>("cells", meshDir, runTime);
writeMeshObject<labelIOList>("owner", meshDir, runTime);
writeMeshObject<labelIOList>("neighbour", meshDir, runTime);
writeMeshObject<faceIOList>("faces", meshDir, runTime);
writeMeshObject<pointIOField>("points", meshDir, runTime);
writeMeshObject<labelIOList>("pointProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("cellProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>
(
"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)
{
......
......@@ -40,13 +40,18 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class T>
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,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment