Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
db
Time
timeSelector.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
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
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
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
19
for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
Class
25
Foam::timeSelector
26
27
Description
28
A List of scalarRange for selecting times.
29
30
The timeSelector provides a convenient means of selecting multiple
31
times. A typical use would be the following:
32
33
@verbatim
34
timeSelector::addOptions();
35
// add other options
36
#include <OpenFOAM/setRootCase.H>
37
#include <OpenFOAM/createTime.H>
38
instantList timeDirs = timeSelector::select0(runTime, args);
39
...
40
forAll(timeDirs, timeI)
41
{
42
...
43
}
44
@endverbatim
45
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.
50
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
55
arguments.
56
57
@verbatim
58
timeSelector::addOptions(false, true);
59
@endverbatim
60
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.
65
66
SourceFiles
67
timeSelector.C
68
69
\*---------------------------------------------------------------------------*/
70
71
#ifndef timeSelector_H
72
#define timeSelector_H
73
74
#include <
OpenFOAM/scalarRanges.H
>
75
#include <
OpenFOAM/instant.H
>
76
77
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78
79
namespace
Foam
80
{
81
82
// Forward declaration of classes
83
class
argList;
84
class
Time;
85
86
/*---------------------------------------------------------------------------*\
87
Class timeSelector Declaration
88
\*---------------------------------------------------------------------------*/
89
90
class
timeSelector
91
:
92
public
scalarRanges
93
{
94
public
:
95
96
// Constructors
97
98
//- Construct Null
99
timeSelector
();
100
101
//- Construct from Istream
102
timeSelector
(
Istream
&);
103
104
105
// Member Functions
106
107
//- Return true if the given instant is within the ranges
108
bool
selected
(
const
instant
&)
const
;
109
110
//- Return the set of selected instants in the given list that are
111
// within the ranges
112
List<bool>
selected
(
const
List<instant>
&)
const
;
113
114
//- Select a list of Time values that are within the ranges
115
List<instant>
select
(
const
List<instant>
&)
const
;
116
117
//- Select a list of Time values that are within the ranges
118
void
inplaceSelect
(
List<instant>
&)
const
;
119
120
//- Add the options handled by timeSelector to argList::validOptions
121
//
122
// @param constant
123
// Add the @b -constant option to include the @c constant/ directory
124
//
125
// @param zeroTime
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
132
(
133
const
bool
constant=
true
,
134
const
bool
zeroTime=
false
135
);
136
137
//- Return the set of times selected based on the argList options
138
static
List<instant>
select
139
(
140
const
List<instant>
&,
141
const
argList
&
args
142
);
143
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
147
(
148
Time
& runTime,
149
const
argList
& args
150
);
151
};
152
153
154
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155
156
}
// End namespace Foam
157
158
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159
160
#endif
161
162
// ************************ vim: set sw=4 sts=4 et: ************************ //