1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 A List of scalarRange for selecting times.
30 The timeSelector provides a convenient means of selecting multiple
31 times. A typical use would be the following:
34 timeSelector::addOptions();
36 #include "setRootCase.H"
37 #include "createTime.H"
38 instantList timeDirs = timeSelector::select0(runTime, args);
40 forAll(timeDirs, timeI)
46 The result program would receive @b -time, @b -latestTime, @b -constant
47 and @b -noZero options. The @b -constant option explicitly includes the
48 @c constant/ directory in the time list and the @b -noZero option
49 explicitly excludes the @c 0/ directory from the time list.
51 There may however also be many cases in which neither the @c constant/
52 directory nor the @c 0/ directory contain particularly relevant
53 information. This might occur, for example, when post-processing
54 results. In this case, addOptions is called with optional boolean
58 timeSelector::addOptions(false, true);
61 The first argument avoids adding the @b -constant option. The second
62 argument adds an additional @b -zeroTime option and also prevents the
63 @c 0/ directory from being included in the default time range and in the
64 @b -latestTime selection.
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
126 // Enable the @b -zeroTime option and alter the normal time selection
127 // behaviour (and @b -latestTime behaviour) to exclude the @c 0/
128 // directory. The @c 0/ directory will only be included when
129 // @b -zeroTime is specified.
130 // The @b -noZero option has precedence over the @b -zeroTime option.
131 static void addOptions
133 const bool constant=true,
134 const bool zeroTime=false
137 //- Return the set of times selected based on the argList options
138 static List<instant> select
140 const List<instant>&,
144 //- Return the set of times selected based on the argList options
145 // also set the runTime to the first instance
146 static List<instant> select0
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 } // End namespace Foam
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 // ************************************************************************* //