Skip to content

Commit 98a1439

Browse files
committed
Add some basic notes on time stepping design
1 parent ef92529 commit 98a1439

File tree

1 file changed

+79
-3
lines changed

1 file changed

+79
-3
lines changed

components/omega/doc/design/TimeStepping.md

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,89 @@ If time permits, other schemes will be added and tested. This includes the four-
9191

9292
## 4 Design
9393

94-
Design specifics will be added at a later time.
94+
To ensure modularity, each time stepper is implemented as a separate class. Since there will be common functionality and common interface between different time steppers, every time stepper inherits from an abstract `TimeStepper` base class.
95+
96+
### 4.1 Data types and parameters
97+
98+
#### 4.1.1 Parameters
99+
100+
The time stepper can be specified in the input configuration file:
101+
```yaml
102+
TimeIntegration:
103+
TimeStepper: Forward-Backward
104+
```
105+
In the code, the time stepper type is represented by an enum:
106+
```c++
107+
enum TimeStepperType {
108+
ForwardBackward,
109+
AdamsBashforth2,
110+
RungeKutta4,
111+
...
112+
}
113+
```
114+
115+
#### 4.1.2 Class/structs/data types
116+
117+
#### 4.1.2.1 TimeStepper
118+
119+
The abstract `TimeStepper` class defines the interface that every time stepper needs to implement, and provides common data members and functionality.
120+
121+
```c++
122+
class TimeStepper {
123+
public:
124+
TimeStepper(TimeStepperType TSType, Tendencies* ModelTendencies);
125+
virtual void doStep(State* ModelState, Clock* ModelClock) const = 0;
126+
virtual ~TimeStepper() = default;
127+
128+
TimeStepperType TSType;
129+
private:
130+
Tendencies* ModelTendencies;
131+
};
132+
```
133+
134+
#### 4.1.2.2 Example of a derived class
135+
As an example, the fourth order Runge-Kutta stepper extends the base class by storing the scheme weights and provides a concrete implementation of the `doStep` method.
136+
137+
```c++
138+
class RK4Stepper : public TimeStepper {
139+
public:
140+
RK4Stepper(Tendencies* ModelTendencies);
141+
void doStep(State* ModelState, Clock* ModelClock) const override;
142+
private:
143+
R8 RKWeights[4];
144+
R8 RKSubstepWeights[4];
145+
};
146+
```
147+
148+
### 4.2 Methods
149+
150+
Every time stepper needs to have a constructor and an implementation of the `doStep` method.
151+
152+
#### 4.2.1 Constructor
153+
154+
The constructor will typically call the base class constructor with the right time stepper type, and
155+
then perform scheme-specific initialization
156+
157+
```c++
158+
RK4Stepper::RK4Stepper(Tendencies* ModelTendencies) : TimeStepper(RungeKutta4, ModelTendencies) {
159+
// fill RKWeights and RKSubstepWeights
160+
...
161+
}
162+
```
163+
164+
#### 4.2.2 Time step advance
165+
166+
The public `doStep` method
167+
```c++
168+
void doStep(State* ModelState, Clock* ModelClock) const;
169+
```
170+
advances the model state and clock by one time step.
95171

96172
## 5 Verification and Testing
97173

98174
The timestepping will be tested with a time-only convergence test on the equations
99175
$$
100-
\frac{\partial \boldsymbol{u}}{\partial t} =
176+
\frac{\partial \boldsymbol{u}}{\partial t} =
101177
-Ra \, \boldsymbol{u}
102178
\hspace{1cm} (1)
103179
$$
@@ -108,7 +184,7 @@ $$
108184
$$
109185

110186
$$
111-
\frac{\partial h \phi}{\partial t} =
187+
\frac{\partial h \phi}{\partial t} =
112188
- \frac{h}{\tau} \left( \phi - \phi_0 \right)
113189
\hspace{1cm} (3)
114190
$$

0 commit comments

Comments
 (0)