Skip to content
Snippets Groups Projects
Commit 56296e89 authored by Mark Olesen's avatar Mark Olesen
Browse files

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

parent 2c6b1368
Branches
Tags
No related merge requests found
......@@ -39,6 +39,10 @@ Usage
@param -zeroTime \n
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
- no parallel data.
- writes to @a Ensight directory to avoid collisions with foamToEnsight.
......@@ -70,6 +74,7 @@ int main(int argc, char *argv[])
timeSelector::addOptions(true, false);
argList::noParallel();
argList::validOptions.insert("ascii", "");
argList::validOptions.insert("index", "start");
const word volFieldTypes[] =
{
......@@ -104,6 +109,15 @@ int main(int argc, char *argv[])
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 dataDir = ensightDir/"data";
fileName caseFileName = "Ensight.case";
......
// Read time index from */uniform/time,
// but treat 0 and constant specially
// Read time index from */uniform/time, but treat 0 and constant specially
// or simply increment from the '-index' option if it was supplied
label timeIndex = 0;
if
if (optIndex)
{
timeIndex = indexingNumber++;
}
else if
(
runTime.timeName() != "constant"
&& runTime.timeName() != "0"
......@@ -22,19 +26,8 @@
if (io.headerOk())
{
IOdictionary timeObject
(
IOobject
(
"time",
runTime.timeName(),
"uniform",
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
io.readOpt() = IOobject::MUST_READ;
IOdictionary timeObject(io);
timeObject.lookup("index") >> timeIndex;
}
......
{
IOobject ioPoints
IOobject io
(
"points",
"points",
runTime.timeName(),
polyMesh::meshSubDir,
mesh
);
if (ioPoints.headerOk())
if (io.headerOk())
{
// Reading new points
pointIOField newPoints
(
IOobject
(
"points",
mesh.time().timeName(),
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
// Read new points
io.readOpt() = IOobject::MUST_READ;
pointIOField newPoints(io);
mesh.movePoints(newPoints);
}
}
......@@ -5,7 +5,8 @@ forAllIter(HashTable<word>, volumeFields, fieldIter)
const word& fieldName = fieldIter.key();
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);
}
......
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