Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_StepperIMEX_RK_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ****************************************************************************
3 // Tempus: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
9 #ifndef Tempus_StepperIMEX_RK_decl_hpp
10 #define Tempus_StepperIMEX_RK_decl_hpp
11 
12 #include "Tempus_config.hpp"
13 #include "Tempus_StepperRKBase.hpp"
15 #include "Tempus_StepperImplicit.hpp"
16 #include "Tempus_WrapperModelEvaluatorPairIMEX_Basic.hpp"
17 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
18  #include "Tempus_StepperRKObserverComposite.hpp"
19 #endif
20 
21 
22 namespace Tempus {
23 
24 /** \brief Implicit-Explicit Runge-Kutta (IMEX-RK) time stepper.
25  *
26  * For the implicit ODE system, \f$ \mathcal{F}(\dot{x},x,t) = 0 \f$,
27  * we need to specialize this in order to separate the explicit, implicit,
28  * and temporal terms for the IMEX-RK time stepper,
29  * \f[
30  * M(x,t)\, \dot{x}(x,t) + G(x,t) + F(x,t) = 0
31  * \f]
32  * or
33  * \f[
34  * \mathcal{G}(\dot{x},x,t) + F(x,t) = 0,
35  * \f]
36  * where \f$\mathcal{G}(\dot{x},x,t) = M(x,t)\, \dot{x} + G(x,t)\f$,
37  * \f$M(x,t)\f$ is the mass matrix, \f$F(x,t)\f$ is the operator
38  * representing the "slow" physics (and is evolved explicitly), and
39  * \f$G(x,t)\f$ is the operator representing the "fast" physics (and is
40  * evolved implicitly). Additionally, we assume that the mass matrix is
41  * invertible, so that
42  * \f[
43  * \dot{x}(x,t) + g(x,t) + f(x,t) = 0
44  * \f]
45  * where \f$f(x,t) = M(x,t)^{-1}\, F(x,t)\f$, and
46  * \f$g(x,t) = M(x,t)^{-1}\, G(x,t)\f$. Using Butcher tableaus for the
47  * explicit and implicit terms,
48  * \f[ \begin{array}{c|c}
49  * \hat{c} & \hat{a} \\ \hline
50  * & \hat{b}^T
51  * \end{array}
52  * \;\;\;\; \mbox{ and } \;\;\;\;
53  * \begin{array}{c|c}
54  * c & a \\ \hline
55  * & b^T
56  * \end{array}, \f]
57  * respectively, the basic IMEX-RK method for \f$s\f$-stages can be written as
58  * \f[ \begin{array}{rcll}
59  * X_i & = & x_{n-1}
60  * - \Delta t \sum_{j=1}^{i-1} \hat{a}_{ij}\, f(X_j,\hat{t}_j)
61  * - \Delta t \sum_{j=1}^i a_{ij}\, g(X_j,t_j)
62  * & \mbox{for } i=1\ldots s, \\
63  * x_n & = & x_{n-1}
64  * - \Delta t \sum_{i=1}^s \hat{b}_{i}\, f(X_i,\hat{t}_i)
65  * - \Delta t \sum_{i=1}^s b_{i}\, g(X_i,t_i) &
66  * \end{array} \f]
67  * where \f$\hat{t}_i = t_{n-1}+\hat{c}_i\Delta t\f$ and
68  * \f$t_i = t_{n-1}+c_i\Delta t\f$. Note that the "slow" explicit physics,
69  * \f$f(X_j,\hat{t}_j)\f$, is evaluated at the explicit stage time,
70  * \f$\hat{t}_j\f$, and the "fast" implicit physics, \f$g(X_j,t_j)\f$, is
71  * evaluated at the implicit stage time, \f$t_j\f$. We can write the stage
72  * solution, \f$X_i\f$, as
73  * \f[
74  * X_i = \tilde{X} - a_{ii} \Delta t\, g(X_i,t_i)
75  * \f]
76  * where
77  * \f[
78  * \tilde{X} = x_{n-1} - \Delta t \sum_{j=1}^{i-1}
79  * \left(\hat{a}_{ij}\, f(X_j,\hat{t}_j) + a_{ij}\, g(X_j,t_j)\right)
80  * \f]
81  * Rewriting this in a form for Newton-type solvers, the implicit ODE is
82  * \f[
83  * \mathcal{G}(\tilde{\dot{X}},X_i,t_i) = \tilde{\dot{X}} + g(X_i,t_i) = 0
84  * \f]
85  * where we have defined a pseudo time derivative, \f$\tilde{\dot{X}}\f$,
86  * \f[
87  * \tilde{\dot{X}} \equiv \frac{X_i - \tilde{X}}{a_{ii} \Delta t}
88  * \quad \quad \left[ = -g(X_i,t_i)\right]
89  * \f]
90  * that can be used with the implicit solve but is <b>not</b> the stage
91  * time derivative, \f$\dot{X}_i\f$. (Note that \f$\tilde{\dot{X}}\f$
92  * can be interpreted as the rate of change of the solution due to the
93  * implicit "fast" physics, and the "mass" version of the implicit ODE,
94  * \f$\mathcal{G}(\tilde{\dot{X}},X_i,t) = M(X_i,t_i)\, \tilde{\dot{X}}
95  * + G(X_i,t_i) = 0\f$, can also be used to solve for \f$\tilde{\dot{X}}\f$).
96  *
97  * To obtain the stage time derivative, \f$\dot{X}_i\f$, we can evaluate
98  * the governing equation at the implicit stage time, \f$t_i\f$,
99  * \f[
100  * \dot{X}_i(X_i,t_i) + g(X_i,t_i) + f(X_i,t_i) = 0
101  * \f]
102  * Note that even the explicit term, \f$f(X_i,t_i)\f$, is evaluated at
103  * the implicit stage time, \f$t_i\f$. Solving for \f$\dot{X}_i\f$, we find
104  * \f{eqnarray*}{
105  * \dot{X}(X_i,t_i) & = & - g(X_i,t_i) - f(X_i,t_i) \\
106  * \dot{X}(X_i,t_i) & = & \tilde{\dot{X}} - f(X_i,t_i)
107  * \f}
108  *
109  * <b> Iteration Matrix, \f$W\f$.</b>
110  * Recalling that the definition of the iteration matrix, \f$W\f$, is
111  * \f[
112  * W = \alpha \frac{\partial \mathcal{F}_n}{\partial \dot{x}_n}
113  * + \beta \frac{\partial \mathcal{F}_n}{\partial x_n},
114  * \f]
115  * where \f$ \alpha \equiv \frac{\partial \dot{x}_n(x_n) }{\partial x_n}, \f$
116  * and \f$ \beta \equiv \frac{\partial x_n}{\partial x_n} = 1\f$. For the stage
117  * solutions, we are solving
118  * \f[
119  * \mathcal{G} = \tilde{\dot{X}} + g(X_i,t_i) = 0.
120  * \f]
121  * where \f$\mathcal{F}_n \rightarrow \mathcal{G}\f$,
122  * \f$x_n \rightarrow X_{i}\f$, and
123  * \f$\dot{x}_n(x_n) \rightarrow \tilde{\dot{X}}(X_{i})\f$.
124  * The time derivative for the implicit solves is
125  * \f[
126  * \tilde{\dot{X}} \equiv \frac{X_i - \tilde{X}}{a_{ii} \Delta t}
127  * \f]
128  * and we can determine that
129  * \f$ \alpha = \frac{1}{a_{ii} \Delta t} \f$
130  * and \f$ \beta = 1 \f$, and therefore write
131  * \f[
132  * W = \frac{1}{a_{ii} \Delta t}
133  * \frac{\partial \mathcal{G}}{\partial \tilde{\dot{X}}}
134  * + \frac{\partial \mathcal{G}}{\partial X_i}.
135  * \f]
136  *
137  * <b>Explicit Stage in the Implicit Tableau.</b>
138  * For the special case of an explicit stage in the implicit tableau,
139  * \f$a_{ii}=0\f$, we find that the stage solution, \f$X_i\f$, is
140  * \f[
141  * X_i = x_{n-1} - \Delta t\,\sum_{j=1}^{i-1} \left(
142  * \hat{a}_{ij}\,f(X_j,\hat{t}_j) + a_{ij}\,g(X_j,t_j) \right) = \tilde{X}
143  * \f]
144  * and the time derivative of the stage solution, \f$\dot{X}(X_i,t_i)\f$, is
145  * \f[
146  * \dot{X}_i(X_i,t_i) = - g(X_i,t_i) - f(X_i,t_i)
147  * \f]
148  * and again note that the explicit term, \f$f(X_i,t_i)\f$, is evaluated
149  * at the implicit stage time, \f$t_i\f$.
150  *
151  * <b> IMEX-RK Algorithm </b>
152  *
153  * The single-timestep algorithm for IMEX-RK is
154  *
155  * \f{algorithm}{
156  * \renewcommand{\thealgorithm}{}
157  * \caption{IMEX RK with the application-action locations indicated.}
158  * \begin{algorithmic}[1]
159  * \State {\it appAction.execute(solutionHistory, stepper, BEGIN\_STEP)}
160  * \State $X \leftarrow x_{n-1}$ \Comment Set initial guess to last timestep.
161  * \For {$i = 0 \ldots s-1$}
162  * \State $\tilde{X} \leftarrow x_{n-1} - \Delta t\,\sum_{j=1}^{i-1} \left(
163  * \hat{a}_{ij}\, f_j + a_{ij}\, g_j \right)$
164  * \State {\it appAction.execute(solutionHistory, stepper, BEGIN\_STAGE)}
165  * \State \Comment Implicit Tableau
166  * \If {$a_{ii} = 0$}
167  * \State $X \leftarrow \tilde{X}$
168  * \If {$a_{k,i} = 0 \;\forall k = (i+1,\ldots, s-1)$, $b(i) = 0$, $b^\ast(i) = 0$}
169  * \State $g_i \leftarrow 0$ \Comment{Not needed for later calculations.}
170  * \Else
171  * \State $g_i \leftarrow M(X, t_i)^{-1}\, G(X, t_i)$
172  * \EndIf
173  * \Else
174  * \State {\it appAction.execute(solutionHistory, stepper, BEFORE\_SOLVE)}
175  * \If {``Zero initial guess.''}
176  * \State $X \leftarrow 0$
177  * \Comment{Else use previous stage value as initial guess.}
178  * \EndIf
179  * \State Solve $\mathcal{G}\left(\tilde{\dot{X}}
180  * = \frac{X-\tilde{X}}{a_{ii} \Delta t},X,t_i\right) = 0$ for $X$
181  * \State {\it appAction.execute(solutionHistory, stepper, AFTER\_SOLVE)}
182  * \State $\tilde{\dot{X}} \leftarrow \frac{X - \tilde{X}}{a_{ii} \Delta t}$
183  * \State $g_i \leftarrow - \tilde{\dot{X}}$
184  * \EndIf
185  * \State \Comment Explicit Tableau
186  * \State {\it appAction.execute(solutionHistory, stepper, BEFORE\_EXPLICIT\_EVAL)}
187  * \State $f_i \leftarrow M(X,\hat{t}_i)^{-1}\, F(X,\hat{t}_i)$
188  * \State $\dot{X} \leftarrow - g_i - f_i$ [Optionally]
189  * \State {\it appAction.execute(solutionHistory, stepper, END\_STAGE)}
190  * \EndFor
191  * \State $x_n \leftarrow x_{n-1} - \Delta t\,\sum_{i=1}^{s}\hat{b}_i\,f_i
192  * - \Delta t\,\sum_{i=1}^{s} b_i \,g_i$
193  * \State {\it appAction.execute(solutionHistory, stepper, END\_STEP)}
194  * \end{algorithmic}
195  * \f}
196  *
197  * The following table contains the pre-coded IMEX-RK tableaus.
198  * <table>
199  * <caption id="multi_row">IMEX-RK Tableaus</caption>
200  * <tr><th> Name <th> Order <th> Implicit Tableau <th> Explicit Tableau
201  * <tr><td> IMEX RK 1st order <td> 1st
202  * <td> \f[ \begin{array}{c|cc}
203  * 0 & 0 & 0 \\
204  * 1 & 0 & 1 \\ \hline
205  * & 0 & 1
206  * \end{array} \f]
207  * <td> \f[ \begin{array}{c|cc}
208  * 0 & 0 & 0 \\
209  * 1 & 1 & 0 \\ \hline
210  * & 1 & 0
211  * \end{array} \f]
212  * <tr><td> SSP1_111 <td> 1st
213  * <td> \f[ \begin{array}{c|c}
214  * 1 & 1 \\ \hline
215  * & 1
216  * \end{array} \f]
217  * <td> \f[ \begin{array}{c|c}
218  * 0 & 0 \\ \hline
219  * & 1
220  * \end{array} \f]
221  * <tr><td> IMEX RK SSP2\n SSP2_222_L\n \f$\gamma = 1-1/\sqrt{2}\f$ <td> 2nd
222  * <td> \f[ \begin{array}{c|cc}
223  * \gamma & \gamma & 0 \\
224  * 1-\gamma & 1-2\gamma & \gamma \\ \hline
225  * & 1/2 & 1/2
226  * \end{array} \f]
227  * <td> \f[ \begin{array}{c|cc}
228  * 0 & 0 & 0 \\
229  * 1 & 1 & 0 \\ \hline
230  * & 1/2 & 1/2
231  * \end{array} \f]
232  * <tr><td> SSP2_222\n SSP2_222_A\n \f$\gamma = 1/2\f$ <td> 2nd
233  * <td> \f[ \begin{array}{c|cc}
234  * \gamma & \gamma & 0 \\
235  * 1-\gamma & 1-2\gamma & \gamma \\ \hline
236  * & 1/2 & 1/2
237  * \end{array} \f]
238  * <td> \f[ \begin{array}{c|cc}
239  * 0 & 0 & 0 \\
240  * 1 & 1 & 0 \\ \hline
241  * & 1/2 & 1/2
242  * \end{array} \f]
243  * <tr><td> IMEX RK SSP3\n SSP3_332\n \f$\gamma = 1/ (2 + \sqrt{2})\f$ <td> 3rd
244  * <td> \f[ \begin{array}{c|ccc}
245  * 0 & 0 & & \\
246  * 1 & 1 & 0 & \\
247  * 1/2 & 1/4 & 1/4 & 0 \\ \hline
248  * & 1/6 & 1/6 & 4/6 \end{array} \f]
249  * <td> \f[ \begin{array}{c|ccc}
250  * \gamma & \gamma & & \\
251  * 1-\gamma & 1-2\gamma & \gamma & \\
252  * 1-2 & 1/2 -\gamma & 0 & \gamma \\ \hline
253  * & 1/6 & 1/6 & 2/3 \end{array} \f]
254  * <tr><td> IMEX RK ARS 233\n ARS 233\n \f$\gamma = (3+\sqrt{3})/6\f$ <td> 3rd
255  * <td> \f[ \begin{array}{c|ccc}
256  * 0 & 0 & 0 & 0 \\
257  * \gamma & 0 & \gamma & 0 \\
258  * 1-\gamma & 0 & 1-2\gamma & \gamma \\ \hline
259  * & 0 & 1/2 & 1/2
260  * \end{array} \f]
261  * <td> \f[ \begin{array}{c|ccc}
262  * 0 & 0 & 0 & 0 \\
263  * \gamma & \gamma & 0 & 0 \\
264  * 1-\gamma & \gamma-1 & 2-2\gamma & 0 \\ \hline
265  * & 0 & 1/2 & 1/2
266  * \end{array} \f]
267  * </table>
268  *
269  * The First-Step-As-Last (FSAL) principle is not valid for IMEX RK.
270  * The default is to set useFSAL=false, and useFSAL=true will result
271  * in an error.
272  *
273  *
274  * #### References
275  * -# Ascher, Ruuth, Spiteri, "Implicit-explicit Runge-Kutta methods for
276  * time-dependent partial differential equations", Applied Numerical
277  * Mathematics 25 (1997) 151-167.
278  * -# Cyr, "IMEX Lagrangian Methods", SAND2015-3745C.
279  * -# Shadid, Cyr, Pawlowski, Widley, Scovazzi, Zeng, Phillips, Conde,
280  * Chuadhry, Hensinger, Fischer, Robinson, Rider, Niederhaus, Sanchez,
281  * "Towards an IMEX Monolithic ALE Method with Integrated UQ for
282  * Multiphysics Shock-hydro", SAND2016-11353, 2016, pp. 21-28.
283  *
284  */
285 template<class Scalar>
286 class StepperIMEX_RK : virtual public Tempus::StepperImplicit<Scalar>,
287  virtual public Tempus::StepperRKBase<Scalar>
288 {
289 public:
290 
291  /** \brief Default constructor.
292  *
293  * Requires subsequent setModel(), setSolver() and initialize()
294  * calls before calling takeStep().
295  */
296  StepperIMEX_RK();
297 
298  /// Constructor for all member data.
299 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
301  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
302  const Teuchos::RCP<StepperObserver<Scalar> >& obs,
303  const Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> >& solver,
304  bool useFSAL,
305  std::string ICConsistency,
306  bool ICConsistencyCheck,
307  bool zeroInitialGuess,
308  std::string stepperType,
309  Teuchos::RCP<const RKButcherTableau<Scalar> > explicitTableau,
310  Teuchos::RCP<const RKButcherTableau<Scalar> > implicitTableau,
311  Scalar order);
312 #endif
314  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
315  const Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> >& solver,
316  bool useFSAL,
317  std::string ICConsistency,
318  bool ICConsistencyCheck,
319  bool zeroInitialGuess,
320  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction,
321  std::string stepperType,
322  Teuchos::RCP<const RKButcherTableau<Scalar> > explicitTableau,
323  Teuchos::RCP<const RKButcherTableau<Scalar> > implicitTableau,
324  Scalar order);
325 
326 
327  /// \name Basic stepper methods
328  //@{
329  /// Returns the explicit tableau!
330  virtual Teuchos::RCP<const RKButcherTableau<Scalar> > getTableau() const
331  { return getExplicitTableau(); }
332 
333  /// Set both the explicit and implicit tableau from ParameterList
334  virtual void setTableaus( std::string stepperType = "",
335  Teuchos::RCP<const RKButcherTableau<Scalar> > explicitTableau = Teuchos::null,
336  Teuchos::RCP<const RKButcherTableau<Scalar> > implicitTableau = Teuchos::null);
337 
338  /// Return explicit tableau.
339  virtual Teuchos::RCP<const RKButcherTableau<Scalar> > getExplicitTableau() const
340  { return explicitTableau_; }
341 
342  /// Set the explicit tableau from tableau
343  virtual void setExplicitTableau(
344  Teuchos::RCP<const RKButcherTableau<Scalar> > explicitTableau);
345 
346  /// Return implicit tableau.
347  virtual Teuchos::RCP<const RKButcherTableau<Scalar> > getImplicitTableau() const
348  { return implicitTableau_; }
349 
350  /// Set the implicit tableau from tableau
351  virtual void setImplicitTableau(
352  Teuchos::RCP<const RKButcherTableau<Scalar> > implicitTableau);
353 
354  virtual void setModel(
355  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel);
356 
357  virtual Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> > getModel()
358  { return this->wrapperModel_; }
359 
360  virtual void setModelPair(
361  const Teuchos::RCP<WrapperModelEvaluatorPairIMEX_Basic<Scalar> >& mePair);
362 
363  virtual void setModelPair(
364  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& explicitModel,
365  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& implicitModel);
366 
367 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
368  virtual void setObserver(
369  Teuchos::RCP<StepperObserver<Scalar> > obs = Teuchos::null);
370 
371  virtual Teuchos::RCP<StepperObserver<Scalar> > getObserver() const
372  { return this->stepperObserver_; }
373 #endif
374  /// Initialize during construction and after changing input parameters.
375  virtual void initialize();
376 
377  /// Set the initial conditions and make them consistent.
378  virtual void setInitialConditions (
379  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
380 
381  /// Take the specified timestep, dt, and return true if successful.
382  virtual void takeStep(
383  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
384 
385  virtual Teuchos::RCP<Tempus::StepperState<Scalar> >getDefaultStepperState();
386  virtual Scalar getOrder()const { return order_; }
387  virtual Scalar getOrderMin()const { return order_; }
388  virtual Scalar getOrderMax()const { return order_; }
389 
390  virtual bool isExplicit() const {return true;}
391  virtual bool isImplicit() const {return true;}
392  virtual bool isExplicitImplicit() const
393  {return isExplicit() and isImplicit();}
394  virtual bool isOneStepMethod() const {return true;}
395  virtual bool isMultiStepMethod() const {return !isOneStepMethod();}
396 
397  virtual OrderODE getOrderODE() const {return FIRST_ORDER_ODE;}
398  //@}
399 
400  std::vector<Teuchos::RCP<Thyra::VectorBase<Scalar> > >& getStageF() {return stageF_;};
401  std::vector<Teuchos::RCP<Thyra::VectorBase<Scalar> > >& getStageG() {return stageG_;};
402  Teuchos::RCP<Thyra::VectorBase<Scalar> >& getXTilde() {return xTilde_;};
403 
404  /// Return alpha = d(xDot)/dx.
405  virtual Scalar getAlpha(const Scalar dt) const
406  {
407  const Teuchos::SerialDenseMatrix<int,Scalar> & A = implicitTableau_->A();
408  return Scalar(1.0)/(dt*A(0,0)); // Getting the first diagonal coeff!
409  }
410  /// Return beta = d(x)/dx.
411  virtual Scalar getBeta (const Scalar ) const { return Scalar(1.0); }
412 
413  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
414 
415  /// \name Overridden from Teuchos::Describable
416  //@{
417  virtual void describe(Teuchos::FancyOStream & out,
418  const Teuchos::EVerbosityLevel verbLevel) const;
419  //@}
420 
421  virtual bool isValidSetup(Teuchos::FancyOStream & out) const;
422 
424  const Teuchos::RCP<const Thyra::VectorBase<Scalar> > & X,
425  Scalar time, Scalar stepSize, Scalar stageNumber,
426  const Teuchos::RCP<Thyra::VectorBase<Scalar> > & G) const;
427 
428  void evalExplicitModel(
429  const Teuchos::RCP<const Thyra::VectorBase<Scalar> > & X,
430  Scalar time, Scalar stepSize, Scalar stageNumber,
431  const Teuchos::RCP<Thyra::VectorBase<Scalar> > & F) const;
432 
433  virtual bool getICConsistencyCheckDefault() const { return false; }
434 
435  void setOrder(Scalar order) { order_ = order; }
436 
437 protected:
438 
439  Teuchos::RCP<const RKButcherTableau<Scalar> > explicitTableau_;
440  Teuchos::RCP<const RKButcherTableau<Scalar> > implicitTableau_;
441 
442  Scalar order_;
443 
444  std::vector<Teuchos::RCP<Thyra::VectorBase<Scalar> > > stageF_;
445  std::vector<Teuchos::RCP<Thyra::VectorBase<Scalar> > > stageG_;
446 
447  Teuchos::RCP<Thyra::VectorBase<Scalar> > xTilde_;
448 
449 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
450  Teuchos::RCP<StepperRKObserverComposite<Scalar> > stepperObserver_;
451 #endif
452 
453 };
454 
455 
456 /** \brief Time-derivative interface for IMEX RK.
457  *
458  * Given the stage state \f$X_i\f$ and
459  * \f[
460  * \tilde{X} = x_{n-1} +\Delta t \sum_{j=1}^{i-1} a_{ij}\,\dot{X}_{j},
461  * \f]
462  * compute the IMEX RK stage time-derivative,
463  * \f[
464  * \dot{X}_i = \frac{X_{i} - \tilde{X}}{a_{ii} \Delta t}
465  * \f]
466  * \f$\ddot{x}\f$ is not used and set to null.
467  */
468 template <typename Scalar>
470  : virtual public Tempus::TimeDerivative<Scalar>
471 {
472 public:
473 
474  /// Constructor
476  Scalar s, Teuchos::RCP<const Thyra::VectorBase<Scalar> > xTilde)
477  { initialize(s, xTilde); }
478 
479  /// Destructor
481 
482  /// Compute the time derivative.
483  virtual void compute(
484  Teuchos::RCP<const Thyra::VectorBase<Scalar> > x,
485  Teuchos::RCP< Thyra::VectorBase<Scalar> > xDot,
486  Teuchos::RCP< Thyra::VectorBase<Scalar> > xDotDot = Teuchos::null)
487  {
488  xDotDot = Teuchos::null;
489 
490  // ith stage
491  // s = 1/(dt*a_ii)
492  // xOld = solution at beginning of time step
493  // xTilde = xOld + dt*(Sum_{j=1}^{i-1} a_ij x_dot_j)
494  // xDotTilde = - (s*x_i - s*xTilde)
495  Thyra::V_StVpStV(xDot.ptr(),s_,*x,-s_,*xTilde_);
496  }
497 
498  virtual void initialize(Scalar s,
499  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xTilde)
500  { s_ = s; xTilde_ = xTilde; }
501 
502 private:
503 
504  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xTilde_;
505  Scalar s_; // = 1/(dt*a_ii)
506 };
507 
508 
509 } // namespace Tempus
510 #endif // Tempus_StepperIMEX_RK_decl_hpp
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual void setImplicitTableau(Teuchos::RCP< const RKButcherTableau< Scalar > > implicitTableau)
Set the implicit tableau from tableau.
virtual Teuchos::RCP< const RKButcherTableau< Scalar > > getImplicitTableau() const
Return implicit tableau.
virtual Scalar getOrder() const
Teuchos::RCP< StepperRKObserverComposite< Scalar > > stepperObserver_
Teuchos::RCP< WrapperModelEvaluator< Scalar > > wrapperModel_
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
ModelEvaluator pair for implicit and explicit (IMEX) evaulations.
std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > & getStageF()
Implicit-Explicit Runge-Kutta (IMEX-RK) time stepper.
virtual void setExplicitTableau(Teuchos::RCP< const RKButcherTableau< Scalar > > explicitTableau)
Set the explicit tableau from tableau.
Teuchos::RCP< Thyra::VectorBase< Scalar > > xTilde_
virtual bool isMultiStepMethod() const
virtual void initialize(Scalar s, Teuchos::RCP< const Thyra::VectorBase< Scalar > > xTilde)
StepperIMEX_RKTimeDerivative(Scalar s, Teuchos::RCP< const Thyra::VectorBase< Scalar > > xTilde)
Constructor.
virtual void compute(Teuchos::RCP< const Thyra::VectorBase< Scalar > > x, Teuchos::RCP< Thyra::VectorBase< Scalar > > xDot, Teuchos::RCP< Thyra::VectorBase< Scalar > > xDotDot=Teuchos::null)
Compute the time derivative.
Teuchos::RCP< const RKButcherTableau< Scalar > > implicitTableau_
Teuchos::RCP< Thyra::VectorBase< Scalar > > & getXTilde()
virtual Teuchos::RCP< const RKButcherTableau< Scalar > > getExplicitTableau() const
Return explicit tableau.
Base class for Runge-Kutta methods, ExplicitRK, DIRK and IMEX.
virtual void setModelPair(const Teuchos::RCP< WrapperModelEvaluatorPairIMEX_Basic< Scalar > > &mePair)
Create WrapperModelPairIMEX from user-supplied ModelEvaluator pair.
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getModel()
Thyra Base interface for implicit time steppers.
Application Action for StepperRKBase.
Teuchos::RCP< const RKButcherTableau< Scalar > > explicitTableau_
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
StepperIMEX_RK()
Default constructor.
virtual void initialize()
Initialize during construction and after changing input parameters.
virtual Scalar getOrderMin() const
virtual bool isExplicitImplicit() const
void evalExplicitModel(const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &X, Scalar time, Scalar stepSize, Scalar stageNumber, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &F) const
std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > stageF_
StepperObserver class for Stepper class.
std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > & getStageG()
virtual void setTableaus(std::string stepperType="", Teuchos::RCP< const RKButcherTableau< Scalar > > explicitTableau=Teuchos::null, Teuchos::RCP< const RKButcherTableau< Scalar > > implicitTableau=Teuchos::null)
Set both the explicit and implicit tableau from ParameterList.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual void setObserver(Teuchos::RCP< StepperObserver< Scalar > > obs=Teuchos::null)
Set Observer.
virtual OrderODE getOrderODE() const
virtual bool getICConsistencyCheckDefault() const
virtual Scalar getBeta(const Scalar) const
Return beta = d(x)/dx.
Stepper integrates first-order ODEs.
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
void evalImplicitModelExplicitly(const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &X, Scalar time, Scalar stepSize, Scalar stageNumber, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &G) const
virtual Scalar getOrderMax() const
This interface defines the time derivative connection between an implicit Stepper and WrapperModelEva...
virtual bool isOneStepMethod() const
virtual Teuchos::RCP< const RKButcherTableau< Scalar > > getTableau() const
Returns the explicit tableau!
std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > stageG_
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions and make them consistent.
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Provide a StepperState to the SolutionState. This Stepper does not have any special state data...
virtual Teuchos::RCP< StepperObserver< Scalar > > getObserver() const
Get Observer.
Time-derivative interface for IMEX RK.
Teuchos::RCP< const Thyra::VectorBase< Scalar > > xTilde_
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
virtual Scalar getAlpha(const Scalar dt) const
Return alpha = d(xDot)/dx.