ENH: Have -region argument to foamFormatConvert

This commit is contained in:
mattijs
2010-04-27 14:55:30 +01:00
parent 626ce2bb16
commit 0da8c1864d
2 changed files with 39 additions and 17 deletions

View File

@ -64,13 +64,13 @@ namespace Foam
// Hack to do zones which have Lists in them. See above. // 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 IOobject io
( (
name, name,
runTime.timeName(), runTime.timeName(),
polyMesh::meshSubDir, meshDir,
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
@ -144,8 +144,20 @@ bool writeZones(const word& name, Time& runTime)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions(); timeSelector::addOptions();
# include "addRegionOption.H"
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.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); Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
forAll(timeDirs, timeI) forAll(timeDirs, timeI)
@ -154,27 +166,32 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
// Convert all the standard mesh files // Convert all the standard mesh files
writeMeshObject<cellIOList>("cells", runTime); writeMeshObject<cellIOList>("cells", meshDir, runTime);
writeMeshObject<labelIOList>("owner", runTime); writeMeshObject<labelIOList>("owner", meshDir, runTime);
writeMeshObject<labelIOList>("neighbour", runTime); writeMeshObject<labelIOList>("neighbour", meshDir, runTime);
writeMeshObject<faceIOList>("faces", runTime); writeMeshObject<faceIOList>("faces", meshDir, runTime);
writeMeshObject<pointIOField>("points", runTime); writeMeshObject<pointIOField>("points", meshDir, runTime);
writeMeshObject<labelIOList>("pointProcAddressing", runTime); writeMeshObject<labelIOList>("pointProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("faceProcAddressing", runTime); writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("cellProcAddressing", runTime); writeMeshObject<labelIOList>("cellProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("boundaryProcAddressing", runTime); writeMeshObject<labelIOList>
(
"boundaryProcAddressing",
meshDir,
runTime
);
if (runTime.writeFormat() == IOstream::ASCII) if (runTime.writeFormat() == IOstream::ASCII)
{ {
// Only do zones when converting from binary to ascii // Only do zones when converting from binary to ascii
// The other way gives problems since working on dictionary level. // The other way gives problems since working on dictionary level.
writeZones("cellZones", runTime); writeZones("cellZones", meshDir, runTime);
writeZones("faceZones", runTime); writeZones("faceZones", meshDir, runTime);
writeZones("pointZones", runTime); writeZones("pointZones", meshDir, runTime);
} }
// Get list of objects from the database // Get list of objects from the database
IOobjectList objects(runTime, runTime.timeName()); IOobjectList objects(runTime, runTime.timeName(), regionPrefix);
forAllConstIter(IOobjectList, objects, iter) forAllConstIter(IOobjectList, objects, iter)
{ {

View File

@ -40,13 +40,18 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class T> template<class T>
inline bool writeMeshObject(const word& name, Time& runTime) inline bool writeMeshObject
(
const word& name,
const fileName& meshDir,
Time& runTime
)
{ {
IOobject io IOobject io
( (
name, name,
runTime.timeName(), runTime.timeName(),
polyMesh::meshSubDir, meshDir,
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,