Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_COMPUTE_KINETIC_ENERGY_VECTOR_H
00002 #define OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_COMPUTE_KINETIC_ENERGY_VECTOR_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace mbd
00015 {
00030 template< typename indirect_body_iterator,typename vector_type>
00031 void compute_kinetic_energy_vector(indirect_body_iterator begin, indirect_body_iterator end, vector_type & energy)
00032 {
00033 typedef typename indirect_body_iterator::value_type body_type;
00034 typedef typename body_type::math_policy math_policy;
00035 typedef typename vector_type::size_type size_type;
00036
00037 size_type n = std::distance(begin,end);
00038
00039 math_policy::resize( energy, n);
00040
00041 size_type i = 0;
00042 for(indirect_body_iterator body=begin;body!=end;++body,++i)
00043 energy(i) = body->compute_kinetic_energy();
00044 }
00045
00046 }
00047 }
00048
00049
00050 #endif