timeSelector: Change select0 to return 'constant' if no times are specified or available
This allows checkMesh and other mesh manipulation utilities to operate on the mesh without any time directories being present.
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -55,7 +55,7 @@ Foam::List<bool> Foam::timeSelector::selected(const instantList& Times) const
|
|||||||
{
|
{
|
||||||
List<bool> lst(Times.size(), false);
|
List<bool> lst(Times.size(), false);
|
||||||
|
|
||||||
// check ranges, avoid false positive on constant/
|
// Check ranges, avoid false positive on constant/
|
||||||
forAll(Times, timeI)
|
forAll(Times, timeI)
|
||||||
{
|
{
|
||||||
if (Times[timeI].name() != "constant" && selected(Times[timeI]))
|
if (Times[timeI].name() != "constant" && selected(Times[timeI]))
|
||||||
@ -64,7 +64,7 @@ Foam::List<bool> Foam::timeSelector::selected(const instantList& Times) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check specific values
|
// Check specific values
|
||||||
forAll(*this, rangeI)
|
forAll(*this, rangeI)
|
||||||
{
|
{
|
||||||
if (operator[](rangeI).isExact())
|
if (operator[](rangeI).isExact())
|
||||||
@ -163,7 +163,7 @@ Foam::List<Foam::instant> Foam::timeSelector::select
|
|||||||
{
|
{
|
||||||
List<bool> selectTimes(timeDirs.size(), true);
|
List<bool> selectTimes(timeDirs.size(), true);
|
||||||
|
|
||||||
// determine locations of constant/ and 0/ directories
|
// Determine locations of constant/ and 0/ directories
|
||||||
label constantIdx = -1;
|
label constantIdx = -1;
|
||||||
label zeroIdx = -1;
|
label zeroIdx = -1;
|
||||||
|
|
||||||
@ -184,15 +184,15 @@ Foam::List<Foam::instant> Foam::timeSelector::select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine latestTime selection (if any)
|
// Determine latestTime selection (if any)
|
||||||
// this must appear before the -time option processing
|
// This must appear before the -time option processing
|
||||||
label latestIdx = -1;
|
label latestIdx = -1;
|
||||||
if (args.optionFound("latestTime"))
|
if (args.optionFound("latestTime"))
|
||||||
{
|
{
|
||||||
selectTimes = false;
|
selectTimes = false;
|
||||||
latestIdx = timeDirs.size() - 1;
|
latestIdx = timeDirs.size() - 1;
|
||||||
|
|
||||||
// avoid false match on constant/
|
// Avoid false match on constant/
|
||||||
if (latestIdx == constantIdx)
|
if (latestIdx == constantIdx)
|
||||||
{
|
{
|
||||||
latestIdx = -1;
|
latestIdx = -1;
|
||||||
@ -201,15 +201,14 @@ Foam::List<Foam::instant> Foam::timeSelector::select
|
|||||||
|
|
||||||
if (args.optionFound("time"))
|
if (args.optionFound("time"))
|
||||||
{
|
{
|
||||||
// can match 0/, but can never match constant/
|
// Can match 0/, but can never match constant/
|
||||||
selectTimes = timeSelector
|
selectTimes = timeSelector
|
||||||
(
|
(
|
||||||
args.optionLookup("time")()
|
args.optionLookup("time")()
|
||||||
).selected(timeDirs);
|
).selected(timeDirs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add in latestTime (if selected)
|
||||||
// add in latestTime (if selected)
|
|
||||||
if (latestIdx >= 0)
|
if (latestIdx >= 0)
|
||||||
{
|
{
|
||||||
selectTimes[latestIdx] = true;
|
selectTimes[latestIdx] = true;
|
||||||
@ -217,21 +216,21 @@ Foam::List<Foam::instant> Foam::timeSelector::select
|
|||||||
|
|
||||||
if (constantIdx >= 0)
|
if (constantIdx >= 0)
|
||||||
{
|
{
|
||||||
// only add constant/ if specifically requested
|
// Only add constant/ if specifically requested
|
||||||
selectTimes[constantIdx] = args.optionFound("constant");
|
selectTimes[constantIdx] = args.optionFound("constant");
|
||||||
}
|
}
|
||||||
|
|
||||||
// special treatment for 0/
|
// Special treatment for 0/
|
||||||
if (zeroIdx >= 0)
|
if (zeroIdx >= 0)
|
||||||
{
|
{
|
||||||
if (args.optionFound("noZero"))
|
if (args.optionFound("noZero"))
|
||||||
{
|
{
|
||||||
// exclude 0/ if specifically requested
|
// Exclude 0/ if specifically requested
|
||||||
selectTimes[zeroIdx] = false;
|
selectTimes[zeroIdx] = false;
|
||||||
}
|
}
|
||||||
else if (argList::validOptions.found("zeroTime"))
|
else if (argList::validOptions.found("zeroTime"))
|
||||||
{
|
{
|
||||||
// with -zeroTime enabled, drop 0/ unless specifically requested
|
// With -zeroTime enabled, drop 0/ unless specifically requested
|
||||||
selectTimes[zeroIdx] = args.optionFound("zeroTime");
|
selectTimes[zeroIdx] = args.optionFound("zeroTime");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,9 +259,11 @@ Foam::List<Foam::instant> Foam::timeSelector::select0
|
|||||||
|
|
||||||
if (timeDirs.empty())
|
if (timeDirs.empty())
|
||||||
{
|
{
|
||||||
FatalErrorIn(args.executable())
|
WarningIn(args.executable())
|
||||||
<< "No times selected"
|
<< "No time specified or available, selecting 'constant'"
|
||||||
<< exit(FatalError);
|
<< endl;
|
||||||
|
|
||||||
|
timeDirs.append(instant(0, runTime.constant()));
|
||||||
}
|
}
|
||||||
|
|
||||||
runTime.setTime(timeDirs[0], 0);
|
runTime.setTime(timeDirs[0], 0);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -143,7 +143,8 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Return the set of times selected based on the argList options
|
//- Return the set of times selected based on the argList options
|
||||||
// also set the runTime to the first instance
|
// also set the runTime to the first instance or the
|
||||||
|
// \c constant/ directory if no instances are specified or available
|
||||||
static instantList select0
|
static instantList select0
|
||||||
(
|
(
|
||||||
Time& runTime,
|
Time& runTime,
|
||||||
|
|||||||
Reference in New Issue
Block a user