00001 #ifndef OPENTISSUE_DYNAMICS_MBD_SIMULATORS_MBD_EXPLICIT_SEPARATE_ERROR_CORRECTION_FIXED_STEP_SIMULATOR_H 00002 #define OPENTISSUE_DYNAMICS_MBD_SIMULATORS_MBD_EXPLICIT_SEPARATE_ERROR_CORRECTION_FIXED_STEP_SIMULATOR_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 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 { 00025 template< typename mbd_types > 00026 class ExplicitSeparateErrorCorrectionFixedStepSimulator 00027 : public SimulatorInterface<mbd_types> 00028 { 00029 protected: 00030 00031 typedef typename mbd_types::math_policy::real_type real_type; 00032 typedef typename mbd_types::math_policy::vector_type vector_type; 00033 typedef typename mbd_types::group_type group_type; 00034 typedef typename mbd_types::group_ptr_container group_ptr_container; 00035 00036 public: 00037 00038 class node_traits{}; 00039 class edge_traits{}; 00040 class constraint_traits{}; 00041 00042 protected: 00043 00044 group_ptr_container m_groups; 00045 00046 public: 00047 00048 ExplicitSeparateErrorCorrectionFixedStepSimulator(){} 00049 00050 virtual ~ExplicitSeparateErrorCorrectionFixedStepSimulator(){} 00051 00052 public: 00053 00054 void run(real_type const & time_step) 00055 { 00056 mbd::compute_scripted_motions(*(this->get_configuration()->get_all_body_group()),this->time()); 00057 00058 this->get_collision_detection()->run( m_groups ); 00059 00060 for(typename group_ptr_container::iterator tmp=m_groups.begin();tmp!=m_groups.end();++tmp) 00061 { 00062 group_type * group = (*tmp); 00063 this->get_sleepy()->evaluate(group->body_begin(),group->body_end()); 00064 if(!mbd::is_all_bodies_sleepy(*group)) 00065 this->get_stepper()->run(*group,time_step); 00066 } 00067 //--- Anti rippling...! 00068 this->get_collision_detection()->run( m_groups ); 00069 for(typename group_ptr_container::iterator tmp=m_groups.begin();tmp!=m_groups.end();++tmp) 00070 { 00071 group_type * group = (*tmp); 00072 this->get_stepper()->error_correction(*group); 00073 } 00074 update_time(time_step); 00075 } 00076 00077 }; 00078 00079 } // namespace mbd 00080 } // namespace OpenTissue 00081 // OPENTISSUE_DYNAMICS_MBD_SIMULATORS_MBD_EXPLICIT_SEPARATE_ERROR_CORRECTION_FIXED_STEP_SIMULATOR_H 00082 #endif