timeControl.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
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::timeControl
26 
27 Description
28  General time dependent execution controller.
29  The default to execute every time-step.
30 
31 SourceFiles
32  timeControl.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef timeControl_H
37 #define timeControl_H
38 
39 #include "Time.H"
40 #include "scalarList.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class timeControl Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class timeControl
52 {
53 public:
54 
55  //- The time control options
56  enum class timeControls
57  {
58  timeStep,
59  writeTime,
60  outputTime,
62  runTime,
63  runTimes,
64  clockTime,
65  cpuTime,
66  none
67  };
68 
69 
70 private:
71 
72  // Private Data
73 
74  //- Reference to time
75  const Time& time_;
76 
77  //- Prefix
78  const word prefix_;
79 
80  //- String representation of timeControls enums
81  static const NamedEnum<timeControls, 9> timeControlNames_;
82 
83  //- Type of time control
84  timeControls timeControl_;
85 
86  //- Execution interval steps for timeStep mode
87  // a value <= 1 means execute at every time step
88  label intervalSteps_;
89 
90  //- Execution interval
91  scalar interval_;
92 
93  //- List of times (for runTimes option)
94  scalarList times_;
95 
96  //- Time delta used for time -> index (for runTimes option)
97  scalar timeDelta_;
98 
99  //- Hash set of mesh mapping time indices (for runTimes option)
100  HashSet<int64_t, Hash<int64_t>> timeIndices_;
101 
102  //- Index of previous execution
103  mutable label executionIndex_;
104 
105 
106 public:
107 
108  // Constructors
109 
110  //- Construct from Time object and dictionary
112  (
113  const Time&,
114  const dictionary&,
115  const word& prefix
116  );
117 
118  //- Disallow default bitwise copy construction
119  timeControl(const timeControl&) = delete;
120 
121 
122  //- Destructor
123  ~timeControl();
124 
125 
126  // Member Functions
127 
128  //- Read from dictionary
129  void read(const dictionary&);
130 
131  //- Return Time
132  inline const Time& time() const;
133 
134  //- Flag to indicate whether to execute
135  bool execute();
136 
137  //- Return the time to the next write
138  scalar timeToNextAction();
139 
140  //- Return control
141  inline timeControls control() const;
142 
143 
144  // Member Operators
145 
146  //- Disallow default bitwise assignment
147  void operator=(const timeControl&) = delete;
148 };
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 #include "timeControlI.H"
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #endif
162 
163 // ************************************************************************* //
A HashTable with keys but without contents.
Definition: HashSet.H:62
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
General time dependent execution controller. The default to execute every time-step.
Definition: timeControl.H:51
const Time & time() const
Return Time.
Definition: timeControlI.H:28
timeControls control() const
Return control.
Definition: timeControlI.H:34
timeControls
The time control options.
Definition: timeControl.H:56
@ adjustableRunTime
Execute/write every 'Interval' run time period.
@ runTime
Execute/write every 'Interval' run time period.
@ clockTime
Execute/write every 'Interval' CPU time period.
@ cpuTime
Execute/write every 'Interval' CPU time period.
@ runTimes
Execute/write at specified list of run times.
@ writeTime
Execute/write every 'Interval' write times.
@ timeStep
Execute/write every 'Interval' time-steps.
@ outputTime
Execute/write every 'Interval' write times.
void read(const dictionary &)
Read from dictionary.
Definition: timeControl.C:82
~timeControl()
Destructor.
Definition: timeControl.C:76
scalar timeToNextAction()
Return the time to the next write.
Definition: timeControl.C:339
bool execute()
Flag to indicate whether to execute.
Definition: timeControl.C:235
void operator=(const timeControl &)=delete
Disallow default bitwise assignment.
timeControl(const Time &, const dictionary &, const word &prefix)
Construct from Time object and dictionary.
Definition: timeControl.C:56
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59