Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_FEM_FEM_EXPORT_K_H
00002 #define OPENTISSUE_DYNAMICS_FEM_FEM_EXPORT_K_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace fem
00015 {
00023 template<typename fem_mesh,typename matrix_type>
00024 inline void export_K(fem_mesh & mesh,matrix_type & bigK)
00025 {
00026 typedef typename fem_mesh::real_type real_type;
00027 typedef typename fem_mesh::vector3_type vector3_type;
00028 typedef typename fem_mesh::matrix3x3_type matrix3x3_type;
00029 typedef typename fem_mesh::node_iterator node_iterator;
00030 typedef typename fem_mesh::node_type::matrix_iterator matrix_iterator;
00031
00032 unsigned int N = mesh.size_nodes();
00033 bigK.resize(N*3,N*3, false );
00034 bigK.clear();
00035
00036 unsigned int row = 0;
00037 for(unsigned int i=0;i<N;++i)
00038 {
00039 node_iterator n_i = mesh.node(i);
00040 for(unsigned int r=0;r<3;++r,++row)
00041 {
00042 if(n_i->m_fixed)
00043 {
00044 bigK.push_back(row ,row, 1.0);
00045 }
00046 else
00047 {
00048 matrix_iterator Kbegin = n_i->Kbegin();
00049 matrix_iterator Kend = n_i->Kend();
00050 for (matrix_iterator K = Kbegin; K != Kend;++K)
00051 {
00052 unsigned int j = K->first;
00053 node_iterator n_j = mesh.node(j);
00054
00055 if(n_j->m_fixed)
00056 continue;
00057
00058 matrix3x3_type & K_ij = K->second;
00059
00060 unsigned int column = j*3;
00061 for(unsigned int c=0;c<3;++c)
00062 bigK.push_back(row,column + c, K_ij(r,c));
00063 }
00064 }
00065 }
00066
00067 }
00068 }
00069
00070 }
00071 }
00072
00073
00074 #endif