Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_FEM_FEM_ADD_PLASTICITY_FORCE_H
00002 #define OPENTISSUE_DYNAMICS_FEM_FEM_ADD_PLASTICITY_FORCE_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 {
00026 template < typename tetrahedron_iterator,typename real_type >
00027 inline void add_plasticity_force(
00028 tetrahedron_iterator begin
00029 , tetrahedron_iterator end
00030 , real_type const & dt
00031 )
00032 {
00033 using std::min;
00034 using std::sqrt;
00035
00036 typedef typename tetrahedron_iterator::value_type::vector3_type vector3_type;
00037
00038
00039
00040
00041
00042 assert(dt>0 || !"add_plasticity_force(): time-step must be positive");
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 for (tetrahedron_iterator T = begin; T != end; ++T)
00076 {
00077
00078 assert(T->m_yield>=0 || !"add_plasticity_force(): yield must be non-negative");
00079 assert(T->m_creep>=0 || !"add_plasticity_force(): creep must be non-negative");
00080 assert(T->m_creep<=(1.0/dt) || !"add_plasticity_force(): creep must be less that reciprocal time-step");
00081 assert(T->m_max>=0 || !"add_plasticity_force(): max must be non-negative");
00082
00083
00084 real_type e_total[6];
00085 real_type e_elastic[6];
00086
00087 for(int i=0;i<6;++i)
00088 e_elastic[i] = e_total[i] = 0;
00089
00090
00091 for(unsigned int j=0;j<4;++j)
00092 {
00093 vector3_type & x_j = T->node(j)->m_coord;
00094 vector3_type & x0_j = T->node(j)->m_model_coord;
00095
00096 vector3_type tmp = (trans(T->m_Re)*x_j) - x0_j;
00097 real_type bj = T->m_B[j](0);
00098 real_type cj = T->m_B[j](1);
00099 real_type dj = T->m_B[j](2);
00100 e_total[0] += bj*tmp(0);
00101 e_total[1] += cj*tmp(1);
00102 e_total[2] += dj*tmp(2);
00103 e_total[3] += cj*tmp(0) + bj*tmp(1);
00104 e_total[4] += dj*tmp(0) + bj*tmp(2);
00105 e_total[5] += dj*tmp(1) + cj*tmp(2);
00106 }
00107
00108
00109 for(int i=0;i<6;++i)
00110 e_elastic[i] = e_total[i] - T->m_plastic[i];
00111
00112
00113 real_type norm_elastic = 0;
00114 for(int i=0;i<6;++i)
00115 norm_elastic += e_elastic[i]*e_elastic[i];
00116 norm_elastic = sqrt(norm_elastic);
00117
00118
00119 if(norm_elastic > T->m_yield)
00120 {
00121 real_type amount = dt*min(T->m_creep,(1.0/dt));
00122 for(int i=0;i<6;++i)
00123 T->m_plastic[i] += amount*e_elastic[i];
00124 }
00125
00126
00127 real_type norm_plastic = 0;
00128 for(int i=0;i<6;++i)
00129 norm_plastic += T->m_plastic[i]*T->m_plastic[i];
00130 norm_plastic = sqrt(norm_plastic);
00131
00132
00133 if(norm_plastic > T->m_max)
00134 {
00135 real_type scale = T->m_max/norm_plastic;
00136 for(int i=0;i<6;++i)
00137 T->m_plastic[i] *= scale;
00138 }
00139
00140 for(unsigned int j=0;j<4;++j)
00141 {
00142 real_type * plastic = T->m_plastic;
00143 real_type bj = T->m_B[j](0);
00144 real_type cj = T->m_B[j](1);
00145 real_type dj = T->m_B[j](2);
00146 real_type E0 = T->m_D(0);
00147 real_type E1 = T->m_D(1);
00148 real_type E2 = T->m_D(2);
00149 vector3_type f;
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 real_type bjE0 = bj*E0;
00184 real_type bjE1 = bj*E1;
00185 real_type bjE2 = bj*E2;
00186 real_type cjE0 = cj*E0;
00187 real_type cjE1 = cj*E1;
00188 real_type cjE2 = cj*E2;
00189 real_type djE0 = dj*E0;
00190 real_type djE1 = dj*E1;
00191 real_type djE2 = dj*E2;
00192
00193 f(0) = bjE0*plastic[0] + bjE1*plastic[1] + bjE1*plastic[2] + cjE2*plastic[3] + djE2*plastic[4];
00194 f(1) = cjE1*plastic[0] + cjE0*plastic[1] + cjE1*plastic[2] + bjE2*plastic[3] + + djE2*plastic[5];
00195 f(2) = djE1*plastic[0] + djE1*plastic[1] + djE0*plastic[2] + bjE2*plastic[4] + cjE2*plastic[5];
00196
00197 f *= T->m_V;
00198 T->node(j)->m_f_external += T->m_Re*f;
00199 }
00200 }
00201
00202
00203
00204 }
00205
00206 }
00207 }
00208 }
00209
00210
00211 #endif