diff --git a/src/OpenFOAM/db/Time/timeSelector.C b/src/OpenFOAM/db/Time/timeSelector.C index 7a8bcc5eb4..05c12671bc 100644 --- a/src/OpenFOAM/db/Time/timeSelector.C +++ b/src/OpenFOAM/db/Time/timeSelector.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,7 +55,7 @@ Foam::List Foam::timeSelector::selected(const instantList& Times) const { List lst(Times.size(), false); - // check ranges, avoid false positive on constant/ + // Check ranges, avoid false positive on constant/ forAll(Times, timeI) { if (Times[timeI].name() != "constant" && selected(Times[timeI])) @@ -64,7 +64,7 @@ Foam::List Foam::timeSelector::selected(const instantList& Times) const } } - // check specific values + // Check specific values forAll(*this, rangeI) { if (operator[](rangeI).isExact()) @@ -163,7 +163,7 @@ Foam::List Foam::timeSelector::select { List selectTimes(timeDirs.size(), true); - // determine locations of constant/ and 0/ directories + // Determine locations of constant/ and 0/ directories label constantIdx = -1; label zeroIdx = -1; @@ -184,15 +184,15 @@ Foam::List Foam::timeSelector::select } } - // determine latestTime selection (if any) - // this must appear before the -time option processing + // Determine latestTime selection (if any) + // This must appear before the -time option processing label latestIdx = -1; if (args.optionFound("latestTime")) { selectTimes = false; latestIdx = timeDirs.size() - 1; - // avoid false match on constant/ + // Avoid false match on constant/ if (latestIdx == constantIdx) { latestIdx = -1; @@ -201,15 +201,14 @@ Foam::List Foam::timeSelector::select if (args.optionFound("time")) { - // can match 0/, but can never match constant/ + // Can match 0/, but can never match constant/ selectTimes = timeSelector ( args.optionLookup("time")() ).selected(timeDirs); } - - // add in latestTime (if selected) + // Add in latestTime (if selected) if (latestIdx >= 0) { selectTimes[latestIdx] = true; @@ -217,21 +216,21 @@ Foam::List Foam::timeSelector::select if (constantIdx >= 0) { - // only add constant/ if specifically requested + // Only add constant/ if specifically requested selectTimes[constantIdx] = args.optionFound("constant"); } - // special treatment for 0/ + // Special treatment for 0/ if (zeroIdx >= 0) { if (args.optionFound("noZero")) { - // exclude 0/ if specifically requested + // Exclude 0/ if specifically requested selectTimes[zeroIdx] = false; } 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"); } } @@ -260,9 +259,11 @@ Foam::List Foam::timeSelector::select0 if (timeDirs.empty()) { - FatalErrorIn(args.executable()) - << "No times selected" - << exit(FatalError); + WarningIn(args.executable()) + << "No time specified or available, selecting 'constant'" + << endl; + + timeDirs.append(instant(0, runTime.constant())); } runTime.setTime(timeDirs[0], 0); diff --git a/src/OpenFOAM/db/Time/timeSelector.H b/src/OpenFOAM/db/Time/timeSelector.H index ce22d83fce..1af2be592e 100644 --- a/src/OpenFOAM/db/Time/timeSelector.H +++ b/src/OpenFOAM/db/Time/timeSelector.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -143,7 +143,8 @@ public: ); //- 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 ( Time& runTime,