Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_SET_CACHED_SOLUTION_VECTOR_H
00002 #define OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_SET_CACHED_SOLUTION_VECTOR_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/math_is_number.h>
00013
00014 namespace OpenTissue
00015 {
00016 namespace mbd
00017 {
00033 template<typename group_type,typename vector_type>
00034 void set_cached_solution_vector(
00035 group_type & group
00036 , size_t const & m
00037 , vector_type & x
00038 )
00039 {
00040 typedef typename group_type::math_policy math_policy;
00041 typedef typename group_type::indirect_constraint_iterator indirect_constraint_iterator;
00042 typedef typename group_type::indirect_contact_iterator indirect_contact_iterator;
00043 typedef typename vector_type::size_type size_type;
00044
00045 assert(x.size()==m || !"set_cached_solution(): wrong dimension");
00046
00047 for(indirect_constraint_iterator constraint = group.constraint_begin();constraint!=group.constraint_end();++constraint)
00048 {
00049 if(constraint->is_active())
00050 {
00051 size_type const start = constraint->get_jacobian_index();
00052 size_type const end = start + constraint->get_number_of_jacobian_rows();
00053 constraint->set_solution( math_policy::subrange( x,start,end ) );
00054 }
00055 }
00056 for(indirect_contact_iterator contact = group.contact_begin();contact!=group.contact_end();++contact)
00057 {
00058 if(contact->is_active())
00059 {
00060 size_type const start = contact->get_jacobian_index();
00061 size_type const end = start + contact->get_number_of_jacobian_rows();
00062 contact->set_solution( math_policy::subrange( x,start,end ) );
00063 }
00064 }
00065 }
00066
00067 }
00068 }
00069
00070 #endif