PageRenderTime 52ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/opensees-websocket/SRC/material/nD/J2PlateFiber.cpp

https://code.google.com/
C++ | 502 lines | 281 code | 121 blank | 100 comment | 15 complexity | a098307bca0df19ccf8953e1550858a2 MD5 | raw file
  1. /* ****************************************************************** **
  2. ** OpenSees - Open System for Earthquake Engineering Simulation **
  3. ** Pacific Earthquake Engineering Research Center **
  4. ** **
  5. ** **
  6. ** (C) Copyright 1999, The Regents of the University of California **
  7. ** All Rights Reserved. **
  8. ** **
  9. ** Commercial use of this program without express permission of the **
  10. ** University of California, Berkeley, is strictly prohibited. See **
  11. ** file 'COPYRIGHT' in main directory for information on usage and **
  12. ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
  13. ** **
  14. ** ****************************************************************** */
  15. // $Revision: 1.6 $
  16. // $Date: 2008-10-20 22:23:03 $
  17. // $Source: /usr/local/cvs/OpenSees/SRC/material/nD/J2PlateFiber.cpp,v $
  18. // Written: Ed "C++" Love
  19. //
  20. // J2PlateFiber isotropic hardening material class
  21. //
  22. // Elastic Model
  23. // sigma = K*trace(epsilion_elastic) + (2*G)*dev(epsilon_elastic)
  24. //
  25. // Yield Function
  26. // phi(sigma,q) = || dev(sigma) || - sqrt(2/3)*q(xi)
  27. //
  28. // Saturation Isotropic Hardening with linear term
  29. // q(xi) = simga_infty + (sigma_0 - sigma_infty)*exp(-delta*xi) + H*xi
  30. //
  31. // Flow Rules
  32. // \dot{epsilon_p} = gamma * d_phi/d_sigma
  33. // \dot{xi} = -gamma * d_phi/d_q
  34. //
  35. // Linear Viscosity
  36. // gamma = phi / eta ( if phi > 0 )
  37. //
  38. // Backward Euler Integration Routine
  39. // Yield condition enforced at time n+1
  40. //
  41. // Send strains in following format :
  42. //
  43. // strain_vec = { eps_00
  44. // eps_11
  45. // 2 eps_01 } <--- note the 2
  46. //
  47. // set eta := 0 for rate independent case
  48. //
  49. #include <J2PlateFiber.h>
  50. #include <Channel.h>
  51. #include <FEM_ObjectBroker.h>
  52. Vector J2PlateFiber :: strain_vec(5) ;
  53. Vector J2PlateFiber :: stress_vec(5) ;
  54. Matrix J2PlateFiber :: tangent_matrix(5,5) ;
  55. //null constructor
  56. J2PlateFiber :: J2PlateFiber( ) :
  57. J2Plasticity( )
  58. {
  59. commitEps22 =0.0;
  60. }
  61. //full constructor
  62. J2PlateFiber ::
  63. J2PlateFiber( int tag,
  64. double K,
  65. double G,
  66. double yield0,
  67. double yield_infty,
  68. double d,
  69. double H,
  70. double viscosity,
  71. double rho) :
  72. J2Plasticity(tag, ND_TAG_J2PlateFiber,
  73. K, G, yield0, yield_infty, d, H, viscosity, rho )
  74. {
  75. commitEps22 =0.0;
  76. }
  77. //elastic constructor
  78. J2PlateFiber ::
  79. J2PlateFiber( int tag,
  80. double K,
  81. double G ) :
  82. J2Plasticity(tag, ND_TAG_J2PlateFiber, K, G )
  83. {
  84. commitEps22 =0.0;
  85. }
  86. //destructor
  87. J2PlateFiber :: ~J2PlateFiber( )
  88. {
  89. }
  90. //make a clone of this material
  91. NDMaterial* J2PlateFiber :: getCopy( )
  92. {
  93. J2PlateFiber *clone;
  94. clone = new J2PlateFiber( ) ; //new instance of this class
  95. *clone = *this ; //asignment to make copy
  96. return clone ;
  97. }
  98. //send back type of material
  99. const char* J2PlateFiber :: getType( ) const
  100. {
  101. return "PlateFiber" ;
  102. }
  103. //send back order of strain in vector form
  104. int J2PlateFiber :: getOrder( ) const
  105. {
  106. return 5 ;
  107. }
  108. //get the strain and integrate plasticity equations
  109. int J2PlateFiber :: setTrialStrain( const Vector &strain_from_element )
  110. {
  111. const double tolerance = 1e-8 ;
  112. const int max_iterations = 25 ;
  113. int iteration_counter = 0 ;
  114. int i, j, k, l ;
  115. int ii, jj ;
  116. double eps22 = strain(2,2) ;
  117. strain.Zero( ) ;
  118. strain(0,0) = strain_from_element(0) ;
  119. strain(1,1) = strain_from_element(1) ;
  120. strain(0,1) = 0.50 * strain_from_element(2) ;
  121. strain(1,0) = strain(0,1) ;
  122. strain(1,2) = 0.50 * strain_from_element(3) ;
  123. strain(2,1) = strain(1,2) ;
  124. strain(2,0) = 0.50 * strain_from_element(4) ;
  125. strain(0,2) = strain(2,0) ;
  126. strain(2,2) = eps22 ;
  127. //enforce the plane stress condition sigma_22 = 0
  128. //solve for epsilon_22
  129. iteration_counter = 0 ;
  130. do {
  131. this->plastic_integrator( ) ;
  132. strain(2,2) -= stress(2,2) / tangent[2][2][2][2] ;
  133. //opserr << stress(2,2) << endln ;
  134. iteration_counter++ ;
  135. if ( iteration_counter > max_iterations ) {
  136. opserr << "More than " << max_iterations ;
  137. opserr << " iterations in setTrialStrain of J2PlateFiber \n" ;
  138. break ;
  139. }// end if
  140. } while ( fabs(stress(2,2)) > tolerance ) ;
  141. //modify tangent for plane stress
  142. for ( ii = 0; ii < 5; ii++ ) {
  143. for ( jj = 0; jj < 5; jj++ ) {
  144. index_map( ii, i, j ) ;
  145. index_map( jj, k, l ) ;
  146. tangent[i][j][k][l] -= tangent[i][j][2][2]
  147. * tangent[2][2][k][l]
  148. / tangent[2][2][2][2] ;
  149. //minor symmetries
  150. tangent [j][i][k][l] = tangent[i][j][k][l] ;
  151. tangent [i][j][l][k] = tangent[i][j][k][l] ;
  152. tangent [j][i][l][k] = tangent[i][j][k][l] ;
  153. } // end for jj
  154. } // end for ii
  155. return 0 ;
  156. }
  157. //unused trial strain functions
  158. int J2PlateFiber :: setTrialStrain( const Vector &v, const Vector &r )
  159. {
  160. return this->setTrialStrain( v ) ;
  161. }
  162. int J2PlateFiber :: setTrialStrainIncr( const Vector &v )
  163. {
  164. return -1 ;
  165. }
  166. int J2PlateFiber :: setTrialStrainIncr( const Vector &v, const Vector &r )
  167. {
  168. return -1 ;
  169. }
  170. //send back the strain
  171. const Vector& J2PlateFiber :: getStrain( )
  172. {
  173. strain_vec(0) = strain(0,0) ;
  174. strain_vec(1) = strain(1,1) ;
  175. strain_vec(2) = 2.0 * strain(0,1) ;
  176. strain_vec(3) = 2.0 * strain(1,2) ;
  177. strain_vec(4) = 2.0 * strain(2,0) ;
  178. return strain_vec ;
  179. }
  180. //send back the stress
  181. const Vector& J2PlateFiber :: getStress( )
  182. {
  183. stress_vec(0) = stress(0,0) ;
  184. stress_vec(1) = stress(1,1) ;
  185. stress_vec(2) = stress(0,1) ;
  186. stress_vec(3) = stress(1,2) ;
  187. stress_vec(4) = stress(2,0) ;
  188. return stress_vec ;
  189. }
  190. //send back the tangent
  191. const Matrix& J2PlateFiber :: getTangent( )
  192. {
  193. // matrix to tensor mapping
  194. // Matrix Tensor
  195. // ------- -------
  196. // 0 0 0
  197. // 1 1 1
  198. // 2 0 1 ( or 1 0 )
  199. // 3 1 2 ( or 2 1 )
  200. // 4 2 0 ( or 0 2 )
  201. int ii, jj ;
  202. int i, j, k, l ;
  203. for ( ii = 0; ii < 5; ii++ ) {
  204. for ( jj = 0; jj < 5; jj++ ) {
  205. index_map( ii, i, j ) ;
  206. index_map( jj, k, l ) ;
  207. tangent_matrix(ii,jj) = tangent[i][j][k][l] ;
  208. } //end for j
  209. } //end for i
  210. return tangent_matrix ;
  211. }
  212. //send back the tangent
  213. const Matrix& J2PlateFiber :: getInitialTangent( )
  214. {
  215. // matrix to tensor mapping
  216. // Matrix Tensor
  217. // ------- -------
  218. // 0 0 0
  219. // 1 1 1
  220. // 2 0 1 ( or 1 0 )
  221. // 3 1 2 ( or 2 1 )
  222. // 4 2 0 ( or 0 2 )
  223. int ii, jj ;
  224. int i, j, k, l ;
  225. this->doInitialTangent();
  226. for ( ii = 0; ii < 5; ii++ ) {
  227. for ( jj = 0; jj < 5; jj++ ) {
  228. index_map( ii, i, j ) ;
  229. index_map( jj, k, l ) ;
  230. tangent_matrix(ii,jj) = initialTangent[i][j][k][l] ;
  231. } //end for j
  232. } //end for i
  233. return tangent_matrix ;
  234. }
  235. //this is mike's problem
  236. int J2PlateFiber :: setTrialStrain(const Tensor &v)
  237. {
  238. return -1 ;
  239. }
  240. int J2PlateFiber :: setTrialStrain(const Tensor &v, const Tensor &r)
  241. {
  242. return -1 ;
  243. }
  244. int J2PlateFiber :: setTrialStrainIncr(const Tensor &v)
  245. {
  246. return -1 ;
  247. }
  248. int J2PlateFiber :: setTrialStrainIncr(const Tensor &v, const Tensor &r)
  249. {
  250. return -1 ;
  251. }
  252. const Tensor& J2PlateFiber :: getTangentTensor( )
  253. {
  254. return rank4 ;
  255. }
  256. //jeremic@ucdavis.edu 22jan2001const Tensor& J2PlateFiber :: getStressTensor( )
  257. //jeremic@ucdavis.edu 22jan2001{
  258. //jeremic@ucdavis.edu 22jan2001 return rank2 ;
  259. //jeremic@ucdavis.edu 22jan2001}
  260. //jeremic@ucdavis.edu 22jan2001
  261. //jeremic@ucdavis.edu 22jan2001const Tensor& J2PlateFiber :: getStrainTensor( )
  262. //jeremic@ucdavis.edu 22jan2001{
  263. //jeremic@ucdavis.edu 22jan2001 return rank2 ;
  264. //jeremic@ucdavis.edu 22jan2001}
  265. int
  266. J2PlateFiber::commitState( )
  267. {
  268. epsilon_p_n = epsilon_p_nplus1 ;
  269. xi_n = xi_nplus1 ;
  270. commitEps22 = strain(2,2);
  271. return 0;
  272. }
  273. int
  274. J2PlateFiber::revertToLastCommit( ) {
  275. strain(2,2) = commitEps22;
  276. return 0;
  277. }
  278. int
  279. J2PlateFiber::revertToStart( ) {
  280. commitEps22 = 0.0;
  281. this->zero( ) ;
  282. return 0;
  283. }
  284. int
  285. J2PlateFiber::sendSelf (int commitTag, Channel &theChannel)
  286. {
  287. // we place all the data needed to define material and it's state
  288. // int a vector object
  289. static Vector data(11+9);
  290. int cnt = 0;
  291. data(cnt++) = this->getTag();
  292. data(cnt++) = bulk;
  293. data(cnt++) = shear;
  294. data(cnt++) = sigma_0;
  295. data(cnt++) = sigma_infty;
  296. data(cnt++) = delta;
  297. data(cnt++) = Hard;
  298. data(cnt++) = eta;
  299. data(cnt++) = rho;
  300. data(cnt++) = xi_n;
  301. data(cnt++) = commitEps22;
  302. for (int i=0; i<3; i++)
  303. for (int j=0; j<3; j++)
  304. data(cnt++) = epsilon_p_n(i,j);
  305. // send the vector object to the channel
  306. if (theChannel.sendVector(this->getDbTag(), commitTag, data) < 0) {
  307. opserr << "J2Plasticity::recvSelf - failed to recv vector from channel\n";
  308. return -1;
  309. }
  310. return 0;
  311. }
  312. int
  313. J2PlateFiber::recvSelf (int commitTag, Channel &theChannel,
  314. FEM_ObjectBroker &theBroker)
  315. {
  316. // recv the vector object from the channel which defines material param and state
  317. static Vector data(11+9);
  318. if (theChannel.recvVector(this->getDbTag(), commitTag, data) < 0) {
  319. opserr << "J2Plasticity::recvSelf - failed to recv vector from channel\n";
  320. return -1;
  321. }
  322. // set the material parameters and state variables
  323. int cnt = 0;
  324. this->setTag(data(cnt++));
  325. bulk = data(cnt++);
  326. shear = data(cnt++);
  327. sigma_0 = data(cnt++);
  328. sigma_infty = data(cnt++);
  329. delta = data(cnt++);
  330. Hard = data(cnt++);
  331. eta = data(cnt++);
  332. rho = data(cnt++);
  333. xi_n = data(cnt++);
  334. commitEps22 = data(cnt++);
  335. for (int i=0; i<3; i++)
  336. for (int j=0; j<3; j++)
  337. epsilon_p_n(i,j) = data(cnt++);
  338. epsilon_p_nplus1 = epsilon_p_n;
  339. xi_nplus1 = xi_n;
  340. strain(2,2) = commitEps22;
  341. return 0;
  342. }
  343. //matrix_index ---> tensor indices i,j
  344. // plane stress different because of condensation on tangent
  345. // case 3 switched to 1-2 and case 4 to 3-3
  346. void J2PlateFiber :: index_map( int matrix_index, int &i, int &j )
  347. {
  348. switch ( matrix_index+1 ) { //add 1 for standard tensor indices
  349. case 1 :
  350. i = 1 ;
  351. j = 1 ;
  352. break ;
  353. case 2 :
  354. i = 2 ;
  355. j = 2 ;
  356. break ;
  357. case 3 :
  358. i = 1 ;
  359. j = 2 ;
  360. break ;
  361. case 4 :
  362. i = 2 ;
  363. j = 3 ;
  364. break ;
  365. case 5 :
  366. i = 3 ;
  367. j = 1 ;
  368. break ;
  369. case 6 :
  370. i = 3 ;
  371. j = 3 ;
  372. break ;
  373. default :
  374. i = 1 ;
  375. j = 1 ;
  376. break ;
  377. } //end switch
  378. i-- ; //subtract 1 for C-indexing
  379. j-- ;
  380. return ;
  381. }