timeSelector : added -latestTime0 to allow 0/ in the latest time selection

This commit is contained in:
Mark Olesen
2008-12-09 19:02:25 +01:00
parent 9a0a0d051e
commit 31e1b1ba0e

View File

@ -133,6 +133,7 @@ void Foam::timeSelector::addOptions
argList::validOptions.insert("noZero", ""); argList::validOptions.insert("noZero", "");
argList::validOptions.insert("time", "time"); argList::validOptions.insert("time", "time");
argList::validOptions.insert("latestTime", ""); argList::validOptions.insert("latestTime", "");
argList::validOptions.insert("latestTime0", "");
} }
@ -169,11 +170,23 @@ Foam::List<Foam::instant> Foam::timeSelector::select
if (args.options().found("time")) if (args.options().found("time"))
{ {
// can match 0/, but never constant/
selectTimes = timeSelector selectTimes = timeSelector
( (
IStringStream(args.options()["time"])() IStringStream(args.options()["time"])()
).selected(timeDirs); ).selected(timeDirs);
} }
else if (args.options().found("latestTime0"))
{
selectTimes = false;
const label latestIdx = timeDirs.size() - 1;
// avoid false match on constant/
if (latestIdx != constantIdx)
{
selectTimes[latestIdx] = true;
}
}
else if (args.options().found("latestTime")) else if (args.options().found("latestTime"))
{ {
selectTimes = false; selectTimes = false;
@ -186,9 +199,9 @@ Foam::List<Foam::instant> Foam::timeSelector::select
} }
} }
// special treatment for constant/
if (constantIdx >= 0) if (constantIdx >= 0)
{ {
// only add constant/ if specifically requested
selectTimes[constantIdx] = args.options().found("constant"); selectTimes[constantIdx] = args.options().found("constant");
} }
@ -197,11 +210,22 @@ Foam::List<Foam::instant> Foam::timeSelector::select
{ {
if (args.options().found("noZero")) if (args.options().found("noZero"))
{ {
// exclude 0/ if specifically requested
selectTimes[zeroIdx] = false; selectTimes[zeroIdx] = false;
} }
else if (argList::validOptions.found("zeroTime")) else if (argList::validOptions.found("zeroTime"))
{ {
selectTimes[zeroIdx] = args.options().found("zeroTime"); // with -zeroTime enabled
if (args.options().found("zeroTime"))
{
// include 0/ if specifically requested
selectTimes[zeroIdx] = true;
}
else
{
// normally drop 0/, except with -latestTime0 option
selectTimes[zeroIdx] = args.options().found("latestTime0");
}
} }
} }