Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_FEM_FEM_STIFFNESS_ASSEMBLY_H
00002 #define OPENTISSUE_DYNAMICS_FEM_FEM_STIFFNESS_ASSEMBLY_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace fem
00015 {
00016 namespace detail
00017 {
00171 template<typename tetrahedron_iterator>
00172 inline void stiffness_assembly(tetrahedron_iterator const & begin, tetrahedron_iterator const & end)
00173 {
00174 typedef typename tetrahedron_iterator::value_type::real_type real_type;
00175 typedef typename tetrahedron_iterator::value_type::vector3_type vector3_type;
00176 typedef typename tetrahedron_iterator::value_type::matrix3x3_type matrix3x3_type;
00177 typedef typename tetrahedron_iterator::value_type::node_iterator node_iterator;
00178
00179 for(tetrahedron_iterator T = begin;T!=end;++T)
00180 {
00181 matrix3x3_type & Re = T->m_Re;
00182 for (int i = 0; i < 4; ++i)
00183 {
00184 node_iterator p_i = T->node(i);
00185 vector3_type f;
00186 f.clear();
00187 for (int j = 0; j < 4; ++j)
00188 {
00189 node_iterator p_j = T->node(j);
00190 matrix3x3_type & Ke_ij = T->m_Ke[i][j];
00191 vector3_type & x0_j = p_j->m_model_coord;
00192
00193 f += Ke_ij * x0_j;
00194 if (j >= i)
00195 {
00196
00197 matrix3x3_type tmp = Re * Ke_ij * trans(Re);
00198
00199 p_i->K(p_j->idx()) += tmp;
00200 if (j > i)
00201 p_j->K(p_i->idx()) += trans(tmp);
00202 }
00203 }
00204
00205 p_i->m_f0 -= Re*f;
00206
00207 }
00208 }
00209 }
00210
00211 }
00212 }
00213 }
00214
00215
00216 #endif