Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_StepperRKButcherTableau.hpp
Go to the documentation of this file.
1 //@HEADER
2 // *****************************************************************************
3 // Tempus: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
10 #ifndef Tempus_StepperRKButcherTableau_hpp
11 #define Tempus_StepperRKButcherTableau_hpp
12 
13 // disable clang warnings
14 #ifdef __clang__
15 #pragma clang system_header
16 #endif
17 
18 #include "Tempus_config.hpp"
19 #include "Tempus_StepperExplicitRK.hpp"
20 #include "Tempus_StepperDIRK.hpp"
22 
23 namespace Tempus {
24 
25 // ----------------------------------------------------------------------------
41 template <class Scalar>
42 class StepperERK_ForwardEuler : virtual public StepperExplicitRK<Scalar> {
43  public:
50  {
51  this->setStepperName("RK Forward Euler");
52  this->setStepperType("RK Forward Euler");
53  this->setupTableau();
54  this->setupDefault();
55  this->setUseFSAL(true);
56  this->setICConsistency("Consistent");
57  this->setICConsistencyCheck(false);
58  }
59 
61  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
62  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
63  bool useEmbedded,
64  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
65  {
66  this->setStepperName("RK Forward Euler");
67  this->setStepperType("RK Forward Euler");
68  this->setupTableau();
69  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
70  useEmbedded, stepperRKAppAction);
71  }
72 
73  std::string getDescription() const
74  {
75  std::ostringstream Description;
76  Description << this->getStepperType() << "\n"
77  << "c = [ 0 ]'\n"
78  << "A = [ 0 ]\n"
79  << "b = [ 1 ]'";
80  return Description.str();
81  }
82 
83  void setUseFSAL(bool a)
84  {
85  this->useFSAL_ = a;
86  this->isInitialized_ = false;
87  }
88 
89  protected:
90  void setupTableau()
91  {
96  A(0, 0) = ST::zero();
97  b(0) = ST::one();
98  c(0) = ST::zero();
99  int order = 1;
100 
102  this->getStepperType(), A, b, c, order, order, order));
103  this->tableau_->setTVD(true);
104  this->tableau_->setTVDCoeff(1.0);
105  }
106 };
107 
109 // ------------------------------------------------------------------------
110 template <class Scalar>
112  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
114 {
115  auto stepper = Teuchos::rcp(new StepperERK_ForwardEuler<Scalar>());
116 
117  // Test for aliases.
118  if (pl != Teuchos::null) {
119  auto stepperType =
120  pl->get<std::string>("Stepper Type", stepper->getStepperType());
121 
123  stepperType != stepper->getStepperType() && stepperType != "RK1",
124  std::logic_error,
125  " ParameterList 'Stepper Type' (='"
126  << stepperType << "')\n"
127  << " does not match type for this Stepper (='"
128  << stepper->getStepperType()
129  << "')\n or one of its aliases ('RK1').\n");
130 
131  // Reset default StepperType.
132  pl->set<std::string>("Stepper Type", stepper->getStepperType());
133  }
134 
135  stepper->setStepperRKValues(pl);
136 
137  if (model != Teuchos::null) {
138  stepper->setModel(model);
139  stepper->initialize();
140  }
141 
142  return stepper;
143 }
144 
145 // ----------------------------------------------------------------------------
164 template <class Scalar>
165 class StepperERK_4Stage4thOrder : virtual public StepperExplicitRK<Scalar> {
166  public:
173  {
174  this->setStepperName("RK Explicit 4 Stage");
175  this->setStepperType("RK Explicit 4 Stage");
176  this->setupTableau();
177  this->setupDefault();
178  this->setUseFSAL(false);
179  this->setICConsistency("None");
180  this->setICConsistencyCheck(false);
181  }
182 
184  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
185  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
186  bool useEmbedded,
187  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
188  {
189  this->setStepperName("RK Explicit 4 Stage");
190  this->setStepperType("RK Explicit 4 Stage");
191  this->setupTableau();
192  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
193  useEmbedded, stepperRKAppAction);
194  }
195 
196  std::string getDescription() const
197  {
198  std::ostringstream Description;
199  Description << this->getStepperType() << "\n"
200  << "\"The\" Runge-Kutta Method (explicit):\n"
201  << "Solving Ordinary Differential Equations I:\n"
202  << "Nonstiff Problems, 2nd Revised Edition\n"
203  << "E. Hairer, S.P. Norsett, G. Wanner\n"
204  << "Table 1.2, pg 138\n"
205  << "c = [ 0 1/2 1/2 1 ]'\n"
206  << "A = [ 0 ] \n"
207  << " [ 1/2 0 ]\n"
208  << " [ 0 1/2 0 ]\n"
209  << " [ 0 0 1 0 ]\n"
210  << "b = [ 1/6 1/3 1/3 1/6 ]'";
211  return Description.str();
212  }
213 
215  {
217  const Scalar one = ST::one();
218  const Scalar zero = ST::zero();
219  const Scalar onehalf = one / (2 * one);
220  const Scalar onesixth = one / (6 * one);
221  const Scalar onethird = one / (3 * one);
222 
223  int NumStages = 4;
224  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
227 
228  // Fill A:
229  A(0, 0) = zero;
230  A(0, 1) = zero;
231  A(0, 2) = zero;
232  A(0, 3) = zero;
233  A(1, 0) = onehalf;
234  A(1, 1) = zero;
235  A(1, 2) = zero;
236  A(1, 3) = zero;
237  A(2, 0) = zero;
238  A(2, 1) = onehalf;
239  A(2, 2) = zero;
240  A(2, 3) = zero;
241  A(3, 0) = zero;
242  A(3, 1) = zero;
243  A(3, 2) = one;
244  A(3, 3) = zero;
245 
246  // Fill b:
247  b(0) = onesixth;
248  b(1) = onethird;
249  b(2) = onethird;
250  b(3) = onesixth;
251 
252  // fill c:
253  c(0) = zero;
254  c(1) = onehalf;
255  c(2) = onehalf;
256  c(3) = one;
257 
258  int order = 4;
259 
261  this->getStepperType(), A, b, c, order, order, order));
262  }
263 };
264 
266 // ------------------------------------------------------------------------
267 template <class Scalar>
270  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
272 {
273  auto stepper = Teuchos::rcp(new StepperERK_4Stage4thOrder<Scalar>());
274  stepper->setStepperRKValues(pl);
275 
276  if (model != Teuchos::null) {
277  stepper->setModel(model);
278  stepper->initialize();
279  }
280 
281  return stepper;
282 }
283 
284 // ----------------------------------------------------------------------------
308 template <class Scalar>
309 class StepperERK_BogackiShampine32 : virtual public StepperExplicitRK<Scalar> {
310  public:
317  {
318  this->setStepperName("Bogacki-Shampine 3(2) Pair");
319  this->setStepperType("Bogacki-Shampine 3(2) Pair");
320  this->setupTableau();
321  this->setupDefault();
322  this->setUseFSAL(true);
323  this->setICConsistency("Consistent");
324  this->setICConsistencyCheck(false);
325  }
326 
328  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
329  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
330  bool useEmbedded,
331  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
332  {
333  this->setStepperName("Bogacki-Shampine 3(2) Pair");
334  this->setStepperType("Bogacki-Shampine 3(2) Pair");
335  this->setupTableau();
336  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
337  useEmbedded, stepperRKAppAction);
338  }
339 
340  std::string getDescription() const
341  {
342  std::ostringstream Description;
343  Description << this->getStepperType() << "\n"
344  << "P. Bogacki and L.F. Shampine.\n"
345  << "A 3(2) pair of Runge–Kutta formulas.\n"
346  << "Applied Mathematics Letters, 2(4):321 – 325, 1989.\n"
347  << "c = [ 0 1/2 3/4 1 ]'\n"
348  << "A = [ 0 ]\n"
349  << " [ 1/2 0 ]\n"
350  << " [ 0 3/4 0 ]\n"
351  << " [ 2/9 1/3 4/9 0 ]\n"
352  << "b = [ 2/9 1/3 4/9 0 ]'\n"
353  << "bstar = [ 7/24 1/4 1/3 1/8 ]'";
354  return Description.str();
355  }
356 
357  void setUseFSAL(bool a)
358  {
359  this->useFSAL_ = a;
360  this->isInitialized_ = false;
361  }
362 
363  protected:
365  {
367  using Teuchos::as;
368  int NumStages = 4;
369  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
373 
374  const Scalar one = ST::one();
375  const Scalar zero = ST::zero();
376  const Scalar onehalf = one / (2 * one);
377  const Scalar onethird = one / (3 * one);
378  const Scalar threefourths = (3 * one) / (4 * one);
379  const Scalar twoninths = (2 * one) / (9 * one);
380  const Scalar fourninths = (4 * one) / (9 * one);
381 
382  // Fill A:
383  A(0, 0) = zero;
384  A(0, 1) = zero;
385  A(0, 2) = zero;
386  A(0, 3) = zero;
387  A(1, 0) = onehalf;
388  A(1, 1) = zero;
389  A(1, 2) = zero;
390  A(1, 3) = zero;
391  A(2, 0) = zero;
392  A(2, 1) = threefourths;
393  A(2, 2) = zero;
394  A(2, 3) = zero;
395  A(3, 0) = twoninths;
396  A(3, 1) = onethird;
397  A(3, 2) = fourninths;
398  A(3, 3) = zero;
399 
400  // Fill b:
401  b(0) = A(3, 0);
402  b(1) = A(3, 1);
403  b(2) = A(3, 2);
404  b(3) = A(3, 3);
405 
406  // Fill c:
407  c(0) = zero;
408  c(1) = onehalf;
409  c(2) = threefourths;
410  c(3) = one;
411 
412  // Fill bstar
413  bstar(0) = as<Scalar>(7 * one / (24 * one));
414  bstar(1) = as<Scalar>(1 * one / (4 * one));
415  bstar(2) = as<Scalar>(1 * one / (3 * one));
416  bstar(3) = as<Scalar>(1 * one / (8 * one));
417  int order = 3;
418 
420  this->getStepperType(), A, b, c, order, order, order, bstar));
421  }
422 };
423 
425 // ------------------------------------------------------------------------
426 template <class Scalar>
429  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
431 {
433  stepper->setStepperRKValues(pl);
434 
435  if (model != Teuchos::null) {
436  stepper->setModel(model);
437  stepper->initialize();
438  }
439 
440  return stepper;
441 }
442 
443 // ----------------------------------------------------------------------------
469 template <class Scalar>
470 class StepperERK_Merson45 : virtual public StepperExplicitRK<Scalar> {
471  public:
478  {
479  this->setStepperName("Merson 4(5) Pair");
480  this->setStepperType("Merson 4(5) Pair");
481  this->setupTableau();
482  this->setupDefault();
483  this->setUseFSAL(false);
484  this->setICConsistency("None");
485  this->setICConsistencyCheck(false);
486  }
487 
489  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
490  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
491  bool useEmbedded,
492  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
493  {
494  this->setStepperName("Merson 4(5) Pair");
495  this->setStepperType("Merson 4(5) Pair");
496  this->setupTableau();
497  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
498  useEmbedded, stepperRKAppAction);
499  }
500 
501  std::string getDescription() const
502  {
503  std::ostringstream Description;
504  Description << this->getStepperType() << "\n"
505  << "Solving Ordinary Differential Equations I:\n"
506  << "Nonstiff Problems, 2nd Revised Edition\n"
507  << "E. Hairer, S.P. Norsett, G. Wanner\n"
508  << "Table 4.1, pg 167\n"
509  << "c = [ 0 1/3 1/3 1/2 1 ]'\n"
510  << "A = [ 0 ]\n"
511  << " [ 1/3 0 ]\n"
512  << " [ 1/6 1/6 0 ]\n"
513  << " [ 1/8 0 3/8 0 ]\n"
514  << " [ 1/2 0 -3/2 2 0 ]\n"
515  << "b = [ 1/6 0 0 2/3 1/6 ]'\n"
516  << "bstar = [ 1/10 0 3/10 2/5 1/5 ]'";
517  return Description.str();
518  }
519 
520  protected:
522  {
524  using Teuchos::as;
525  int NumStages = 5;
526  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages, true);
527  Teuchos::SerialDenseVector<int, Scalar> b(NumStages, true);
528  Teuchos::SerialDenseVector<int, Scalar> c(NumStages, true);
529  Teuchos::SerialDenseVector<int, Scalar> bstar(NumStages, true);
530 
531  const Scalar one = ST::one();
532  const Scalar zero = ST::zero();
533 
534  // Fill A:
535  A(1, 0) = as<Scalar>(one / (3 * one));
536 
537  A(2, 0) = as<Scalar>(one / (6 * one));
538  A(2, 1) = as<Scalar>(one / (6 * one));
539 
540  A(3, 0) = as<Scalar>(one / (8 * one));
541  A(3, 2) = as<Scalar>(3 * one / (8 * one));
542 
543  A(4, 0) = as<Scalar>(one / (2 * one));
544  A(4, 2) = as<Scalar>(-3 * one / (2 * one));
545  A(4, 3) = 2 * one;
546 
547  // Fill b:
548  b(0) = as<Scalar>(one / (6 * one));
549  b(3) = as<Scalar>(2 * one / (3 * one));
550  b(4) = as<Scalar>(one / (6 * one));
551 
552  // Fill c:
553  c(0) = zero;
554  c(1) = as<Scalar>(1 * one / (3 * one));
555  c(2) = as<Scalar>(1 * one / (3 * one));
556  c(3) = as<Scalar>(1 * one / (2 * one));
557  c(4) = one;
558 
559  // Fill bstar
560  bstar(0) = as<Scalar>(1 * one / (10 * one));
561  bstar(2) = as<Scalar>(3 * one / (10 * one));
562  bstar(3) = as<Scalar>(2 * one / (5 * one));
563  bstar(4) = as<Scalar>(1 * one / (5 * one));
564  int order = 4;
565 
567  this->getStepperType(), A, b, c, order, order, order, bstar));
568  }
569 };
570 
572 // ------------------------------------------------------------------------
573 template <class Scalar>
575  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
577 {
578  auto stepper = Teuchos::rcp(new StepperERK_Merson45<Scalar>());
579  stepper->setStepperRKValues(pl);
580 
581  if (model != Teuchos::null) {
582  stepper->setModel(model);
583  stepper->initialize();
584  }
585 
586  return stepper;
587 }
588 
589 // ----------------------------------------------------------------------------
612 template <class Scalar>
613 class StepperERK_3_8Rule : virtual public StepperExplicitRK<Scalar> {
614  public:
616  {
617  this->setStepperName("RK Explicit 3/8 Rule");
618  this->setStepperType("RK Explicit 3/8 Rule");
619  this->setupTableau();
620  this->setupDefault();
621  this->setUseFSAL(false);
622  this->setICConsistency("None");
623  this->setICConsistencyCheck(false);
624  }
625 
627  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
628  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
629  bool useEmbedded,
630  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
631  {
632  this->setStepperName("RK Explicit 3/8 Rule");
633  this->setStepperType("RK Explicit 3/8 Rule");
634  this->setupTableau();
635  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
636  useEmbedded, stepperRKAppAction);
637  }
638 
639  std::string getDescription() const
640  {
641  std::ostringstream Description;
642  Description << this->getStepperType() << "\n"
643  << "Solving Ordinary Differential Equations I:\n"
644  << "Nonstiff Problems, 2nd Revised Edition\n"
645  << "E. Hairer, S.P. Norsett, G. Wanner\n"
646  << "Table 1.2, pg 138\n"
647  << "c = [ 0 1/3 2/3 1 ]'\n"
648  << "A = [ 0 ]\n"
649  << " [ 1/3 0 ]\n"
650  << " [-1/3 1 0 ]\n"
651  << " [ 1 -1 1 0 ]\n"
652  << "b = [ 1/8 3/8 3/8 1/8 ]'";
653  return Description.str();
654  }
655 
656  protected:
658  {
660  using Teuchos::as;
661  int NumStages = 4;
662  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
665 
666  const Scalar one = ST::one();
667  const Scalar zero = ST::zero();
668  const Scalar onethird = as<Scalar>(one / (3 * one));
669  const Scalar twothirds = as<Scalar>(2 * one / (3 * one));
670  const Scalar oneeighth = as<Scalar>(one / (8 * one));
671  const Scalar threeeighths = as<Scalar>(3 * one / (8 * one));
672 
673  // Fill A:
674  A(0, 0) = zero;
675  A(0, 1) = zero;
676  A(0, 2) = zero;
677  A(0, 3) = zero;
678  A(1, 0) = onethird;
679  A(1, 1) = zero;
680  A(1, 2) = zero;
681  A(1, 3) = zero;
682  A(2, 0) = -onethird;
683  A(2, 1) = one;
684  A(2, 2) = zero;
685  A(2, 3) = zero;
686  A(3, 0) = one;
687  A(3, 1) = -one;
688  A(3, 2) = one;
689  A(3, 3) = zero;
690 
691  // Fill b:
692  b(0) = oneeighth;
693  b(1) = threeeighths;
694  b(2) = threeeighths;
695  b(3) = oneeighth;
696 
697  // Fill c:
698  c(0) = zero;
699  c(1) = onethird;
700  c(2) = twothirds;
701  c(3) = one;
702 
703  int order = 4;
704 
706  this->getStepperType(), A, b, c, order, order, order));
707  }
708 };
709 
711 // ------------------------------------------------------------------------
712 template <class Scalar>
714  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
716 {
717  auto stepper = Teuchos::rcp(new StepperERK_3_8Rule<Scalar>());
718  stepper->setStepperRKValues(pl);
719 
720  if (model != Teuchos::null) {
721  stepper->setModel(model);
722  stepper->initialize();
723  }
724 
725  return stepper;
726 }
727 
728 // ----------------------------------------------------------------------------
751 template <class Scalar>
753  : virtual public StepperExplicitRK<Scalar> {
754  public:
761  {
762  this->setStepperName("RK Explicit 4 Stage 3rd order by Runge");
763  this->setStepperType("RK Explicit 4 Stage 3rd order by Runge");
764  this->setupTableau();
765  this->setupDefault();
766  this->setUseFSAL(false);
767  this->setICConsistency("None");
768  this->setICConsistencyCheck(false);
769  }
770 
772  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
773  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
774  bool useEmbedded,
775  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
776  {
777  this->setStepperName("RK Explicit 4 Stage 3rd order by Runge");
778  this->setStepperType("RK Explicit 4 Stage 3rd order by Runge");
779  this->setupTableau();
780  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
781  useEmbedded, stepperRKAppAction);
782  }
783 
784  std::string getDescription() const
785  {
786  std::ostringstream Description;
787  Description << this->getStepperType() << "\n"
788  << "Solving Ordinary Differential Equations I:\n"
789  << "Nonstiff Problems, 2nd Revised Edition\n"
790  << "E. Hairer, S.P. Norsett, G. Wanner\n"
791  << "Table 1.1, pg 135\n"
792  << "c = [ 0 1/2 1 1 ]'\n"
793  << "A = [ 0 ]\n"
794  << " [ 1/2 0 ]\n"
795  << " [ 0 1 0 ]\n"
796  << " [ 0 0 1 0 ]\n"
797  << "b = [ 1/6 2/3 0 1/6 ]'";
798  return Description.str();
799  }
800 
801  protected:
803  {
805  int NumStages = 4;
806  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
809 
810  const Scalar one = ST::one();
811  const Scalar onehalf = one / (2 * one);
812  const Scalar onesixth = one / (6 * one);
813  const Scalar twothirds = 2 * one / (3 * one);
814  const Scalar zero = ST::zero();
815 
816  // Fill A:
817  A(0, 0) = zero;
818  A(0, 1) = zero;
819  A(0, 2) = zero;
820  A(0, 3) = zero;
821  A(1, 0) = onehalf;
822  A(1, 1) = zero;
823  A(1, 2) = zero;
824  A(1, 3) = zero;
825  A(2, 0) = zero;
826  A(2, 1) = one;
827  A(2, 2) = zero;
828  A(2, 3) = zero;
829  A(3, 0) = zero;
830  A(3, 1) = zero;
831  A(3, 2) = one;
832  A(3, 3) = zero;
833 
834  // Fill b:
835  b(0) = onesixth;
836  b(1) = twothirds;
837  b(2) = zero;
838  b(3) = onesixth;
839 
840  // Fill c:
841  c(0) = zero;
842  c(1) = onehalf;
843  c(2) = one;
844  c(3) = one;
845 
846  int order = 3;
847 
849  this->getStepperType(), A, b, c, order, order, order));
850  }
851 };
852 
854 // ------------------------------------------------------------------------
855 template <class Scalar>
858  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
860 {
862  stepper->setStepperRKValues(pl);
863 
864  if (model != Teuchos::null) {
865  stepper->setModel(model);
866  stepper->initialize();
867  }
868 
869  return stepper;
870 }
871 
872 // ----------------------------------------------------------------------------
894 template <class Scalar>
896  : virtual public StepperExplicitRK<Scalar> {
897  public:
904  {
905  this->setStepperName("RK Explicit 5 Stage 3rd order by Kinnmark and Gray");
906  this->setStepperType("RK Explicit 5 Stage 3rd order by Kinnmark and Gray");
907  this->setupTableau();
908  this->setupDefault();
909  this->setUseFSAL(false);
910  this->setICConsistency("None");
911  this->setICConsistencyCheck(false);
912  }
913 
915  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
916  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
917  bool useEmbedded,
918  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
919  {
920  this->setStepperName("RK Explicit 5 Stage 3rd order by Kinnmark and Gray");
921  this->setStepperType("RK Explicit 5 Stage 3rd order by Kinnmark and Gray");
922  this->setupTableau();
923  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
924  useEmbedded, stepperRKAppAction);
925  }
926 
927  std::string getDescription() const
928  {
929  std::ostringstream Description;
930  Description << this->getStepperType() << "\n"
931  << "Kinnmark & Gray 5 stage, 3rd order scheme \n"
932  << "Modified by P. Ullrich. From the prim_advance_mod.F90 \n"
933  << "routine in the HOMME atmosphere model code.\n"
934  << "c = [ 0 1/5 1/5 1/3 2/3 ]'\n"
935  << "A = [ 0 ]\n"
936  << " [ 1/5 0 ]\n"
937  << " [ 0 1/5 0 ]\n"
938  << " [ 0 0 1/3 0 ]\n"
939  << " [ 0 0 0 2/3 0 ]\n"
940  << "b = [ 1/4 0 0 0 3/4 ]'";
941  return Description.str();
942  }
943 
944  protected:
946  {
948  int NumStages = 5;
949  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
952 
953  const Scalar one = ST::one();
954  const Scalar onefifth = one / (5 * one);
955  const Scalar onefourth = one / (4 * one);
956  const Scalar onethird = one / (3 * one);
957  const Scalar twothirds = 2 * one / (3 * one);
958  const Scalar threefourths = 3 * one / (4 * one);
959  const Scalar zero = ST::zero();
960 
961  // Fill A:
962  A(0, 0) = zero;
963  A(0, 1) = zero;
964  A(0, 2) = zero;
965  A(0, 3) = zero;
966  A(0, 4) = zero;
967  A(1, 0) = onefifth;
968  A(1, 1) = zero;
969  A(1, 2) = zero;
970  A(1, 3) = zero;
971  A(1, 4) = zero;
972  A(2, 0) = zero;
973  A(2, 1) = onefifth;
974  A(2, 2) = zero;
975  A(2, 3) = zero;
976  A(2, 4) = zero;
977  A(3, 0) = zero;
978  A(3, 1) = zero;
979  A(3, 2) = onethird;
980  A(3, 3) = zero;
981  A(3, 4) = zero;
982  A(4, 0) = zero;
983  A(4, 1) = zero;
984  A(4, 2) = zero;
985  A(4, 3) = twothirds;
986  A(4, 4) = zero;
987 
988  // Fill b:
989  b(0) = onefourth;
990  b(1) = zero;
991  b(2) = zero;
992  b(3) = zero;
993  b(4) = threefourths;
994 
995  // Fill c:
996  c(0) = zero;
997  c(1) = onefifth;
998  c(2) = onefifth;
999  c(3) = onethird;
1000  c(4) = twothirds;
1001 
1002  int order = 3;
1003 
1005  this->getStepperType(), A, b, c, order, order, order));
1006  }
1007 };
1008 
1010 // ------------------------------------------------------------------------
1011 template <class Scalar>
1014  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
1016 {
1018  stepper->setStepperRKValues(pl);
1019 
1020  if (model != Teuchos::null) {
1021  stepper->setModel(model);
1022  stepper->initialize();
1023  }
1024 
1025  return stepper;
1026 }
1027 
1028 // ----------------------------------------------------------------------------
1046 template <class Scalar>
1047 class StepperERK_3Stage3rdOrder : virtual public StepperExplicitRK<Scalar> {
1048  public:
1055  {
1056  this->setStepperName("RK Explicit 3 Stage 3rd order");
1057  this->setStepperType("RK Explicit 3 Stage 3rd order");
1058  this->setupTableau();
1059  this->setupDefault();
1060  this->setUseFSAL(false);
1061  this->setICConsistency("None");
1062  this->setICConsistencyCheck(false);
1063  }
1064 
1066  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
1067  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
1068  bool useEmbedded,
1069  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
1070  {
1071  this->setStepperName("RK Explicit 3 Stage 3rd order");
1072  this->setStepperType("RK Explicit 3 Stage 3rd order");
1073  this->setupTableau();
1074  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
1075  useEmbedded, stepperRKAppAction);
1076  }
1077 
1078  std::string getDescription() const
1079  {
1080  std::ostringstream Description;
1081  Description << this->getStepperType() << "\n"
1082  << "c = [ 0 1/2 1 ]'\n"
1083  << "A = [ 0 ]\n"
1084  << " [ 1/2 0 ]\n"
1085  << " [ -1 2 0 ]\n"
1086  << "b = [ 1/6 4/6 1/6 ]'";
1087  return Description.str();
1088  }
1089 
1090  protected:
1092  {
1093  typedef Teuchos::ScalarTraits<Scalar> ST;
1094  const Scalar one = ST::one();
1095  const Scalar two = Teuchos::as<Scalar>(2 * one);
1096  const Scalar zero = ST::zero();
1097  const Scalar onehalf = one / (2 * one);
1098  const Scalar onesixth = one / (6 * one);
1099  const Scalar foursixth = 4 * one / (6 * one);
1100 
1101  int NumStages = 3;
1102  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
1105 
1106  // Fill A:
1107  A(0, 0) = zero;
1108  A(0, 1) = zero;
1109  A(0, 2) = zero;
1110  A(1, 0) = onehalf;
1111  A(1, 1) = zero;
1112  A(1, 2) = zero;
1113  A(2, 0) = -one;
1114  A(2, 1) = two;
1115  A(2, 2) = zero;
1116 
1117  // Fill b:
1118  b(0) = onesixth;
1119  b(1) = foursixth;
1120  b(2) = onesixth;
1121 
1122  // fill c:
1123  c(0) = zero;
1124  c(1) = onehalf;
1125  c(2) = one;
1126 
1127  int order = 3;
1128 
1130  this->getStepperType(), A, b, c, order, order, order));
1131  }
1132 };
1133 
1135 // ------------------------------------------------------------------------
1136 template <class Scalar>
1139  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
1141 {
1142  auto stepper = Teuchos::rcp(new StepperERK_3Stage3rdOrder<Scalar>());
1143  stepper->setStepperRKValues(pl);
1144 
1145  if (model != Teuchos::null) {
1146  stepper->setModel(model);
1147  stepper->initialize();
1148  }
1149 
1150  return stepper;
1151 }
1152 
1153 // ----------------------------------------------------------------------------
1182 template <class Scalar>
1183 class StepperERK_3Stage3rdOrderTVD : virtual public StepperExplicitRK<Scalar> {
1184  public:
1191  {
1192  this->setStepperName("RK Explicit 3 Stage 3rd order TVD");
1193  this->setStepperType("RK Explicit 3 Stage 3rd order TVD");
1194  this->setupTableau();
1195  this->setupDefault();
1196  this->setUseFSAL(false);
1197  this->setICConsistency("None");
1198  this->setICConsistencyCheck(false);
1199  }
1200 
1202  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
1203  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
1204  bool useEmbedded,
1205  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
1206  {
1207  this->setStepperName("RK Explicit 3 Stage 3rd order TVD");
1208  this->setStepperType("RK Explicit 3 Stage 3rd order TVD");
1209  this->setupTableau();
1210  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
1211  useEmbedded, stepperRKAppAction);
1212  }
1213 
1214  std::string getDescription() const
1215  {
1216  std::ostringstream Description;
1217  Description << this->getStepperType() << "\n"
1218  << "This Stepper is known as 'RK Explicit 3 Stage 3rd order "
1219  "TVD' or 'SSPERK33'.\n"
1220  << "Sigal Gottlieb and Chi-Wang Shu\n"
1221  << "`Total Variation Diminishing Runge-Kutta Schemes'\n"
1222  << "Mathematics of Computation\n"
1223  << "Volume 67, Number 221, January 1998, pp. 73-85\n"
1224  << "c = [ 0 1 1/2 ]'\n"
1225  << "A = [ 0 ]\n"
1226  << " [ 1 0 ]\n"
1227  << " [ 1/4 1/4 0 ]\n"
1228  << "b = [ 1/6 1/6 4/6 ]'\n"
1229  << "This is also written in the following set of updates.\n"
1230  << "u1 = u^n + dt L(u^n)\n"
1231  << "u2 = 3 u^n/4 + u1/4 + dt L(u1)/4\n"
1232  << "u^(n+1) = u^n/3 + 2 u2/2 + 2 dt L(u2)/3";
1233  return Description.str();
1234  }
1235 
1236  protected:
1238  {
1239  typedef Teuchos::ScalarTraits<Scalar> ST;
1240  using Teuchos::as;
1241  const Scalar one = ST::one();
1242  const Scalar zero = ST::zero();
1243  const Scalar onehalf = one / (2 * one);
1244  const Scalar onefourth = one / (4 * one);
1245  const Scalar onesixth = one / (6 * one);
1246  const Scalar foursixth = 4 * one / (6 * one);
1247 
1248  int NumStages = 3;
1249  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
1252  Teuchos::SerialDenseVector<int, Scalar> bstar(NumStages);
1253 
1254  // Fill A:
1255  A(0, 0) = zero;
1256  A(0, 1) = zero;
1257  A(0, 2) = zero;
1258  A(1, 0) = one;
1259  A(1, 1) = zero;
1260  A(1, 2) = zero;
1261  A(2, 0) = onefourth;
1262  A(2, 1) = onefourth;
1263  A(2, 2) = zero;
1264 
1265  // Fill b:
1266  b(0) = onesixth;
1267  b(1) = onesixth;
1268  b(2) = foursixth;
1269 
1270  // fill c:
1271  c(0) = zero;
1272  c(1) = one;
1273  c(2) = onehalf;
1274 
1275  // Fill bstar:
1276  bstar(0) = as<Scalar>(0.291485418878409);
1277  bstar(1) = as<Scalar>(0.291485418878409);
1278  bstar(2) = as<Scalar>(0.417029162243181);
1279 
1280  int order = 3;
1281 
1283  this->getStepperType(), A, b, c, order, order, order, bstar));
1284  this->tableau_->setTVD(true);
1285  this->tableau_->setTVDCoeff(1.0);
1286  }
1287 };
1288 
1290 // ------------------------------------------------------------------------
1291 template <class Scalar>
1294  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
1296 {
1297  auto stepper = Teuchos::rcp(new StepperERK_3Stage3rdOrderTVD<Scalar>());
1298 
1299  // Test for aliases.
1300  if (pl != Teuchos::null) {
1301  auto stepperType =
1302  pl->get<std::string>("Stepper Type", stepper->getStepperType());
1303 
1305  stepperType != stepper->getStepperType() && stepperType != "SSPERK33" &&
1306  stepperType != "SSPRK3",
1307  std::logic_error,
1308  " ParameterList 'Stepper Type' (='"
1309  << stepperType
1310  << "')\n does not match type for this Stepper (='"
1311  << stepper->getStepperType()
1312  << "')\n or one of its aliases ('SSPERK33' or 'SSPRK3').\n");
1313 
1314  // Reset default StepperType.
1315  pl->set<std::string>("Stepper Type", stepper->getStepperType());
1316  }
1317 
1318  stepper->setStepperRKValues(pl);
1319 
1320  if (model != Teuchos::null) {
1321  stepper->setModel(model);
1322  stepper->initialize();
1323  }
1324 
1325  return stepper;
1326 }
1327 
1328 // ----------------------------------------------------------------------------
1350 template <class Scalar>
1351 class StepperERK_3Stage3rdOrderHeun : virtual public StepperExplicitRK<Scalar> {
1352  public:
1359  {
1360  this->setStepperName("RK Explicit 3 Stage 3rd order by Heun");
1361  this->setStepperType("RK Explicit 3 Stage 3rd order by Heun");
1362  this->setupTableau();
1363  this->setupDefault();
1364  this->setUseFSAL(false);
1365  this->setICConsistency("None");
1366  this->setICConsistencyCheck(false);
1367  }
1368 
1370  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
1371  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
1372  bool useEmbedded,
1373  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
1374  {
1375  this->setStepperName("RK Explicit 3 Stage 3rd order by Heun");
1376  this->setStepperType("RK Explicit 3 Stage 3rd order by Heun");
1377  this->setupTableau();
1378  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
1379  useEmbedded, stepperRKAppAction);
1380  }
1381 
1382  std::string getDescription() const
1383  {
1384  std::ostringstream Description;
1385  Description << this->getStepperType() << "\n"
1386  << "Solving Ordinary Differential Equations I:\n"
1387  << "Nonstiff Problems, 2nd Revised Edition\n"
1388  << "E. Hairer, S.P. Norsett, G. Wanner\n"
1389  << "Table 1.1, pg 135\n"
1390  << "c = [ 0 1/3 2/3 ]'\n"
1391  << "A = [ 0 ] \n"
1392  << " [ 1/3 0 ]\n"
1393  << " [ 0 2/3 0 ]\n"
1394  << "b = [ 1/4 0 3/4 ]'";
1395  return Description.str();
1396  }
1397 
1398  protected:
1400  {
1401  typedef Teuchos::ScalarTraits<Scalar> ST;
1402  const Scalar one = ST::one();
1403  const Scalar zero = ST::zero();
1404  const Scalar onethird = one / (3 * one);
1405  const Scalar twothirds = 2 * one / (3 * one);
1406  const Scalar onefourth = one / (4 * one);
1407  const Scalar threefourths = 3 * one / (4 * one);
1408 
1409  int NumStages = 3;
1410  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
1413 
1414  // Fill A:
1415  A(0, 0) = zero;
1416  A(0, 1) = zero;
1417  A(0, 2) = zero;
1418  A(1, 0) = onethird;
1419  A(1, 1) = zero;
1420  A(1, 2) = zero;
1421  A(2, 0) = zero;
1422  A(2, 1) = twothirds;
1423  A(2, 2) = zero;
1424 
1425  // Fill b:
1426  b(0) = onefourth;
1427  b(1) = zero;
1428  b(2) = threefourths;
1429 
1430  // fill c:
1431  c(0) = zero;
1432  c(1) = onethird;
1433  c(2) = twothirds;
1434 
1435  int order = 3;
1436 
1438  this->getStepperType(), A, b, c, order, order, order));
1439  }
1440 };
1441 
1443 // ------------------------------------------------------------------------
1444 template <class Scalar>
1447  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
1449 {
1451  stepper->setStepperRKValues(pl);
1452 
1453  if (model != Teuchos::null) {
1454  stepper->setModel(model);
1455  stepper->initialize();
1456  }
1457 
1458  return stepper;
1459 }
1460 
1461 // ----------------------------------------------------------------------------
1482 template <class Scalar>
1483 class StepperERK_Midpoint : virtual public StepperExplicitRK<Scalar> {
1484  public:
1491  {
1492  this->setStepperName("RK Explicit Midpoint");
1493  this->setStepperType("RK Explicit Midpoint");
1494  this->setupTableau();
1495  this->setupDefault();
1496  this->setUseFSAL(false);
1497  this->setICConsistency("None");
1498  this->setICConsistencyCheck(false);
1499  }
1500 
1502  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
1503  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
1504  bool useEmbedded,
1505  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
1506  {
1507  this->setStepperName("RK Explicit Midpoint");
1508  this->setStepperType("RK Explicit Midpoint");
1509  this->setupTableau();
1510  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
1511  useEmbedded, stepperRKAppAction);
1512  }
1513 
1514  std::string getDescription() const
1515  {
1516  std::ostringstream Description;
1517  Description << this->getStepperType() << "\n"
1518  << "Solving Ordinary Differential Equations I:\n"
1519  << "Nonstiff Problems, 2nd Revised Edition\n"
1520  << "E. Hairer, S.P. Norsett, G. Wanner\n"
1521  << "Table 1.1, pg 135\n"
1522  << "c = [ 0 1/2 ]'\n"
1523  << "A = [ 0 ]\n"
1524  << " [ 1/2 0 ]\n"
1525  << "b = [ 0 1 ]'";
1526  return Description.str();
1527  }
1528 
1529  protected:
1531  {
1532  typedef Teuchos::ScalarTraits<Scalar> ST;
1533  const Scalar one = ST::one();
1534  const Scalar zero = ST::zero();
1535  const Scalar onehalf = one / (2 * one);
1536 
1537  int NumStages = 2;
1538  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
1541 
1542  // Fill A:
1543  A(0, 0) = zero;
1544  A(0, 1) = zero;
1545  A(1, 0) = onehalf;
1546  A(1, 1) = zero;
1547 
1548  // Fill b:
1549  b(0) = zero;
1550  b(1) = one;
1551 
1552  // fill c:
1553  c(0) = zero;
1554  c(1) = onehalf;
1555 
1556  int order = 2;
1557 
1559  this->getStepperType(), A, b, c, order, order, order));
1560  }
1561 };
1562 
1564 // ------------------------------------------------------------------------
1565 template <class Scalar>
1567  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
1569 {
1570  auto stepper = Teuchos::rcp(new StepperERK_Midpoint<Scalar>());
1571  stepper->setStepperRKValues(pl);
1572 
1573  if (model != Teuchos::null) {
1574  stepper->setModel(model);
1575  stepper->initialize();
1576  }
1577 
1578  return stepper;
1579 }
1580 
1581 // ----------------------------------------------------------------------------
1598 template <class Scalar>
1599 class StepperERK_Ralston : virtual public StepperExplicitRK<Scalar> {
1600  public:
1607  {
1608  this->setStepperName("RK Explicit Ralston");
1609  this->setStepperType("RK Explicit Ralston");
1610  this->setupTableau();
1611  this->setupDefault();
1612  this->setUseFSAL(false);
1613  this->setICConsistency("None");
1614  this->setICConsistencyCheck(false);
1615  }
1616 
1618  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
1619  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
1620  bool useEmbedded,
1621  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
1622  {
1623  this->setStepperName("RK Explicit Ralston");
1624  this->setStepperType("RK Explicit Ralston");
1625  this->setupTableau();
1626  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
1627  useEmbedded, stepperRKAppAction);
1628  }
1629 
1630  std::string getDescription() const
1631  {
1632  std::ostringstream Description;
1633  Description << this->getStepperType() << "\n"
1634  << "This Stepper is known as 'RK Explicit Ralston' or 'RK2'.\n"
1635  << "c = [ 0 2/3 ]'\n"
1636  << "A = [ 0 ]\n"
1637  << " [ 2/3 0 ]\n"
1638  << "b = [ 1/4 3/4 ]'";
1639  return Description.str();
1640  }
1641 
1642  protected:
1644  {
1645  typedef Teuchos::ScalarTraits<Scalar> ST;
1646  const Scalar one = ST::one();
1647  const Scalar zero = ST::zero();
1648 
1649  const int NumStages = 2;
1650  const int order = 2;
1651  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
1654 
1655  // Fill A:
1656  A(0, 0) = zero;
1657  A(0, 1) = zero;
1658  A(1, 1) = zero;
1659  A(1, 0) = (2 * one) / (3 * one);
1660 
1661  // Fill b:
1662  b(0) = (1 * one) / (4 * one);
1663  b(1) = (3 * one) / (4 * one);
1664 
1665  // fill c:
1666  c(0) = zero;
1667  c(1) = (2 * one) / (3 * one);
1668 
1670  this->getStepperType(), A, b, c, order, order, order));
1671  this->tableau_->setTVD(true);
1672  this->tableau_->setTVDCoeff(0.5);
1673  }
1674 };
1675 
1677 // ------------------------------------------------------------------------
1678 template <class Scalar>
1680  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
1682 {
1683  auto stepper = Teuchos::rcp(new StepperERK_Ralston<Scalar>());
1684 
1685  // Test for aliases.
1686  if (pl != Teuchos::null) {
1687  auto stepperType =
1688  pl->get<std::string>("Stepper Type", stepper->getStepperType());
1689 
1691  stepperType != stepper->getStepperType() && stepperType != "RK2",
1692  std::logic_error,
1693  " ParameterList 'Stepper Type' (='"
1694  << stepperType
1695  << "')\n does not match type for this Stepper (='"
1696  << stepper->getStepperType()
1697  << "')\n or one of its aliases ('RK2').\n");
1698 
1699  // Reset default StepperType.
1700  pl->set<std::string>("Stepper Type", stepper->getStepperType());
1701  }
1702 
1703  stepper->setStepperRKValues(pl);
1704 
1705  if (model != Teuchos::null) {
1706  stepper->setModel(model);
1707  stepper->initialize();
1708  }
1709 
1710  return stepper;
1711 }
1712 
1713 // ----------------------------------------------------------------------------
1731 template <class Scalar>
1732 class StepperERK_Trapezoidal : virtual public StepperExplicitRK<Scalar> {
1733  public:
1740  {
1741  this->setStepperName("RK Explicit Trapezoidal");
1742  this->setStepperType("RK Explicit Trapezoidal");
1743  this->setupTableau();
1744  this->setupDefault();
1745  this->setUseFSAL(false);
1746  this->setICConsistency("None");
1747  this->setICConsistencyCheck(false);
1748  }
1749 
1751  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
1752  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
1753  bool useEmbedded,
1754  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
1755  {
1756  this->setStepperName("RK Explicit Trapezoidal");
1757  this->setStepperType("RK Explicit Trapezoidal");
1758  this->setupTableau();
1759  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
1760  useEmbedded, stepperRKAppAction);
1761  }
1762 
1763  std::string getDescription() const
1764  {
1765  std::ostringstream Description;
1766  Description << this->getStepperType() << "\n"
1767  << "This Stepper is known as 'RK Explicit Trapezoidal' or "
1768  "'Heuns Method' or 'SSPERK22'.\n"
1769  << "c = [ 0 1 ]'\n"
1770  << "A = [ 0 ]\n"
1771  << " [ 1 0 ]\n"
1772  << "b = [ 1/2 1/2 ]\n"
1773  << "bstart = [ 3/4 1/4 ]'";
1774  return Description.str();
1775  }
1776 
1777  protected:
1779  {
1780  typedef Teuchos::ScalarTraits<Scalar> ST;
1781  using Teuchos::as;
1782  const Scalar one = ST::one();
1783  const Scalar zero = ST::zero();
1784  const Scalar onehalf = one / (2 * one);
1785 
1786  int NumStages = 2;
1787  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
1790  Teuchos::SerialDenseVector<int, Scalar> bstar(NumStages);
1791 
1792  // Fill A:
1793  A(0, 0) = zero;
1794  A(0, 1) = zero;
1795  A(1, 0) = one;
1796  A(1, 1) = zero;
1797 
1798  // Fill b:
1799  b(0) = onehalf;
1800  b(1) = onehalf;
1801 
1802  // fill c:
1803  c(0) = zero;
1804  c(1) = one;
1805 
1806  // Fill bstar
1807  bstar(0) = as<Scalar>(3 * one / (4 * one));
1808  bstar(1) = as<Scalar>(1 * one / (4 * one));
1809 
1810  int order = 2;
1811 
1813  this->getStepperType(), A, b, c, order, order, order, bstar));
1814  this->tableau_->setTVD(true);
1815  this->tableau_->setTVDCoeff(1.0);
1816  }
1817 };
1818 
1820 // ------------------------------------------------------------------------
1821 template <class Scalar>
1823  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
1825 {
1826  auto stepper = Teuchos::rcp(new StepperERK_Trapezoidal<Scalar>());
1827 
1828  // Test for aliases.
1829  if (pl != Teuchos::null) {
1830  auto stepperType =
1831  pl->get<std::string>("Stepper Type", stepper->getStepperType());
1832 
1834  stepperType != stepper->getStepperType() &&
1835  stepperType != "Heuns Method" && stepperType != "SSPERK22" &&
1836  stepperType != "SSPRK2",
1837  std::logic_error,
1838  " ParameterList 'Stepper Type' (='"
1839  << stepperType
1840  << "')\n does not match type for this Stepper (='"
1841  << stepper->getStepperType()
1842  << "')\n or one of its aliases ('Heuns Method' or 'SSPERK22' or "
1843  << "'SSPRK2').\n");
1844 
1845  // Reset default StepperType.
1846  pl->set<std::string>("Stepper Type", stepper->getStepperType());
1847  }
1848 
1849  stepper->setStepperRKValues(pl);
1850 
1851  if (model != Teuchos::null) {
1852  stepper->setModel(model);
1853  stepper->initialize();
1854  }
1855 
1856  return stepper;
1857 }
1858 
1859 // ----------------------------------------------------------------------------
1876 template <class Scalar>
1877 class StepperERK_SSPERK54 : virtual public StepperExplicitRK<Scalar> {
1878  public:
1880  {
1881  this->setStepperName("SSPERK54");
1882  this->setStepperType("SSPERK54");
1883  this->setupTableau();
1884  this->setupDefault();
1885  this->setUseFSAL(false);
1886  this->setICConsistency("None");
1887  this->setICConsistencyCheck(false);
1888  }
1889 
1891  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
1892  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
1893  bool useEmbedded,
1894  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
1895  {
1896  this->setStepperName("SSPERK54");
1897  this->setStepperType("SSPERK54");
1898  this->setupTableau();
1899  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
1900  useEmbedded, stepperRKAppAction);
1901  }
1902 
1903  std::string getDescription() const
1904  {
1905  std::ostringstream Description;
1906  Description
1907  << this->getStepperType() << "\n"
1908  << "Strong Stability Preserving Explicit RK (stage=5, order=4)\n"
1909  << std::endl;
1910  return Description.str();
1911  }
1912 
1913  protected:
1915  {
1916  typedef Teuchos::ScalarTraits<Scalar> ST;
1917  using Teuchos::as;
1918  const int NumStages = 5;
1919  const int order = 4;
1920  const Scalar sspcoef = 1.5082;
1921  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
1924  Teuchos::SerialDenseVector<int, Scalar> bstar(NumStages);
1925  const Scalar zero = ST::zero();
1926 
1927  // Fill A:
1928  A(0, 0) = A(0, 1) = A(0, 2) = A(0, 3) = A(0, 4) = zero;
1929 
1930  A(1, 0) = as<Scalar>(0.391752226571889);
1931  A(1, 1) = A(1, 2) = A(1, 3) = A(0, 4) = zero;
1932 
1933  A(2, 0) = as<Scalar>(0.217669096261169);
1934  A(2, 1) = as<Scalar>(0.368410593050372);
1935  A(2, 2) = A(2, 3) = A(2, 4) = zero;
1936 
1937  A(3, 0) = as<Scalar>(0.082692086657811);
1938  A(3, 1) = as<Scalar>(0.139958502191896);
1939  A(3, 2) = as<Scalar>(0.251891774271693);
1940  A(3, 3) = A(2, 4) = zero;
1941 
1942  A(4, 0) = as<Scalar>(0.067966283637115);
1943  A(4, 1) = as<Scalar>(0.115034698504632);
1944  A(4, 2) = as<Scalar>(0.207034898597385);
1945  A(4, 3) = as<Scalar>(0.544974750228520);
1946  A(4, 4) = zero;
1947 
1948  // Fill b:
1949  b(0) = as<Scalar>(0.146811876084786);
1950  b(1) = as<Scalar>(0.248482909444976);
1951  b(2) = as<Scalar>(0.104258830331980);
1952  b(3) = as<Scalar>(0.274438900901350);
1953  b(4) = as<Scalar>(0.226007483236908);
1954 
1955  // fill c:
1956  c(0) = zero;
1957  c(1) = A(1, 0);
1958  c(2) = A(2, 0) + A(2, 1);
1959  c(3) = A(3, 0) + A(3, 1) + A(3, 2);
1960  c(4) = A(4, 0) + A(4, 1) + A(4, 2) + A(4, 3);
1961 
1962  // Fill bstar:
1963  bstar(0) = as<Scalar>(0.130649104813131);
1964  bstar(1) = as<Scalar>(0.317716031201302);
1965  bstar(2) = as<Scalar>(0.000000869337261);
1966  bstar(3) = as<Scalar>(0.304581512634772);
1967  bstar(4) = as<Scalar>(0.247052482013534);
1968 
1970  this->getStepperType(), A, b, c, order, order, order, bstar));
1971  this->tableau_->setTVD(true);
1972  this->tableau_->setTVDCoeff(sspcoef);
1973  }
1974 };
1975 
1977 // ------------------------------------------------------------------------
1978 template <class Scalar>
1980  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
1982 {
1983  auto stepper = Teuchos::rcp(new StepperERK_SSPERK54<Scalar>());
1984  stepper->setStepperRKValues(pl);
1985 
1986  if (model != Teuchos::null) {
1987  stepper->setModel(model);
1988  stepper->initialize();
1989  }
1990 
1991  return stepper;
1992 }
1993 
1994 // ----------------------------------------------------------------------------
2024 template <class Scalar>
2025 class StepperERK_General : virtual public StepperExplicitRK<Scalar> {
2026  public:
2028  {
2029  this->setStepperName("General ERK");
2030  this->setStepperType("General ERK");
2031  this->setupTableau();
2032  this->setupDefault();
2033  this->setUseFSAL(false);
2034  this->setICConsistency("None");
2035  this->setICConsistencyCheck(false);
2036  }
2037 
2039  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
2040  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
2041  bool useEmbedded, const Teuchos::SerialDenseMatrix<int, Scalar>& A,
2043  const Teuchos::SerialDenseVector<int, Scalar>& c, const int order,
2044  const int orderMin, const int orderMax,
2046  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction =
2047  Teuchos::null)
2048  {
2049  this->setStepperName("General ERK");
2050  this->setStepperType("General ERK");
2051  this->setTableau(A, b, c, order, orderMin, orderMax, bstar);
2052 
2054  this->tableau_->isImplicit() == true, std::logic_error,
2055  "Error - General ERK received an implicit Butcher Tableau!\n");
2056 
2057  this->setup(appModel, useFSAL, ICConsistency, ICConsistencyCheck,
2058  useEmbedded, stepperRKAppAction);
2059  }
2060 
2061  virtual std::string getDescription() const
2062  {
2063  std::stringstream Description;
2064  Description
2065  << this->getStepperType() << "\n"
2066  << "The format of the Butcher Tableau parameter list is\n"
2067  << " <Parameter name=\"A\" type=\"string\" value=\"# # # ;\n"
2068  << " # # # ;\n"
2069  << " # # #\"/>\n"
2070  << " <Parameter name=\"b\" type=\"string\" value=\"# # #\"/>\n"
2071  << " <Parameter name=\"c\" type=\"string\" value=\"# # #\"/>\n\n"
2072  << "Note the number of stages is implicit in the number of entries.\n"
2073  << "The number of stages must be consistent.\n"
2074  << "\n"
2075  << "Default tableau is RK4 (order=4):\n"
2076  << "c = [ 0 1/2 1/2 1 ]'\n"
2077  << "A = [ 0 ]\n"
2078  << " [ 1/2 0 ]\n"
2079  << " [ 0 1/2 0 ]\n"
2080  << " [ 0 0 1 0 ]\n"
2081  << "b = [ 1/6 1/3 1/3 1/6 ]'";
2082  return Description.str();
2083  }
2084 
2086  {
2087  if (this->tableau_ == Teuchos::null) {
2088  // Set tableau to the default if null, otherwise keep current tableau.
2089  auto stepper = Teuchos::rcp(new StepperERK_4Stage4thOrder<Scalar>());
2090  auto t = stepper->getTableau();
2092  this->getStepperType(), t->A(), t->b(), t->c(), t->order(),
2093  t->orderMin(), t->orderMax(), t->bstar()));
2094  }
2095  }
2096 
2100  const int order, const int orderMin, const int orderMax,
2103  {
2105  this->getStepperType(), A, b, c, order, orderMin, orderMax, bstar));
2106  this->isInitialized_ = false;
2107  }
2108 
2109  virtual std::string getDefaultICConsistency() const { return "Consistent"; }
2110 
2112  {
2113  auto pl = this->getValidParametersBasicERK();
2114 
2115  // Tableau ParameterList
2119  Teuchos::SerialDenseVector<int, Scalar> bstar = this->tableau_->bstar();
2120 
2121  Teuchos::RCP<Teuchos::ParameterList> tableauPL = Teuchos::parameterList();
2122 
2123  std::ostringstream Astream;
2124  Astream.precision(15);
2125  for (int i = 0; i < A.numRows(); i++) {
2126  for (int j = 0; j < A.numCols() - 1; j++) {
2127  Astream << A(i, j) << " ";
2128  }
2129  Astream << A(i, A.numCols() - 1);
2130  if (i != A.numRows() - 1) Astream << "; ";
2131  }
2132  tableauPL->set<std::string>("A", Astream.str());
2133 
2134  std::ostringstream bstream;
2135  bstream.precision(15);
2136  for (int i = 0; i < b.length() - 1; i++) {
2137  bstream << b(i) << " ";
2138  }
2139  bstream << b(b.length() - 1);
2140  tableauPL->set<std::string>("b", bstream.str());
2141 
2142  std::ostringstream cstream;
2143  cstream.precision(15);
2144  for (int i = 0; i < c.length() - 1; i++) {
2145  cstream << c(i) << " ";
2146  }
2147  cstream << c(c.length() - 1);
2148  tableauPL->set<std::string>("c", cstream.str());
2149 
2150  tableauPL->set<int>("order", this->tableau_->order());
2151 
2152  if (bstar.length() == 0) {
2153  tableauPL->set("bstar", "");
2154  }
2155  else {
2156  std::ostringstream bstarstream;
2157  bstarstream.precision(15);
2158  for (int i = 0; i < bstar.length() - 1; i++) {
2159  bstarstream << bstar(i) << " ";
2160  }
2161  bstarstream << bstar(bstar.length() - 1);
2162  tableauPL->set<std::string>("bstar", bstarstream.str());
2163  }
2164 
2165  pl->set("Tableau", *tableauPL);
2166 
2167  return pl;
2168  }
2169 };
2170 
2172 // ------------------------------------------------------------------------
2173 template <class Scalar>
2175  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
2177 {
2178  auto stepper = Teuchos::rcp(new StepperERK_General<Scalar>());
2179  stepper->setStepperRKValues(pl);
2180 
2181  if (pl != Teuchos::null) {
2182  if (pl->isParameter("Tableau")) {
2183  auto t = stepper->createTableau(pl);
2184  stepper->setTableau(t->A(), t->b(), t->c(), t->order(), t->orderMin(),
2185  t->orderMax(), t->bstar());
2186  }
2187  }
2189  stepper->getTableau()->isImplicit() == true, std::logic_error,
2190  "Error - General ERK received an implicit Butcher Tableau!\n");
2191 
2192  if (model != Teuchos::null) {
2193  stepper->setModel(model);
2194  stepper->initialize();
2195  }
2196 
2197  return stepper;
2198 }
2199 
2200 // ----------------------------------------------------------------------------
2216 template <class Scalar>
2217 class StepperDIRK_BackwardEuler : virtual public StepperDIRK<Scalar> {
2218  public:
2225  {
2226  this->setStepperName("RK Backward Euler");
2227  this->setStepperType("RK Backward Euler");
2228  this->setupTableau();
2229  this->setupDefault();
2230  this->setUseFSAL(false);
2231  this->setICConsistency("None");
2232  this->setICConsistencyCheck(false);
2233  }
2234 
2236  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
2238  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
2239  bool useEmbedded, bool zeroInitialGuess,
2240  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
2241  {
2242  this->setStepperName("RK Backward Euler");
2243  this->setStepperType("RK Backward Euler");
2244  this->setupTableau();
2245  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
2246  useEmbedded, zeroInitialGuess, stepperRKAppAction);
2247  }
2248 
2249  std::string getDescription() const
2250  {
2251  std::ostringstream Description;
2252  Description << this->getStepperType() << "\n"
2253  << "c = [ 1 ]'\n"
2254  << "A = [ 1 ]\n"
2255  << "b = [ 1 ]'";
2256  return Description.str();
2257  }
2258 
2259  protected:
2261  {
2262  typedef Teuchos::ScalarTraits<Scalar> ST;
2263  const Scalar sspcoef = std::numeric_limits<Scalar>::max();
2264  int NumStages = 1;
2265  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
2268 
2269  // Fill A:
2270  A(0, 0) = ST::one();
2271 
2272  // Fill b:
2273  b(0) = ST::one();
2274 
2275  // Fill c:
2276  c(0) = ST::one();
2277 
2278  int order = 1;
2279 
2281  this->getStepperType(), A, b, c, order, order, order));
2282  this->tableau_->setTVD(true);
2283  this->tableau_->setTVDCoeff(sspcoef);
2284  }
2285 };
2286 
2288 // ------------------------------------------------------------------------
2289 template <class Scalar>
2292  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
2294 {
2295  auto stepper = Teuchos::rcp(new StepperDIRK_BackwardEuler<Scalar>());
2296  stepper->setStepperDIRKValues(pl);
2297 
2298  if (model != Teuchos::null) {
2299  stepper->setModel(model);
2300  stepper->initialize();
2301  }
2302 
2303  return stepper;
2304 }
2305 
2306 // ----------------------------------------------------------------------------
2331 template <class Scalar>
2332 class StepperSDIRK_2Stage2ndOrder : virtual public StepperDIRK<Scalar> {
2333  public:
2340  {
2341  typedef Teuchos::ScalarTraits<Scalar> ST;
2342  const Scalar one = ST::one();
2343  gammaDefault_ =
2344  Teuchos::as<Scalar>((2 * one - ST::squareroot(2 * one)) / (2 * one));
2345 
2346  this->setStepperName("SDIRK 2 Stage 2nd order");
2347  this->setStepperType("SDIRK 2 Stage 2nd order");
2348  this->setGamma(gammaDefault_);
2349  this->setupTableau();
2350  this->setupDefault();
2351  this->setUseFSAL(false);
2352  this->setICConsistency("None");
2353  this->setICConsistencyCheck(false);
2354  }
2355 
2357  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
2359  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
2360  bool useEmbedded, bool zeroInitialGuess,
2361  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction,
2362  Scalar gamma = Scalar(0.2928932188134524))
2363  {
2364  typedef Teuchos::ScalarTraits<Scalar> ST;
2365  const Scalar one = ST::one();
2366  gammaDefault_ =
2367  Teuchos::as<Scalar>((2 * one - ST::squareroot(2 * one)) / (2 * one));
2368 
2369  this->setStepperName("SDIRK 2 Stage 2nd order");
2370  this->setStepperType("SDIRK 2 Stage 2nd order");
2371  this->setGamma(gamma);
2372  this->setupTableau();
2373  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
2374  useEmbedded, zeroInitialGuess, stepperRKAppAction);
2375  }
2376 
2377  void setGamma(Scalar gamma)
2378  {
2379  gamma_ = gamma;
2380  this->isInitialized_ = false;
2381  this->setupTableau();
2382  }
2383 
2384  Scalar getGamma() const { return gamma_; }
2385 
2386  std::string getDescription() const
2387  {
2388  std::ostringstream Description;
2389  Description << this->getStepperType() << "\n"
2390  << "Computer Methods for ODEs and DAEs\n"
2391  << "U. M. Ascher and L. R. Petzold\n"
2392  << "p. 106\n"
2393  << "gamma = (2+-sqrt(2))/2\n"
2394  << "c = [ gamma 1 ]'\n"
2395  << "A = [ gamma 0 ]\n"
2396  << " [ 1-gamma gamma ]\n"
2397  << "b = [ 1-gamma gamma ]'";
2398  return Description.str();
2399  }
2400 
2402  {
2403  auto pl = this->getValidParametersBasicDIRK();
2404  pl->template set<double>(
2405  "gamma", this->getGamma(),
2406  "The default value is gamma = (2-sqrt(2))/2. "
2407  "This will produce an L-stable 2nd order method with the stage "
2408  "times within the timestep. Other values of gamma will still "
2409  "produce an L-stable scheme, but will only be 1st order accurate.");
2410 
2411  return pl;
2412  }
2413 
2414  protected:
2416  {
2417  typedef Teuchos::ScalarTraits<Scalar> ST;
2418  int NumStages = 2;
2419  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
2422 
2423  const Scalar one = ST::one();
2424  const Scalar zero = ST::zero();
2425 
2426  // Fill A:
2427  A(0, 0) = gamma_;
2428  A(0, 1) = zero;
2429  A(1, 0) = Teuchos::as<Scalar>(one - gamma_);
2430  A(1, 1) = gamma_;
2431 
2432  // Fill b:
2433  b(0) = Teuchos::as<Scalar>(one - gamma_);
2434  b(1) = gamma_;
2435 
2436  // Fill c:
2437  c(0) = gamma_;
2438  c(1) = one;
2439 
2440  int order = 1;
2441  if (std::abs((gamma_ - gammaDefault_) / gamma_) < 1.0e-08) order = 2;
2442 
2444  this->getStepperType(), A, b, c, order, order, order));
2445  }
2446 
2447  private:
2449  Scalar gamma_;
2450 };
2451 
2453 // ------------------------------------------------------------------------
2454 template <class Scalar>
2457  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
2459 {
2460  auto stepper = Teuchos::rcp(new StepperSDIRK_2Stage2ndOrder<Scalar>());
2461  stepper->setStepperDIRKValues(pl);
2462 
2463  if (pl != Teuchos::null)
2464  stepper->setGamma(pl->get<double>("gamma", 0.2928932188134524));
2465 
2466  if (model != Teuchos::null) {
2467  stepper->setModel(model);
2468  stepper->initialize();
2469  }
2470 
2471  return stepper;
2472 }
2473 
2474 // ----------------------------------------------------------------------------
2502 template <class Scalar>
2503 class StepperSDIRK_3Stage2ndOrder : virtual public StepperDIRK<Scalar> {
2504  public:
2511  {
2512  this->setStepperName("SDIRK 3 Stage 2nd order");
2513  this->setStepperType("SDIRK 3 Stage 2nd order");
2514  this->setupTableau();
2515  this->setupDefault();
2516  this->setUseFSAL(false);
2517  this->setICConsistency("None");
2518  this->setICConsistencyCheck(false);
2519  }
2520 
2522  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
2524  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
2525  bool useEmbedded, bool zeroInitialGuess,
2526  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
2527  {
2528  this->setStepperName("SDIRK 3 Stage 2nd order");
2529  this->setStepperType("SDIRK 3 Stage 2nd order");
2530  this->setupTableau();
2531  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
2532  useEmbedded, zeroInitialGuess, stepperRKAppAction);
2533  }
2534 
2535  std::string getDescription() const
2536  {
2537  std::ostringstream Description;
2538  Description << this->getStepperType() << "\n"
2539  << "Implicit-explicit Runge-Kutta schemes and applications to\n"
2540  << "hyperbolic systems with relaxation\n"
2541  << "L Pareschi, G Russo\n"
2542  << "Journal of Scientific computing, 2005 - Springer\n"
2543  << "Table 5\n"
2544  << "gamma = 1/(2+sqrt(2))\n"
2545  << "c = [ gamma (1-gamma) 1/2 ]'\n"
2546  << "A = [ gamma 0 0 ]\n"
2547  << " [ 1-2gamma gamma 0 ]\n"
2548  << " [ 1/2-gamma 0 gamma ]\n"
2549  << "b = [ 1/6 1/6 2/3 ]'";
2550  return Description.str();
2551  }
2552 
2553  protected:
2555  {
2556  typedef Teuchos::ScalarTraits<Scalar> ST;
2557  using Teuchos::as;
2558  const int NumStages = 3;
2559  const int order = 2;
2560  const Scalar sspcoef = 1.0529;
2561  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
2564  const Scalar one = ST::one();
2565  const Scalar zero = ST::zero();
2566  const Scalar gamma = as<Scalar>(one - (one / ST::squareroot(2 * one)));
2567 
2568  // Fill A:
2569  A(0, 0) = A(1, 1) = A(2, 2) = gamma;
2570  A(0, 1) = A(0, 2) = A(1, 2) = A(2, 1) = zero;
2571  A(1, 0) = as<Scalar>(one - 2 * gamma);
2572  A(2, 0) = as<Scalar>((one / (2. * one)) - gamma);
2573 
2574  // Fill b:
2575  b(0) = b(1) = (one / (6 * one));
2576  b(2) = (2 * one) / (3 * one);
2577 
2578  // Fill c:
2579  c(0) = gamma;
2580  c(1) = one - gamma;
2581  c(2) = one / (2 * one);
2582 
2584  this->getStepperType(), A, b, c, order, order, order));
2585  this->tableau_->setTVD(true);
2586  this->tableau_->setTVDCoeff(sspcoef);
2587  }
2588 };
2589 
2591 // ------------------------------------------------------------------------
2592 template <class Scalar>
2595  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
2597 {
2598  auto stepper = Teuchos::rcp(new StepperSDIRK_3Stage2ndOrder<Scalar>());
2599  stepper->setStepperDIRKValues(pl);
2600 
2601  if (model != Teuchos::null) {
2602  stepper->setModel(model);
2603  stepper->initialize();
2604  }
2605 
2606  return stepper;
2607 }
2608 
2609 // ----------------------------------------------------------------------------
2638 template <class Scalar>
2639 class StepperSDIRK_2Stage3rdOrder : virtual public StepperDIRK<Scalar> {
2640  public:
2647  {
2648  typedef Teuchos::ScalarTraits<Scalar> ST;
2649  using Teuchos::as;
2650  const Scalar one = ST::one();
2651  gammaDefault_ = as<Scalar>((3 * one + ST::squareroot(3 * one)) / (6 * one));
2652  gammaTypeDefault_ = "3rd Order A-stable";
2653 
2654  this->setStepperName("SDIRK 2 Stage 3rd order");
2655  this->setStepperType("SDIRK 2 Stage 3rd order");
2656  this->setGammaType(gammaTypeDefault_);
2657  this->setGamma(gammaDefault_);
2658  this->setupTableau();
2659  this->setupDefault();
2660  this->setUseFSAL(false);
2661  this->setICConsistency("None");
2662  this->setICConsistencyCheck(false);
2663  }
2664 
2666  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
2668  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
2669  bool useEmbedded, bool zeroInitialGuess,
2670  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction,
2671  std::string gammaType = "3rd Order A-stable",
2672  Scalar gamma = Scalar(0.7886751345948128))
2673  {
2674  typedef Teuchos::ScalarTraits<Scalar> ST;
2675  using Teuchos::as;
2676  const Scalar one = ST::one();
2677  gammaDefault_ = as<Scalar>((3 * one + ST::squareroot(3 * one)) / (6 * one));
2678  gammaTypeDefault_ = "3rd Order A-stable";
2679 
2680  this->setStepperName("SDIRK 2 Stage 3rd order");
2681  this->setStepperType("SDIRK 2 Stage 3rd order");
2682  this->setGammaType(gammaType);
2683  this->setGamma(gamma);
2684  this->setupTableau();
2685  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
2686  useEmbedded, zeroInitialGuess, stepperRKAppAction);
2687  }
2688 
2689  void setGammaType(std::string gammaType)
2690  {
2692  !(gammaType == "3rd Order A-stable" ||
2693  gammaType == "2nd Order L-stable" || gammaType == "gamma"),
2694  std::logic_error,
2695  "gammaType needs to be '3rd Order A-stable', '2nd Order L-stable' "
2696  "or 'gamma'.");
2697 
2698  gammaType_ = gammaType;
2699  this->isInitialized_ = false;
2700  this->setupTableau();
2701  }
2702 
2703  std::string getGammaType() const { return gammaType_; }
2704 
2705  void setGamma(Scalar gamma)
2706  {
2707  if (gammaType_ == "gamma") {
2708  gamma_ = gamma;
2709  this->setupTableau();
2710  }
2711  this->isInitialized_ = false;
2712  }
2713 
2714  Scalar getGamma() const { return gamma_; }
2715 
2716  std::string getDescription() const
2717  {
2718  std::ostringstream Description;
2719  Description << this->getStepperType() << "\n"
2720  << "Solving Ordinary Differential Equations I:\n"
2721  << "Nonstiff Problems, 2nd Revised Edition\n"
2722  << "E. Hairer, S. P. Norsett, and G. Wanner\n"
2723  << "Table 7.2, pg 207\n"
2724  << "gamma = (3+sqrt(3))/6 -> 3rd order and A-stable\n"
2725  << "gamma = (2-sqrt(2))/2 -> 2nd order and L-stable\n"
2726  << "c = [ gamma 1-gamma ]'\n"
2727  << "A = [ gamma 0 ]\n"
2728  << " [ 1-2*gamma gamma ]\n"
2729  << "b = [ 1/2 1/2 ]'";
2730  return Description.str();
2731  }
2732 
2734  {
2735  auto pl = this->getValidParametersBasicDIRK();
2736 
2737  pl->template set<std::string>(
2738  "Gamma Type", this->getGammaType(),
2739  "Valid values are '3rd Order A-stable' ((3+sqrt(3))/6.), "
2740  "'2nd Order L-stable' ((2-sqrt(2))/2) and 'gamma' (user defined). "
2741  "The default value is '3rd Order A-stable'.");
2742  pl->template set<double>(
2743  "gamma", this->getGamma(),
2744  "Equal to (3+sqrt(3))/6 if 'Gamma Type' = '3rd Order A-stable', or "
2745  "(2-sqrt(2))/2 if 'Gamma Type' = '2nd Order L-stable', or "
2746  "user-defined gamma value if 'Gamma Type = 'gamma'. "
2747  "The default value is gamma = (3+sqrt(3))/6, which matches "
2748  "the default 'Gamma Type' = '3rd Order A-stable'.");
2749 
2750  return pl;
2751  }
2752 
2753  protected:
2755  {
2756  typedef Teuchos::ScalarTraits<Scalar> ST;
2757  using Teuchos::as;
2758  int NumStages = 2;
2759  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
2762  const Scalar one = ST::one();
2763  const Scalar zero = ST::zero();
2764 
2765  int order = 0;
2766  if (gammaType_ == "3rd Order A-stable") {
2767  order = 3;
2769  }
2770  else if (gammaType_ == "2nd Order L-stable") {
2771  order = 2;
2772  gamma_ = as<Scalar>((2 * one - ST::squareroot(2 * one)) / (2 * one));
2773  }
2774  else if (gammaType_ == "gamma") {
2775  order = 2;
2776  }
2777 
2778  // Fill A:
2779  A(0, 0) = gamma_;
2780  A(0, 1) = zero;
2781  A(1, 0) = as<Scalar>(one - 2 * gamma_);
2782  A(1, 1) = gamma_;
2783 
2784  // Fill b:
2785  b(0) = as<Scalar>(one / (2 * one));
2786  b(1) = as<Scalar>(one / (2 * one));
2787 
2788  // Fill c:
2789  c(0) = gamma_;
2790  c(1) = as<Scalar>(one - gamma_);
2791 
2793  this->getStepperType(), A, b, c, order, 2, 3));
2794  }
2795 
2796  private:
2797  std::string gammaTypeDefault_;
2798  std::string gammaType_;
2800  Scalar gamma_;
2801 };
2802 
2804 // ------------------------------------------------------------------------
2805 template <class Scalar>
2808  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
2810 {
2811  auto stepper = Teuchos::rcp(new StepperSDIRK_2Stage3rdOrder<Scalar>());
2812  stepper->setStepperDIRKValues(pl);
2813 
2814  if (pl != Teuchos::null) {
2815  stepper->setGammaType(
2816  pl->get<std::string>("Gamma Type", "3rd Order A-stable"));
2817  stepper->setGamma(pl->get<double>("gamma", 0.7886751345948128));
2818  }
2819 
2820  if (model != Teuchos::null) {
2821  stepper->setModel(model);
2822  stepper->initialize();
2823  }
2824 
2825  return stepper;
2826 }
2827 
2828 // ----------------------------------------------------------------------------
2849 template <class Scalar>
2850 class StepperEDIRK_2Stage3rdOrder : virtual public StepperDIRK<Scalar> {
2851  public:
2858  {
2859  this->setStepperName("EDIRK 2 Stage 3rd order");
2860  this->setStepperType("EDIRK 2 Stage 3rd order");
2861  this->setupTableau();
2862  this->setupDefault();
2863  this->setUseFSAL(false);
2864  this->setICConsistency("None");
2865  this->setICConsistencyCheck(false);
2866  }
2867 
2869  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
2871  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
2872  bool useEmbedded, bool zeroInitialGuess,
2873  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
2874  {
2875  this->setStepperName("EDIRK 2 Stage 3rd order");
2876  this->setStepperType("EDIRK 2 Stage 3rd order");
2877  this->setupTableau();
2878  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
2879  useEmbedded, zeroInitialGuess, stepperRKAppAction);
2880  }
2881 
2882  std::string getDescription() const
2883  {
2884  std::ostringstream Description;
2885  Description << this->getStepperType() << "\n"
2886  << "Hammer & Hollingsworth method\n"
2887  << "Solving Ordinary Differential Equations I:\n"
2888  << "Nonstiff Problems, 2nd Revised Edition\n"
2889  << "E. Hairer, S. P. Norsett, and G. Wanner\n"
2890  << "Table 7.1, pg 205\n"
2891  << "c = [ 0 2/3 ]'\n"
2892  << "A = [ 0 0 ]\n"
2893  << " [ 1/3 1/3 ]\n"
2894  << "b = [ 1/4 3/4 ]'";
2895  return Description.str();
2896  }
2897 
2898  protected:
2900  {
2901  typedef Teuchos::ScalarTraits<Scalar> ST;
2902  using Teuchos::as;
2903  int NumStages = 2;
2904  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
2907  const Scalar one = ST::one();
2908  const Scalar zero = ST::zero();
2909 
2910  // Fill A:
2911  A(0, 0) = zero;
2912  A(0, 1) = zero;
2913  A(1, 0) = as<Scalar>(one / (3 * one));
2914  A(1, 1) = as<Scalar>(one / (3 * one));
2915 
2916  // Fill b:
2917  b(0) = as<Scalar>(one / (4 * one));
2918  b(1) = as<Scalar>(3 * one / (4 * one));
2919 
2920  // Fill c:
2921  c(0) = zero;
2922  c(1) = as<Scalar>(2 * one / (3 * one));
2923  int order = 3;
2924 
2926  this->getStepperType(), A, b, c, order, order, order));
2927  this->tableau_->setTVD(true);
2928  this->tableau_->setTVDCoeff(1.5);
2929  }
2930 };
2931 
2933 template <class Scalar>
2936  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
2938 {
2939  auto stepper = Teuchos::rcp(new StepperEDIRK_2Stage3rdOrder<Scalar>());
2940  stepper->setStepperDIRKValues(pl);
2941 
2942  if (model != Teuchos::null) {
2943  stepper->setModel(model);
2944  stepper->initialize();
2945  }
2946 
2947  return stepper;
2948 }
2949 
2950 // ----------------------------------------------------------------------------
2978 template <class Scalar>
2979 class StepperDIRK_1StageTheta : virtual public StepperDIRK<Scalar> {
2980  public:
2987  {
2988  typedef Teuchos::ScalarTraits<Scalar> ST;
2989  thetaDefault_ = ST::one() / (2 * ST::one());
2990 
2991  this->setStepperName("DIRK 1 Stage Theta Method");
2992  this->setStepperType("DIRK 1 Stage Theta Method");
2993  this->setTheta(thetaDefault_);
2994  this->setupTableau();
2995  this->setupDefault();
2996  this->setUseFSAL(false);
2997  this->setICConsistency("None");
2998  this->setICConsistencyCheck(false);
2999  }
3000 
3002  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
3004  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
3005  bool useEmbedded, bool zeroInitialGuess,
3006  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction,
3007  Scalar theta = Scalar(0.5))
3008  {
3009  typedef Teuchos::ScalarTraits<Scalar> ST;
3010  thetaDefault_ = ST::one() / (2 * ST::one());
3011 
3012  this->setStepperName("DIRK 1 Stage Theta Method");
3013  this->setStepperType("DIRK 1 Stage Theta Method");
3014  this->setTheta(theta);
3015  this->setupTableau();
3016  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
3017  useEmbedded, zeroInitialGuess, stepperRKAppAction);
3018  }
3019 
3020  void setTheta(Scalar theta)
3021  {
3023  theta == Teuchos::ScalarTraits<Scalar>::zero(), std::logic_error,
3024  "'theta' can not be zero, as it makes this stepper explicit. \n"
3025  "Try using the 'RK Forward Euler' stepper.\n");
3026  theta_ = theta;
3027  this->setupTableau();
3028  this->isInitialized_ = false;
3029  }
3030 
3031  Scalar getTheta() const { return theta_; }
3032 
3033  std::string getDescription() const
3034  {
3035  std::ostringstream Description;
3036  Description << this->getStepperType() << "\n"
3037  << "Non-standard finite-difference methods\n"
3038  << "in dynamical systems, P. Kama,\n"
3039  << "Dissertation, University of Pretoria, pg. 49.\n"
3040  << "Comment: Generalized Implicit Midpoint Method\n"
3041  << "c = [ theta ]'\n"
3042  << "A = [ theta ]\n"
3043  << "b = [ 1 ]'";
3044  return Description.str();
3045  }
3046 
3048  {
3049  auto pl = this->getValidParametersBasicDIRK();
3050 
3051  pl->template set<double>(
3052  "theta", getTheta(),
3053  "Valid values are 0 <= theta <= 1, where theta = 0 "
3054  "implies Forward Euler, theta = 1/2 implies implicit midpoint "
3055  "method (default), and theta = 1 implies Backward Euler. "
3056  "For theta != 1/2, this method is first-order accurate, "
3057  "and with theta = 1/2, it is second-order accurate. "
3058  "This method is A-stable, but becomes L-stable with theta=1.");
3059 
3060  return pl;
3061  }
3062 
3063  protected:
3065  {
3066  typedef Teuchos::ScalarTraits<Scalar> ST;
3067  int NumStages = 1;
3068  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
3071  A(0, 0) = theta_;
3072  b(0) = ST::one();
3073  c(0) = theta_;
3074 
3075  int order = 1;
3076  if (std::abs((theta_ - thetaDefault_) / theta_) < 1.0e-08) order = 2;
3077 
3079  this->getStepperType(), A, b, c, order, 1, 2));
3080  this->tableau_->setTVD(true);
3081  this->tableau_->setTVDCoeff(2.0);
3082  }
3083 
3084  private:
3086  Scalar theta_;
3087 };
3088 
3090 // ------------------------------------------------------------------------
3091 template <class Scalar>
3093  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
3095 {
3096  auto stepper = Teuchos::rcp(new StepperDIRK_1StageTheta<Scalar>());
3097  stepper->setStepperDIRKValues(pl);
3098 
3099  if (pl != Teuchos::null) {
3100  stepper->setTheta(pl->get<double>("theta", 0.5));
3101  }
3102 
3103  if (model != Teuchos::null) {
3104  stepper->setModel(model);
3105  stepper->initialize();
3106  }
3107 
3108  return stepper;
3109 }
3110 
3111 // ----------------------------------------------------------------------------
3138 template <class Scalar>
3139 class StepperEDIRK_2StageTheta : virtual public StepperDIRK<Scalar> {
3140  public:
3147  {
3148  typedef Teuchos::ScalarTraits<Scalar> ST;
3149  thetaDefault_ = ST::one() / (2 * ST::one());
3150 
3151  this->setStepperName("EDIRK 2 Stage Theta Method");
3152  this->setStepperType("EDIRK 2 Stage Theta Method");
3153  this->setTheta(thetaDefault_);
3154  this->setupTableau();
3155  this->setupDefault();
3156  this->setUseFSAL(true);
3157  this->setICConsistency("Consistent");
3158  this->setICConsistencyCheck(false);
3159  }
3160 
3162  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
3164  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
3165  bool useEmbedded, bool zeroInitialGuess,
3166  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction,
3167  Scalar theta = Scalar(0.5))
3168  {
3169  typedef Teuchos::ScalarTraits<Scalar> ST;
3170  thetaDefault_ = ST::one() / (2 * ST::one());
3171 
3172  this->setStepperName("EDIRK 2 Stage Theta Method");
3173  this->setStepperType("EDIRK 2 Stage Theta Method");
3174  this->setTheta(theta);
3175  this->setupTableau();
3176  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
3177  useEmbedded, zeroInitialGuess, stepperRKAppAction);
3178  }
3179 
3180  void setTheta(Scalar theta)
3181  {
3183  theta == Teuchos::ScalarTraits<Scalar>::zero(), std::logic_error,
3184  "'theta' can not be zero, as it makes this stepper explicit. \n"
3185  "Try using the 'RK Forward Euler' stepper.\n");
3186  theta_ = theta;
3187  this->isInitialized_ = false;
3188  this->setupTableau();
3189  }
3190 
3191  Scalar getTheta() const { return theta_; }
3192 
3193  std::string getDescription() const
3194  {
3195  std::ostringstream Description;
3196  Description << this->getStepperType() << "\n"
3197  << "Computer Methods for ODEs and DAEs\n"
3198  << "U. M. Ascher and L. R. Petzold\n"
3199  << "p. 113\n"
3200  << "c = [ 0 1 ]'\n"
3201  << "A = [ 0 0 ]\n"
3202  << " [ 1-theta theta ]\n"
3203  << "b = [ 1-theta theta ]'";
3204  return Description.str();
3205  }
3206 
3208  {
3209  auto pl = this->getValidParametersBasicDIRK();
3210 
3211  pl->template set<double>(
3212  "theta", getTheta(),
3213  "Valid values are 0 < theta <= 1, where theta = 0 "
3214  "implies Forward Euler, theta = 1/2 implies trapezoidal "
3215  "method (default), and theta = 1 implies Backward Euler. "
3216  "For theta != 1/2, this method is first-order accurate, "
3217  "and with theta = 1/2, it is second-order accurate. "
3218  "This method is A-stable, but becomes L-stable with theta=1.");
3219 
3220  return pl;
3221  }
3222 
3223  void setUseFSAL(bool a)
3224  {
3225  this->useFSAL_ = a;
3226  this->isInitialized_ = false;
3227  }
3228 
3229  protected:
3231  {
3232  typedef Teuchos::ScalarTraits<Scalar> ST;
3233  const Scalar one = ST::one();
3234  const Scalar zero = ST::zero();
3235 
3236  int NumStages = 2;
3237  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
3240 
3241  // Fill A:
3242  A(0, 0) = zero;
3243  A(0, 1) = zero;
3244  A(1, 0) = Teuchos::as<Scalar>(one - theta_);
3245  A(1, 1) = theta_;
3246 
3247  // Fill b:
3248  b(0) = Teuchos::as<Scalar>(one - theta_);
3249  b(1) = theta_;
3250 
3251  // Fill c:
3252  c(0) = zero;
3253  c(1) = one;
3254 
3255  int order = 1;
3256  if (std::abs((theta_ - thetaDefault_) / theta_) < 1.0e-08) order = 2;
3257 
3259  this->getStepperType(), A, b, c, order, 1, 2));
3260  this->tableau_->setTVD(true);
3261  this->tableau_->setTVDCoeff(2.0);
3262  }
3263 
3264  private:
3266  Scalar theta_;
3267 };
3268 
3270 // ------------------------------------------------------------------------
3271 template <class Scalar>
3273  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
3275 {
3276  auto stepper = Teuchos::rcp(new StepperEDIRK_2StageTheta<Scalar>());
3277  stepper->setStepperDIRKValues(pl);
3278 
3279  if (pl != Teuchos::null) {
3280  stepper->setTheta(pl->get<double>("theta", 0.5));
3281  }
3282 
3283  if (model != Teuchos::null) {
3284  stepper->setModel(model);
3285  stepper->initialize();
3286  }
3287 
3288  return stepper;
3289 }
3290 
3291 // ----------------------------------------------------------------------------
3312 template <class Scalar>
3313 class StepperEDIRK_TrapezoidalRule : virtual public StepperDIRK<Scalar> {
3314  public:
3321  {
3322  this->setStepperName("RK Trapezoidal Rule");
3323  this->setStepperType("RK Trapezoidal Rule");
3324  this->setupTableau();
3325  this->setupDefault();
3326  this->setUseFSAL(true);
3327  this->setICConsistency("Consistent");
3328  this->setICConsistencyCheck(false);
3329  }
3330 
3332  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
3334  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
3335  bool useEmbedded, bool zeroInitialGuess,
3336  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
3337  {
3338  this->setStepperName("RK Trapezoidal Rule");
3339  this->setStepperType("RK Trapezoidal Rule");
3340  this->setupTableau();
3341  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
3342  useEmbedded, zeroInitialGuess, stepperRKAppAction);
3343  }
3344 
3345  std::string getDescription() const
3346  {
3347  std::ostringstream Description;
3348  Description << this->getStepperType() << "\n"
3349  << "Also known as Crank-Nicolson Method.\n"
3350  << "c = [ 0 1 ]'\n"
3351  << "A = [ 0 0 ]\n"
3352  << " [ 1/2 1/2 ]\n"
3353  << "b = [ 1/2 1/2 ]'";
3354  return Description.str();
3355  }
3356 
3357  void setUseFSAL(bool a)
3358  {
3359  this->useFSAL_ = a;
3360  this->isInitialized_ = false;
3361  }
3362 
3363  protected:
3365  {
3366  typedef Teuchos::ScalarTraits<Scalar> ST;
3367  const Scalar one = ST::one();
3368  const Scalar zero = ST::zero();
3369  const Scalar onehalf = ST::one() / (2 * ST::one());
3370 
3371  int NumStages = 2;
3372  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
3375 
3376  // Fill A:
3377  A(0, 0) = zero;
3378  A(0, 1) = zero;
3379  A(1, 0) = onehalf;
3380  A(1, 1) = onehalf;
3381 
3382  // Fill b:
3383  b(0) = onehalf;
3384  b(1) = onehalf;
3385 
3386  // Fill c:
3387  c(0) = zero;
3388  c(1) = one;
3389 
3390  int order = 2;
3391 
3393  this->getStepperType(), A, b, c, order, order, order));
3394  this->tableau_->setTVD(true);
3395  this->tableau_->setTVDCoeff(2.0);
3396  }
3397 };
3398 
3400 // ------------------------------------------------------------------------
3401 template <class Scalar>
3404  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
3406 {
3407  auto stepper = Teuchos::rcp(new StepperEDIRK_TrapezoidalRule<Scalar>());
3408 
3409  // Test for aliases.
3410  if (pl != Teuchos::null) {
3411  auto stepperType =
3412  pl->get<std::string>("Stepper Type", stepper->getStepperType());
3413 
3415  stepperType != stepper->getStepperType() &&
3416  stepperType != "RK Crank-Nicolson",
3417  std::logic_error,
3418  " ParameterList 'Stepper Type' (='" + stepperType
3419  << "')\n does not match type for this Stepper (='"
3420  << stepper->getStepperType()
3421  << "')\n or one of its aliases ('RK Crank-Nicolson').\n");
3422 
3423  // Reset default StepperType.
3424  pl->set<std::string>("Stepper Type", stepper->getStepperType());
3425  }
3426 
3427  stepper->setStepperDIRKValues(pl);
3428 
3429  if (model != Teuchos::null) {
3430  stepper->setModel(model);
3431  stepper->initialize();
3432  }
3433 
3434  return stepper;
3435 }
3436 
3437 // ----------------------------------------------------------------------------
3464 template <class Scalar>
3465 class StepperSDIRK_ImplicitMidpoint : virtual public StepperDIRK<Scalar> {
3466  public:
3473  {
3474  this->setStepperName("RK Implicit Midpoint");
3475  this->setStepperType("RK Implicit Midpoint");
3476  this->setupTableau();
3477  this->setupDefault();
3478  this->setUseFSAL(false);
3479  this->setICConsistency("None");
3480  this->setICConsistencyCheck(false);
3481  }
3482 
3484  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
3486  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
3487  bool useEmbedded, bool zeroInitialGuess,
3488  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
3489  {
3490  this->setStepperName("RK Implicit Midpoint");
3491  this->setStepperType("RK Implicit Midpoint");
3492  this->setupTableau();
3493  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
3494  useEmbedded, zeroInitialGuess, stepperRKAppAction);
3495  }
3496 
3497  std::string getDescription() const
3498  {
3499  std::ostringstream Description;
3500  Description << this->getStepperType() << "\n"
3501  << "A-stable\n"
3502  << "Solving Ordinary Differential Equations II:\n"
3503  << "Stiff and Differential-Algebraic Problems,\n"
3504  << "2nd Revised Edition\n"
3505  << "E. Hairer and G. Wanner\n"
3506  << "Table 5.2, pg 72\n"
3507  << "Solving Ordinary Differential Equations I:\n"
3508  << "Nonstiff Problems, 2nd Revised Edition\n"
3509  << "E. Hairer, S. P. Norsett, and G. Wanner\n"
3510  << "Table 7.1, pg 205\n"
3511  << "c = [ 1/2 ]'\n"
3512  << "A = [ 1/2 ]\n"
3513  << "b = [ 1 ]'";
3514  return Description.str();
3515  }
3516 
3517  protected:
3519  {
3520  typedef Teuchos::ScalarTraits<Scalar> ST;
3521  int NumStages = 1;
3522  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
3525  const Scalar onehalf = ST::one() / (2 * ST::one());
3526  const Scalar one = ST::one();
3527 
3528  // Fill A:
3529  A(0, 0) = onehalf;
3530 
3531  // Fill b:
3532  b(0) = one;
3533 
3534  // Fill c:
3535  c(0) = onehalf;
3536 
3537  int order = 2;
3538 
3540  this->getStepperType(), A, b, c, order, order, order));
3541  this->tableau_->setTVD(true);
3542  this->tableau_->setTVDCoeff(2.0);
3543  }
3544 };
3545 
3547 // ------------------------------------------------------------------------
3548 template <class Scalar>
3551  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
3553 {
3555  stepper->setStepperDIRKValues(pl);
3556 
3557  if (model != Teuchos::null) {
3558  stepper->setModel(model);
3559  stepper->initialize();
3560  }
3561 
3562  return stepper;
3563 }
3564 
3565 // ----------------------------------------------------------------------------
3586 template <class Scalar>
3587 class StepperSDIRK_SSPDIRK22 : virtual public StepperDIRK<Scalar> {
3588  public:
3590  {
3591  this->setStepperName("SSPDIRK22");
3592  this->setStepperType("SSPDIRK22");
3593  this->setupTableau();
3594  this->setupDefault();
3595  this->setUseFSAL(false);
3596  this->setICConsistency("None");
3597  this->setICConsistencyCheck(false);
3598  }
3599 
3601  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
3603  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
3604  bool useEmbedded, bool zeroInitialGuess,
3605  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
3606  {
3607  this->setStepperName("SSPDIRK22");
3608  this->setStepperType("SSPDIRK22");
3609  this->setupTableau();
3610  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
3611  useEmbedded, zeroInitialGuess, stepperRKAppAction);
3612  }
3613 
3614  std::string getDescription() const
3615  {
3616  std::ostringstream Description;
3617  Description << this->getStepperType() << "\n"
3618  << "Strong Stability Preserving Diagonally-Implicit RK "
3619  "(stage=2, order=2)\n"
3620  << "SSP-Coef = 4\n"
3621  << "c = [ 1/4 3/4 ]'\n"
3622  << "A = [ 1/4 ]\n"
3623  << " [ 1/2 1/4 ]\n"
3624  << "b = [ 1/2 1/2 ]\n"
3625  << std::endl;
3626  return Description.str();
3627  }
3628 
3629  protected:
3631  {
3632  typedef Teuchos::ScalarTraits<Scalar> ST;
3633  using Teuchos::as;
3634  const int NumStages = 2;
3635  const int order = 2;
3636  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
3639 
3640  const Scalar one = ST::one();
3641  const Scalar zero = ST::zero();
3642  const Scalar onehalf = one / (2 * one);
3643  const Scalar onefourth = one / (4 * one);
3644 
3645  // Fill A:
3646  A(0, 0) = A(1, 1) = onefourth;
3647  A(0, 1) = zero;
3648  A(1, 0) = onehalf;
3649 
3650  // Fill b:
3651  b(0) = b(1) = onehalf;
3652 
3653  // Fill c:
3654  c(0) = A(0, 0);
3655  c(1) = A(1, 0) + A(1, 1);
3656 
3658  this->getStepperType(), A, b, c, order, order, order));
3659  this->tableau_->setTVD(true);
3660  this->tableau_->setTVDCoeff(4.0);
3661  }
3662 };
3663 
3665 // ------------------------------------------------------------------------
3666 template <class Scalar>
3668  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
3670 {
3671  auto stepper = Teuchos::rcp(new StepperSDIRK_SSPDIRK22<Scalar>());
3672  stepper->setStepperDIRKValues(pl);
3673 
3674  if (model != Teuchos::null) {
3675  stepper->setModel(model);
3676  stepper->initialize();
3677  }
3678 
3679  return stepper;
3680 }
3681 
3682 // ----------------------------------------------------------------------------
3704 template <class Scalar>
3705 class StepperSDIRK_SSPDIRK32 : virtual public StepperDIRK<Scalar> {
3706  public:
3708  {
3709  this->setStepperName("SSPDIRK32");
3710  this->setStepperType("SSPDIRK32");
3711  this->setupTableau();
3712  this->setupDefault();
3713  this->setUseFSAL(false);
3714  this->setICConsistency("None");
3715  this->setICConsistencyCheck(false);
3716  }
3717 
3719  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
3721  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
3722  bool useEmbedded, bool zeroInitialGuess,
3723  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
3724  {
3725  this->setStepperName("SSPDIRK32");
3726  this->setStepperType("SSPDIRK32");
3727  this->setupTableau();
3728  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
3729  useEmbedded, zeroInitialGuess, stepperRKAppAction);
3730  }
3731 
3732  std::string getDescription() const
3733  {
3734  std::ostringstream Description;
3735  Description << this->getStepperType() << "\n"
3736  << "Strong Stability Preserving Diagonally-Implicit RK "
3737  "(stage=3, order=2)\n"
3738  << "SSP-Coef = 6\n"
3739  << "c = [ 1/6 1/2 5/6 ]'\n"
3740  << "A = [ 1/6 ]\n"
3741  << " [ 1/3 1/6 ]\n"
3742  << " [ 1/3 1/3 1/6 ]\n"
3743  << "b = [ 1/3 1/3 1/3 ]\n"
3744  << std::endl;
3745  return Description.str();
3746  }
3747 
3748  protected:
3750  {
3751  typedef Teuchos::ScalarTraits<Scalar> ST;
3752  using Teuchos::as;
3753  const int NumStages = 3;
3754  const int order = 2;
3755  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
3758 
3759  const Scalar one = ST::one();
3760  const Scalar zero = ST::zero();
3761  const Scalar onethird = one / (3 * one);
3762  const Scalar onesixth = one / (6 * one);
3763 
3764  // Fill A:
3765  A(0, 0) = A(1, 1) = A(2, 2) = onesixth;
3766  A(1, 0) = A(2, 0) = A(2, 1) = onethird;
3767  A(0, 1) = A(0, 2) = A(1, 2) = zero;
3768 
3769  // Fill b:
3770  b(0) = b(1) = b(2) = onethird;
3771 
3772  // Fill c:
3773  c(0) = A(0, 0);
3774  c(1) = A(1, 0) + A(1, 1);
3775  c(2) = A(2, 0) + A(2, 1) + A(2, 2);
3776 
3778  this->getStepperType(), A, b, c, order, order, order));
3779  this->tableau_->setTVD(true);
3780  this->tableau_->setTVDCoeff(6.0);
3781  }
3782 };
3783 
3785 // ------------------------------------------------------------------------
3786 template <class Scalar>
3788  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
3790 {
3791  auto stepper = Teuchos::rcp(new StepperSDIRK_SSPDIRK32<Scalar>());
3792  stepper->setStepperDIRKValues(pl);
3793 
3794  if (model != Teuchos::null) {
3795  stepper->setModel(model);
3796  stepper->initialize();
3797  }
3798 
3799  return stepper;
3800 }
3801 
3802 // ----------------------------------------------------------------------------
3821 template <class Scalar>
3822 class StepperSDIRK_SSPDIRK23 : virtual public StepperDIRK<Scalar> {
3823  public:
3825  {
3826  this->setStepperName("SSPDIRK23");
3827  this->setStepperType("SSPDIRK23");
3828  this->setupTableau();
3829  this->setupDefault();
3830  this->setUseFSAL(false);
3831  this->setICConsistency("None");
3832  this->setICConsistencyCheck(false);
3833  }
3834 
3836  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
3838  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
3839  bool useEmbedded, bool zeroInitialGuess,
3840  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
3841  {
3842  this->setStepperName("SSPDIRK23");
3843  this->setStepperType("SSPDIRK23");
3844  this->setupTableau();
3845  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
3846  useEmbedded, zeroInitialGuess, stepperRKAppAction);
3847  }
3848 
3849  std::string getDescription() const
3850  {
3851  std::ostringstream Description;
3852  Description << this->getStepperType() << "\n"
3853  << "Strong Stability Preserving Diagonally-Implicit RK "
3854  "(stage=2, order=3)\n"
3855  << "SSP-Coef = 1 + sqrt( 3 )\n"
3856  << "c = [ 1/(3 + sqrt( 3 )) (1/6)(3 + sqrt( 3 )) ] '\n"
3857  << "A = [ 1/(3 + sqrt( 3 )) ] \n"
3858  << " [ 1/sqrt( 3 ) 1/(3 + sqrt( 3 )) ] \n"
3859  << "b = [ 1/2 1/2 ] \n"
3860  << std::endl;
3861  return Description.str();
3862  }
3863 
3864  protected:
3866  {
3867  typedef Teuchos::ScalarTraits<Scalar> ST;
3868  using Teuchos::as;
3869  const int NumStages = 2;
3870  const int order = 3;
3871  const Scalar sspcoef = 2.7321;
3872  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
3875 
3876  const Scalar one = ST::one();
3877  const Scalar zero = ST::zero();
3878  const Scalar onehalf = one / (2 * one);
3879  const Scalar rootthree = ST::squareroot(3 * one);
3880 
3881  // Fill A:
3882  A(0, 0) = A(1, 1) = one / (3 * one + rootthree);
3883  A(1, 0) = one / rootthree;
3884  A(0, 1) = zero;
3885 
3886  // Fill b:
3887  b(0) = b(1) = onehalf;
3888 
3889  // Fill c:
3890  c(0) = A(0, 0);
3891  c(1) = A(1, 0) + A(1, 1);
3892 
3894  this->getStepperType(), A, b, c, order, order, order));
3895  this->tableau_->setTVD(true);
3896  this->tableau_->setTVDCoeff(sspcoef);
3897  }
3898 };
3899 
3901 // ------------------------------------------------------------------------
3902 template <class Scalar>
3904  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
3906 {
3907  auto stepper = Teuchos::rcp(new StepperSDIRK_SSPDIRK23<Scalar>());
3908  stepper->setStepperDIRKValues(pl);
3909 
3910  if (model != Teuchos::null) {
3911  stepper->setModel(model);
3912  stepper->initialize();
3913  }
3914 
3915  return stepper;
3916 }
3917 
3918 // ----------------------------------------------------------------------------
3940 template <class Scalar>
3941 class StepperSDIRK_SSPDIRK33 : virtual public StepperDIRK<Scalar> {
3942  public:
3944  {
3945  this->setStepperName("SSPDIRK33");
3946  this->setStepperType("SSPDIRK33");
3947  this->setupTableau();
3948  this->setupDefault();
3949  this->setUseFSAL(false);
3950  this->setICConsistency("None");
3951  this->setICConsistencyCheck(false);
3952  }
3953 
3955  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
3957  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
3958  bool useEmbedded, bool zeroInitialGuess,
3959  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
3960  {
3961  this->setStepperName("SSPDIRK33");
3962  this->setStepperType("SSPDIRK33");
3963  this->setupTableau();
3964  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
3965  useEmbedded, zeroInitialGuess, stepperRKAppAction);
3966  }
3967 
3968  std::string getDescription() const
3969  {
3970  std::ostringstream Description;
3971  Description << this->getStepperType() << "\n"
3972  << "Strong Stability Preserving Diagonally-Implicit RK "
3973  "(stage=3, order=3)\n"
3974  << "SSP-Coef = 2 + 2 sqrt(2)\n"
3975  << "c = [ 1/( 4 + 2 sqrt(2) 1/2 (1/4)(2 + "
3976  "sqrt(2) ] '\n"
3977  << "A = [ 1/( 4 + 2 sqrt(2) "
3978  " ] \n"
3979  << " [ 1/(2 sqrt(2) 1/( 4 + 2 sqrt(2) "
3980  " ] \n"
3981  << " [ 1/(2 sqrt(2) 1/(2 sqrt(2) 1/( 4 + 2 "
3982  "sqrt(2) ] \n"
3983  << "b = [ 1/3 1/3 1/3 "
3984  " ] \n"
3985  << std::endl;
3986  return Description.str();
3987  }
3988 
3989  protected:
3991  {
3992  typedef Teuchos::ScalarTraits<Scalar> ST;
3993  using Teuchos::as;
3994  const int NumStages = 3;
3995  const int order = 3;
3996  const Scalar sspcoef = 4.8284;
3997  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
4000 
4001  const Scalar one = ST::one();
4002  const Scalar zero = ST::zero();
4003  const Scalar onethird = one / (3 * one);
4004  const Scalar rootwo = ST::squareroot(2 * one);
4005 
4006  // Fill A:
4007  A(0, 0) = A(1, 1) = A(2, 2) = one / (4 * one + 2 * rootwo);
4008  A(1, 0) = A(2, 0) = A(2, 1) = one / (2 * rootwo);
4009  A(0, 1) = A(0, 2) = A(1, 2) = zero;
4010 
4011  // Fill b:
4012  b(0) = b(1) = b(2) = onethird;
4013 
4014  // Fill c:
4015  c(0) = A(0, 0);
4016  c(1) = A(1, 0) + A(1, 1);
4017  c(2) = A(2, 0) + A(2, 1) + A(2, 2);
4018 
4020  this->getStepperType(), A, b, c, order, order, order));
4021  this->tableau_->setTVD(true);
4022  this->tableau_->setTVDCoeff(sspcoef);
4023  }
4024 };
4025 
4027 // ------------------------------------------------------------------------
4028 template <class Scalar>
4030  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
4032 {
4033  auto stepper = Teuchos::rcp(new StepperSDIRK_SSPDIRK33<Scalar>());
4034  stepper->setStepperDIRKValues(pl);
4035 
4036  if (model != Teuchos::null) {
4037  stepper->setModel(model);
4038  stepper->initialize();
4039  }
4040 
4041  return stepper;
4042 }
4043 
4044 // ----------------------------------------------------------------------------
4065 template <class Scalar>
4066 class StepperDIRK_1Stage1stOrderRadauIA : virtual public StepperDIRK<Scalar> {
4067  public:
4074  {
4075  this->setStepperName("RK Implicit 1 Stage 1st order Radau IA");
4076  this->setStepperType("RK Implicit 1 Stage 1st order Radau IA");
4077  this->setupTableau();
4078  this->setupDefault();
4079  this->setUseFSAL(false);
4080  this->setICConsistency("None");
4081  this->setICConsistencyCheck(false);
4082  }
4083 
4085  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
4087  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
4088  bool useEmbedded, bool zeroInitialGuess,
4089  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
4090  {
4091  this->setStepperName("RK Implicit 1 Stage 1st order Radau IA");
4092  this->setStepperType("RK Implicit 1 Stage 1st order Radau IA");
4093  this->setupTableau();
4094  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
4095  useEmbedded, zeroInitialGuess, stepperRKAppAction);
4096  }
4097 
4098  std::string getDescription() const
4099  {
4100  std::ostringstream Description;
4101  Description << this->getStepperType() << "\n"
4102  << "A-stable\n"
4103  << "Solving Ordinary Differential Equations II:\n"
4104  << "Stiff and Differential-Algebraic Problems,\n"
4105  << "2nd Revised Edition\n"
4106  << "E. Hairer and G. Wanner\n"
4107  << "Table 5.3, pg 73\n"
4108  << "c = [ 0 ]'\n"
4109  << "A = [ 1 ]\n"
4110  << "b = [ 1 ]'";
4111  return Description.str();
4112  }
4113 
4114  protected:
4116  {
4117  typedef Teuchos::ScalarTraits<Scalar> ST;
4118  int NumStages = 1;
4119  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
4122  const Scalar one = ST::one();
4123  const Scalar zero = ST::zero();
4124  A(0, 0) = one;
4125  b(0) = one;
4126  c(0) = zero;
4127  int order = 1;
4128 
4129  auto emptyBStar = Teuchos::SerialDenseVector<int, Scalar>();
4130  this->tableau_ = Teuchos::rcp(
4131  new RKButcherTableau<Scalar>(this->getStepperType(), A, b, c, order,
4132  order, order, emptyBStar, false));
4133  }
4134 };
4135 
4137 // ------------------------------------------------------------------------
4138 template <class Scalar>
4141  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
4143 {
4145  stepper->setStepperDIRKValues(pl);
4146 
4147  if (model != Teuchos::null) {
4148  stepper->setModel(model);
4149  stepper->initialize();
4150  }
4151 
4152  return stepper;
4153 }
4154 
4155 // ----------------------------------------------------------------------------
4178 template <class Scalar>
4180  : virtual public StepperDIRK<Scalar> {
4181  public:
4188  {
4189  this->setStepperName("RK Implicit 2 Stage 2nd order Lobatto IIIB");
4190  this->setStepperType("RK Implicit 2 Stage 2nd order Lobatto IIIB");
4191  this->setupTableau();
4192  this->setupDefault();
4193  this->setUseFSAL(false);
4194  this->setICConsistency("None");
4195  this->setICConsistencyCheck(false);
4196  }
4197 
4199  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
4201  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
4202  bool useEmbedded, bool zeroInitialGuess,
4203  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
4204  {
4205  this->setStepperName("RK Implicit 2 Stage 2nd order Lobatto IIIB");
4206  this->setStepperType("RK Implicit 2 Stage 2nd order Lobatto IIIB");
4207  this->setupTableau();
4208  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
4209  useEmbedded, zeroInitialGuess, stepperRKAppAction);
4210  }
4211 
4212  std::string getDescription() const
4213  {
4214  std::ostringstream Description;
4215  Description << this->getStepperType() << "\n"
4216  << "A-stable\n"
4217  << "Solving Ordinary Differential Equations II:\n"
4218  << "Stiff and Differential-Algebraic Problems,\n"
4219  << "2nd Revised Edition\n"
4220  << "E. Hairer and G. Wanner\n"
4221  << "Table 5.9, pg 76\n"
4222  << "c = [ 0 1 ]'\n"
4223  << "A = [ 1/2 0 ]\n"
4224  << " [ 1/2 0 ]\n"
4225  << "b = [ 1/2 1/2 ]'";
4226  return Description.str();
4227  }
4228 
4229  protected:
4231  {
4232  typedef Teuchos::ScalarTraits<Scalar> ST;
4233  using Teuchos::as;
4234  int NumStages = 2;
4235  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
4238  const Scalar zero = ST::zero();
4239  const Scalar one = ST::one();
4240 
4241  // Fill A:
4242  A(0, 0) = as<Scalar>(one / (2 * one));
4243  A(0, 1) = zero;
4244  A(1, 0) = as<Scalar>(one / (2 * one));
4245  A(1, 1) = zero;
4246 
4247  // Fill b:
4248  b(0) = as<Scalar>(one / (2 * one));
4249  b(1) = as<Scalar>(one / (2 * one));
4250 
4251  // Fill c:
4252  c(0) = zero;
4253  c(1) = one;
4254  int order = 2;
4255 
4256  auto emptyBStar = Teuchos::SerialDenseVector<int, Scalar>();
4257  this->tableau_ = Teuchos::rcp(
4258  new RKButcherTableau<Scalar>(this->getStepperType(), A, b, c, order,
4259  order, order, emptyBStar, false));
4260  this->tableau_->setTVD(true);
4261  this->tableau_->setTVDCoeff(2.0);
4262  }
4263 };
4264 
4266 // ------------------------------------------------------------------------
4267 template <class Scalar>
4270  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
4272 {
4273  auto stepper =
4275  stepper->setStepperDIRKValues(pl);
4276 
4277  if (model != Teuchos::null) {
4278  stepper->setModel(model);
4279  stepper->initialize();
4280  }
4281 
4282  return stepper;
4283 }
4284 
4285 // ----------------------------------------------------------------------------
4311 template <class Scalar>
4312 class StepperSDIRK_5Stage4thOrder : virtual public StepperDIRK<Scalar> {
4313  public:
4320  {
4321  this->setStepperName("SDIRK 5 Stage 4th order");
4322  this->setStepperType("SDIRK 5 Stage 4th order");
4323  this->setupTableau();
4324  this->setupDefault();
4325  this->setUseFSAL(false);
4326  this->setICConsistency("None");
4327  this->setICConsistencyCheck(false);
4328  }
4329 
4331  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
4333  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
4334  bool useEmbedded, bool zeroInitialGuess,
4335  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
4336  {
4337  this->setStepperName("SDIRK 5 Stage 4th order");
4338  this->setStepperType("SDIRK 5 Stage 4th order");
4339  this->setupTableau();
4340  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
4341  useEmbedded, zeroInitialGuess, stepperRKAppAction);
4342  }
4343 
4344  std::string getDescription() const
4345  {
4346  std::ostringstream Description;
4347  Description << this->getStepperType() << "\n"
4348  << "L-stable\n"
4349  << "Solving Ordinary Differential Equations II:\n"
4350  << "Stiff and Differential-Algebraic Problems,\n"
4351  << "2nd Revised Edition\n"
4352  << "E. Hairer and G. Wanner\n"
4353  << "pg100 \n"
4354  << "c = [ 1/4 3/4 11/20 1/2 1 ]'\n"
4355  << "A = [ 1/4 ]\n"
4356  << " [ 1/2 1/4 ]\n"
4357  << " [ 17/50 -1/25 1/4 ]\n"
4358  << " [ 371/1360 -137/2720 15/544 1/4 ]\n"
4359  << " [ 25/24 -49/48 125/16 -85/12 1/4 ]\n"
4360  << "b = [ 25/24 -49/48 125/16 -85/12 1/4 ]'";
4361  // << "b = [ 59/48 -17/96 225/32 -85/12 0 ]'";
4362  return Description.str();
4363  }
4364 
4365  protected:
4367  {
4368  typedef Teuchos::ScalarTraits<Scalar> ST;
4369  using Teuchos::as;
4370  int NumStages = 5;
4371  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
4374  const Scalar zero = ST::zero();
4375  const Scalar one = ST::one();
4376  const Scalar onequarter = as<Scalar>(one / (4 * one));
4377 
4378  // Fill A:
4379  A(0, 0) = onequarter;
4380  A(0, 1) = zero;
4381  A(0, 2) = zero;
4382  A(0, 3) = zero;
4383  A(0, 4) = zero;
4384 
4385  A(1, 0) = as<Scalar>(one / (2 * one));
4386  A(1, 1) = onequarter;
4387  A(1, 2) = zero;
4388  A(1, 3) = zero;
4389  A(1, 4) = zero;
4390 
4391  A(2, 0) = as<Scalar>(17 * one / (50 * one));
4392  A(2, 1) = as<Scalar>(-one / (25 * one));
4393  A(2, 2) = onequarter;
4394  A(2, 3) = zero;
4395  A(2, 4) = zero;
4396 
4397  A(3, 0) = as<Scalar>(371 * one / (1360 * one));
4398  A(3, 1) = as<Scalar>(-137 * one / (2720 * one));
4399  A(3, 2) = as<Scalar>(15 * one / (544 * one));
4400  A(3, 3) = onequarter;
4401  A(3, 4) = zero;
4402 
4403  A(4, 0) = as<Scalar>(25 * one / (24 * one));
4404  A(4, 1) = as<Scalar>(-49 * one / (48 * one));
4405  A(4, 2) = as<Scalar>(125 * one / (16 * one));
4406  A(4, 3) = as<Scalar>(-85 * one / (12 * one));
4407  A(4, 4) = onequarter;
4408 
4409  // Fill b:
4410  b(0) = as<Scalar>(25 * one / (24 * one));
4411  b(1) = as<Scalar>(-49 * one / (48 * one));
4412  b(2) = as<Scalar>(125 * one / (16 * one));
4413  b(3) = as<Scalar>(-85 * one / (12 * one));
4414  b(4) = onequarter;
4415 
4416  /*
4417  // Alternate version
4418  b(0) = as<Scalar>( 59*one/(48*one) );
4419  b(1) = as<Scalar>( -17*one/(96*one) );
4420  b(2) = as<Scalar>( 225*one/(32*one) );
4421  b(3) = as<Scalar>( -85*one/(12*one) );
4422  b(4) = zero;
4423  */
4424 
4425  // Fill c:
4426  c(0) = onequarter;
4427  c(1) = as<Scalar>(3 * one / (4 * one));
4428  c(2) = as<Scalar>(11 * one / (20 * one));
4429  c(3) = as<Scalar>(one / (2 * one));
4430  c(4) = one;
4431 
4432  int order = 4;
4433 
4435  this->getStepperType(), A, b, c, order, order, order));
4436  }
4437 };
4438 
4440 // ------------------------------------------------------------------------
4441 template <class Scalar>
4444  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
4446 {
4447  auto stepper = Teuchos::rcp(new StepperSDIRK_5Stage4thOrder<Scalar>());
4448  stepper->setStepperDIRKValues(pl);
4449 
4450  if (model != Teuchos::null) {
4451  stepper->setModel(model);
4452  stepper->initialize();
4453  }
4454 
4455  return stepper;
4456 }
4457 
4458 // ----------------------------------------------------------------------------
4483 template <class Scalar>
4484 class StepperSDIRK_3Stage4thOrder : virtual public StepperDIRK<Scalar> {
4485  public:
4492  {
4493  this->setStepperName("SDIRK 3 Stage 4th order");
4494  this->setStepperType("SDIRK 3 Stage 4th order");
4495  this->setupTableau();
4496  this->setupDefault();
4497  this->setUseFSAL(false);
4498  this->setICConsistency("None");
4499  this->setICConsistencyCheck(false);
4500  }
4501 
4503  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
4505  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
4506  bool useEmbedded, bool zeroInitialGuess,
4507  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
4508  {
4509  this->setStepperName("SDIRK 3 Stage 4th order");
4510  this->setStepperType("SDIRK 3 Stage 4th order");
4511  this->setupTableau();
4512  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
4513  useEmbedded, zeroInitialGuess, stepperRKAppAction);
4514  }
4515 
4516  std::string getDescription() const
4517  {
4518  std::ostringstream Description;
4519  Description << this->getStepperType() << "\n"
4520  << "A-stable\n"
4521  << "Solving Ordinary Differential Equations II:\n"
4522  << "Stiff and Differential-Algebraic Problems,\n"
4523  << "2nd Revised Edition\n"
4524  << "E. Hairer and G. Wanner\n"
4525  << "p. 100 \n"
4526  << "gamma = (1/sqrt(3))*cos(pi/18)+1/2\n"
4527  << "delta = 1/(6*(2*gamma-1)^2)\n"
4528  << "c = [ gamma 1/2 1-gamma ]'\n"
4529  << "A = [ gamma ]\n"
4530  << " [ 1/2-gamma gamma ]\n"
4531  << " [ 2*gamma 1-4*gamma gamma ]\n"
4532  << "b = [ delta 1-2*delta delta ]'";
4533  return Description.str();
4534  }
4535 
4536  protected:
4538  {
4539  typedef Teuchos::ScalarTraits<Scalar> ST;
4540  using Teuchos::as;
4541  int NumStages = 3;
4542  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
4545  const Scalar zero = ST::zero();
4546  const Scalar one = ST::one();
4547  const Scalar pi = as<Scalar>(4 * one) * std::atan(one);
4548  const Scalar gamma =
4549  as<Scalar>(one / ST::squareroot(3 * one) * std::cos(pi / (18 * one)) +
4550  one / (2 * one));
4551  const Scalar delta =
4552  as<Scalar>(one / (6 * one * std::pow(2 * gamma - one, 2 * one)));
4553 
4554  // Fill A:
4555  A(0, 0) = gamma;
4556  A(0, 1) = zero;
4557  A(0, 2) = zero;
4558 
4559  A(1, 0) = as<Scalar>(one / (2 * one) - gamma);
4560  A(1, 1) = gamma;
4561  A(1, 2) = zero;
4562 
4563  A(2, 0) = as<Scalar>(2 * gamma);
4564  A(2, 1) = as<Scalar>(one - 4 * gamma);
4565  A(2, 2) = gamma;
4566 
4567  // Fill b:
4568  b(0) = delta;
4569  b(1) = as<Scalar>(one - 2 * delta);
4570  b(2) = delta;
4571 
4572  // Fill c:
4573  c(0) = gamma;
4574  c(1) = as<Scalar>(one / (2 * one));
4575  c(2) = as<Scalar>(one - gamma);
4576 
4577  int order = 4;
4578 
4580  this->getStepperType(), A, b, c, order, order, order));
4581  }
4582 };
4583 
4585 // ------------------------------------------------------------------------
4586 template <class Scalar>
4589  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
4591 {
4592  auto stepper = Teuchos::rcp(new StepperSDIRK_3Stage4thOrder<Scalar>());
4593  stepper->setStepperDIRKValues(pl);
4594 
4595  if (model != Teuchos::null) {
4596  stepper->setModel(model);
4597  stepper->initialize();
4598  }
4599 
4600  return stepper;
4601 }
4602 
4603 // ----------------------------------------------------------------------------
4632 template <class Scalar>
4633 class StepperSDIRK_5Stage5thOrder : virtual public StepperDIRK<Scalar> {
4634  public:
4641  {
4642  this->setStepperName("SDIRK 5 Stage 5th order");
4643  this->setStepperType("SDIRK 5 Stage 5th order");
4644  this->setupTableau();
4645  this->setupDefault();
4646  this->setUseFSAL(false);
4647  this->setICConsistency("None");
4648  this->setICConsistencyCheck(false);
4649  }
4650 
4652  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
4654  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
4655  bool useEmbedded, bool zeroInitialGuess,
4656  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
4657  {
4658  this->setStepperName("SDIRK 5 Stage 5th order");
4659  this->setStepperType("SDIRK 5 Stage 5th order");
4660  this->setupTableau();
4661  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
4662  useEmbedded, zeroInitialGuess, stepperRKAppAction);
4663  }
4664 
4665  std::string getDescription() const
4666  {
4667  std::ostringstream Description;
4668  Description << this->getStepperType() << "\n"
4669  << "Solving Ordinary Differential Equations II:\n"
4670  << "Stiff and Differential-Algebraic Problems,\n"
4671  << "2nd Revised Edition\n"
4672  << "E. Hairer and G. Wanner\n"
4673  << "pg101 \n"
4674  << "c = [ (6-sqrt(6))/10 ]\n"
4675  << " [ (6+9*sqrt(6))/35 ]\n"
4676  << " [ 1 ]\n"
4677  << " [ (4-sqrt(6))/10 ]\n"
4678  << " [ (4+sqrt(6))/10 ]\n"
4679  << "A = [ A1 A2 A3 A4 A5 ]\n"
4680  << " A1 = [ (6-sqrt(6))/10 ]\n"
4681  << " [ (-6+5*sqrt(6))/14 ]\n"
4682  << " [ (888+607*sqrt(6))/2850 ]\n"
4683  << " [ (3153-3082*sqrt(6))/14250 ]\n"
4684  << " [ (-32583+14638*sqrt(6))/71250 ]\n"
4685  << " A2 = [ 0 ]\n"
4686  << " [ (6-sqrt(6))/10 ]\n"
4687  << " [ (126-161*sqrt(6))/1425 ]\n"
4688  << " [ (3213+1148*sqrt(6))/28500 ]\n"
4689  << " [ (-17199+364*sqrt(6))/142500 ]\n"
4690  << " A3 = [ 0 ]\n"
4691  << " [ 0 ]\n"
4692  << " [ (6-sqrt(6))/10 ]\n"
4693  << " [ (-267+88*sqrt(6))/500 ]\n"
4694  << " [ (1329-544*sqrt(6))/2500 ]\n"
4695  << " A4 = [ 0 ]\n"
4696  << " [ 0 ]\n"
4697  << " [ 0 ]\n"
4698  << " [ (6-sqrt(6))/10 ]\n"
4699  << " [ (-96+131*sqrt(6))/625 ]\n"
4700  << " A5 = [ 0 ]\n"
4701  << " [ 0 ]\n"
4702  << " [ 0 ]\n"
4703  << " [ 0 ]\n"
4704  << " [ (6-sqrt(6))/10 ]\n"
4705  << "b = [ 0 ]\n"
4706  << " [ 0 ]\n"
4707  << " [ 1/9 ]\n"
4708  << " [ (16-sqrt(6))/36 ]\n"
4709  << " [ (16+sqrt(6))/36 ]'";
4710  return Description.str();
4711  }
4712 
4713  protected:
4715  {
4716  typedef Teuchos::ScalarTraits<Scalar> ST;
4717  using Teuchos::as;
4718  int NumStages = 5;
4719  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
4722  const Scalar zero = ST::zero();
4723  const Scalar one = ST::one();
4724  const Scalar sqrt6 = ST::squareroot(as<Scalar>(6 * one));
4725  const Scalar gamma =
4726  as<Scalar>((6 * one - sqrt6) / (10 * one)); // diagonal
4727 
4728  // Fill A:
4729  A(0, 0) = gamma;
4730  A(0, 1) = zero;
4731  A(0, 2) = zero;
4732  A(0, 3) = zero;
4733  A(0, 4) = zero;
4734 
4735  A(1, 0) = as<Scalar>((-6 * one + 5 * one * sqrt6) / (14 * one));
4736  A(1, 1) = gamma;
4737  A(1, 2) = zero;
4738  A(1, 3) = zero;
4739  A(1, 4) = zero;
4740 
4741  A(2, 0) = as<Scalar>((888 * one + 607 * one * sqrt6) / (2850 * one));
4742  A(2, 1) = as<Scalar>((126 * one - 161 * one * sqrt6) / (1425 * one));
4743  A(2, 2) = gamma;
4744  A(2, 3) = zero;
4745  A(2, 4) = zero;
4746 
4747  A(3, 0) = as<Scalar>((3153 * one - 3082 * one * sqrt6) / (14250 * one));
4748  A(3, 1) = as<Scalar>((3213 * one + 1148 * one * sqrt6) / (28500 * one));
4749  A(3, 2) = as<Scalar>((-267 * one + 88 * one * sqrt6) / (500 * one));
4750  A(3, 3) = gamma;
4751  A(3, 4) = zero;
4752 
4753  A(4, 0) = as<Scalar>((-32583 * one + 14638 * one * sqrt6) / (71250 * one));
4754  A(4, 1) = as<Scalar>((-17199 * one + 364 * one * sqrt6) / (142500 * one));
4755  A(4, 2) = as<Scalar>((1329 * one - 544 * one * sqrt6) / (2500 * one));
4756  A(4, 3) = as<Scalar>((-96 * one + 131 * sqrt6) / (625 * one));
4757  A(4, 4) = gamma;
4758 
4759  // Fill b:
4760  b(0) = zero;
4761  b(1) = zero;
4762  b(2) = as<Scalar>(one / (9 * one));
4763  b(3) = as<Scalar>((16 * one - sqrt6) / (36 * one));
4764  b(4) = as<Scalar>((16 * one + sqrt6) / (36 * one));
4765 
4766  // Fill c:
4767  c(0) = gamma;
4768  c(1) = as<Scalar>((6 * one + 9 * one * sqrt6) / (35 * one));
4769  c(2) = one;
4770  c(3) = as<Scalar>((4 * one - sqrt6) / (10 * one));
4771  c(4) = as<Scalar>((4 * one + sqrt6) / (10 * one));
4772 
4773  int order = 5;
4774 
4776  this->getStepperType(), A, b, c, order, order, order));
4777  }
4778 };
4779 
4781 // ------------------------------------------------------------------------
4782 template <class Scalar>
4785  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
4787 {
4788  auto stepper = Teuchos::rcp(new StepperSDIRK_5Stage5thOrder<Scalar>());
4789  stepper->setStepperDIRKValues(pl);
4790 
4791  if (model != Teuchos::null) {
4792  stepper->setModel(model);
4793  stepper->initialize();
4794  }
4795 
4796  return stepper;
4797 }
4798 
4799 // ----------------------------------------------------------------------------
4818 template <class Scalar>
4819 class StepperSDIRK_21Pair : virtual public StepperDIRK<Scalar> {
4820  public:
4827  {
4828  this->setStepperName("SDIRK 2(1) Pair");
4829  this->setStepperType("SDIRK 2(1) Pair");
4830  this->setupTableau();
4831  this->setupDefault();
4832  this->setUseFSAL(false);
4833  this->setICConsistency("None");
4834  this->setICConsistencyCheck(false);
4835  }
4836 
4838  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
4840  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
4841  bool useEmbedded, bool zeroInitialGuess,
4842  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction)
4843  {
4844  this->setStepperName("SDIRK 2(1) Pair");
4845  this->setStepperType("SDIRK 2(1) Pair");
4846  this->setupTableau();
4847  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
4848  useEmbedded, zeroInitialGuess, stepperRKAppAction);
4849  }
4850 
4851  std::string getDescription() const
4852  {
4853  std::ostringstream Description;
4854  Description << this->getStepperType() << "\n"
4855  << "c = [ 1 0 ]'\n"
4856  << "A = [ 1 ]\n"
4857  << " [ -1 1 ]\n"
4858  << "b = [ 1/2 1/2 ]'\n"
4859  << "bstar = [ 1 0 ]'";
4860  return Description.str();
4861  }
4862 
4863  protected:
4865  {
4866  typedef Teuchos::ScalarTraits<Scalar> ST;
4867  using Teuchos::as;
4868  int NumStages = 2;
4869  Teuchos::SerialDenseMatrix<int, Scalar> A(NumStages, NumStages);
4872  Teuchos::SerialDenseVector<int, Scalar> bstar(NumStages);
4873 
4874  const Scalar one = ST::one();
4875  const Scalar zero = ST::zero();
4876 
4877  // Fill A:
4878  A(0, 0) = one;
4879  A(0, 1) = zero;
4880  A(1, 0) = -one;
4881  A(1, 1) = one;
4882 
4883  // Fill b:
4884  b(0) = as<Scalar>(one / (2 * one));
4885  b(1) = as<Scalar>(one / (2 * one));
4886 
4887  // Fill c:
4888  c(0) = one;
4889  c(1) = zero;
4890 
4891  // Fill bstar
4892  bstar(0) = one;
4893  bstar(1) = zero;
4894  int order = 2;
4895 
4897  this->getStepperType(), A, b, c, order, order, order, bstar));
4898  }
4899 };
4900 
4902 // ------------------------------------------------------------------------
4903 template <class Scalar>
4905  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
4907 {
4908  auto stepper = Teuchos::rcp(new StepperSDIRK_21Pair<Scalar>());
4909  stepper->setStepperDIRKValues(pl);
4910 
4911  if (model != Teuchos::null) {
4912  stepper->setModel(model);
4913  stepper->initialize();
4914  }
4915 
4916  return stepper;
4917 }
4918 
4919 // ----------------------------------------------------------------------------
4952 template <class Scalar>
4953 class StepperDIRK_General : virtual public StepperDIRK<Scalar> {
4954  public:
4961  {
4962  this->setStepperName("General DIRK");
4963  this->setStepperType("General DIRK");
4964  this->setupTableau();
4965  this->setupDefault();
4966  this->setUseFSAL(false);
4967  this->setICConsistency("None");
4968  this->setICConsistencyCheck(false);
4969  }
4970 
4972  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
4974  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
4975  bool useEmbedded, bool zeroInitialGuess,
4976  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction,
4979  const Teuchos::SerialDenseVector<int, Scalar>& c, const int order,
4980  const int orderMin, const int orderMax,
4982  {
4983  this->setStepperName("General DIRK");
4984  this->setStepperType("General DIRK");
4985  this->setTableau(A, b, c, order, orderMin, orderMax, bstar);
4986 
4988  this->tableau_->isImplicit() != true, std::logic_error,
4989  "Error - General DIRK did not receive a DIRK Butcher Tableau!\n");
4990 
4991  this->setup(appModel, solver, useFSAL, ICConsistency, ICConsistencyCheck,
4992  useEmbedded, zeroInitialGuess, stepperRKAppAction);
4993  }
4994 
4995  std::string getDescription() const
4996  {
4997  std::stringstream Description;
4998  Description
4999  << this->getStepperType() << "\n"
5000  << "The format of the Butcher Tableau parameter list is\n"
5001  << " <Parameter name=\"A\" type=\"string\" value=\"# # # ;\n"
5002  << " # # # ;\n"
5003  << " # # #\"/>\n"
5004  << " <Parameter name=\"b\" type=\"string\" value=\"# # #\"/>\n"
5005  << " <Parameter name=\"c\" type=\"string\" value=\"# # #\"/>\n\n"
5006  << "Note the number of stages is implicit in the number of entries.\n"
5007  << "The number of stages must be consistent.\n"
5008  << "\n"
5009  << "Default tableau is 'SDIRK 2 Stage 2nd order':\n"
5010  << " Computer Methods for ODEs and DAEs\n"
5011  << " U. M. Ascher and L. R. Petzold\n"
5012  << " p. 106\n"
5013  << " gamma = (2-sqrt(2))/2\n"
5014  << " c = [ gamma 1 ]'\n"
5015  << " A = [ gamma 0 ]\n"
5016  << " [ 1-gamma gamma ]\n"
5017  << " b = [ 1-gamma gamma ]'";
5018  return Description.str();
5019  }
5020 
5022  {
5023  if (this->tableau_ == Teuchos::null) {
5024  // Set tableau to the default if null, otherwise keep current tableau.
5025  auto stepper = Teuchos::rcp(new StepperSDIRK_2Stage2ndOrder<Scalar>());
5026  auto t = stepper->getTableau();
5028  this->getStepperType(), t->A(), t->b(), t->c(), t->order(),
5029  t->orderMin(), t->orderMax(), t->bstar()));
5030  this->isInitialized_ = false;
5031  }
5032  }
5033 
5037  const int order, const int orderMin, const int orderMax,
5040  {
5042  this->getStepperType(), A, b, c, order, orderMin, orderMax, bstar));
5043  this->isInitialized_ = false;
5044  }
5045 
5047  {
5048  auto pl = this->getValidParametersBasicDIRK();
5049 
5050  // Tableau ParameterList
5054  Teuchos::SerialDenseVector<int, Scalar> bstar = this->tableau_->bstar();
5055 
5056  Teuchos::RCP<Teuchos::ParameterList> tableauPL = Teuchos::parameterList();
5057 
5058  std::ostringstream Astream;
5059  Astream.precision(15);
5060  for (int i = 0; i < A.numRows(); i++) {
5061  for (int j = 0; j < A.numCols() - 1; j++) {
5062  Astream << A(i, j) << " ";
5063  }
5064  Astream << A(i, A.numCols() - 1);
5065  if (i != A.numRows() - 1) Astream << "; ";
5066  }
5067  tableauPL->set<std::string>("A", Astream.str());
5068 
5069  std::ostringstream bstream;
5070  bstream.precision(15);
5071  for (int i = 0; i < b.length() - 1; i++) {
5072  bstream << b(i) << " ";
5073  }
5074  bstream << b(b.length() - 1);
5075  tableauPL->set<std::string>("b", bstream.str());
5076 
5077  std::ostringstream cstream;
5078  cstream.precision(15);
5079  for (int i = 0; i < c.length() - 1; i++) {
5080  cstream << c(i) << " ";
5081  }
5082  cstream << c(c.length() - 1);
5083  tableauPL->set<std::string>("c", cstream.str());
5084 
5085  tableauPL->set<int>("order", this->tableau_->order());
5086 
5087  if (bstar.length() == 0) {
5088  tableauPL->set("bstar", "");
5089  }
5090  else {
5091  std::ostringstream bstarstream;
5092  bstarstream.precision(15);
5093  for (int i = 0; i < bstar.length() - 1; i++) {
5094  bstarstream << bstar(i) << " ";
5095  }
5096  bstarstream << bstar(bstar.length() - 1);
5097  tableauPL->set<std::string>("bstar", bstarstream.str());
5098  }
5099 
5100  pl->set("Tableau", *tableauPL);
5101 
5102  return pl;
5103  }
5104 };
5105 
5107 // ------------------------------------------------------------------------
5108 template <class Scalar>
5110  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
5112 {
5113  auto stepper = Teuchos::rcp(new StepperDIRK_General<Scalar>());
5114  stepper->setStepperDIRKValues(pl);
5115 
5116  if (pl != Teuchos::null) {
5117  if (pl->isParameter("Tableau")) {
5118  auto t = stepper->createTableau(pl);
5119  stepper->setTableau(t->A(), t->b(), t->c(), t->order(), t->orderMin(),
5120  t->orderMax(), t->bstar());
5121  }
5122  }
5124  stepper->getTableau()->isDIRK() != true, std::logic_error,
5125  "Error - General DIRK did not receive a DIRK Butcher Tableau!\n");
5126 
5127  if (model != Teuchos::null) {
5128  stepper->setModel(model);
5129  stepper->initialize();
5130  }
5131 
5132  return stepper;
5133 }
5134 
5135 } // namespace Tempus
5136 
5137 #endif // Tempus_StepperRKButcherTableau_hpp
StepperERK_3Stage3rdOrderTVD(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
StepperERK_Merson45(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< StepperEDIRK_TrapezoidalRule< Scalar > > createStepperEDIRK_TrapezoidalRule(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
General Implicit Runge-Kutta Butcher Tableau.
StepperEDIRK_TrapezoidalRule(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
StepperERK_3Stage3rdOrderHeun(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
RK Implicit 2 Stage 2nd order Lobatto IIIB.
virtual std::string getDefaultICConsistency() const
std::string getStepperType() const
Get the stepper type. The stepper type is used as an identifier for the stepper, and can only be set ...
Teuchos::RCP< StepperSDIRK_SSPDIRK33< Scalar > > createStepperSDIRK_SSPDIRK33(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Explicit Runge-Kutta time stepper.
virtual void setupDefault()
Default setup for constructor.
Strong Stability Preserving Diagonally-Implicit RK Butcher Tableau.
Teuchos::RCP< Teuchos::ParameterList > getValidParametersBasicDIRK() const
StepperSDIRK_SSPDIRK33(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
StepperDIRK_BackwardEuler(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< StepperEDIRK_2Stage3rdOrder< Scalar > > createStepperEDIRK_2Stage3rdOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
StepperERK_SSPERK54(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< StepperSDIRK_5Stage4thOrder< Scalar > > createStepperSDIRK_5Stage4thOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
StepperEDIRK_2StageTheta(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction, Scalar theta=Scalar(0.5))
Backward Euler Runge-Kutta Butcher Tableau.
StepperSDIRK_3Stage4thOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< RKButcherTableau< Scalar > > tableau_
T & get(const std::string &name, T def_value)
Teuchos::RCP< StepperERK_SSPERK54< Scalar > > createStepperERK_SSPERK54(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
StepperSDIRK_ImplicitMidpoint(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
General Explicit Runge-Kutta Butcher Tableau.
StepperDIRK_General(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction, const Teuchos::SerialDenseMatrix< int, Scalar > &A, const Teuchos::SerialDenseVector< int, Scalar > &b, const Teuchos::SerialDenseVector< int, Scalar > &c, const int order, const int orderMin, const int orderMax, const Teuchos::SerialDenseVector< int, Scalar > &bstar)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Teuchos::RCP< StepperERK_3Stage3rdOrderHeun< Scalar > > createStepperERK_3Stage3rdOrderHeun(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
RK Explicit 5 Stage 3rd order by Kinnmark and Gray.
Teuchos::RCP< StepperERK_Merson45< Scalar > > createStepperERK_Merson45(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< StepperEDIRK_2StageTheta< Scalar > > createStepperEDIRK_2StageTheta(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
StepperSDIRK_SSPDIRK23(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
StepperSDIRK_3Stage2ndOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
void setStepperName(std::string s)
Set the stepper name.
Strong Stability Preserving Explicit RK Butcher Tableau.
RK Explicit 4 Stage 3rd order by Runge.
StepperERK_5Stage3rdOrderKandG(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
StepperEDIRK_2Stage3rdOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< StepperERK_3_8Rule< Scalar > > createStepperERK_3_8Rule(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< StepperERK_BogackiShampine32< Scalar > > createStepperERK_BogackiShampine32(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< StepperSDIRK_5Stage5thOrder< Scalar > > createStepperSDIRK_5Stage5thOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< StepperERK_3Stage3rdOrder< Scalar > > createStepperERK_3Stage3rdOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
StepperDIRK_2Stage2ndOrderLobattoIIIB(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
RK Trapezoidal Rule (A.K.A. RK Crank-Nicolson)
Teuchos::RCP< StepperDIRK_2Stage2ndOrderLobattoIIIB< Scalar > > createStepperDIRK_2Stage2ndOrderLobattoIIIB(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< StepperERK_ForwardEuler< Scalar > > createStepperERK_ForwardEuler(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< StepperSDIRK_21Pair< Scalar > > createStepperSDIRK_21Pair(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
bool isInitialized_
True if stepper&#39;s member data is initialized.
Teuchos::RCP< StepperSDIRK_SSPDIRK23< Scalar > > createStepperSDIRK_SSPDIRK23(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
StepperERK_4Stage3rdOrderRunge(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< StepperERK_3Stage3rdOrderTVD< Scalar > > createStepperERK_3Stage3rdOrderTVD(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< StepperSDIRK_3Stage4thOrder< Scalar > > createStepperSDIRK_3Stage4thOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Explicit RK 3/8th Rule Butcher Tableau.
StepperSDIRK_2Stage3rdOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction, std::string gammaType="3rd Order A-stable", Scalar gamma=Scalar(0.7886751345948128))
bool isParameter(const std::string &name) const
StepperERK_Midpoint(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Diagonally Implicit Runge-Kutta (DIRK) time stepper.
StepperERK_4Stage4thOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Strong Stability Preserving Diagonally-Implicit RK Butcher Tableau.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Application Action for StepperRKBase.
Teuchos::RCP< StepperDIRK_1Stage1stOrderRadauIA< Scalar > > createStepperDIRK_1Stage1stOrderRadauIA(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
bool useFSAL_
Use First-Same-As-Last (FSAL) principle.
virtual void setupDefault()
Default setup for constructor.
Explicit RK Bogacki-Shampine Butcher Tableau.
StepperSDIRK_5Stage5thOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
void setICConsistencyCheck(bool c)
Teuchos::RCP< StepperSDIRK_3Stage2ndOrder< Scalar > > createStepperSDIRK_3Stage2ndOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< StepperERK_5Stage3rdOrderKandG< Scalar > > createStepperERK_5Stage3rdOrderKandG(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
OrdinalType length() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
StepperSDIRK_21Pair(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< StepperDIRK_BackwardEuler< Scalar > > createStepperDIRK_BackwardEuler(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
StepperERK_Trapezoidal(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
StepperDIRK_1Stage1stOrderRadauIA(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Strong Stability Preserving Diagonally-Implicit RK Butcher Tableau.
Teuchos::RCP< StepperSDIRK_2Stage3rdOrder< Scalar > > createStepperSDIRK_2Stage3rdOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< Teuchos::ParameterList > getValidParametersBasicERK() const
StepperSDIRK_SSPDIRK22(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
void setTableau(const Teuchos::SerialDenseMatrix< int, Scalar > &A, const Teuchos::SerialDenseVector< int, Scalar > &b, const Teuchos::SerialDenseVector< int, Scalar > &c, const int order, const int orderMin, const int orderMax, const Teuchos::SerialDenseVector< int, Scalar > &bstar=Teuchos::SerialDenseVector< int, Scalar >())
Teuchos::RCP< StepperERK_Midpoint< Scalar > > createStepperERK_Midpoint(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
OrdinalType numCols() const
Teuchos::RCP< StepperSDIRK_SSPDIRK22< Scalar > > createStepperSDIRK_SSPDIRK22(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
StepperERK_ForwardEuler(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< StepperERK_Trapezoidal< Scalar > > createStepperERK_Trapezoidal(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Forward Euler Runge-Kutta Butcher Tableau.
StepperDIRK_1StageTheta(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction, Scalar theta=Scalar(0.5))
StepperERK_BogackiShampine32(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< StepperSDIRK_ImplicitMidpoint< Scalar > > createStepperSDIRK_ImplicitMidpoint(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
StepperERK_3Stage3rdOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< StepperERK_General< Scalar > > createStepperERK_General(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
virtual std::string getDescription() const
TypeTo as(const TypeFrom &t)
Teuchos::RCP< StepperSDIRK_2Stage2ndOrder< Scalar > > createStepperSDIRK_2Stage2ndOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Explicit RK Merson Butcher Tableau.
Runge-Kutta 4th order Butcher Tableau.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void setTableau(const Teuchos::SerialDenseMatrix< int, Scalar > &A, const Teuchos::SerialDenseVector< int, Scalar > &b, const Teuchos::SerialDenseVector< int, Scalar > &c, const int order, const int orderMin, const int orderMax, const Teuchos::SerialDenseVector< int, Scalar > &bstar=Teuchos::SerialDenseVector< int, Scalar >())
StepperERK_Ralston(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
virtual void setup(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &wrapperModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Setup for constructor.
StepperSDIRK_5Stage4thOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Teuchos::RCP< StepperERK_Ralston< Scalar > > createStepperERK_Ralston(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
virtual void setUseFSAL(bool a)
StepperSDIRK_2Stage2ndOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction, Scalar gamma=Scalar(0.2928932188134524))
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
StepperSDIRK_SSPDIRK32(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, const Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > &solver, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, bool zeroInitialGuess, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
StepperERK_3_8Rule(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
void setStepperType(std::string s)
Set the stepper type.
RK Explicit 3 Stage 3rd order by Heun.
StepperERK_General(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::SerialDenseMatrix< int, Scalar > &A, const Teuchos::SerialDenseVector< int, Scalar > &b, const Teuchos::SerialDenseVector< int, Scalar > &c, const int order, const int orderMin, const int orderMax, const Teuchos::SerialDenseVector< int, Scalar > &bstar, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction=Teuchos::null)
Teuchos::RCP< StepperERK_4Stage4thOrder< Scalar > > createStepperERK_4Stage4thOrder(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
OrdinalType numRows() const
virtual void setup(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel, bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck, bool useEmbedded, const Teuchos::RCP< StepperRKAppAction< Scalar > > &stepperRKAppAction)
Setup for constructor.
Teuchos::RCP< StepperSDIRK_SSPDIRK32< Scalar > > createStepperSDIRK_SSPDIRK32(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< StepperDIRK_1StageTheta< Scalar > > createStepperDIRK_1StageTheta(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
void setICConsistency(std::string s)
Strong Stability Preserving Diagonally-Implicit RK Butcher Tableau.
Teuchos::RCP< StepperERK_4Stage3rdOrderRunge< Scalar > > createStepperERK_4Stage3rdOrderRunge(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< StepperDIRK_General< Scalar > > createStepperDIRK_General(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.