Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_MBD_UTIL_SIMULATORS_MBD_SEMI_IMPLICIT_FIXED_STEP_SIMULATOR_H
00002 #define OPENTISSUE_DYNAMICS_MBD_UTIL_SIMULATORS_MBD_SEMI_IMPLICIT_FIXED_STEP_SIMULATOR_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/dynamics/mbd/interfaces/mbd_simulator_interface.h>
00013
00014 namespace OpenTissue
00015 {
00016 namespace mbd
00017 {
00023 template< typename mbd_types >
00024 class SemiImplicitFixedStepSimulator
00025 : public SimulatorInterface<mbd_types>
00026 {
00027 protected:
00028
00029 typedef typename mbd_types::math_policy::real_type real_type;
00030 typedef typename mbd_types::math_policy::vector_type vector_type;
00031 typedef typename mbd_types::group_type group_type;
00032 typedef typename mbd_types::group_ptr_container group_ptr_container;
00033
00034 public:
00035
00036 class node_traits{};
00037 class edge_traits{};
00038 class constraint_traits{};
00039
00040 protected:
00041
00042 vector_type m_s;
00043 vector_type m_ss;
00044 vector_type m_u;
00045 vector_type m_uu;
00046 vector_type m_F;
00047 group_type * m_all;
00048 group_ptr_container m_groups;
00049
00050 public:
00051
00052 SemiImplicitFixedStepSimulator(){}
00053
00054 virtual ~SemiImplicitFixedStepSimulator(){}
00055
00056 public:
00057
00058 void run(real_type const & time_step)
00059 {
00060 m_all = this->get_configuration()->get_all_body_group();
00061
00062 mbd::compute_scripted_motions(*m_all,this->time());
00063 mbd::get_position_vector(*m_all, m_s);
00064 mbd::get_velocity_vector(*m_all, m_u);
00065
00066
00067 mbd::compute_position_update(*m_all,m_s,m_u,time_step,m_ss);
00068 mbd::set_position_vector(*m_all,m_ss);
00069
00070 this->get_collision_detection()->run( m_groups );
00071 for(typename group_ptr_container::iterator tmp=m_groups.begin();tmp!=m_groups.end();++tmp)
00072 {
00073 group_type * group = (*tmp);
00074 this->get_sleepy()->evaluate(group->body_begin(),group->body_end());
00075 if(!mbd::is_all_bodies_sleepy(*group))
00076 this->get_stepper()->run(*group,time_step);
00077 }
00078 mbd::get_velocity_vector(*m_all, m_u);
00079 mbd::compute_position_update(*m_all,m_s,m_u,time_step,m_ss);
00080 mbd::set_position_vector(*m_all,m_ss);
00081 mbd::compute_scripted_motions(*m_all,this->time() + time_step);
00082
00083 update_time(time_step);
00084 }
00085
00086 };
00087
00088 }
00089 }
00090
00091 #endif