DUNE-FEM (unstable)

butchertable.hh
1#ifndef DUNE_FEM_SOLVER_RUNGEKUTTA_BUTCHERTABLE_HH
2#define DUNE_FEM_SOLVER_RUNGEKUTTA_BUTCHERTABLE_HH
3
4#include <algorithm>
5
8
9namespace DuneODE
10{
11
12 // SimpleButcherTable
13 // ------------------
14
15 template< class Field >
16 class SimpleButcherTable
17 {
18 typedef SimpleButcherTable< Field > This;
19
20 public:
21 typedef Field FieldType;
22
23 SimpleButcherTable ( int stages, int order, const FieldType *a, const FieldType *b, const FieldType *c )
24 : stages_( stages ), order_( order ),
25 a_( a ), b_( b ), c_( c )
26 {}
27
28 Dune::DynamicMatrix< FieldType > A () const { return makeMatrix( stages_, stages_, a_ ); }
29 Dune::DynamicVector< FieldType > b () const { return makeVector( stages_, b_ ); }
30 Dune::DynamicVector< FieldType > c () const { return makeVector( stages_, c_ ); }
31
32 int order () const { return order_; }
33 int stages () const { return stages_; }
34
35 protected:
36 static Dune::DynamicMatrix< FieldType > makeMatrix ( int m, int n, const FieldType *data )
37 {
39 for( int i = 0; i < m; ++i )
40 std::copy( data + i*n, data + (i+1)*n, A[ i ].begin() );
41 return A;
42 }
43
44 static Dune::DynamicVector< FieldType > makeVector ( int n, const FieldType *data )
45 {
47 std::copy( data, data + n, v.begin() );
48 return v;
49 }
50
51 int stages_, order_;
52 const FieldType *a_, *b_, *c_;
53 };
54
55
56
57 // explicit butcher tables
58 // -----------------------
59 SimpleButcherTable< double > explicitEulerButcherTable ();
60 SimpleButcherTable< double > tvd2ButcherTable ();
61 SimpleButcherTable< double > tvd3ButcherTable ();
62 SimpleButcherTable< double > rk4ButcherTable ();
63 SimpleButcherTable< double > expl6ButcherTable ();
64
65 // implicit butcher tables
66 // -----------------------
67
68 SimpleButcherTable< double > implicit34ButcherTable ();
69 SimpleButcherTable< double > implicit3ButcherTable ();
70 SimpleButcherTable< double > implicitEulerButcherTable ();
71 SimpleButcherTable< double > gauss2ButcherTable ();
72
73
74
75 // semiimplicit butcher tables
76 // ---------------------------
77
78 SimpleButcherTable< double > semiImplicitEulerButcherTable ( bool expl );
79 SimpleButcherTable< double > semiImplicit23ButcherTable ( bool expl );
80 SimpleButcherTable< double > semiImplicit33ButcherTable ( bool expl );
81 SimpleButcherTable< double > semiImplicitSSP222ButcherTable ( bool expl );
82 SimpleButcherTable< double > semiImplicitARK34ButcherTable ( bool expl );
83 SimpleButcherTable< double > semiImplicitARK46ButcherTable ( bool expl );
84 SimpleButcherTable< double > semiImplicitIERK45ButcherTable ( bool expl );
85
86 // ROW butcher tables
87 // -----------------------
88
89 template< class Field >
90 class ROWSimpleButcherTable : public SimpleButcherTable<Field>
91 {
92 typedef ROWSimpleButcherTable< Field > This;
93 typedef SimpleButcherTable< Field > Base;
94
95 public:
96 typedef Field FieldType;
97
98 ROWSimpleButcherTable ( int stages, int order, const FieldType *a, const FieldType *b, const FieldType *c, const FieldType *a2 )
99 : Base(stages,order,a,b,c)
100 , a2_(a2)
101 {}
102
103 Dune::DynamicMatrix< FieldType > B () const { return Base::makeMatrix( stages_, stages_, a2_ ); }
104
105 private:
106 using Base::stages_;
107 const FieldType *a2_;
108 };
109 ROWSimpleButcherTable< double > row2ButcherTable ();
110 ROWSimpleButcherTable< double > row3ButcherTable ();
111} // namespace DuneODE
112
113#endif // #ifndef DUNE_FEM_SOLVER_RUNGEKUTTA_BUTCHERTABLE_HH
Construct a matrix with a dynamic size.
Definition: dynmatrix.hh:61
Construct a vector with a dynamic size.
Definition: dynvector.hh:59
This file implements a dense matrix with dynamic numbers of rows and columns.
This file implements a dense vector with a dynamic size.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)