Geomi
Integrator.hpp
1 #ifndef DEF_VARIATIONAL_INTEGRATOR
2 #define DEF_VARIATIONAL_INTEGRATOR
3 
4 #include <iostream>
5 #include <cmath>
6 #include <vector>
7 #include <typeinfo> // ??
8 
9 #include <gsl/gsl_vector.h>
10 #include <gsl/gsl_multiroots.h>
11 
12 
13 namespace Variational {
14 namespace Abstract {
15 
21 {
22 public:
23  virtual bool
24  integrate () = 0;
25 
26  virtual void
27  initialize () = 0;
28 };
29 } // namespace Abstract
30 } // namespace Variational
31 
32 namespace Variational {
33 
34 template <typename T_M,
35  typename T_Q,
36  typename T_INTERNALS,
37  typename T_PROBLEM,
38  typename T_TQ = T_Q>
40 {
41 private:
42  T_PROBLEM& m_problem;
44 
45 public:
48  : m_problem(problem), m_step(step)
49  { }
50 
52  { }
53 
54  // is supposed to do nothing for 1 step methods
55  void
56  initialize (void)
57  {
58  /* Achtung ! On suppose que pos(0) et pos(1) sont initialisés */
59  int i;
60  bool success = false;
61 
62  T_Q q0 = m_problem.pos(0);
63  T_Q q1 = m_problem.pos(1);
64  double h = m_problem.base(1)-m_problem.base(0);
65 
66  m_step.setData(h,q0,q1);
67 
68  m_step.initialize();
69  }
70 
71  bool
72  integrate (void)
73  {
74  /* Achtung ! On suppose que pos(0) et pos(1) sont initialisés */
75  int i;
76  bool success = false;
77  double h;
78  int n_steps = m_problem.size();
79  T_Q q0, q1;
80 
81  for (i=0; i<n_steps-2; i++) {
82  q0 = m_problem.pos(i);
83  q1 = m_problem.pos(i+1);
84  h = m_problem.base(i+1)-m_problem.base(i);
85  m_step.setData(h,q0,q1);
86 
87  q1 = m_step.makeStep();
88  m_problem.pos(i+2,q1);
89  }
90 
91  return success;
92  }
93 };
94 } // namespace Variational
95 
96 #endif
Definition: Abstract_Step.hpp:12
Definition: Integrator.hpp:39
Definition: Abstract_LieProblem.hpp:6
Definition: Integrator.hpp:20
Definition: Abstract_NOXStep.hpp:9