TimeState.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::TimeState
29 
30 Description
31  The time value with time-stepping information, user-defined remapping, etc.
32 
33 SourceFiles
34  TimeState.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_TimeState_H
39 #define Foam_TimeState_H
40 
41 #include "dimensionedScalar.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class TimeState Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class TimeState
53 :
54  public dimensionedScalar
55 {
56  // Private Member Functions
57 
58  // //- Dimensions for 1/time
59  // inline static dimensionSet dimInvTime()
60  // {
61  // return dimensionSet(0, 0, -1, 0, 0, 0, 0);
62  // }
63 
64 
65 protected:
66 
67  // Protected Data
68 
69  label timeIndex_;
70  label writeTimeIndex_;
71 
72  scalar deltaT_;
73  scalar deltaT0_;
74  scalar deltaTSave_;
75 
76  bool deltaTchanged_;
77  bool writeTime_;
78 
79 
80  // Protected Member Functions
81 
82  //- Reset some of TimeState (name, value, index)
83  void resetTimeState
84  (
85  const word& newName,
86  const scalar newValue,
87  const label newIndex
88  )
89  {
90  dimensionedScalar::name() = newName;
91  dimensionedScalar::value() = newValue;
92  timeIndex_ = newIndex;
93  }
94 
95 
96 public:
97 
98  // Constructors
99 
100  //- Construct a zero time state, using the current time formatting
101  TimeState();
102 
103 
104  //- Destructor
105  virtual ~TimeState() = default;
106 
107 
108  // Member Functions
109 
110  // Conversion
111 
112  //- Convert the user-time (e.g. CA deg) to real-time (s).
113  virtual scalar userTimeToTime(const scalar theta) const;
114 
115  //- Convert the real-time (s) into user-time (e.g. CA deg)
116  virtual scalar timeToUserTime(const scalar t) const;
117 
118 
119  // Access
120 
121  //- Return the current user-time value.
122  //- (ie, after applying any timeToUserTime() conversion)
123  inline scalar timeOutputValue() const;
124 
125  //- Return the current time name
126  inline const word& timeName() const noexcept;
127 
128  //- Return the current time index
129  inline label timeIndex() const noexcept;
130 
131  //- Return time step value
132  inline scalar deltaTValue() const noexcept;
133 
134  //- Return old time step value
135  inline scalar deltaT0Value() const noexcept;
136 
137  //- Return time step
138  inline dimensionedScalar deltaT() const;
139 
140  //- Return old time step
141  inline dimensionedScalar deltaT0() const;
142 
143  //- True if this is a write interval
144  inline bool writeTime() const noexcept;
145 
146 
147  // Housekeeping
148 
149  //- Deprecated(2016-05) return true if this is a write time.
150  // \deprecated(2016-05) - use writeTime() method
151  bool outputTime() const noexcept { return this->writeTime(); }
152 };
153 
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 } // End namespace Foam
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #include "TimeStateI.H"
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #endif
166 
167 // ************************************************************************* //
const scalar & value() const noexcept
Return const reference to value.
scalar deltaT_
Definition: TimeState.H:67
dimensionedScalar deltaT0() const
Return old time step.
Definition: TimeStateI.H:67
scalar deltaTValue() const noexcept
Return time step value.
Definition: TimeStateI.H:49
The time value with time-stepping information, user-defined remapping, etc.
Definition: TimeState.H:47
virtual ~TimeState()=default
Destructor.
scalar deltaTSave_
Definition: TimeState.H:69
void resetTimeState(const word &newName, const scalar newValue, const label newIndex)
Reset some of TimeState (name, value, index)
Definition: TimeState.H:81
bool writeTime() const noexcept
True if this is a write interval.
Definition: TimeStateI.H:73
const word & timeName() const noexcept
Return the current time name.
Definition: TimeStateI.H:30
label writeTimeIndex_
Definition: TimeState.H:65
virtual scalar timeToUserTime(const scalar t) const
Convert the real-time (s) into user-time (e.g. CA deg)
Definition: TimeState.C:48
scalar deltaT0_
Definition: TimeState.H:68
bool outputTime() const noexcept
Deprecated(2016-05) return true if this is a write time.
Definition: TimeState.H:175
virtual scalar userTimeToTime(const scalar theta) const
Convert the user-time (e.g. CA deg) to real-time (s).
Definition: TimeState.C:42
A class for handling words, derived from Foam::string.
Definition: word.H:63
label timeIndex() const noexcept
Return the current time index.
Definition: TimeStateI.H:43
const direction noexcept
Definition: Scalar.H:258
scalar deltaT0Value() const noexcept
Return old time step value.
Definition: TimeStateI.H:55
bool deltaTchanged_
Definition: TimeState.H:71
const word & name() const noexcept
Return const reference to name.
scalar timeOutputValue() const
Return the current user-time value. (ie, after applying any timeToUserTime() conversion) ...
Definition: TimeStateI.H:24
TimeState()
Construct a zero time state, using the current time formatting.
Definition: TimeState.C:27
dimensionedScalar deltaT() const
Return time step.
Definition: TimeStateI.H:61
Namespace for OpenFOAM.
label timeIndex_
Definition: TimeState.H:64