Geomi
Factory.hpp
1 #ifndef DEF_RKMK_FACTORY
2 #define DEF_RKMK_FACTORY
3 
4 //#include "RKMK_Abstract_Integrator.hpp"
5 //#include "RKMK_ExplicitStep.hpp"
6 //#include "RKMK_DiagonalStep.hpp"
7 
8 namespace RKMK {
9 
23 template <typename T_LIE_ALGEBRA, typename T_M = double>
24 class Factory
25 {
26 public:
27  static Abstract::Integrator&
28  createIntegrator (Abstract::Problem<T_LIE_ALGEBRA,T_M>& problem, std::string s)
29  {
30  Abstract::Integrator* integrator = NULL;
31 
32  if (s=="Explicit Euler") {
33  double a[] = { 0.0 };
34  double b[] = { 1.0 };
35  std::vector<double> va(a,a+sizeof(a)/sizeof(double));
36  std::vector<double> vb(b,b+sizeof(b)/sizeof(double));
38  integrator = new Integrator<T_LIE_ALGEBRA,1,T_M>(problem, *step);
39  integrator->setCoeffs(va,vb);
40  }
41  else if (s=="Implicit Euler") {
42  double a[] = { 1.0 };
43  double b[] = { 1.0 };
44  std::vector<double> va(a,a+sizeof(a)/sizeof(double));
45  std::vector<double> vb(b,b+sizeof(b)/sizeof(double));
47  integrator = new Integrator<T_LIE_ALGEBRA,1,T_M>(problem, *step);
48  integrator->setCoeffs(va,vb);
49  }
50  else if (s=="Midpoint") {
51  double a[] = { 0.5 };
52  double b[] = { 1.0 };
53  std::vector<double> va(a,a+sizeof(a)/sizeof(double));
54  std::vector<double> vb(b,b+sizeof(b)/sizeof(double));
56  integrator = new Integrator<T_LIE_ALGEBRA,1,T_M>(problem, *step);
57  integrator->setCoeffs(va,vb);
58  }
59  else if (s=="RK 4") {
60  double a[] = { 0.0,0.0,0.0,0.0, 0.5,0.0,0.0,0.0, 0.0,0.5,0.0,0.0, 0.0,0.0,1.0,0.0 };
61  double b[] = { 1.0/6.0,2.0/6.0,2.0/6.0,1.0/6.0 };
62  std::vector<double> va(a,a+sizeof(a)/sizeof(double));
63  std::vector<double> vb(b,b+sizeof(b)/sizeof(double));
65  integrator = new Integrator<T_LIE_ALGEBRA,4,T_M>(problem, *step);
66  integrator->setCoeffs(va,vb);
67  }
68 
69  return *integrator;
70  }
71 };
72 
73 } // namespace RKMK
74 
75 #endif
Definition: Abstract_Problem.hpp:10
Definition: Abstract_Integrator.hpp:51
Definition: Abstract_Integrator.hpp:4
Definition: Abstract_Integrator.hpp:11
Definition: DiagonalStep.hpp:25
Definition: Factory.hpp:24
Definition: ExplicitStep.hpp:15