00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::timeSelector 00026 00027 Description 00028 A List of scalarRange for selecting times. 00029 00030 The timeSelector provides a convenient means of selecting multiple 00031 times. A typical use would be the following: 00032 00033 @verbatim 00034 timeSelector::addOptions(); 00035 // add other options 00036 #include <OpenFOAM/setRootCase.H> 00037 #include <OpenFOAM/createTime.H> 00038 instantList timeDirs = timeSelector::select0(runTime, args); 00039 ... 00040 forAll(timeDirs, timeI) 00041 { 00042 ... 00043 } 00044 @endverbatim 00045 00046 The result program would receive @b -time, @b -latestTime, @b -constant 00047 and @b -noZero options. The @b -constant option explicitly includes the 00048 @c constant/ directory in the time list and the @b -noZero option 00049 explicitly excludes the @c 0/ directory from the time list. 00050 00051 There may however also be many cases in which neither the @c constant/ 00052 directory nor the @c 0/ directory contain particularly relevant 00053 information. This might occur, for example, when post-processing 00054 results. In this case, addOptions is called with optional boolean 00055 arguments. 00056 00057 @verbatim 00058 timeSelector::addOptions(false, true); 00059 @endverbatim 00060 00061 The first argument avoids adding the @b -constant option. The second 00062 argument adds an additional @b -zeroTime option and also prevents the 00063 @c 0/ directory from being included in the default time range and in the 00064 @b -latestTime selection. 00065 00066 SourceFiles 00067 timeSelector.C 00068 00069 \*---------------------------------------------------------------------------*/ 00070 00071 #ifndef timeSelector_H 00072 #define timeSelector_H 00073 00074 #include <OpenFOAM/scalarRanges.H> 00075 #include <OpenFOAM/instant.H> 00076 00077 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00078 00079 namespace Foam 00080 { 00081 00082 // Forward declaration of classes 00083 class argList; 00084 class Time; 00085 00086 /*---------------------------------------------------------------------------*\ 00087 Class timeSelector Declaration 00088 \*---------------------------------------------------------------------------*/ 00089 00090 class timeSelector 00091 : 00092 public scalarRanges 00093 { 00094 public: 00095 00096 // Constructors 00097 00098 //- Construct Null 00099 timeSelector(); 00100 00101 //- Construct from Istream 00102 timeSelector(Istream&); 00103 00104 00105 // Member Functions 00106 00107 //- Return true if the given instant is within the ranges 00108 bool selected(const instant&) const; 00109 00110 //- Return the set of selected instants in the given list that are 00111 // within the ranges 00112 List<bool> selected(const List<instant>&) const; 00113 00114 //- Select a list of Time values that are within the ranges 00115 List<instant> select(const List<instant>&) const; 00116 00117 //- Select a list of Time values that are within the ranges 00118 void inplaceSelect(List<instant>&) const; 00119 00120 //- Add the options handled by timeSelector to argList::validOptions 00121 // 00122 // @param constant 00123 // Add the @b -constant option to include the @c constant/ directory 00124 // 00125 // @param zeroTime 00126 // Enable the @b -zeroTime option and alter the normal time selection 00127 // behaviour (and @b -latestTime behaviour) to exclude the @c 0/ 00128 // directory. The @c 0/ directory will only be included when 00129 // @b -zeroTime is specified. 00130 // The @b -noZero option has precedence over the @b -zeroTime option. 00131 static void addOptions 00132 ( 00133 const bool constant=true, 00134 const bool zeroTime=false 00135 ); 00136 00137 //- Return the set of times selected based on the argList options 00138 static List<instant> select 00139 ( 00140 const List<instant>&, 00141 const argList& args 00142 ); 00143 00144 //- Return the set of times selected based on the argList options 00145 // also set the runTime to the first instance 00146 static List<instant> select0 00147 ( 00148 Time& runTime, 00149 const argList& args 00150 ); 00151 }; 00152 00153 00154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00155 00156 } // End namespace Foam 00157 00158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00159 00160 #endif 00161 00162 // ************************ vim: set sw=4 sts=4 et: ************************ //