All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2020 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 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class timeControl Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class timeControl
51 {
52 public:
53 
54  //- The time control options
55  enum class timeControls
56  {
57  timeStep,
58  writeTime,
59  outputTime,
61  runTime,
62  clockTime,
63  cpuTime,
64  none
65  };
66 
67 
68 private:
69 
70  // Private Data
71 
72  //- Time object
73  const Time& time_;
74 
75  //- Prefix
76  const word prefix_;
77 
78  //- String representation of timeControls enums
79  static const NamedEnum<timeControls, 8> timeControlNames_;
80 
81  //- Type of time control
82  timeControls timeControl_;
83 
84  //- Execution interval steps for timeStep mode
85  // a value <= 1 means execute at every time step
86  label intervalSteps_;
87 
88  //- Execution interval
89  scalar interval_;
90 
91  //- Index of previous execution
92  label executionIndex_;
93 
94 
95 public:
96 
97  // Constructors
98 
99  //- Construct from Time object and dictionary
101  (
102  const Time&,
103  const dictionary&,
104  const word& prefix
105  );
106 
107  //- Disallow default bitwise copy construction
108  timeControl(const timeControl&) = delete;
109 
110 
111  //- Destructor
112  ~timeControl();
113 
114 
115  // Member Functions
116 
117  //- Read from dictionary
118  void read(const dictionary&);
119 
120  //- Return Time
121  inline const Time& time() const;
122 
123  //- Flag to indicate whether to execute
124  bool execute();
125 
126  //- Return control
127  inline timeControls control() const;
128 
129  //- Return interval
130  inline scalar interval() const;
131 
132  //- Return the index of the previous execution
133  inline label executionIndex() const;
134 
135 
136  // Member Operators
137 
138  //- Disallow default bitwise assignment
139  void operator=(const timeControl&) = delete;
140 };
141 
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 } // End namespace Foam
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 #include "timeControlI.H"
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 #endif
154 
155 // ************************************************************************* //
timeControl(const Time &, const dictionary &, const word &prefix)
Construct from Time object and dictionary.
Definition: timeControl.C:55
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
timeControls control() const
Return control.
Definition: timeControlI.H:34
label executionIndex() const
Return the index of the previous execution.
Definition: timeControlI.H:46
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
timeControls
The time control options.
Definition: timeControl.H:54
bool execute()
Flag to indicate whether to execute.
Definition: timeControl.C:140
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
const Time & time() const
Return Time.
Definition: timeControlI.H:28
A class for handling words, derived from string.
Definition: word.H:59
scalar interval() const
Return interval.
Definition: timeControlI.H:40
execution is coupled to the write-time
execution is coupled to the output-time
~timeControl()
Destructor.
Definition: timeControl.C:74
General time dependent execution controller. The default to execute every time-step.
Definition: timeControl.H:49
void operator=(const timeControl &)=delete
Disallow default bitwise assignment.
void read(const dictionary &)
Read from dictionary.
Definition: timeControl.C:80
execution is coupled to the time-step
Namespace for OpenFOAM.