6#include <unordered_map>
30template<
class real_type>
47 m_a(
a,
a+s*s), m_b(
b,
b+s), m_c(
c,
c+s), m_bt(
b,
b+s), m_q(
order), m_p(
order), m_s(s){}
60 m_a(
a,
a+s*s), m_b(
b,
b+s), m_c(
c,
c+s), m_bt(
bt,
bt+s), m_q(
order), m_p(
embedded_order), m_s(s), m_embedded(true){}
77 real_type
c(
unsigned i)
const {
116 for(
unsigned i=0; i<m_s; i++)
117 for(
unsigned j=i; j<m_s; j++)
134 std::vector<function_type> m_b;
135 std::vector<real_type> m_c;
136 std::vector<function_type> m_bt;
137 unsigned m_q, m_p, m_s;
138 bool m_embedded =
false;
142namespace func_tableau{
146template<
class real_type>
147FunctionalButcherTableau<real_type> explicit_euler_1_1( )
149 auto zero = [&](real_type){
return 0;};
150 using function_type = std::function<real_type(real_type)>;
151 function_type a[1] = {
zero};
152 function_type b[1] = {[&](real_type
x){
return dg::mat::phi1(x);}};
153 real_type c[1] = {0.};
154 return FunctionalButcherTableau<real_type>( 1,1, a,b,c);
156template<
class real_type>
157FunctionalButcherTableau<real_type> midpoint_2_2()
159 auto zero = [&](real_type){
return 0;};
160 using function_type = std::function<real_type(real_type)>;
164 function_type b[2] = {
zero,
166 real_type c[2] = {0, 0.5};
167 return FunctionalButcherTableau<real_type>( 2,2, a,b,c);
169template<
class real_type>
170FunctionalButcherTableau<real_type> classic_4_4()
172 auto zero = [&](real_type){
return 0;};
173 using function_type = std::function<real_type(real_type)>;
174 function_type a[16] = {
180 function_type b[4] = {
186 real_type c[4] = {0, 0.5, 0.5, 1.};
187 return FunctionalButcherTableau<real_type>( 4,4, a,b,c);
189template<
class real_type>
190FunctionalButcherTableau<real_type> hochbruck_3_3_4()
192 auto zero = [&](real_type){
return 0;};
193 using function_type = std::function<real_type(real_type)>;
194 function_type a[9] = {
199 function_type b[3] = {
204 function_type bt[3] = {
209 real_type c[3] = {0, 0.5, 1.};
210 return FunctionalButcherTableau<real_type>( 3,3,4, a,b,bt,c);
229enum func_tableau_identifier{
239static std::unordered_map<std::string, enum func_tableau_identifier> str2id{
244 {
"Hochbruck-3-3-4", HOCHBRUCK_3_3_4},
246static inline enum func_tableau_identifier str2func_tableau( std::string name)
248 if( str2id.find(name) == str2id.end())
253static inline std::string func_tableau2str(
enum func_tableau_identifier
id)
255 for(
auto name: str2id)
257 if( name.second ==
id)
263template<
class real_type>
264FunctionalButcherTableau<real_type> func_tableau(
enum func_tableau_identifier
id)
268 return func_tableau::explicit_euler_1_1<real_type>();
270 return func_tableau::midpoint_2_2<real_type>();
272 return func_tableau::classic_4_4<real_type>();
273 case HOCHBRUCK_3_3_4:
274 return func_tableau::hochbruck_3_3_4<real_type>();
276 return FunctionalButcherTableau<real_type>();
280template<
class real_type>
281FunctionalButcherTableau<real_type> func_tableau( std::string name)
283 return func_tableau<real_type>( str2func_tableau(name));
321template<
class real_type>
static DG_DEVICE double zero(double x)
T phi1(T x)
Definition: functors.h:56
T phi3(T x)
Definition: functors.h:86
T phi4(T x)
Definition: functors.h:100
T phi2(T x)
Definition: functors.h:71
Classes for Krylov space approximations of a Matrix-Vector product.
Convert identifiers to their corresponding dg::mat::FunctionalButcherTableau.
Definition: tableau.h:323
ConvertsToFunctionalButcherTableau(enum tableau_identifier id)
Create FunctionalButcherTableau from dg::mat::func_tableau_identifier.
Definition: tableau.h:334
ConvertsToFunctionalButcherTableau(FunctionalButcherTableau< real_type > tableau)
Definition: tableau.h:327
real_type value_type
Definition: tableau.h:324
ConvertsToFunctionalButcherTableau(const char *name)
Create FunctionalButcherTableau from its name (very useful)
Definition: tableau.h:345
ConvertsToFunctionalButcherTableau(std::string name)
Create FunctionalButcherTableau from its name (very useful)
Definition: tableau.h:343
Manage coefficients of a functional (extended) Butcher tableau.
Definition: tableau.h:31
unsigned num_stages() const
The number of stages s.
Definition: tableau.h:99
unsigned order() const
global order of accuracy for the method represented by b
Definition: tableau.h:103
FunctionalButcherTableau(unsigned s, unsigned order, const function_type *a, const function_type *b, const real_type *c)
Construct a classic non-embedded tableau.
Definition: tableau.h:45
real_type c(unsigned i) const
Read the c_i coefficients.
Definition: tableau.h:77
bool isImplicit() const
True if an element on or above the diagonal in a is non-zero.
Definition: tableau.h:115
function_type bt(unsigned j) const
Read the embedded bt_j coefficients.
Definition: tableau.h:95
function_type a(unsigned i, unsigned j) const
Read the a_ij coefficients.
Definition: tableau.h:69
FunctionalButcherTableau()=default
No memory allocation.
FunctionalButcherTableau(unsigned s, unsigned embedded_order, unsigned order, const function_type *a, const function_type *b, const function_type *bt, const real_type *c)
Construct an embedded tableau.
Definition: tableau.h:58
real_type value_type
Definition: tableau.h:32
std::function< value_type(value_type)> function_type
Definition: tableau.h:33
bool isEmbedded() const
True if the method has an embedding.
Definition: tableau.h:111
unsigned embedded_order() const
global order of accuracy for the embedded method represented by bt
Definition: tableau.h:107
function_type b(unsigned j) const
Read the b_j coefficients.
Definition: tableau.h:86