00001 #ifndef OPENTISSUE_DYNAMICS_MBD_MBD_CONSTRAINT_INTERFACE_H 00002 #define OPENTISSUE_DYNAMICS_MBD_MBD_CONSTRAINT_INTERFACE_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_core_constraint_interface.h> 00013 00014 namespace OpenTissue 00015 { 00016 namespace mbd 00017 { 00027 template< typename mbd_types > 00028 class ConstraintInterface : public CoreConstraintInterface<mbd_types> 00029 { 00030 public: 00031 00032 typedef typename mbd_types::body_type body_type; 00033 typedef typename mbd_types::math_policy::size_type size_type; 00034 typedef typename mbd_types::math_policy::real_type real_type; 00035 typedef typename mbd_types::math_policy::vector_range vector_range; 00036 typedef typename mbd_types::math_policy::idx_vector_range idx_vector_range; 00037 typedef typename mbd_types::math_policy::matrix_range matrix_range; 00038 00039 protected: 00040 00041 body_type * m_bodyA; 00042 body_type * m_bodyB; 00043 size_type m_jacobian_idx; 00044 00045 public: 00046 00047 ConstraintInterface() 00048 : m_bodyA(0) 00049 , m_bodyB(0) 00050 , m_jacobian_idx(0u) 00051 {} 00052 00053 virtual ~ConstraintInterface(){} 00054 00055 public: 00056 00062 body_type * get_body_A() const { return m_bodyA; } 00063 00069 body_type * get_body_B() const { return m_bodyB; } 00070 00078 void set_jacobian_index(size_type const & idx) 00079 { 00080 assert(idx>=0u || !"ConstraintInterface::set_jacobian_idx(): idx must be non-negative"); 00081 m_jacobian_idx = idx; 00082 } 00083 00090 size_type const & get_jacobian_index() const { return m_jacobian_idx; } 00091 00092 public: 00093 00106 virtual void evaluate() = 0; 00107 00115 virtual void get_linear_jacobian_A(matrix_range & J) const = 0; 00116 00124 virtual void get_linear_jacobian_B(matrix_range & J) const = 0; 00125 00133 virtual void get_angular_jacobian_A(matrix_range & J) const = 0; 00134 00142 virtual void get_angular_jacobian_B(matrix_range & J) const = 0; 00143 00152 virtual void get_stabilization_term(vector_range & b_error) const = 0; 00153 00161 virtual void get_low_limits(vector_range & lo) const = 0; 00162 00170 virtual void get_high_limits(vector_range & hi) const = 0; 00171 00193 virtual void get_dependency_indices(idx_vector_range & dep) const = 0; 00194 00209 virtual void get_dependency_factors(vector_range & factors) const = 0; 00210 00221 virtual void set_regularization(vector_range const & gamma) = 0; 00222 00230 virtual void get_regularization(vector_range & gamma) const = 0; 00231 00239 virtual void set_solution(vector_range const & solution) = 0; 00240 00248 virtual void get_solution(vector_range & solution) const = 0; 00249 00250 }; 00251 00252 } // namespace mbd 00253 } // namespace OpenTissue 00254 // OPENTISSUE_DYNAMICS_MBD_MBD_CONSTRAINT_INTERFACE_H 00255 #endif