Commit 56296e89 authored by Mark Olesen's avatar Mark Olesen
Browse files

foamToEnsightParts: added -index option, streamlined IOobject usage, fixed typo

parent 2c6b1368
...@@ -39,6 +39,10 @@ Usage ...@@ -39,6 +39,10 @@ Usage
@param -zeroTime \n @param -zeroTime \n
Include the often incomplete initial conditions. Include the often incomplete initial conditions.
@param -index \<start\>\n
Ignore the time index contained in the time file and use a
simple indexing when creating the @c Ensight/data/######## files.
Note Note
- no parallel data. - no parallel data.
- writes to @a Ensight directory to avoid collisions with foamToEnsight. - writes to @a Ensight directory to avoid collisions with foamToEnsight.
...@@ -70,6 +74,7 @@ int main(int argc, char *argv[]) ...@@ -70,6 +74,7 @@ int main(int argc, char *argv[])
timeSelector::addOptions(true, false); timeSelector::addOptions(true, false);
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("ascii", ""); argList::validOptions.insert("ascii", "");
argList::validOptions.insert("index", "start");
const word volFieldTypes[] = const word volFieldTypes[] =
{ {
...@@ -104,6 +109,15 @@ int main(int argc, char *argv[]) ...@@ -104,6 +109,15 @@ int main(int argc, char *argv[])
format = IOstream::ASCII; format = IOstream::ASCII;
} }
// control for renumbering iterations
bool optIndex = false;
label indexingNumber = 0;
if (args.options().found("index"))
{
optIndex = true;
indexingNumber = readLabel(IStringStream(args.options()["index"])());
}
fileName ensightDir = args.rootPath()/args.globalCaseName()/"Ensight"; fileName ensightDir = args.rootPath()/args.globalCaseName()/"Ensight";
fileName dataDir = ensightDir/"data"; fileName dataDir = ensightDir/"data";
fileName caseFileName = "Ensight.case"; fileName caseFileName = "Ensight.case";
......
// Read time index from */uniform/time, // Read time index from */uniform/time, but treat 0 and constant specially
// but treat 0 and constant specially // or simply increment from the '-index' option if it was supplied
label timeIndex = 0; label timeIndex = 0;
if if (optIndex)
{
timeIndex = indexingNumber++;
}
else if
( (
runTime.timeName() != "constant" runTime.timeName() != "constant"
&& runTime.timeName() != "0" && runTime.timeName() != "0"
...@@ -22,19 +26,8 @@ ...@@ -22,19 +26,8 @@
if (io.headerOk()) if (io.headerOk())
{ {
IOdictionary timeObject io.readOpt() = IOobject::MUST_READ;
( IOdictionary timeObject(io);
IOobject
(
"time",
runTime.timeName(),
"uniform",
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
timeObject.lookup("index") >> timeIndex; timeObject.lookup("index") >> timeIndex;
} }
......
{ {
IOobject ioPoints IOobject io
( (
"points", "points",
runTime.timeName(), runTime.timeName(),
polyMesh::meshSubDir, polyMesh::meshSubDir,
mesh mesh
); );
if (ioPoints.headerOk()) if (io.headerOk())
{ {
// Reading new points // Read new points
pointIOField newPoints io.readOpt() = IOobject::MUST_READ;
( pointIOField newPoints(io);
IOobject
(
"points",
mesh.time().timeName(),
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
mesh.movePoints(newPoints); mesh.movePoints(newPoints);
} }
} }
...@@ -5,7 +5,8 @@ forAllIter(HashTable<word>, volumeFields, fieldIter) ...@@ -5,7 +5,8 @@ forAllIter(HashTable<word>, volumeFields, fieldIter)
const word& fieldName = fieldIter.key(); const word& fieldName = fieldIter.key();
const word& fieldType = fieldIter(); const word& fieldType = fieldIter();
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) != "_0") // ignore _0 fields
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
{ {
volumeFields.erase(fieldIter); volumeFields.erase(fieldIter);
} }
......
Supports Markdown
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