mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Have -region argument to foamFormatConvert
This commit is contained in:
@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user