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