Geomi
MidpointStepInternals.hpp
1 #ifndef DEF_VARIATIONAL_MIDPOINTSTEPINTERNALS
2 #define DEF_VARIATIONAL_MIDPOINTSTEPINTERNALS
3 
4 #include <vector>
5 
6 namespace Variational {
7 
8 template <typename T_M,
9  typename T_Q,
10  typename T_TQ>
11 class MidpointStepInternals : public Abstract::StepInternals<T_M,T_Q,T_TQ>, public ::Abstract::NOXStep<T_Q,1>
12 {
13 public:
16  { }
17 
19  getInitialGuess ()
20  {
21  NOXVector<T_Q::DOF> ret((1.0+1.0/this->m_h)*this->m_q1-(1.0/this->m_h)*this->m_q0);
22  return ret;
23  }
24 
25  bool
26  computeF (NOXVector<T_Q::DOF>& f, const NOXVector<T_Q::DOF>& q)
27  {
28  std::cout << "q0+q1/2 = \n" << (this->m_q0+this->m_q1)/2.0 << std::endl;
29  std::cout << "q1-q0/h = \n" << (this->m_q1-this->m_q0)/this->m_h << std::endl;
30  std::cout << "q1+q/2 = \n" << (this->m_q1+q)/2.0 << std::endl;
31  std::cout << "q-q1/h = \n" << (q-this->m_q1)/this->m_h << std::endl;
32  f = (this->m_h/2.0) * this->m_problem.dLdq((this->m_q0+this->m_q1)/2.0,(this->m_q1-this->m_q0)/this->m_h)
33  + this->m_problem.dLdv((this->m_q0+this->m_q1)/2.0,(this->m_q1-this->m_q0)/this->m_h)
34  + (this->m_h/2.0) * this->m_problem.dLdq((this->m_q1+q)/2.0,(q-this->m_q1)/this->m_h)
35  - this->m_problem.dLdv((this->m_q1+q)/2.0,(q-this->m_q1)/this->m_h);
36  return true;
37  }
38 
39  bool
40  computeJacobian (Eigen::Matrix<double,T_Q::DOF,T_Q::DOF>& J, const NOXVector<T_Q::DOF>& q)
41  {
42  NOXVector<T_Q::DOF> pos = (q+this->m_q1)/2.0;
43  NOXVector<T_Q::DOF> vel = (q-this->m_q1)/this->m_h;
44  J = (this->m_h/4.0) * this->m_problem.JqdLdq(pos,vel)
45  + this->m_problem.JvdLdq(pos,vel)/2.0
46  - this->m_problem.JqdLdv(pos,vel)/2.0
47  - this->m_problem.JvdLdv(pos,vel)/this->m_h;
48  return true;
49  }
50 };
51 } // namespace Variational
52 
53 #endif
Definition: MidpointStepInternals.hpp:11
Definition: Abstract_Problem.hpp:10
Definition: Abstract_LieProblem.hpp:6
Definition: Abstract_StepInternals.hpp:13
Definition: NOXVector.hpp:14
Definition: Abstract_NOXStep.hpp:12