00001 #ifndef OPENTISSUE_DYNAMICS_MBD_UTIL_STEPPERS_MBD_DYNAMICS_PROJECTION_STEPPER_H 00002 #define OPENTISSUE_DYNAMICS_MBD_UTIL_STEPPERS_MBD_DYNAMICS_PROJECTION_STEPPER_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_stepper_interface.h> 00013 #include <OpenTissue/dynamics/mbd/steppers/mbd_dynamics_stepper.h> 00014 #include <OpenTissue/dynamics/mbd/steppers/mbd_first_order_stepper.h> 00015 00016 namespace OpenTissue 00017 { 00018 00019 namespace mbd 00020 { 00025 template< typename mbd_types, typename solver_type > 00026 class DynamicsProjectionStepper 00027 : public StepperInterface<mbd_types> 00028 { 00029 protected: 00030 00031 typedef typename mbd_types::math_policy::real_type real_type; 00032 typedef typename mbd_types::math_policy::vector3_type vector3_type; 00033 typedef typename mbd_types::math_policy::vector_type vector_type; 00034 typedef typename mbd_types::math_policy::idx_vector_type idx_vector_type; 00035 typedef typename mbd_types::group_type group_type; 00036 typedef typename mbd_types::math_policy::index_type size_type; 00037 00038 typedef DynamicsStepper<mbd_types,solver_type> dynamics_algorithm; 00039 typedef FirstOrderStepper<mbd_types,solver_type> error_correction_algorithm; 00040 00041 protected: 00042 00043 dynamics_algorithm m_dynamics; 00044 error_correction_algorithm m_correction; 00045 00046 public: 00047 00048 class node_traits 00049 : public dynamics_algorithm::node_traits 00050 , public error_correction_algorithm::node_traits 00051 {}; 00052 00053 class edge_traits 00054 : public dynamics_algorithm::edge_traits 00055 , public error_correction_algorithm::edge_traits 00056 {}; 00057 00058 class constraint_traits 00059 : public dynamics_algorithm::constraint_traits 00060 , public error_correction_algorithm::constraint_traits 00061 {}; 00062 00063 public: 00064 00065 DynamicsProjectionStepper() 00066 { 00067 // Setup the dynamics stepper 00068 m_dynamics.warm_starting() = false; 00069 m_dynamics.use_stabilization() = false; 00070 m_dynamics.use_friction() = true; 00071 m_dynamics.use_bounce() = true; 00072 m_dynamics.get_solver()->set_max_iterations(10); 00073 00074 // Setup the error correction stepper 00075 m_correction.warm_starting() = false; 00076 m_correction.use_external_forces() = false; 00077 m_correction.use_erp() = false; 00078 m_correction.get_solver()->set_max_iterations(10); 00079 } 00080 00081 virtual ~DynamicsProjectionStepper(){} 00082 00083 public: 00084 00085 void run(group_type & group,real_type const & time_step) 00086 { 00087 m_dynamics.run(group,time_step); 00088 m_correction.error_correction(group); 00089 } 00090 00091 void error_correction(group_type & group) 00092 { 00093 m_correction.error_correction(group); 00094 } 00095 00096 void resolve_collisions(group_type & group) 00097 { 00098 m_dynamics.resolve_collisions(group); 00099 } 00100 00101 }; 00102 00103 } // namespace mbd 00104 } // namespace OpenTissue 00105 // OPENTISSUE_DYNAMICS_MBD_UTIL_STEPPERS_MBD_DYNAMICS_PROJECTION_STEPPER_H 00106 #endif