Rythmos - Transient Integration for Differential Equations  Version of the Day
Rythmos_RKButcherTableau.hpp
1 //@HEADER
2 // ***********************************************************************
3 //
4 // Rythmos Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // USA
24 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
25 //
26 // ***********************************************************************
27 //@HEADER
28 
29 
30 #ifndef RYTHMOS_RK_BUTCHER_TABLEAU_HPP
31 #define RYTHMOS_RK_BUTCHER_TABLEAU_HPP
32 
33 #include "Rythmos_Types.hpp"
34 #include "Rythmos_RKButcherTableauBase.hpp"
35 
36 #include "Teuchos_Assert.hpp"
37 #include "Teuchos_as.hpp"
38 #include "Teuchos_StandardParameterEntryValidators.hpp"
39 #include "Teuchos_Describable.hpp"
40 #include "Teuchos_VerboseObject.hpp"
41 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
42 #include "Teuchos_ParameterListAcceptor.hpp"
43 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
44 
45 #include "Thyra_ProductVectorBase.hpp"
46 
47 namespace Rythmos {
48 
49  using Teuchos::as;
50 
51  inline const std::string RKBT_ForwardEuler_name() { return "Forward Euler"; } // done
52  inline const std::string RKBT_BackwardEuler_name() { return "Backward Euler"; } // done
53  inline const std::string Explicit4Stage_name() { return "Explicit 4 Stage"; } // done
54  inline const std::string Explicit3_8Rule_name() { return "Explicit 3/8 Rule"; } // done
55 
56  inline const std::string ExplicitTrapezoidal_name() { return "Explicit Trapezoidal"; } // done
57  inline const std::string Explicit2Stage2ndOrderRunge_name() { return "Explicit 2 Stage 2nd order by Runge"; } // done
58  inline const std::string Explicit3Stage3rdOrderHeun_name() { return "Explicit 3 Stage 3rd order by Heun"; } // done
59  inline const std::string Explicit3Stage3rdOrder_name() { return "Explicit 3 Stage 3rd order"; } // done
60  inline const std::string Explicit3Stage3rdOrderTVD_name() { return "Explicit 3 Stage 3rd order TVD"; } // done
61  inline const std::string Explicit4Stage3rdOrderRunge_name() { return "Explicit 4 Stage 3rd order by Runge"; } // done
62 
63  inline const std::string Implicit1Stage2ndOrderGauss_name() { return "Implicit 1 Stage 2nd order Gauss"; } // done
64  inline const std::string Implicit2Stage4thOrderGauss_name() { return "Implicit 2 Stage 4th order Gauss"; } // done
65  inline const std::string Implicit3Stage6thOrderGauss_name() { return "Implicit 3 Stage 6th order Gauss"; } // done
66 
67  inline const std::string Implicit1Stage1stOrderRadauA_name() { return "Implicit 1 Stage 1st order Radau left"; } // done
68  inline const std::string Implicit2Stage3rdOrderRadauA_name() { return "Implicit 2 Stage 3rd order Radau left"; } // done
69  inline const std::string Implicit3Stage5thOrderRadauA_name() { return "Implicit 3 Stage 5th order Radau left"; } // done
70 
71  inline const std::string Implicit1Stage1stOrderRadauB_name() { return "Implicit 1 Stage 1st order Radau right"; } // done
72  inline const std::string Implicit2Stage3rdOrderRadauB_name() { return "Implicit 2 Stage 3rd order Radau right"; } // done
73  inline const std::string Implicit3Stage5thOrderRadauB_name() { return "Implicit 3 Stage 5th order Radau right"; } // done
74 
75  inline const std::string Implicit2Stage2ndOrderLobattoA_name() { return "Implicit 2 Stage 2nd order Lobatto A"; } // done
76  inline const std::string Implicit3Stage4thOrderLobattoA_name() { return "Implicit 3 Stage 4th order Lobatto A"; } // done
77  inline const std::string Implicit4Stage6thOrderLobattoA_name() { return "Implicit 4 Stage 6th order Lobatto A"; } // done
78 
79  inline const std::string Implicit2Stage2ndOrderLobattoB_name() { return "Implicit 2 Stage 2nd order Lobatto B"; } // done
80  inline const std::string Implicit3Stage4thOrderLobattoB_name() { return "Implicit 3 Stage 4th order Lobatto B"; } // done
81  inline const std::string Implicit4Stage6thOrderLobattoB_name() { return "Implicit 4 Stage 6th order Lobatto B"; } // done
82 
83  inline const std::string Implicit2Stage2ndOrderLobattoC_name() { return "Implicit 2 Stage 2nd order Lobatto C"; } // done
84  inline const std::string Implicit3Stage4thOrderLobattoC_name() { return "Implicit 3 Stage 4th order Lobatto C"; } // done
85  inline const std::string Implicit4Stage6thOrderLobattoC_name() { return "Implicit 4 Stage 6th order Lobatto C"; } // done
86 
87  inline const std::string Implicit2Stage4thOrderHammerHollingsworth_name() { return "Implicit 2 Stage 4th Order Hammer & Hollingsworth"; } // done
88  inline const std::string Implicit3Stage6thOrderKuntzmannButcher_name() { return "Implicit 3 Stage 6th Order Kuntzmann & Butcher"; } // done
89  inline const std::string Implicit4Stage8thOrderKuntzmannButcher_name() { return "Implicit 4 Stage 8th Order Kuntzmann & Butcher"; } // done
90 
91  inline const std::string DIRK2Stage3rdOrder_name() { return "Diagonal IRK 2 Stage 3rd order"; } // done
92 
93  inline const std::string SDIRK2Stage2ndOrder_name() { return "Singly Diagonal IRK 2 Stage 2nd order"; } // done
94  inline const std::string SDIRK2Stage3rdOrder_name() { return "Singly Diagonal IRK 2 Stage 3rd order"; } // done
95  inline const std::string SDIRK5Stage5thOrder_name() { return "Singly Diagonal IRK 5 Stage 5th order"; } // done
96  inline const std::string SDIRK5Stage4thOrder_name() { return "Singly Diagonal IRK 5 Stage 4th order"; } // done
97  inline const std::string SDIRK3Stage4thOrder_name() { return "Singly Diagonal IRK 3 Stage 4th order"; } // done
98 
99 template<class Scalar>
100 class RKButcherTableauDefaultBase :
101  virtual public RKButcherTableauBase<Scalar>,
102  virtual public Teuchos::ParameterListAcceptorDefaultBase
103 {
104  public:
106  virtual int numStages() const { return A_.numRows(); }
108  virtual const Teuchos::SerialDenseMatrix<int,Scalar>& A() const { return A_; }
110  virtual const Teuchos::SerialDenseVector<int,Scalar>& b() const { return b_; }
112  virtual const Teuchos::SerialDenseVector<int,Scalar>& c() const { return c_; }
114  virtual int order() const { return order_; }
116  virtual void setDescription(std::string longDescription) { longDescription_ = longDescription; }
117 
119  virtual void initialize(
120  const Teuchos::SerialDenseMatrix<int,Scalar>& A_in,
121  const Teuchos::SerialDenseVector<int,Scalar>& b_in,
122  const Teuchos::SerialDenseVector<int,Scalar>& c_in,
123  const int order_in,
124  const std::string& longDescription_in
125  )
126  {
127  const int numStages_in = A_in.numRows();
128  TEUCHOS_ASSERT_EQUALITY( A_in.numRows(), numStages_in );
129  TEUCHOS_ASSERT_EQUALITY( A_in.numCols(), numStages_in );
130  TEUCHOS_ASSERT_EQUALITY( b_in.length(), numStages_in );
131  TEUCHOS_ASSERT_EQUALITY( c_in.length(), numStages_in );
132  TEUCHOS_ASSERT( order_in > 0 );
133  A_ = A_in;
134  b_ = b_in;
135  c_ = c_in;
136  order_ = order_in;
137  longDescription_ = longDescription_in;
138  }
139 
140  /* \brief Redefined from Teuchos::ParameterListAcceptorDefaultBase */
142 
144  virtual void setParameterList(RCP<Teuchos::ParameterList> const& paramList)
145  {
146  TEUCHOS_TEST_FOR_EXCEPT( is_null(paramList) );
147  paramList->validateParameters(*this->getValidParameters());
148  Teuchos::readVerboseObjectSublist(&*paramList,this);
149  setMyParamList(paramList);
150  }
151 
153  virtual RCP<const Teuchos::ParameterList> getValidParameters() const
154  {
155  if (is_null(validPL_)) {
156  validPL_ = Teuchos::parameterList();
157  validPL_->set("Description","",this->getMyDescription());
158  Teuchos::setupVerboseObjectSublist(&*validPL_);
159  }
160  return validPL_;
161  }
162 
164 
165  /* \brief Redefined from Teuchos::Describable */
167 
169  virtual std::string description() const { return "Rythmos::RKButcherTableauDefaultBase"; }
170 
172  virtual void describe(
173  Teuchos::FancyOStream &out,
174  const Teuchos::EVerbosityLevel verbLevel
175  ) const
176  {
177  if (verbLevel != Teuchos::VERB_NONE) {
178  out << this->description() << std::endl;
179  out << this->getMyDescription() << std::endl;
180  out << "number of Stages = " << this->numStages() << std::endl;
181  out << "A = " << this->A() << std::endl;
182  out << "b = " << this->b() << std::endl;
183  out << "c = " << this->c() << std::endl;
184  out << "order = " << this->order() << std::endl;
185  }
186  }
187 
189 
190  protected:
191  void setMyDescription(std::string longDescription) { longDescription_ = longDescription; }
192  const std::string& getMyDescription() const { return longDescription_; }
193 
194  void setMy_A(const Teuchos::SerialDenseMatrix<int,Scalar>& new_A) { A_ = new_A; }
195  void setMy_b(const Teuchos::SerialDenseVector<int,Scalar>& new_b) { b_ = new_b; }
196  void setMy_c(const Teuchos::SerialDenseVector<int,Scalar>& new_c) { c_ = new_c; }
197  void setMy_order(const int& new_order) { order_ = new_order; }
198 
199  void setMyValidParameterList( const RCP<ParameterList> validPL ) { validPL_ = validPL; }
200  RCP<ParameterList> getMyNonconstValidParameterList() { return validPL_; }
201 
202  private:
203  Teuchos::SerialDenseMatrix<int,Scalar> A_;
204  Teuchos::SerialDenseVector<int,Scalar> b_;
205  Teuchos::SerialDenseVector<int,Scalar> c_;
206  int order_;
207  std::string longDescription_;
208  mutable RCP<ParameterList> validPL_;
209 };
210 
211 
212 // Nonmember constructor
213 template<class Scalar>
214 RCP<RKButcherTableauBase<Scalar> > rKButcherTableau()
215 {
216  return(rcp(new RKButcherTableauDefaultBase<Scalar>()));
217 }
218 
219 // Nonmember constructor
220 template<class Scalar>
221 RCP<RKButcherTableauBase<Scalar> > rKButcherTableau(
222  const Teuchos::SerialDenseMatrix<int,Scalar>& A_in,
223  const Teuchos::SerialDenseVector<int,Scalar>& b_in,
224  const Teuchos::SerialDenseVector<int,Scalar>& c_in,
225  int order_in,
226  const std::string& description_in = ""
227  )
228 {
229  RCP<RKButcherTableauDefaultBase<Scalar> > rkbt = rcp(new RKButcherTableauDefaultBase<Scalar>());
230  rkbt->initialize(A_in,b_in,c_in,order_in,description_in);
231  return(rkbt);
232 }
233 
234 
235 template<class Scalar>
236 class BackwardEuler_RKBT :
237  virtual public RKButcherTableauDefaultBase<Scalar>
238 {
239  public:
240  BackwardEuler_RKBT()
241  {
242  std::ostringstream myDescription;
243  myDescription << RKBT_BackwardEuler_name() << "\n"
244  << "c = [ 1 ]'\n"
245  << "A = [ 1 ]\n"
246  << "b = [ 1 ]'" << std::endl;
247  typedef ScalarTraits<Scalar> ST;
248  Teuchos::SerialDenseMatrix<int,Scalar> myA(1,1);
249  myA(0,0) = ST::one();
250  Teuchos::SerialDenseVector<int,Scalar> myb(1);
251  myb(0) = ST::one();
252  Teuchos::SerialDenseVector<int,Scalar> myc(1);
253  myc(0) = ST::one();
254 
255  this->setMyDescription(myDescription.str());
256  this->setMy_A(myA);
257  this->setMy_b(myb);
258  this->setMy_c(myc);
259  this->setMy_order(1);
260  }
261 };
262 
263 
264 
265 template<class Scalar>
266 class ForwardEuler_RKBT :
267  virtual public RKButcherTableauDefaultBase<Scalar>
268 {
269  public:
270 
271  ForwardEuler_RKBT()
272  {
273  std::ostringstream myDescription;
274  myDescription << RKBT_ForwardEuler_name() << "\n"
275  << "c = [ 0 ]'\n"
276  << "A = [ 0 ]\n"
277  << "b = [ 1 ]'" << std::endl;
278  typedef ScalarTraits<Scalar> ST;
279  Teuchos::SerialDenseMatrix<int,Scalar> myA(1,1);
280  Teuchos::SerialDenseVector<int,Scalar> myb(1);
281  myb(0) = ST::one();
282  Teuchos::SerialDenseVector<int,Scalar> myc(1);
283 
284  this->setMyDescription(myDescription.str());
285  this->setMy_A(myA);
286  this->setMy_b(myb);
287  this->setMy_c(myc);
288  this->setMy_order(1);
289  }
290 };
291 
292 
293 template<class Scalar>
294 class Explicit4Stage4thOrder_RKBT :
295  virtual public RKButcherTableauDefaultBase<Scalar>
296 {
297  public:
298  Explicit4Stage4thOrder_RKBT()
299  {
300  std::ostringstream myDescription;
301  myDescription << Explicit4Stage_name() << "\n"
302  << "\"The\" Runge-Kutta Method (explicit):\n"
303  << "Solving Ordinary Differential Equations I:\n"
304  << "Nonstiff Problems, 2nd Revised Edition\n"
305  << "E. Hairer, S.P. Norsett, G. Wanner\n"
306  << "Table 1.2, pg 138\n"
307  << "c = [ 0 1/2 1/2 1 ]'\n"
308  << "A = [ 0 ] \n"
309  << " [ 1/2 0 ]\n"
310  << " [ 0 1/2 0 ]\n"
311  << " [ 0 0 1 0 ]\n"
312  << "b = [ 1/6 1/3 1/3 1/6 ]'" << std::endl;
313  typedef ScalarTraits<Scalar> ST;
314  Scalar one = ST::one();
315  Scalar zero = ST::zero();
316  Scalar onehalf = ST::one()/(2*ST::one());
317  Scalar onesixth = ST::one()/(6*ST::one());
318  Scalar onethird = ST::one()/(3*ST::one());
319 
320  int myNumStages = 4;
321  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
322  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
323  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
324 
325  // Fill A:
326  myA(0,0) = zero;
327  myA(0,1) = zero;
328  myA(0,2) = zero;
329  myA(0,3) = zero;
330 
331  myA(1,0) = onehalf;
332  myA(1,1) = zero;
333  myA(1,2) = zero;
334  myA(1,3) = zero;
335 
336  myA(2,0) = zero;
337  myA(2,1) = onehalf;
338  myA(2,2) = zero;
339  myA(2,3) = zero;
340 
341  myA(3,0) = zero;
342  myA(3,1) = zero;
343  myA(3,2) = one;
344  myA(3,3) = zero;
345 
346  // Fill myb:
347  myb(0) = onesixth;
348  myb(1) = onethird;
349  myb(2) = onethird;
350  myb(3) = onesixth;
351 
352  // fill b_c_
353  myc(0) = zero;
354  myc(1) = onehalf;
355  myc(2) = onehalf;
356  myc(3) = one;
357 
358  this->setMyDescription(myDescription.str());
359  this->setMy_A(myA);
360  this->setMy_b(myb);
361  this->setMy_c(myc);
362  this->setMy_order(4);
363  }
364 };
365 
366 
367 template<class Scalar>
368 class Explicit3_8Rule_RKBT :
369  virtual public RKButcherTableauDefaultBase<Scalar>
370 {
371  public:
372  Explicit3_8Rule_RKBT()
373  {
374 
375  std::ostringstream myDescription;
376  myDescription << Explicit3_8Rule_name() << "\n"
377  << "Solving Ordinary Differential Equations I:\n"
378  << "Nonstiff Problems, 2nd Revided Edition\n"
379  << "E. Hairer, S.P. Norsett, G. Wanner\n"
380  << "Table 1.2, pg 138\n"
381  << "c = [ 0 1/3 2/3 1 ]'\n"
382  << "A = [ 0 ]\n"
383  << " [ 1/3 0 ]\n"
384  << " [-1/3 1 0 ]\n"
385  << " [ 1 -1 1 0 ]\n"
386  << "b = [ 1/8 3/8 3/8 1/8 ]'" << std::endl;
387  typedef ScalarTraits<Scalar> ST;
388  int myNumStages = 4;
389  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
390  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
391  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
392 
393  Scalar one = ST::one();
394  Scalar zero = ST::zero();
395  Scalar one_third = as<Scalar>(ST::one()/(3*ST::one()));
396  Scalar two_third = as<Scalar>(2*ST::one()/(3*ST::one()));
397  Scalar one_eighth = as<Scalar>(ST::one()/(8*ST::one()));
398  Scalar three_eighth = as<Scalar>(3*ST::one()/(8*ST::one()));
399 
400  // Fill myA:
401  myA(0,0) = zero;
402  myA(0,1) = zero;
403  myA(0,2) = zero;
404  myA(0,3) = zero;
405 
406  myA(1,0) = one_third;
407  myA(1,1) = zero;
408  myA(1,2) = zero;
409  myA(1,3) = zero;
410 
411  myA(2,0) = as<Scalar>(-one_third);
412  myA(2,1) = one;
413  myA(2,2) = zero;
414  myA(2,3) = zero;
415 
416  myA(3,0) = one;
417  myA(3,1) = as<Scalar>(-one);
418  myA(3,2) = one;
419  myA(3,3) = zero;
420 
421  // Fill myb:
422  myb(0) = one_eighth;
423  myb(1) = three_eighth;
424  myb(2) = three_eighth;
425  myb(3) = one_eighth;
426 
427  // Fill myc:
428  myc(0) = zero;
429  myc(1) = one_third;
430  myc(2) = two_third;
431  myc(3) = one;
432 
433  this->setMyDescription(myDescription.str());
434  this->setMy_A(myA);
435  this->setMy_b(myb);
436  this->setMy_c(myc);
437  this->setMy_order(4);
438  }
439 };
440 
441 
442 template<class Scalar>
443 class Explicit4Stage3rdOrderRunge_RKBT :
444  virtual public RKButcherTableauDefaultBase<Scalar>
445 {
446  public:
447  Explicit4Stage3rdOrderRunge_RKBT()
448  {
449 
450  std::ostringstream myDescription;
451  myDescription << Explicit4Stage3rdOrderRunge_name() << "\n"
452  << "Solving Ordinary Differential Equations I:\n"
453  << "Nonstiff Problems, 2nd Revided Edition\n"
454  << "E. Hairer, S.P. Norsett, G. Wanner\n"
455  << "Table 1.1, pg 135\n"
456  << "c = [ 0 1/2 1 1 ]'\n"
457  << "A = [ 0 ]\n"
458  << " [ 1/2 0 ]\n"
459  << " [ 0 1 0 ]\n"
460  << " [ 0 0 1 0 ]\n"
461  << "b = [ 1/6 2/3 0 1/6 ]'" << std::endl;
462  typedef ScalarTraits<Scalar> ST;
463  int myNumStages = 4;
464  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
465  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
466  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
467 
468  Scalar one = ST::one();
469  Scalar onehalf = ST::one()/(2*ST::one());
470  Scalar onesixth = ST::one()/(6*ST::one());
471  Scalar twothirds = 2*ST::one()/(3*ST::one());
472  Scalar zero = ST::zero();
473 
474  // Fill A:
475  myA(0,0) = zero;
476  myA(0,1) = zero;
477  myA(0,2) = zero;
478  myA(0,3) = zero;
479 
480  myA(1,0) = onehalf;
481  myA(1,1) = zero;
482  myA(1,2) = zero;
483  myA(1,3) = zero;
484 
485  myA(2,0) = zero;
486  myA(2,1) = one;
487  myA(2,2) = zero;
488  myA(2,3) = zero;
489 
490  myA(3,0) = zero;
491  myA(3,1) = zero;
492  myA(3,2) = one;
493  myA(3,3) = zero;
494 
495  // Fill b:
496  myb(0) = onesixth;
497  myb(1) = twothirds;
498  myb(2) = zero;
499  myb(3) = onesixth;
500 
501  // Fill myc:
502  myc(0) = zero;
503  myc(1) = onehalf;
504  myc(2) = one;
505  myc(3) = one;
506 
507  this->setMyDescription(myDescription.str());
508  this->setMy_A(myA);
509  this->setMy_b(myb);
510  this->setMy_c(myc);
511  this->setMy_order(3);
512  }
513 };
514 
515 
516 template<class Scalar>
517 class Explicit3Stage3rdOrder_RKBT :
518  virtual public RKButcherTableauDefaultBase<Scalar>
519 {
520  public:
521  Explicit3Stage3rdOrder_RKBT()
522  {
523 
524  std::ostringstream myDescription;
525  myDescription << Explicit3Stage3rdOrder_name() << "\n"
526  << "c = [ 0 1/2 1 ]'\n"
527  << "A = [ 0 ]\n"
528  << " [ 1/2 0 ]\n"
529  << " [ -1 2 0 ]\n"
530  << "b = [ 1/6 4/6 1/6 ]'" << std::endl;
531  typedef ScalarTraits<Scalar> ST;
532  Scalar one = ST::one();
533  Scalar two = as<Scalar>(2*ST::one());
534  Scalar zero = ST::zero();
535  Scalar onehalf = ST::one()/(2*ST::one());
536  Scalar onesixth = ST::one()/(6*ST::one());
537  Scalar foursixth = 4*ST::one()/(6*ST::one());
538 
539  int myNumStages = 3;
540  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
541  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
542  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
543 
544  // Fill myA:
545  myA(0,0) = zero;
546  myA(0,1) = zero;
547  myA(0,2) = zero;
548 
549  myA(1,0) = onehalf;
550  myA(1,1) = zero;
551  myA(1,2) = zero;
552 
553  myA(2,0) = -one;
554  myA(2,1) = two;
555  myA(2,2) = zero;
556 
557  // Fill myb:
558  myb(0) = onesixth;
559  myb(1) = foursixth;
560  myb(2) = onesixth;
561 
562  // fill b_c_
563  myc(0) = zero;
564  myc(1) = onehalf;
565  myc(2) = one;
566 
567  this->setMyDescription(myDescription.str());
568  this->setMy_A(myA);
569  this->setMy_b(myb);
570  this->setMy_c(myc);
571  this->setMy_order(3);
572  }
573 };
574 
575 
576 template<class Scalar>
577 class Explicit3Stage3rdOrderTVD_RKBT :
578  virtual public RKButcherTableauDefaultBase<Scalar>
579 {
580  public:
581  Explicit3Stage3rdOrderTVD_RKBT()
582  {
583 
584  std::ostringstream myDescription;
585  myDescription << Explicit3Stage3rdOrderTVD_name() << "\n"
586  << "Sigal Gottlieb and Chi-Wang Shu\n"
587  << "'Total Variation Diminishing Runge-Kutta Schemes'\n"
588  << "Mathematics of Computation\n"
589  << "Volume 67, Number 221, January 1998, pp. 73-85\n"
590  << "c = [ 0 1 1/2 ]'\n"
591  << "A = [ 0 ]\n"
592  << " [ 1 0 ]\n"
593  << " [ 1/4 1/4 0 ]\n"
594  << "b = [ 1/6 1/6 4/6 ]'" << std::endl;
595  typedef ScalarTraits<Scalar> ST;
596  Scalar one = ST::one();
597  Scalar zero = ST::zero();
598  Scalar onehalf = ST::one()/(2*ST::one());
599  Scalar onefourth = ST::one()/(4*ST::one());
600  Scalar onesixth = ST::one()/(6*ST::one());
601  Scalar foursixth = 4*ST::one()/(6*ST::one());
602 
603  int myNumStages = 3;
604  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
605  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
606  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
607 
608  // Fill myA:
609  myA(0,0) = zero;
610  myA(0,1) = zero;
611  myA(0,2) = zero;
612 
613  myA(1,0) = one;
614  myA(1,1) = zero;
615  myA(1,2) = zero;
616 
617  myA(2,0) = onefourth;
618  myA(2,1) = onefourth;
619  myA(2,2) = zero;
620 
621  // Fill myb:
622  myb(0) = onesixth;
623  myb(1) = onesixth;
624  myb(2) = foursixth;
625 
626  // fill b_c_
627  myc(0) = zero;
628  myc(1) = one;
629  myc(2) = onehalf;
630 
631  this->setMyDescription(myDescription.str());
632  this->setMy_A(myA);
633  this->setMy_b(myb);
634  this->setMy_c(myc);
635  this->setMy_order(3);
636  }
637 };
638 
639 
640 template<class Scalar>
641 class Explicit3Stage3rdOrderHeun_RKBT :
642  virtual public RKButcherTableauDefaultBase<Scalar>
643 {
644  public:
645  Explicit3Stage3rdOrderHeun_RKBT()
646  {
647  std::ostringstream myDescription;
648  myDescription << Explicit3Stage3rdOrderHeun_name() << "\n"
649  << "Solving Ordinary Differential Equations I:\n"
650  << "Nonstiff Problems, 2nd Revided Edition\n"
651  << "E. Hairer, S.P. Norsett, G. Wanner\n"
652  << "Table 1.1, pg 135\n"
653  << "c = [ 0 1/3 2/3 ]'\n"
654  << "A = [ 0 ] \n"
655  << " [ 1/3 0 ]\n"
656  << " [ 0 2/3 0 ]\n"
657  << "b = [ 1/4 0 3/4 ]'" << std::endl;
658  typedef ScalarTraits<Scalar> ST;
659  Scalar one = ST::one();
660  Scalar zero = ST::zero();
661  Scalar onethird = one/(3*one);
662  Scalar twothirds = 2*one/(3*one);
663  Scalar onefourth = one/(4*one);
664  Scalar threefourths = 3*one/(4*one);
665 
666  int myNumStages = 3;
667  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
668  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
669  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
670 
671  // Fill myA:
672  myA(0,0) = zero;
673  myA(0,1) = zero;
674  myA(0,2) = zero;
675 
676  myA(1,0) = onethird;
677  myA(1,1) = zero;
678  myA(1,2) = zero;
679 
680  myA(2,0) = zero;
681  myA(2,1) = twothirds;
682  myA(2,2) = zero;
683 
684  // Fill myb:
685  myb(0) = onefourth;
686  myb(1) = zero;
687  myb(2) = threefourths;
688 
689  // fill b_c_
690  myc(0) = zero;
691  myc(1) = onethird;
692  myc(2) = twothirds;
693 
694  this->setMyDescription(myDescription.str());
695  this->setMy_A(myA);
696  this->setMy_b(myb);
697  this->setMy_c(myc);
698  this->setMy_order(3);
699  }
700 };
701 
702 
703 template<class Scalar>
704 class Explicit2Stage2ndOrderRunge_RKBT :
705  virtual public RKButcherTableauDefaultBase<Scalar>
706 {
707  public:
708  Explicit2Stage2ndOrderRunge_RKBT()
709  {
710  std::ostringstream myDescription;
711  myDescription << Explicit2Stage2ndOrderRunge_name() << "\n"
712  << "Also known as Explicit Midpoint\n"
713  << "Solving Ordinary Differential Equations I:\n"
714  << "Nonstiff Problems, 2nd Revided Edition\n"
715  << "E. Hairer, S.P. Norsett, G. Wanner\n"
716  << "Table 1.1, pg 135\n"
717  << "c = [ 0 1/2 ]'\n"
718  << "A = [ 0 ]\n"
719  << " [ 1/2 0 ]\n"
720  << "b = [ 0 1 ]'" << std::endl;
721  typedef ScalarTraits<Scalar> ST;
722  Scalar one = ST::one();
723  Scalar zero = ST::zero();
724  Scalar onehalf = ST::one()/(2*ST::one());
725 
726  int myNumStages = 2;
727  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
728  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
729  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
730 
731  // Fill myA:
732  myA(0,0) = zero;
733  myA(0,1) = zero;
734 
735  myA(1,0) = onehalf;
736  myA(1,1) = zero;
737 
738  // Fill myb:
739  myb(0) = zero;
740  myb(1) = one;
741 
742  // fill b_c_
743  myc(0) = zero;
744  myc(1) = onehalf;
745 
746  this->setMyDescription(myDescription.str());
747  this->setMy_A(myA);
748  this->setMy_b(myb);
749  this->setMy_c(myc);
750  this->setMy_order(2);
751  }
752 };
753 
754 
755 template<class Scalar>
756 class ExplicitTrapezoidal_RKBT :
757  virtual public RKButcherTableauDefaultBase<Scalar>
758 {
759  public:
760  ExplicitTrapezoidal_RKBT()
761  {
762  std::ostringstream myDescription;
763  myDescription << ExplicitTrapezoidal_name() << "\n"
764  << "c = [ 0 1 ]'\n"
765  << "A = [ 0 ]\n"
766  << " [ 1 0 ]\n"
767  << "b = [ 1/2 1/2 ]'" << std::endl;
768  typedef ScalarTraits<Scalar> ST;
769  Scalar one = ST::one();
770  Scalar zero = ST::zero();
771  Scalar onehalf = ST::one()/(2*ST::one());
772 
773  int myNumStages = 2;
774  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
775  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
776  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
777 
778  // Fill myA:
779  myA(0,0) = zero;
780  myA(0,1) = zero;
781 
782  myA(1,0) = one;
783  myA(1,1) = zero;
784 
785  // Fill myb:
786  myb(0) = onehalf;
787  myb(1) = onehalf;
788 
789  // fill b_c_
790  myc(0) = zero;
791  myc(1) = one;
792 
793  this->setMyDescription(myDescription.str());
794  this->setMy_A(myA);
795  this->setMy_b(myb);
796  this->setMy_c(myc);
797  this->setMy_order(2);
798  }
799 };
800 
801 
802 template<class Scalar>
803 class SDIRK2Stage2ndOrder_RKBT :
804  virtual public RKButcherTableauDefaultBase<Scalar>
805 {
806  public:
807  SDIRK2Stage2ndOrder_RKBT()
808  {
809  std::ostringstream myDescription;
810  myDescription << SDIRK2Stage2ndOrder_name() << "\n"
811  << "Computer Methods for ODEs and DAEs\n"
812  << "U. M. Ascher and L. R. Petzold\n"
813  << "p. 106\n"
814  << "gamma = (2+-sqrt(2))/2\n"
815  << "c = [ gamma 1 ]'\n"
816  << "A = [ gamma 0 ]\n"
817  << " [ 1-gamma gamma ]\n"
818  << "b = [ 1-gamma gamma ]'" << std::endl;
819 
820  this->setMyDescription(myDescription.str());
821  typedef ScalarTraits<Scalar> ST;
822  Scalar one = ST::one();
823  gamma_default_ = as<Scalar>( (2*one - ST::squareroot(2*one))/(2*one) );
824  gamma_ = gamma_default_;
825  this->setupData();
826 
827  RCP<ParameterList> validPL = Teuchos::parameterList();
828  validPL->set("Description","",this->getMyDescription());
829  validPL->set<double>("gamma",gamma_default_,
830  "The default value is gamma = (2-sqrt(2))/2 = 0.29289321881345243. "
831  "This will produce an L-stable 2nd order method with the stage "
832  "times within the timestep. Other values of gamma will still "
833  "produce an L-stable scheme, but will only be 1st order accurate.");
834  Teuchos::setupVerboseObjectSublist(&*validPL);
835  this->setMyValidParameterList(validPL);
836  }
837  void setupData()
838  {
839  typedef ScalarTraits<Scalar> ST;
840  int myNumStages = 2;
841  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
842  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
843  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
844  Scalar one = ST::one();
845  Scalar zero = ST::zero();
846  myA(0,0) = gamma_;
847  myA(0,1) = zero;
848  myA(1,0) = as<Scalar>( one - gamma_ );
849  myA(1,1) = gamma_;
850  myb(0) = as<Scalar>( one - gamma_ );
851  myb(1) = gamma_;
852  myc(0) = gamma_;
853  myc(1) = one;
854 
855  this->setMy_A(myA);
856  this->setMy_b(myb);
857  this->setMy_c(myc);
858  this->setMy_order(2);
859  }
860  void setParameterList(RCP<Teuchos::ParameterList> const& paramList)
861  {
862  TEUCHOS_TEST_FOR_EXCEPT( is_null(paramList) );
863  paramList->validateParameters(*this->getValidParameters());
864  Teuchos::readVerboseObjectSublist(&*paramList,this);
865  gamma_ = paramList->get<double>("gamma",gamma_default_);
866  this->setupData();
867  this->setMyParamList(paramList);
868  }
869  private:
870  Scalar gamma_default_;
871  Scalar gamma_;
872 };
873 
874 
875 // 04/07/09 tscoffe: I verified manually that the Convergence Testing passes
876 // with gamma_default_ = -1.
877 template<class Scalar>
878 class SDIRK2Stage3rdOrder_RKBT :
879  virtual public RKButcherTableauDefaultBase<Scalar>
880 {
881  public:
882  SDIRK2Stage3rdOrder_RKBT()
883  {
884  std::ostringstream myDescription;
885  myDescription << SDIRK2Stage3rdOrder_name() << "\n"
886  << "Solving Ordinary Differential Equations I:\n"
887  << "Nonstiff Problems, 2nd Revided Edition\n"
888  << "E. Hairer, S. P. Norsett, and G. Wanner\n"
889  << "Table 7.2, pg 207\n"
890  << "gamma = (3+-sqrt(3))/6 -> 3rd order and A-stable\n"
891  << "gamma = (2+-sqrt(2))/2 -> 2nd order and L-stable\n"
892  << "c = [ gamma 1-gamma ]'\n"
893  << "A = [ gamma 0 ]\n"
894  << " [ 1-2*gamma gamma ]\n"
895  << "b = [ 1/2 1/2 ]'" << std::endl;
896 
897  this->setMyDescription(myDescription.str());
898  thirdOrderAStable_default_ = true;
899  secondOrderLStable_default_ = false;
900  thirdOrderAStable_ = true;
901  secondOrderLStable_ = false;
902  typedef ScalarTraits<Scalar> ST;
903  Scalar one = ST::one();
904  gamma_default_ = as<Scalar>( (3*one + ST::squareroot(3*one))/(6*one) );
905  gamma_ = gamma_default_;
906  this->setupData();
907 
908  RCP<ParameterList> validPL = Teuchos::parameterList();
909  validPL->set("Description","",this->getMyDescription());
910  validPL->set("3rd Order A-stable",thirdOrderAStable_default_,
911  "If true, set gamma to gamma = (3+sqrt(3))/6 to obtain "
912  "a 3rd order A-stable scheme. '3rd Order A-stable' and "
913  "'2nd Order L-stable' can not both be true.");
914  validPL->set("2nd Order L-stable",secondOrderLStable_default_,
915  "If true, set gamma to gamma = (2+sqrt(2))/2 to obtain "
916  "a 2nd order L-stable scheme. '3rd Order A-stable' and "
917  "'2nd Order L-stable' can not both be true.");
918  validPL->set("gamma",gamma_default_,
919  "If both '3rd Order A-stable' and '2nd Order L-stable' "
920  "are false, gamma will be used. The default value is the "
921  "'3rd Order A-stable' gamma value, (3+sqrt(3))/6.");
922 
923  Teuchos::setupVerboseObjectSublist(&*validPL);
924  this->setMyValidParameterList(validPL);
925  }
926  void setupData()
927  {
928  typedef ScalarTraits<Scalar> ST;
929  int myNumStages = 2;
930  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
931  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
932  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
933  Scalar one = ST::one();
934  Scalar zero = ST::zero();
935  Scalar gamma;
936  if (thirdOrderAStable_)
937  gamma = as<Scalar>( (3*one + ST::squareroot(3*one))/(6*one) );
938  else if (secondOrderLStable_)
939  gamma = as<Scalar>( (2*one + ST::squareroot(2*one))/(2*one) );
940  else
941  gamma = gamma_;
942  myA(0,0) = gamma;
943  myA(0,1) = zero;
944  myA(1,0) = as<Scalar>( one - 2*gamma );
945  myA(1,1) = gamma;
946  myb(0) = as<Scalar>( one/(2*one) );
947  myb(1) = as<Scalar>( one/(2*one) );
948  myc(0) = gamma;
949  myc(1) = as<Scalar>( one - gamma );
950 
951  this->setMy_A(myA);
952  this->setMy_b(myb);
953  this->setMy_c(myc);
954  this->setMy_order(3);
955  }
956  void setParameterList(RCP<Teuchos::ParameterList> const& paramList)
957  {
958  TEUCHOS_TEST_FOR_EXCEPT( is_null(paramList) );
959  paramList->validateParameters(*this->getValidParameters());
960  Teuchos::readVerboseObjectSublist(&*paramList,this);
961  thirdOrderAStable_ = paramList->get("3rd Order A-stable",
962  thirdOrderAStable_default_);
963  secondOrderLStable_ = paramList->get("2nd Order L-stable",
964  secondOrderLStable_default_);
965  TEUCHOS_TEST_FOR_EXCEPTION(
966  thirdOrderAStable_ && secondOrderLStable_, std::logic_error,
967  "'3rd Order A-stable' and '2nd Order L-stable' can not both be true.");
968  gamma_ = paramList->get("gamma",gamma_default_);
969 
970  this->setupData();
971  this->setMyParamList(paramList);
972  }
973  private:
974  bool thirdOrderAStable_default_;
975  bool thirdOrderAStable_;
976  bool secondOrderLStable_default_;
977  bool secondOrderLStable_;
978  Scalar gamma_default_;
979  Scalar gamma_;
980 };
981 
982 
983 template<class Scalar>
984 class DIRK2Stage3rdOrder_RKBT :
985  virtual public RKButcherTableauDefaultBase<Scalar>
986 {
987  public:
988  DIRK2Stage3rdOrder_RKBT()
989  {
990 
991  std::ostringstream myDescription;
992  myDescription << DIRK2Stage3rdOrder_name() << "\n"
993  << "Hammer & Hollingsworth method\n"
994  << "Solving Ordinary Differential Equations I:\n"
995  << "Nonstiff Problems, 2nd Revided Edition\n"
996  << "E. Hairer, S. P. Norsett, and G. Wanner\n"
997  << "Table 7.1, pg 205\n"
998  << "c = [ 0 2/3 ]'\n"
999  << "A = [ 0 0 ]\n"
1000  << " [ 1/3 1/3 ]\n"
1001  << "b = [ 1/4 3/4 ]'" << std::endl;
1002  typedef ScalarTraits<Scalar> ST;
1003  int myNumStages = 2;
1004  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1005  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1006  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1007  Scalar one = ST::one();
1008  Scalar zero = ST::zero();
1009  myA(0,0) = zero;
1010  myA(0,1) = zero;
1011  myA(1,0) = as<Scalar>( one/(3*one) );
1012  myA(1,1) = as<Scalar>( one/(3*one) );
1013  myb(0) = as<Scalar>( one/(4*one) );
1014  myb(1) = as<Scalar>( 3*one/(4*one) );
1015  myc(0) = zero;
1016  myc(1) = as<Scalar>( 2*one/(3*one) );
1017  this->setMyDescription(myDescription.str());
1018  this->setMy_A(myA);
1019  this->setMy_b(myb);
1020  this->setMy_c(myc);
1021  this->setMy_order(3);
1022  }
1023 };
1024 
1025 
1026 template<class Scalar>
1027 class Implicit3Stage6thOrderKuntzmannButcher_RKBT :
1028  virtual public RKButcherTableauDefaultBase<Scalar>
1029 {
1030  public:
1031  Implicit3Stage6thOrderKuntzmannButcher_RKBT()
1032  {
1033 
1034  std::ostringstream myDescription;
1035  myDescription << Implicit3Stage6thOrderKuntzmannButcher_name() << "\n"
1036  << "Kuntzmann & Butcher method\n"
1037  << "Solving Ordinary Differential Equations I:\n"
1038  << "Nonstiff Problems, 2nd Revided Edition\n"
1039  << "E. Hairer, S. P. Norsett, and G. Wanner\n"
1040  << "Table 7.4, pg 209\n"
1041  << "c = [ 1/2-sqrt(15)/10 1/2 1/2-sqrt(15)/10 ]'\n"
1042  << "A = [ 5/36 2/9-sqrt(15)/15 5/36-sqrt(15)/30 ]\n"
1043  << " [ 5/36+sqrt(15)/24 2/9 5/36-sqrt(15)/24 ]\n"
1044  << " [ 5/36+sqrt(15)/30 2/9+sqrt(15)/15 5/36 ]\n"
1045  << "b = [ 5/18 4/9 5/18 ]'" << std::endl;
1046  typedef ScalarTraits<Scalar> ST;
1047  int myNumStages = 3;
1048  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1049  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1050  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1051  Scalar one = ST::one();
1052  myA(0,0) = as<Scalar>( 5*one/(36*one) );
1053  myA(0,1) = as<Scalar>( 2*one/(9*one) - ST::squareroot(15*one)/(15*one) );
1054  myA(0,2) = as<Scalar>( 5*one/(36*one) - ST::squareroot(15*one)/(30*one) );
1055  myA(1,0) = as<Scalar>( 5*one/(36*one) + ST::squareroot(15*one)/(24*one) );
1056  myA(1,1) = as<Scalar>( 2*one/(9*one) );
1057  myA(1,2) = as<Scalar>( 5*one/(36*one) - ST::squareroot(15*one)/(24*one) );
1058  myA(2,0) = as<Scalar>( 5*one/(36*one) + ST::squareroot(15*one)/(30*one) );
1059  myA(2,1) = as<Scalar>( 2*one/(9*one) + ST::squareroot(15*one)/(15*one) );
1060  myA(2,2) = as<Scalar>( 5*one/(36*one) );
1061  myb(0) = as<Scalar>( 5*one/(18*one) );
1062  myb(1) = as<Scalar>( 4*one/(9*one) );
1063  myb(2) = as<Scalar>( 5*one/(18*one) );
1064  myc(0) = as<Scalar>( one/(2*one)-ST::squareroot(15*one)/(10*one) );
1065  myc(1) = as<Scalar>( one/(2*one) );
1066  myc(2) = as<Scalar>( one/(2*one)+ST::squareroot(15*one)/(10*one) );
1067  this->setMyDescription(myDescription.str());
1068  this->setMy_A(myA);
1069  this->setMy_b(myb);
1070  this->setMy_c(myc);
1071  this->setMy_order(6);
1072  }
1073 };
1074 
1075 
1076 template<class Scalar>
1077 class Implicit4Stage8thOrderKuntzmannButcher_RKBT :
1078  virtual public RKButcherTableauDefaultBase<Scalar>
1079 {
1080  public:
1081  Implicit4Stage8thOrderKuntzmannButcher_RKBT()
1082  {
1083 
1084  std::ostringstream myDescription;
1085  myDescription << Implicit4Stage8thOrderKuntzmannButcher_name() << "\n"
1086  << "Kuntzmann & Butcher method\n"
1087  << "Solving Ordinary Differential Equations I:\n"
1088  << "Nonstiff Problems, 2nd Revided Edition\n"
1089  << "E. Hairer, S. P. Norsett, and G. Wanner\n"
1090  << "Table 7.5, pg 209\n"
1091  << "c = [ 1/2-w2 1/2-w2p 1/2+w2p 1/2+w2 ]'\n"
1092  << "A = [ w1 w1p-w3+w4p w1p-w3-w4p w1-w5 ]\n"
1093  << " [ w1-w3p+w4 w1p w1p-w5p w1-w3p-w4 ]\n"
1094  << " [ w1+w3p+w4 w1p+w5p w1p w1+w3p-w4 ]\n"
1095  << " [ w1+w5 w1p+w3+w4p w1p+w3-w4p w1 ]\n"
1096  << "b = [ 2*w1 2*w1p 2*w1p 2*w1 ]'\n"
1097  << "w1 = 1/8-sqrt(30)/144\n"
1098  << "w2 = (1/2)*sqrt((15+2*sqrt(3))/35)\n"
1099  << "w3 = w2*(1/6+sqrt(30)/24)\n"
1100  << "w4 = w2*(1/21+5*sqrt(30)/168)\n"
1101  << "w5 = w2-2*w3\n"
1102  << "w1p = 1/8+sqrt(30)/144\n"
1103  << "w2p = (1/2)*sqrt((15-2*sqrt(3))/35)\n"
1104  << "w3p = w2*(1/6-sqrt(30)/24)\n"
1105  << "w4p = w2*(1/21-5*sqrt(30)/168)\n"
1106  << "w5p = w2p-2*w3p" << std::endl;
1107  typedef ScalarTraits<Scalar> ST;
1108  int myNumStages = 4;
1109  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1110  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1111  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1112  Scalar one = ST::one();
1113  Scalar onehalf = as<Scalar>( one/(2*one) );
1114  Scalar w1 = as<Scalar>( one/(8*one) - ST::squareroot(30*one)/(144*one) );
1115  Scalar w2 = as<Scalar>( (one/(2*one))*ST::squareroot((15*one+2*one*ST::squareroot(30*one))/(35*one)) );
1116  Scalar w3 = as<Scalar>( w2*(one/(6*one)+ST::squareroot(30*one)/(24*one)) );
1117  Scalar w4 = as<Scalar>( w2*(one/(21*one)+5*one*ST::squareroot(30*one)/(168*one)) );
1118  Scalar w5 = as<Scalar>( w2-2*w3 );
1119  Scalar w1p = as<Scalar>( one/(8*one) + ST::squareroot(30*one)/(144*one) );
1120  Scalar w2p = as<Scalar>( (one/(2*one))*ST::squareroot((15*one-2*one*ST::squareroot(30*one))/(35*one)) );
1121  Scalar w3p = as<Scalar>( w2p*(one/(6*one)-ST::squareroot(30*one)/(24*one)) );
1122  Scalar w4p = as<Scalar>( w2p*(one/(21*one)-5*one*ST::squareroot(30*one)/(168*one)) );
1123  Scalar w5p = as<Scalar>( w2p-2*w3p );
1124  myA(0,0) = w1;
1125  myA(0,1) = w1p-w3+w4p;
1126  myA(0,2) = w1p-w3-w4p;
1127  myA(0,3) = w1-w5;
1128  myA(1,0) = w1-w3p+w4;
1129  myA(1,1) = w1p;
1130  myA(1,2) = w1p-w5p;
1131  myA(1,3) = w1-w3p-w4;
1132  myA(2,0) = w1+w3p+w4;
1133  myA(2,1) = w1p+w5p;
1134  myA(2,2) = w1p;
1135  myA(2,3) = w1+w3p-w4;
1136  myA(3,0) = w1+w5;
1137  myA(3,1) = w1p+w3+w4p;
1138  myA(3,2) = w1p+w3-w4p;
1139  myA(3,3) = w1;
1140  myb(0) = 2*w1;
1141  myb(1) = 2*w1p;
1142  myb(2) = 2*w1p;
1143  myb(3) = 2*w1;
1144  myc(0) = onehalf - w2;
1145  myc(1) = onehalf - w2p;
1146  myc(2) = onehalf + w2p;
1147  myc(3) = onehalf + w2;
1148  this->setMyDescription(myDescription.str());
1149  this->setMy_A(myA);
1150  this->setMy_b(myb);
1151  this->setMy_c(myc);
1152  this->setMy_order(8);
1153  }
1154 };
1155 
1156 
1157 template<class Scalar>
1158 class Implicit2Stage4thOrderHammerHollingsworth_RKBT :
1159  virtual public RKButcherTableauDefaultBase<Scalar>
1160 {
1161  public:
1162  Implicit2Stage4thOrderHammerHollingsworth_RKBT()
1163  {
1164 
1165  std::ostringstream myDescription;
1166  myDescription << Implicit2Stage4thOrderHammerHollingsworth_name() << "\n"
1167  << "Hammer & Hollingsworth method\n"
1168  << "Solving Ordinary Differential Equations I:\n"
1169  << "Nonstiff Problems, 2nd Revided Edition\n"
1170  << "E. Hairer, S. P. Norsett, and G. Wanner\n"
1171  << "Table 7.3, pg 207\n"
1172  << "c = [ 1/2-sqrt(3)/6 1/2+sqrt(3)/6 ]'\n"
1173  << "A = [ 1/4 1/4-sqrt(3)/6 ]\n"
1174  << " [ 1/4+sqrt(3)/6 1/4 ]\n"
1175  << "b = [ 1/2 1/2 ]'" << std::endl;
1176  typedef ScalarTraits<Scalar> ST;
1177  int myNumStages = 2;
1178  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1179  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1180  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1181  Scalar one = ST::one();
1182  Scalar onequarter = as<Scalar>( one/(4*one) );
1183  Scalar onehalf = as<Scalar>( one/(2*one) );
1184  myA(0,0) = onequarter;
1185  myA(0,1) = as<Scalar>( onequarter-ST::squareroot(3*one)/(6*one) );
1186  myA(1,0) = as<Scalar>( onequarter+ST::squareroot(3*one)/(6*one) );
1187  myA(1,1) = onequarter;
1188  myb(0) = onehalf;
1189  myb(1) = onehalf;
1190  myc(0) = as<Scalar>( onehalf - ST::squareroot(3*one)/(6*one) );
1191  myc(1) = as<Scalar>( onehalf + ST::squareroot(3*one)/(6*one) );
1192  this->setMyDescription(myDescription.str());
1193  this->setMy_A(myA);
1194  this->setMy_b(myb);
1195  this->setMy_c(myc);
1196  this->setMy_order(4);
1197  }
1198 };
1199 
1200 
1201 template<class Scalar>
1202 class Implicit1Stage2ndOrderGauss_RKBT :
1203  virtual public RKButcherTableauDefaultBase<Scalar>
1204 {
1205  public:
1206  Implicit1Stage2ndOrderGauss_RKBT()
1207  {
1208 
1209  std::ostringstream myDescription;
1210  myDescription << Implicit1Stage2ndOrderGauss_name() << "\n"
1211  << "A-stable\n"
1212  << "Solving Ordinary Differential Equations II:\n"
1213  << "Stiff and Differential-Algebraic Problems,\n"
1214  << "2nd Revised Edition\n"
1215  << "E. Hairer and G. Wanner\n"
1216  << "Table 5.2, pg 72\n"
1217  << "Also: Implicit midpoint rule\n"
1218  << "Solving Ordinary Differential Equations I:\n"
1219  << "Nonstiff Problems, 2nd Revided Edition\n"
1220  << "E. Hairer, S. P. Norsett, and G. Wanner\n"
1221  << "Table 7.1, pg 205\n"
1222  << "c = [ 1/2 ]'\n"
1223  << "A = [ 1/2 ]\n"
1224  << "b = [ 1 ]'" << std::endl;
1225  typedef ScalarTraits<Scalar> ST;
1226  int myNumStages = 1;
1227  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1228  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1229  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1230  Scalar onehalf = ST::one()/(2*ST::one());
1231  Scalar one = ST::one();
1232  myA(0,0) = onehalf;
1233  myb(0) = one;
1234  myc(0) = onehalf;
1235  this->setMyDescription(myDescription.str());
1236  this->setMy_A(myA);
1237  this->setMy_b(myb);
1238  this->setMy_c(myc);
1239  this->setMy_order(2);
1240  }
1241 };
1242 
1243 
1244 template<class Scalar>
1245 class Implicit2Stage4thOrderGauss_RKBT :
1246  virtual public RKButcherTableauDefaultBase<Scalar>
1247 {
1248  public:
1249  Implicit2Stage4thOrderGauss_RKBT()
1250  {
1251 
1252  std::ostringstream myDescription;
1253  myDescription << Implicit2Stage4thOrderGauss_name() << "\n"
1254  << "A-stable\n"
1255  << "Solving Ordinary Differential Equations II:\n"
1256  << "Stiff and Differential-Algebraic Problems,\n"
1257  << "2nd Revised Edition\n"
1258  << "E. Hairer and G. Wanner\n"
1259  << "Table 5.2, pg 72\n"
1260  << "c = [ 1/2-sqrt(3)/6 1/2+sqrt(3)/6 ]'\n"
1261  << "A = [ 1/4 1/4-sqrt(3)/6 ]\n"
1262  << " [ 1/4+sqrt(3)/6 1/4 ]\n"
1263  << "b = [ 1/2 1/2 ]'" << std::endl;
1264  typedef ScalarTraits<Scalar> ST;
1265  int myNumStages = 2;
1266  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1267  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1268  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1269  Scalar one = ST::one();
1270  Scalar onehalf = as<Scalar>(one/(2*one));
1271  Scalar three = as<Scalar>(3*one);
1272  Scalar six = as<Scalar>(6*one);
1273  Scalar onefourth = as<Scalar>(one/(4*one));
1274  Scalar alpha = ST::squareroot(three)/six;
1275 
1276  myA(0,0) = onefourth;
1277  myA(0,1) = onefourth-alpha;
1278  myA(1,0) = onefourth+alpha;
1279  myA(1,1) = onefourth;
1280  myb(0) = onehalf;
1281  myb(1) = onehalf;
1282  myc(0) = onehalf-alpha;
1283  myc(1) = onehalf+alpha;
1284  this->setMyDescription(myDescription.str());
1285  this->setMy_A(myA);
1286  this->setMy_b(myb);
1287  this->setMy_c(myc);
1288  this->setMy_order(4);
1289  }
1290 };
1291 
1292 
1293 template<class Scalar>
1294 class Implicit3Stage6thOrderGauss_RKBT :
1295  virtual public RKButcherTableauDefaultBase<Scalar>
1296 {
1297  public:
1298  Implicit3Stage6thOrderGauss_RKBT()
1299  {
1300 
1301  std::ostringstream myDescription;
1302  myDescription << Implicit3Stage6thOrderGauss_name() << "\n"
1303  << "A-stable\n"
1304  << "Solving Ordinary Differential Equations II:\n"
1305  << "Stiff and Differential-Algebraic Problems,\n"
1306  << "2nd Revised Edition\n"
1307  << "E. Hairer and G. Wanner\n"
1308  << "Table 5.2, pg 72\n"
1309  << "c = [ 1/2-sqrt(15)/10 1/2 1/2+sqrt(15)/10 ]'\n"
1310  << "A = [ 5/36 2/9-sqrt(15)/15 5/36-sqrt(15)/30 ]\n"
1311  << " [ 5/36+sqrt(15)/24 2/9 5/36-sqrt(15)/24 ]\n"
1312  << " [ 5/36+sqrt(15)/30 2/9+sqrt(15)/15 5/36 ]\n"
1313  << "b = [ 5/18 4/9 5/18 ]'" << std::endl;
1314  typedef ScalarTraits<Scalar> ST;
1315  int myNumStages = 3;
1316  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1317  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1318  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1319  Scalar one = ST::one();
1320  Scalar ten = as<Scalar>(10*one);
1321  Scalar fifteen = as<Scalar>(15*one);
1322  Scalar twentyfour = as<Scalar>(24*one);
1323  Scalar thirty = as<Scalar>(30*one);
1324  Scalar sqrt15over10 = as<Scalar>(ST::squareroot(fifteen)/ten);
1325  Scalar sqrt15over15 = as<Scalar>(ST::squareroot(fifteen)/fifteen);
1326  Scalar sqrt15over24 = as<Scalar>(ST::squareroot(fifteen)/twentyfour);
1327  Scalar sqrt15over30 = as<Scalar>(ST::squareroot(fifteen)/thirty);
1328 
1329  myA(0,0) = as<Scalar>(5*one/(36*one));
1330  myA(0,1) = as<Scalar>(2*one/(9*one))-sqrt15over15;
1331  myA(0,2) = as<Scalar>(5*one/(36*one))-sqrt15over30;
1332  myA(1,0) = as<Scalar>(5*one/(36*one))+sqrt15over24;
1333  myA(1,1) = as<Scalar>(2*one/(9*one));
1334  myA(1,2) = as<Scalar>(5*one/(36*one))-sqrt15over24;
1335  myA(2,0) = as<Scalar>(5*one/(36*one))+sqrt15over30;
1336  myA(2,1) = as<Scalar>(2*one/(9*one))+sqrt15over15;
1337  myA(2,2) = as<Scalar>(5*one/(36*one));
1338  myb(0) = as<Scalar>(5*one/(18*one));
1339  myb(1) = as<Scalar>(4*one/(9*one));
1340  myb(2) = as<Scalar>(5*one/(18*one));
1341  myc(0) = as<Scalar>(one/(2*one))-sqrt15over10;
1342  myc(1) = as<Scalar>(one/(2*one));
1343  myc(2) = as<Scalar>(one/(2*one))+sqrt15over10;
1344  this->setMyDescription(myDescription.str());
1345  this->setMy_A(myA);
1346  this->setMy_b(myb);
1347  this->setMy_c(myc);
1348  this->setMy_order(6);
1349  }
1350 };
1351 
1352 
1353 template<class Scalar>
1354 class Implicit1Stage1stOrderRadauA_RKBT :
1355  virtual public RKButcherTableauDefaultBase<Scalar>
1356 {
1357  public:
1358  Implicit1Stage1stOrderRadauA_RKBT()
1359  {
1360 
1361  std::ostringstream myDescription;
1362  myDescription << Implicit1Stage1stOrderRadauA_name() << "\n"
1363  << "A-stable\n"
1364  << "Solving Ordinary Differential Equations II:\n"
1365  << "Stiff and Differential-Algebraic Problems,\n"
1366  << "2nd Revised Edition\n"
1367  << "E. Hairer and G. Wanner\n"
1368  << "Table 5.3, pg 73\n"
1369  << "c = [ 0 ]'\n"
1370  << "A = [ 1 ]\n"
1371  << "b = [ 1 ]'" << std::endl;
1372  typedef ScalarTraits<Scalar> ST;
1373  int myNumStages = 1;
1374  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1375  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1376  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1377  Scalar one = ST::one();
1378  Scalar zero = ST::zero();
1379  myA(0,0) = one;
1380  myb(0) = one;
1381  myc(0) = zero;
1382  this->setMyDescription(myDescription.str());
1383  this->setMy_A(myA);
1384  this->setMy_b(myb);
1385  this->setMy_c(myc);
1386  this->setMy_order(1);
1387  }
1388 };
1389 
1390 
1391 template<class Scalar>
1392 class Implicit2Stage3rdOrderRadauA_RKBT :
1393  virtual public RKButcherTableauDefaultBase<Scalar>
1394 {
1395  public:
1396  Implicit2Stage3rdOrderRadauA_RKBT()
1397  {
1398 
1399  std::ostringstream myDescription;
1400  myDescription << Implicit2Stage3rdOrderRadauA_name() << "\n"
1401  << "A-stable\n"
1402  << "Solving Ordinary Differential Equations II:\n"
1403  << "Stiff and Differential-Algebraic Problems,\n"
1404  << "2nd Revised Edition\n"
1405  << "E. Hairer and G. Wanner\n"
1406  << "Table 5.3, pg 73\n"
1407  << "c = [ 0 2/3 ]'\n"
1408  << "A = [ 1/4 -1/4 ]\n"
1409  << " [ 1/4 5/12 ]\n"
1410  << "b = [ 1/4 3/4 ]'" << std::endl;
1411  typedef ScalarTraits<Scalar> ST;
1412  int myNumStages = 2;
1413  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1414  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1415  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1416  Scalar zero = ST::zero();
1417  Scalar one = ST::one();
1418  myA(0,0) = as<Scalar>(one/(4*one));
1419  myA(0,1) = as<Scalar>(-one/(4*one));
1420  myA(1,0) = as<Scalar>(one/(4*one));
1421  myA(1,1) = as<Scalar>(5*one/(12*one));
1422  myb(0) = as<Scalar>(one/(4*one));
1423  myb(1) = as<Scalar>(3*one/(4*one));
1424  myc(0) = zero;
1425  myc(1) = as<Scalar>(2*one/(3*one));
1426  this->setMyDescription(myDescription.str());
1427  this->setMy_A(myA);
1428  this->setMy_b(myb);
1429  this->setMy_c(myc);
1430  this->setMy_order(3);
1431  }
1432 };
1433 
1434 
1435 template<class Scalar>
1436 class Implicit3Stage5thOrderRadauA_RKBT :
1437  virtual public RKButcherTableauDefaultBase<Scalar>
1438 {
1439  public:
1440  Implicit3Stage5thOrderRadauA_RKBT()
1441  {
1442 
1443  std::ostringstream myDescription;
1444  myDescription << Implicit3Stage5thOrderRadauA_name() << "\n"
1445  << "A-stable\n"
1446  << "Solving Ordinary Differential Equations II:\n"
1447  << "Stiff and Differential-Algebraic Problems,\n"
1448  << "2nd Revised Edition\n"
1449  << "E. Hairer and G. Wanner\n"
1450  << "Table 5.4, pg 73\n"
1451  << "c = [ 0 (6-sqrt(6))/10 (6+sqrt(6))/10 ]'\n"
1452  << "A = [ 1/9 (-1-sqrt(6))/18 (-1+sqrt(6))/18 ]\n"
1453  << " [ 1/9 (88+7*sqrt(6))/360 (88-43*sqrt(6))/360 ]\n"
1454  << " [ 1/9 (88+43*sqrt(6))/360 (88-7*sqrt(6))/360 ]\n"
1455  << "b = [ 1/9 (16+sqrt(6))/36 (16-sqrt(6))/36 ]'" << std::endl;
1456  typedef ScalarTraits<Scalar> ST;
1457  int myNumStages = 3;
1458  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1459  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1460  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1461  Scalar zero = ST::zero();
1462  Scalar one = ST::one();
1463  myA(0,0) = as<Scalar>(one/(9*one));
1464  myA(0,1) = as<Scalar>( (-one-ST::squareroot(6*one))/(18*one) );
1465  myA(0,2) = as<Scalar>( (-one+ST::squareroot(6*one))/(18*one) );
1466  myA(1,0) = as<Scalar>(one/(9*one));
1467  myA(1,1) = as<Scalar>( (88*one+7*one*ST::squareroot(6*one))/(360*one) );
1468  myA(1,2) = as<Scalar>( (88*one-43*one*ST::squareroot(6*one))/(360*one) );
1469  myA(2,0) = as<Scalar>(one/(9*one));
1470  myA(2,1) = as<Scalar>( (88*one+43*one*ST::squareroot(6*one))/(360*one) );
1471  myA(2,2) = as<Scalar>( (88*one-7*one*ST::squareroot(6*one))/(360*one) );
1472  myb(0) = as<Scalar>(one/(9*one));
1473  myb(1) = as<Scalar>( (16*one+ST::squareroot(6*one))/(36*one) );
1474  myb(2) = as<Scalar>( (16*one-ST::squareroot(6*one))/(36*one) );
1475  myc(0) = zero;
1476  myc(1) = as<Scalar>( (6*one-ST::squareroot(6*one))/(10*one) );
1477  myc(2) = as<Scalar>( (6*one+ST::squareroot(6*one))/(10*one) );
1478  this->setMyDescription(myDescription.str());
1479  this->setMy_A(myA);
1480  this->setMy_b(myb);
1481  this->setMy_c(myc);
1482  this->setMy_order(5);
1483  }
1484 };
1485 
1486 
1487 template<class Scalar>
1488 class Implicit1Stage1stOrderRadauB_RKBT :
1489  virtual public RKButcherTableauDefaultBase<Scalar>
1490 {
1491  public:
1492  Implicit1Stage1stOrderRadauB_RKBT()
1493  {
1494 
1495  std::ostringstream myDescription;
1496  myDescription << Implicit1Stage1stOrderRadauB_name() << "\n"
1497  << "A-stable\n"
1498  << "Solving Ordinary Differential Equations II:\n"
1499  << "Stiff and Differential-Algebraic Problems,\n"
1500  << "2nd Revised Edition\n"
1501  << "E. Hairer and G. Wanner\n"
1502  << "Table 5.5, pg 74\n"
1503  << "c = [ 1 ]'\n"
1504  << "A = [ 1 ]\n"
1505  << "b = [ 1 ]'" << std::endl;
1506  typedef ScalarTraits<Scalar> ST;
1507  int myNumStages = 1;
1508  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1509  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1510  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1511  Scalar one = ST::one();
1512  myA(0,0) = one;
1513  myb(0) = one;
1514  myc(0) = one;
1515  this->setMyDescription(myDescription.str());
1516  this->setMy_A(myA);
1517  this->setMy_b(myb);
1518  this->setMy_c(myc);
1519  this->setMy_order(1);
1520  }
1521 };
1522 
1523 
1524 template<class Scalar>
1525 class Implicit2Stage3rdOrderRadauB_RKBT :
1526  virtual public RKButcherTableauDefaultBase<Scalar>
1527 {
1528  public:
1529  Implicit2Stage3rdOrderRadauB_RKBT()
1530  {
1531 
1532  std::ostringstream myDescription;
1533  myDescription << Implicit2Stage3rdOrderRadauB_name() << "\n"
1534  << "A-stable\n"
1535  << "Solving Ordinary Differential Equations II:\n"
1536  << "Stiff and Differential-Algebraic Problems,\n"
1537  << "2nd Revised Edition\n"
1538  << "E. Hairer and G. Wanner\n"
1539  << "Table 5.5, pg 74\n"
1540  << "c = [ 1/3 1 ]'\n"
1541  << "A = [ 5/12 -1/12 ]\n"
1542  << " [ 3/4 1/4 ]\n"
1543  << "b = [ 3/4 1/4 ]'" << std::endl;
1544  typedef ScalarTraits<Scalar> ST;
1545  int myNumStages = 2;
1546  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1547  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1548  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1549  Scalar one = ST::one();
1550  myA(0,0) = as<Scalar>( 5*one/(12*one) );
1551  myA(0,1) = as<Scalar>( -one/(12*one) );
1552  myA(1,0) = as<Scalar>( 3*one/(4*one) );
1553  myA(1,1) = as<Scalar>( one/(4*one) );
1554  myb(0) = as<Scalar>( 3*one/(4*one) );
1555  myb(1) = as<Scalar>( one/(4*one) );
1556  myc(0) = as<Scalar>( one/(3*one) );
1557  myc(1) = one;
1558  this->setMyDescription(myDescription.str());
1559  this->setMy_A(myA);
1560  this->setMy_b(myb);
1561  this->setMy_c(myc);
1562  this->setMy_order(3);
1563  }
1564 };
1565 
1566 
1567 template<class Scalar>
1568 class Implicit3Stage5thOrderRadauB_RKBT :
1569  virtual public RKButcherTableauDefaultBase<Scalar>
1570 {
1571  public:
1572  Implicit3Stage5thOrderRadauB_RKBT()
1573  {
1574 
1575  std::ostringstream myDescription;
1576  myDescription << Implicit3Stage5thOrderRadauB_name() << "\n"
1577  << "A-stable\n"
1578  << "Solving Ordinary Differential Equations II:\n"
1579  << "Stiff and Differential-Algebraic Problems,\n"
1580  << "2nd Revised Edition\n"
1581  << "E. Hairer and G. Wanner\n"
1582  << "Table 5.6, pg 74\n"
1583  << "c = [ (4-sqrt(6))/10 (4+sqrt(6))/10 1 ]'\n"
1584  << "A = [ (88-7*sqrt(6))/360 (296-169*sqrt(6))/1800 (-2+3*sqrt(6))/225 ]\n"
1585  << " [ (296+169*sqrt(6))/1800 (88+7*sqrt(6))/360 (-2-3*sqrt(6))/225 ]\n"
1586  << " [ (16-sqrt(6))/36 (16+sqrt(6))/36 1/9 ]\n"
1587  << "b = [ (16-sqrt(6))/36 (16+sqrt(6))/36 1/9 ]'" << std::endl;
1588  typedef ScalarTraits<Scalar> ST;
1589  int myNumStages = 3;
1590  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1591  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1592  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1593  Scalar one = ST::one();
1594  myA(0,0) = as<Scalar>( (88*one-7*one*ST::squareroot(6*one))/(360*one) );
1595  myA(0,1) = as<Scalar>( (296*one-169*one*ST::squareroot(6*one))/(1800*one) );
1596  myA(0,2) = as<Scalar>( (-2*one+3*one*ST::squareroot(6*one))/(225*one) );
1597  myA(1,0) = as<Scalar>( (296*one+169*one*ST::squareroot(6*one))/(1800*one) );
1598  myA(1,1) = as<Scalar>( (88*one+7*one*ST::squareroot(6*one))/(360*one) );
1599  myA(1,2) = as<Scalar>( (-2*one-3*one*ST::squareroot(6*one))/(225*one) );
1600  myA(2,0) = as<Scalar>( (16*one-ST::squareroot(6*one))/(36*one) );
1601  myA(2,1) = as<Scalar>( (16*one+ST::squareroot(6*one))/(36*one) );
1602  myA(2,2) = as<Scalar>( one/(9*one) );
1603  myb(0) = as<Scalar>( (16*one-ST::squareroot(6*one))/(36*one) );
1604  myb(1) = as<Scalar>( (16*one+ST::squareroot(6*one))/(36*one) );
1605  myb(2) = as<Scalar>( one/(9*one) );
1606  myc(0) = as<Scalar>( (4*one-ST::squareroot(6*one))/(10*one) );
1607  myc(1) = as<Scalar>( (4*one+ST::squareroot(6*one))/(10*one) );
1608  myc(2) = one;
1609  this->setMyDescription(myDescription.str());
1610  this->setMy_A(myA);
1611  this->setMy_b(myb);
1612  this->setMy_c(myc);
1613  this->setMy_order(5);
1614  }
1615 };
1616 
1617 
1618 template<class Scalar>
1619 class Implicit2Stage2ndOrderLobattoA_RKBT :
1620  virtual public RKButcherTableauDefaultBase<Scalar>
1621 {
1622  public:
1623  Implicit2Stage2ndOrderLobattoA_RKBT()
1624  {
1625 
1626  std::ostringstream myDescription;
1627  myDescription << Implicit2Stage2ndOrderLobattoA_name() << "\n"
1628  << "A-stable\n"
1629  << "Solving Ordinary Differential Equations II:\n"
1630  << "Stiff and Differential-Algebraic Problems,\n"
1631  << "2nd Revised Edition\n"
1632  << "E. Hairer and G. Wanner\n"
1633  << "Table 5.7, pg 75\n"
1634  << "c = [ 0 1 ]'\n"
1635  << "A = [ 0 0 ]\n"
1636  << " [ 1/2 1/2 ]\n"
1637  << "b = [ 1/2 1/2 ]'" << std::endl;
1638  typedef ScalarTraits<Scalar> ST;
1639  int myNumStages = 2;
1640  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1641  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1642  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1643  Scalar zero = ST::zero();
1644  Scalar one = ST::one();
1645  myA(0,0) = zero;
1646  myA(0,1) = zero;
1647  myA(1,0) = as<Scalar>( one/(2*one) );
1648  myA(1,1) = as<Scalar>( one/(2*one) );
1649  myb(0) = as<Scalar>( one/(2*one) );
1650  myb(1) = as<Scalar>( one/(2*one) );
1651  myc(0) = zero;
1652  myc(1) = one;
1653  this->setMyDescription(myDescription.str());
1654  this->setMy_A(myA);
1655  this->setMy_b(myb);
1656  this->setMy_c(myc);
1657  this->setMy_order(2);
1658  }
1659 };
1660 
1661 
1662 template<class Scalar>
1663 class Implicit3Stage4thOrderLobattoA_RKBT :
1664  virtual public RKButcherTableauDefaultBase<Scalar>
1665 {
1666  public:
1667  Implicit3Stage4thOrderLobattoA_RKBT()
1668  {
1669 
1670  std::ostringstream myDescription;
1671  myDescription << Implicit3Stage4thOrderLobattoA_name() << "\n"
1672  << "A-stable\n"
1673  << "Solving Ordinary Differential Equations II:\n"
1674  << "Stiff and Differential-Algebraic Problems,\n"
1675  << "2nd Revised Edition\n"
1676  << "E. Hairer and G. Wanner\n"
1677  << "Table 5.7, pg 75\n"
1678  << "c = [ 0 1/2 1 ]'\n"
1679  << "A = [ 0 0 0 ]\n"
1680  << " [ 5/24 1/3 -1/24 ]\n"
1681  << " [ 1/6 2/3 1/6 ]\n"
1682  << "b = [ 1/6 2/3 1/6 ]'" << std::endl;
1683  typedef ScalarTraits<Scalar> ST;
1684  int myNumStages = 3;
1685  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1686  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1687  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1688  Scalar zero = ST::zero();
1689  Scalar one = ST::one();
1690  myA(0,0) = zero;
1691  myA(0,1) = zero;
1692  myA(0,2) = zero;
1693  myA(1,0) = as<Scalar>( (5*one)/(24*one) );
1694  myA(1,1) = as<Scalar>( (one)/(3*one) );
1695  myA(1,2) = as<Scalar>( (-one)/(24*one) );
1696  myA(2,0) = as<Scalar>( (one)/(6*one) );
1697  myA(2,1) = as<Scalar>( (2*one)/(3*one) );
1698  myA(2,2) = as<Scalar>( (1*one)/(6*one) );
1699  myb(0) = as<Scalar>( (one)/(6*one) );
1700  myb(1) = as<Scalar>( (2*one)/(3*one) );
1701  myb(2) = as<Scalar>( (1*one)/(6*one) );
1702  myc(0) = zero;
1703  myc(1) = as<Scalar>( one/(2*one) );
1704  myc(2) = one;
1705  this->setMyDescription(myDescription.str());
1706  this->setMy_A(myA);
1707  this->setMy_b(myb);
1708  this->setMy_c(myc);
1709  this->setMy_order(4);
1710  }
1711 };
1712 
1713 
1714 template<class Scalar>
1715 class Implicit4Stage6thOrderLobattoA_RKBT :
1716  virtual public RKButcherTableauDefaultBase<Scalar>
1717 {
1718  public:
1719  Implicit4Stage6thOrderLobattoA_RKBT()
1720  {
1721 
1722  using Teuchos::as;
1723  typedef Teuchos::ScalarTraits<Scalar> ST;
1724 
1725  std::ostringstream myDescription;
1726  myDescription << Implicit4Stage6thOrderLobattoA_name() << "\n"
1727  << "A-stable\n"
1728  << "Solving Ordinary Differential Equations II:\n"
1729  << "Stiff and Differential-Algebraic Problems,\n"
1730  << "2nd Revised Edition\n"
1731  << "E. Hairer and G. Wanner\n"
1732  << "Table 5.8, pg 75\n"
1733  << "c = [ 0 (5-sqrt(5))/10 (5+sqrt(5))/10 1 ]'\n"
1734  << "A = [ 0 0 0 0 ]\n"
1735  << " [ (11+sqrt(5)/120 (25-sqrt(5))/120 (25-13*sqrt(5))/120 (-1+sqrt(5))/120 ]\n"
1736  << " [ (11-sqrt(5)/120 (25+13*sqrt(5))/120 (25+sqrt(5))/120 (-1-sqrt(5))/120 ]\n"
1737  << " [ 1/12 5/12 5/12 1/12 ]\n"
1738  << "b = [ 1/12 5/12 5/12 1/12 ]'" << std::endl;
1739  typedef ScalarTraits<Scalar> ST;
1740  int myNumStages = 4;
1741  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1742  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1743  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1744  Scalar zero = ST::zero();
1745  Scalar one = ST::one();
1746  myA(0,0) = zero;
1747  myA(0,1) = zero;
1748  myA(0,2) = zero;
1749  myA(0,3) = zero;
1750  myA(1,0) = as<Scalar>( (11*one+ST::squareroot(5*one))/(120*one) );
1751  myA(1,1) = as<Scalar>( (25*one-ST::squareroot(5*one))/(120*one) );
1752  myA(1,2) = as<Scalar>( (25*one-13*one*ST::squareroot(5*one))/(120*one) );
1753  myA(1,3) = as<Scalar>( (-one+ST::squareroot(5*one))/(120*one) );
1754  myA(2,0) = as<Scalar>( (11*one-ST::squareroot(5*one))/(120*one) );
1755  myA(2,1) = as<Scalar>( (25*one+13*one*ST::squareroot(5*one))/(120*one) );
1756  myA(2,2) = as<Scalar>( (25*one+ST::squareroot(5*one))/(120*one) );
1757  myA(2,3) = as<Scalar>( (-one-ST::squareroot(5*one))/(120*one) );
1758  myA(3,0) = as<Scalar>( one/(12*one) );
1759  myA(3,1) = as<Scalar>( 5*one/(12*one) );
1760  myA(3,2) = as<Scalar>( 5*one/(12*one) );
1761  myA(3,3) = as<Scalar>( one/(12*one) );
1762  myb(0) = as<Scalar>( one/(12*one) );
1763  myb(1) = as<Scalar>( 5*one/(12*one) );
1764  myb(2) = as<Scalar>( 5*one/(12*one) );
1765  myb(3) = as<Scalar>( one/(12*one) );
1766  myc(0) = zero;
1767  myc(1) = as<Scalar>( (5*one-ST::squareroot(5))/(10*one) );
1768  myc(2) = as<Scalar>( (5*one+ST::squareroot(5))/(10*one) );
1769  myc(3) = one;
1770  this->setMyDescription(myDescription.str());
1771  this->setMy_A(myA);
1772  this->setMy_b(myb);
1773  this->setMy_c(myc);
1774  this->setMy_order(6);
1775  }
1776 };
1777 
1778 
1779 template<class Scalar>
1780 class Implicit2Stage2ndOrderLobattoB_RKBT :
1781  virtual public RKButcherTableauDefaultBase<Scalar>
1782 {
1783  public:
1784  Implicit2Stage2ndOrderLobattoB_RKBT()
1785  {
1786 
1787  std::ostringstream myDescription;
1788  myDescription << Implicit2Stage2ndOrderLobattoB_name() << "\n"
1789  << "A-stable\n"
1790  << "Solving Ordinary Differential Equations II:\n"
1791  << "Stiff and Differential-Algebraic Problems,\n"
1792  << "2nd Revised Edition\n"
1793  << "E. Hairer and G. Wanner\n"
1794  << "Table 5.9, pg 76\n"
1795  << "c = [ 0 1 ]'\n"
1796  << "A = [ 1/2 0 ]\n"
1797  << " [ 1/2 0 ]\n"
1798  << "b = [ 1/2 1/2 ]'" << std::endl;
1799  typedef ScalarTraits<Scalar> ST;
1800  int myNumStages = 2;
1801  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1802  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1803  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1804  Scalar zero = ST::zero();
1805  Scalar one = ST::one();
1806  myA(0,0) = as<Scalar>( one/(2*one) );
1807  myA(0,1) = zero;
1808  myA(1,0) = as<Scalar>( one/(2*one) );
1809  myA(1,1) = zero;
1810  myb(0) = as<Scalar>( one/(2*one) );
1811  myb(1) = as<Scalar>( one/(2*one) );
1812  myc(0) = zero;
1813  myc(1) = one;
1814  this->setMyDescription(myDescription.str());
1815  this->setMy_A(myA);
1816  this->setMy_b(myb);
1817  this->setMy_c(myc);
1818  this->setMy_order(2);
1819  }
1820 };
1821 
1822 
1823 template<class Scalar>
1824 class Implicit3Stage4thOrderLobattoB_RKBT :
1825  virtual public RKButcherTableauDefaultBase<Scalar>
1826 {
1827  public:
1828  Implicit3Stage4thOrderLobattoB_RKBT()
1829  {
1830 
1831  std::ostringstream myDescription;
1832  myDescription << Implicit3Stage4thOrderLobattoB_name() << "\n"
1833  << "A-stable\n"
1834  << "Solving Ordinary Differential Equations II:\n"
1835  << "Stiff and Differential-Algebraic Problems,\n"
1836  << "2nd Revised Edition\n"
1837  << "E. Hairer and G. Wanner\n"
1838  << "Table 5.9, pg 76\n"
1839  << "c = [ 0 1/2 1 ]'\n"
1840  << "A = [ 1/6 -1/6 0 ]\n"
1841  << " [ 1/6 1/3 0 ]\n"
1842  << " [ 1/6 5/6 0 ]\n"
1843  << "b = [ 1/6 2/3 1/6 ]'" << std::endl;
1844  typedef ScalarTraits<Scalar> ST;
1845  int myNumStages = 3;
1846  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1847  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1848  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1849  Scalar zero = ST::zero();
1850  Scalar one = ST::one();
1851  myA(0,0) = as<Scalar>( one/(6*one) );
1852  myA(0,1) = as<Scalar>( -one/(6*one) );
1853  myA(0,2) = zero;
1854  myA(1,0) = as<Scalar>( one/(6*one) );
1855  myA(1,1) = as<Scalar>( one/(3*one) );
1856  myA(1,2) = zero;
1857  myA(2,0) = as<Scalar>( one/(6*one) );
1858  myA(2,1) = as<Scalar>( 5*one/(6*one) );
1859  myA(2,2) = zero;
1860  myb(0) = as<Scalar>( one/(6*one) );
1861  myb(1) = as<Scalar>( 2*one/(3*one) );
1862  myb(2) = as<Scalar>( one/(6*one) );
1863  myc(0) = zero;
1864  myc(1) = as<Scalar>( one/(2*one) );
1865  myc(2) = one;
1866  this->setMyDescription(myDescription.str());
1867  this->setMy_A(myA);
1868  this->setMy_b(myb);
1869  this->setMy_c(myc);
1870  this->setMy_order(4);
1871  }
1872 };
1873 
1874 
1875 template<class Scalar>
1876 class Implicit4Stage6thOrderLobattoB_RKBT :
1877  virtual public RKButcherTableauDefaultBase<Scalar>
1878 {
1879  public:
1880  Implicit4Stage6thOrderLobattoB_RKBT()
1881  {
1882 
1883  std::ostringstream myDescription;
1884  myDescription << Implicit4Stage6thOrderLobattoB_name() << "\n"
1885  << "A-stable\n"
1886  << "Solving Ordinary Differential Equations II:\n"
1887  << "Stiff and Differential-Algebraic Problems,\n"
1888  << "2nd Revised Edition\n"
1889  << "E. Hairer and G. Wanner\n"
1890  << "Table 5.10, pg 76\n"
1891  << "c = [ 0 (5-sqrt(5))/10 (5+sqrt(5))/10 1 ]'\n"
1892  << "A = [ 1/12 (-1-sqrt(5))/24 (-1+sqrt(5))/24 0 ]\n"
1893  << " [ 1/12 (25+sqrt(5))/120 (25-13*sqrt(5))/120 0 ]\n"
1894  << " [ 1/12 (25+13*sqrt(5))/120 (25-sqrt(5))/120 0 ]\n"
1895  << " [ 1/12 (11-sqrt(5))/24 (11+sqrt(5))/24 0 ]\n"
1896  << "b = [ 1/12 5/12 5/12 1/12 ]'" << std::endl;
1897  typedef ScalarTraits<Scalar> ST;
1898  int myNumStages = 4;
1899  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1900  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1901  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1902  Scalar zero = ST::zero();
1903  Scalar one = ST::one();
1904  myA(0,0) = as<Scalar>( one/(12*one) );
1905  myA(0,1) = as<Scalar>( (-one-ST::squareroot(5))/(24*one) );
1906  myA(0,2) = as<Scalar>( (-one+ST::squareroot(5))/(24*one) );
1907  myA(0,3) = zero;
1908  myA(1,0) = as<Scalar>( one/(12*one) );
1909  myA(1,1) = as<Scalar>( (25*one+ST::squareroot(5))/(120*one) );
1910  myA(1,2) = as<Scalar>( (25*one-13*one*ST::squareroot(5))/(120*one) );
1911  myA(1,3) = zero;
1912  myA(2,0) = as<Scalar>( one/(12*one) );
1913  myA(2,1) = as<Scalar>( (25*one+13*one*ST::squareroot(5))/(120*one) );
1914  myA(2,2) = as<Scalar>( (25*one-ST::squareroot(5))/(120*one) );
1915  myA(2,3) = zero;
1916  myA(3,0) = as<Scalar>( one/(12*one) );
1917  myA(3,1) = as<Scalar>( (11*one-ST::squareroot(5*one))/(24*one) );
1918  myA(3,2) = as<Scalar>( (11*one+ST::squareroot(5*one))/(24*one) );
1919  myA(3,3) = zero;
1920  myb(0) = as<Scalar>( one/(12*one) );
1921  myb(1) = as<Scalar>( 5*one/(12*one) );
1922  myb(2) = as<Scalar>( 5*one/(12*one) );
1923  myb(3) = as<Scalar>( one/(12*one) );
1924  myc(0) = zero;
1925  myc(1) = as<Scalar>( (5*one-ST::squareroot(5*one))/(10*one) );
1926  myc(2) = as<Scalar>( (5*one+ST::squareroot(5*one))/(10*one) );
1927  myc(3) = one;
1928  this->setMyDescription(myDescription.str());
1929  this->setMy_A(myA);
1930  this->setMy_b(myb);
1931  this->setMy_c(myc);
1932  this->setMy_order(6);
1933  }
1934 };
1935 
1936 
1937 template<class Scalar>
1938 class Implicit2Stage2ndOrderLobattoC_RKBT :
1939  virtual public RKButcherTableauDefaultBase<Scalar>
1940 {
1941  public:
1942  Implicit2Stage2ndOrderLobattoC_RKBT()
1943  {
1944 
1945  std::ostringstream myDescription;
1946  myDescription << Implicit2Stage2ndOrderLobattoC_name() << "\n"
1947  << "A-stable\n"
1948  << "Solving Ordinary Differential Equations II:\n"
1949  << "Stiff and Differential-Algebraic Problems,\n"
1950  << "2nd Revised Edition\n"
1951  << "E. Hairer and G. Wanner\n"
1952  << "Table 5.11, pg 76\n"
1953  << "c = [ 0 1 ]'\n"
1954  << "A = [ 1/2 -1/2 ]\n"
1955  << " [ 1/2 1/2 ]\n"
1956  << "b = [ 1/2 1/2 ]'" << std::endl;
1957  typedef ScalarTraits<Scalar> ST;
1958  int myNumStages = 2;
1959  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
1960  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
1961  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
1962  Scalar zero = ST::zero();
1963  Scalar one = ST::one();
1964  myA(0,0) = as<Scalar>( one/(2*one) );
1965  myA(0,1) = as<Scalar>( -one/(2*one) );
1966  myA(1,0) = as<Scalar>( one/(2*one) );
1967  myA(1,1) = as<Scalar>( one/(2*one) );
1968  myb(0) = as<Scalar>( one/(2*one) );
1969  myb(1) = as<Scalar>( one/(2*one) );
1970  myc(0) = zero;
1971  myc(1) = one;
1972  this->setMyDescription(myDescription.str());
1973  this->setMy_A(myA);
1974  this->setMy_b(myb);
1975  this->setMy_c(myc);
1976  this->setMy_order(2);
1977  }
1978 };
1979 
1980 
1981 template<class Scalar>
1982 class Implicit3Stage4thOrderLobattoC_RKBT :
1983  virtual public RKButcherTableauDefaultBase<Scalar>
1984 {
1985  public:
1986  Implicit3Stage4thOrderLobattoC_RKBT()
1987  {
1988 
1989  std::ostringstream myDescription;
1990  myDescription << Implicit3Stage4thOrderLobattoC_name() << "\n"
1991  << "A-stable\n"
1992  << "Solving Ordinary Differential Equations II:\n"
1993  << "Stiff and Differential-Algebraic Problems,\n"
1994  << "2nd Revised Edition\n"
1995  << "E. Hairer and G. Wanner\n"
1996  << "Table 5.11, pg 76\n"
1997  << "c = [ 0 1/2 1 ]'\n"
1998  << "A = [ 1/6 -1/3 1/6 ]\n"
1999  << " [ 1/6 5/12 -1/12 ]\n"
2000  << " [ 1/6 2/3 1/6 ]\n"
2001  << "b = [ 1/6 2/3 1/6 ]'" << std::endl;
2002  typedef ScalarTraits<Scalar> ST;
2003  int myNumStages = 3;
2004  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
2005  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
2006  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
2007  Scalar zero = ST::zero();
2008  Scalar one = ST::one();
2009  myA(0,0) = as<Scalar>( one/(6*one) );
2010  myA(0,1) = as<Scalar>( -one/(3*one) );
2011  myA(0,2) = as<Scalar>( one/(6*one) );
2012  myA(1,0) = as<Scalar>( one/(6*one) );
2013  myA(1,1) = as<Scalar>( 5*one/(12*one) );
2014  myA(1,2) = as<Scalar>( -one/(12*one) );
2015  myA(2,0) = as<Scalar>( one/(6*one) );
2016  myA(2,1) = as<Scalar>( 2*one/(3*one) );
2017  myA(2,2) = as<Scalar>( one/(6*one) );
2018  myb(0) = as<Scalar>( one/(6*one) );
2019  myb(1) = as<Scalar>( 2*one/(3*one) );
2020  myb(2) = as<Scalar>( one/(6*one) );
2021  myc(0) = zero;
2022  myc(1) = as<Scalar>( one/(2*one) );
2023  myc(2) = one;
2024  this->setMyDescription(myDescription.str());
2025  this->setMy_A(myA);
2026  this->setMy_b(myb);
2027  this->setMy_c(myc);
2028  this->setMy_order(4);
2029  }
2030 };
2031 
2032 
2033 template<class Scalar>
2034 class Implicit4Stage6thOrderLobattoC_RKBT :
2035  virtual public RKButcherTableauDefaultBase<Scalar>
2036 {
2037  public:
2038  Implicit4Stage6thOrderLobattoC_RKBT()
2039  {
2040 
2041  std::ostringstream myDescription;
2042  myDescription << Implicit4Stage6thOrderLobattoC_name() << "\n"
2043  << "A-stable\n"
2044  << "Solving Ordinary Differential Equations II:\n"
2045  << "Stiff and Differential-Algebraic Problems,\n"
2046  << "2nd Revised Edition\n"
2047  << "E. Hairer and G. Wanner\n"
2048  << "Table 5.12, pg 76\n"
2049  << "c = [ 0 (5-sqrt(5))/10 (5+sqrt(5))/10 1 ]'\n"
2050  << "A = [ 1/12 -sqrt(5)/12 sqrt(5)/12 -1/12 ]\n"
2051  << " [ 1/12 1/4 (10-7*sqrt(5))/60 sqrt(5)/60 ]\n"
2052  << " [ 1/12 (10+7*sqrt(5))/60 1/4 -sqrt(5)/60 ]\n"
2053  << " [ 1/12 5/12 5/12 1/12 ]\n"
2054  << "b = [ 1/12 5/12 5/12 1/12 ]'" << std::endl;
2055  typedef ScalarTraits<Scalar> ST;
2056  int myNumStages = 4;
2057  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
2058  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
2059  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
2060  Scalar zero = ST::zero();
2061  Scalar one = ST::one();
2062  myA(0,0) = as<Scalar>( one/(12*one) );
2063  myA(0,1) = as<Scalar>( -ST::squareroot(5*one)/(12*one) );
2064  myA(0,2) = as<Scalar>( ST::squareroot(5*one)/(12*one) );
2065  myA(0,3) = as<Scalar>( -one/(12*one) );
2066  myA(1,0) = as<Scalar>( one/(12*one) );
2067  myA(1,1) = as<Scalar>( one/(4*one) );
2068  myA(1,2) = as<Scalar>( (10*one-7*one*ST::squareroot(5*one))/(60*one) );
2069  myA(1,3) = as<Scalar>( ST::squareroot(5*one)/(60*one) );
2070  myA(2,0) = as<Scalar>( one/(12*one) );
2071  myA(2,1) = as<Scalar>( (10*one+7*one*ST::squareroot(5*one))/(60*one) );
2072  myA(2,2) = as<Scalar>( one/(4*one) );
2073  myA(2,3) = as<Scalar>( -ST::squareroot(5*one)/(60*one) );
2074  myA(3,0) = as<Scalar>( one/(12*one) );
2075  myA(3,1) = as<Scalar>( 5*one/(12*one) );
2076  myA(3,2) = as<Scalar>( 5*one/(12*one) );
2077  myA(3,3) = as<Scalar>( one/(12*one) );
2078  myb(0) = as<Scalar>( one/(12*one) );
2079  myb(1) = as<Scalar>( 5*one/(12*one) );
2080  myb(2) = as<Scalar>( 5*one/(12*one) );
2081  myb(3) = as<Scalar>( one/(12*one) );
2082  myc(0) = zero;
2083  myc(1) = as<Scalar>( (5*one-ST::squareroot(5*one))/(10*one) );
2084  myc(2) = as<Scalar>( (5*one+ST::squareroot(5*one))/(10*one) );
2085  myc(3) = one;
2086  this->setMyDescription(myDescription.str());
2087  this->setMy_A(myA);
2088  this->setMy_b(myb);
2089  this->setMy_c(myc);
2090  this->setMy_order(6);
2091  }
2092 };
2093 
2094 
2095 
2096 template<class Scalar>
2097 class SDIRK5Stage5thOrder_RKBT :
2098  virtual public RKButcherTableauDefaultBase<Scalar>
2099 {
2100  public:
2101  SDIRK5Stage5thOrder_RKBT()
2102  {
2103 
2104  std::ostringstream myDescription;
2105  myDescription << SDIRK5Stage5thOrder_name() << "\n"
2106  << "A-stable\n"
2107  << "Solving Ordinary Differential Equations II:\n"
2108  << "Stiff and Differential-Algebraic Problems,\n"
2109  << "2nd Revised Edition\n"
2110  << "E. Hairer and G. Wanner\n"
2111  << "pg101 \n"
2112  << "c = [ (6-sqrt(6))/10 (6+9*sqrt(6))/35 1 (4-sqrt(6))/10 (4+sqrt(6))/10 ]'\n"
2113  << "A = [ (6-sqrt(6))/10 ]\n"
2114  << " [ (-6+5*sqrt(6))/14 (6-sqrt(6))/10 ]\n"
2115  << " [ (888+607*sqrt(6))/2850 (126-161*sqrt(6))/1425 (6-sqrt(6))/10 ]\n"
2116  << " [ (3153-3082*sqrt(6))/14250 (3213+1148*sqrt(6))/28500 (-267+88*sqrt(6))/500 (6-sqrt(6))/10 ]\n"
2117  << " [ (-32583+14638*sqrt(6))/71250 (-17199+364*sqrt(6))/142500 (1329-544*sqrt(6))/2500 (-96+131*sqrt(6))/625 (6-sqrt(6))/10 ]\n"
2118  << "b = [ 0 0 1/9 (16-sqrt(6))/36 (16+sqrt(6))/36 ]'" << std::endl;
2119  typedef ScalarTraits<Scalar> ST;
2120  int myNumStages = 5;
2121  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
2122  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
2123  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
2124  Scalar zero = ST::zero();
2125  Scalar one = ST::one();
2126  Scalar sqrt6 = ST::squareroot(as<Scalar>(6*one));
2127  Scalar gamma = as<Scalar>( (6*one - sqrt6) / (10*one) ); // diagonal
2128  myA(0,0) = gamma;
2129  myA(0,1) = zero;
2130  myA(0,2) = zero;
2131  myA(0,3) = zero;
2132  myA(0,4) = zero;
2133 
2134  myA(1,0) = as<Scalar>( (-6*one+5*one*sqrt6)/(14*one) );
2135  myA(1,1) = gamma;
2136  myA(1,2) = zero;
2137  myA(1,3) = zero;
2138  myA(1,4) = zero;
2139 
2140  myA(2,0) = as<Scalar>( (888*one+607*one*sqrt6)/(2850*one) );
2141  myA(2,1) = as<Scalar>( (126*one-161*one*sqrt6)/(1425*one) );
2142  myA(2,2) = gamma;
2143  myA(2,3) = zero;
2144  myA(2,4) = zero;
2145 
2146  myA(3,0) = as<Scalar>( (3153*one-3082*one*sqrt6)/(14250*one) );
2147  myA(3,1) = as<Scalar>( (3213*one+1148*one*sqrt6)/(28500*one) );
2148  myA(3,2) = as<Scalar>( (-267*one+88*one*sqrt6)/(500*one) );
2149  myA(3,3) = gamma;
2150  myA(3,4) = zero;
2151 
2152  myA(4,0) = as<Scalar>( (-32583*one+14638*one*sqrt6)/(71250*one) );
2153  myA(4,1) = as<Scalar>( (-17199*one+364*one*sqrt6)/(142500*one) );
2154  myA(4,2) = as<Scalar>( (1329*one-544*one*sqrt6)/(2500*one) );
2155  myA(4,3) = as<Scalar>( (-96*one+131*sqrt6)/(625*one) );
2156  myA(4,4) = gamma;
2157 
2158  myb(0) = zero;
2159  myb(1) = zero;
2160  myb(2) = as<Scalar>( one/(9*one) );
2161  myb(3) = as<Scalar>( (16*one-sqrt6)/(36*one) );
2162  myb(4) = as<Scalar>( (16*one+sqrt6)/(36*one) );
2163 
2164  myc(0) = gamma;
2165  myc(1) = as<Scalar>( (6*one+9*one*sqrt6)/(35*one) );
2166  myc(2) = one;
2167  myc(3) = as<Scalar>( (4*one-sqrt6)/(10*one) );
2168  myc(4) = as<Scalar>( (4*one+sqrt6)/(10*one) );
2169 
2170  this->setMyDescription(myDescription.str());
2171  this->setMy_A(myA);
2172  this->setMy_b(myb);
2173  this->setMy_c(myc);
2174  this->setMy_order(5);
2175  }
2176 };
2177 
2178 
2179 template<class Scalar>
2180 class SDIRK5Stage4thOrder_RKBT :
2181  virtual public RKButcherTableauDefaultBase<Scalar>
2182 {
2183  public:
2184  SDIRK5Stage4thOrder_RKBT()
2185  {
2186 
2187  std::ostringstream myDescription;
2188  myDescription << SDIRK5Stage4thOrder_name() << "\n"
2189  << "L-stable\n"
2190  << "Solving Ordinary Differential Equations II:\n"
2191  << "Stiff and Differential-Algebraic Problems,\n"
2192  << "2nd Revised Edition\n"
2193  << "E. Hairer and G. Wanner\n"
2194  << "pg100 \n"
2195  << "c = [ 1/4 3/4 11/20 1/2 1 ]'\n"
2196  << "A = [ 1/4 ]\n"
2197  << " [ 1/2 1/4 ]\n"
2198  << " [ 17/50 -1/25 1/4 ]\n"
2199  << " [ 371/1360 -137/2720 15/544 1/4 ]\n"
2200  << " [ 25/24 -49/48 125/16 -85/12 1/4 ]\n"
2201  << "b = [ 25/24 -49/48 125/16 -85/12 1/4 ]'\n"
2202  << "b' = [ 59/48 -17/96 225/32 -85/12 0 ]'" << std::endl;
2203  typedef ScalarTraits<Scalar> ST;
2204  int myNumStages = 5;
2205  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
2206  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
2207  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
2208  Scalar zero = ST::zero();
2209  Scalar one = ST::one();
2210  Scalar onequarter = as<Scalar>( one/(4*one) );
2211  myA(0,0) = onequarter;
2212  myA(0,1) = zero;
2213  myA(0,2) = zero;
2214  myA(0,3) = zero;
2215  myA(0,4) = zero;
2216 
2217  myA(1,0) = as<Scalar>( one / (2*one) );
2218  myA(1,1) = onequarter;
2219  myA(1,2) = zero;
2220  myA(1,3) = zero;
2221  myA(1,4) = zero;
2222 
2223  myA(2,0) = as<Scalar>( 17*one/(50*one) );
2224  myA(2,1) = as<Scalar>( -one/(25*one) );
2225  myA(2,2) = onequarter;
2226  myA(2,3) = zero;
2227  myA(2,4) = zero;
2228 
2229  myA(3,0) = as<Scalar>( 371*one/(1360*one) );
2230  myA(3,1) = as<Scalar>( -137*one/(2720*one) );
2231  myA(3,2) = as<Scalar>( 15*one/(544*one) );
2232  myA(3,3) = onequarter;
2233  myA(3,4) = zero;
2234 
2235  myA(4,0) = as<Scalar>( 25*one/(24*one) );
2236  myA(4,1) = as<Scalar>( -49*one/(48*one) );
2237  myA(4,2) = as<Scalar>( 125*one/(16*one) );
2238  myA(4,3) = as<Scalar>( -85*one/(12*one) );
2239  myA(4,4) = onequarter;
2240 
2241  myb(0) = as<Scalar>( 25*one/(24*one) );
2242  myb(1) = as<Scalar>( -49*one/(48*one) );
2243  myb(2) = as<Scalar>( 125*one/(16*one) );
2244  myb(3) = as<Scalar>( -85*one/(12*one) );
2245  myb(4) = onequarter;
2246 
2247  /*
2248  // Alternate version
2249  myb(0) = as<Scalar>( 59*one/(48*one) );
2250  myb(1) = as<Scalar>( -17*one/(96*one) );
2251  myb(2) = as<Scalar>( 225*one/(32*one) );
2252  myb(3) = as<Scalar>( -85*one/(12*one) );
2253  myb(4) = zero;
2254  */
2255  myc(0) = onequarter;
2256  myc(1) = as<Scalar>( 3*one/(4*one) );
2257  myc(2) = as<Scalar>( 11*one/(20*one) );
2258  myc(3) = as<Scalar>( one/(2*one) );
2259  myc(4) = one;
2260 
2261  this->setMyDescription(myDescription.str());
2262  this->setMy_A(myA);
2263  this->setMy_b(myb);
2264  this->setMy_c(myc);
2265  this->setMy_order(4);
2266  }
2267 };
2268 
2269 
2270 template<class Scalar>
2271 class SDIRK3Stage4thOrder_RKBT :
2272  virtual public RKButcherTableauDefaultBase<Scalar>
2273 {
2274  public:
2275  SDIRK3Stage4thOrder_RKBT()
2276  {
2277 
2278  std::ostringstream myDescription;
2279  myDescription << SDIRK3Stage4thOrder_name() << "\n"
2280  << "A-stable\n"
2281  << "Solving Ordinary Differential Equations II:\n"
2282  << "Stiff and Differential-Algebraic Problems,\n"
2283  << "2nd Revised Edition\n"
2284  << "E. Hairer and G. Wanner\n"
2285  << "pg100 \n"
2286  << "gamma = (1/sqrt(3))*cos(pi/18)+1/2\n"
2287  << "delta = 1/(6*(2*gamma-1)^2)\n"
2288  << "c = [ gamma 1/2 1-gamma ]'\n"
2289  << "A = [ gamma ]\n"
2290  << " [ 1/2-gamma gamma ]\n"
2291  << " [ 2*gamma 1-4*gamma gamma ]\n"
2292  << "b = [ delta 1-2*delta delta ]'" << std::endl;
2293  typedef ScalarTraits<Scalar> ST;
2294  int myNumStages = 3;
2295  Teuchos::SerialDenseMatrix<int,Scalar> myA(myNumStages,myNumStages);
2296  Teuchos::SerialDenseVector<int,Scalar> myb(myNumStages);
2297  Teuchos::SerialDenseVector<int,Scalar> myc(myNumStages);
2298  Scalar zero = ST::zero();
2299  Scalar one = ST::one();
2300  Scalar pi = as<Scalar>(4*one)*std::atan(one);
2301  Scalar gamma = as<Scalar>( one/ST::squareroot(3*one)*std::cos(pi/(18*one))+one/(2*one) );
2302  Scalar delta = as<Scalar>( one/(6*one*std::pow(2*gamma-one,2*one)) );
2303  myA(0,0) = gamma;
2304  myA(0,1) = zero;
2305  myA(0,2) = zero;
2306 
2307  myA(1,0) = as<Scalar>( one/(2*one) - gamma );
2308  myA(1,1) = gamma;
2309  myA(1,2) = zero;
2310 
2311  myA(2,0) = as<Scalar>( 2*gamma );
2312  myA(2,1) = as<Scalar>( one - 4*gamma );
2313  myA(2,2) = gamma;
2314 
2315  myb(0) = delta;
2316  myb(1) = as<Scalar>( one-2*delta );
2317  myb(2) = delta;
2318 
2319  myc(0) = gamma;
2320  myc(1) = as<Scalar>( one/(2*one) );
2321  myc(2) = as<Scalar>( one - gamma );
2322 
2323  this->setMyDescription(myDescription.str());
2324  this->setMy_A(myA);
2325  this->setMy_b(myb);
2326  this->setMy_c(myc);
2327  this->setMy_order(4);
2328  }
2329 };
2330 
2331 
2332 } // namespace Rythmos
2333 
2334 
2335 #endif // RYTHMOS_RK_BUTCHER_TABLEAU_HPP