1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 A List of scalarRange for selecting times.
31 The timeSelector provides a convenient means of selecting multiple
32 times. A typical use would be the following:
35 timeSelector::addOptions();
37 #include "setRootCase.H"
38 #include "createTime.H"
39 instantList timeDirs = timeSelector::select0(runTime, args);
41 forAll(timeDirs, timeI)
47 The result program would receive @b -time, @b -latestTime, @b -constant
48 and @b -noZero options. The @b -constant option explicitly includes the
49 @c constant/ directory in the time list and the @b -noZero option
50 explicitly excludes the @c 0/ directory from the time list.
52 There may however also be many cases in which neither the @c constant/
53 directory nor the @c 0/ directory contain particularly relevant
54 information. This might occur, for example, when post-processing
55 results. In this case, addOptions is called with optional boolean
59 timeSelector::addOptions(false, true);
62 The first argument avoids adding the @b -constant option. The second
63 argument adds an additional @b -zeroTime option and prevents the @c 0/
64 directory from being included in the default time range.
69 \*---------------------------------------------------------------------------*/
71 #ifndef timeSelector_H
72 #define timeSelector_H
74 #include "scalarRanges.H"
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 // Forward declaration of classes
86 /*---------------------------------------------------------------------------*\
87 Class timeSelector Declaration
88 \*---------------------------------------------------------------------------*/
101 //- Construct from Istream
102 timeSelector(Istream&);
107 //- Return true if the given instant is within the ranges
108 bool selected(const instant&) const;
110 //- Return the set of selected instants in the given list that are
112 List<bool> selected(const List<instant>&) const;
114 //- Select a list of Time values that are within the ranges
115 List<instant> select(const List<instant>&) const;
117 //- Select a list of Time values that are within the ranges
118 void inplaceSelect(List<instant>&) const;
120 //- Add the options handled by timeSelector to argList::validOptions
123 // Add the @b -constant option to include the @c constant/ directory
125 // Additional to the @b -noZero option (explicitly exclude the
126 // @c 0/ directory), add the @b -zeroTime option to include the
127 // @c 0/ directory. The @b -noZero option has precedence.
128 static void addOptions
130 const bool constant = true,
131 const bool zeroTime = false
134 //- Return the set of times selected based on the argList options
135 static List<Foam::instant> select
137 const List<instant>&,
141 //- Return the set of times selected based on the argList options
142 // also set the runTime to the first instance
143 static List<Foam::instant> select0
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 } // End namespace Foam
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 // ************************************************************************* //