PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://code.google.com/
C++ | 486 lines | 283 code | 134 blank | 69 comment | 28 complexity | 606ed946f200556fff225082178bd6ec 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. ** Developed by: **
  15. ** Frank McKenna (fmckenna@ce.berkeley.edu) **
  16. ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
  17. ** Filip C. Filippou (filippou@ce.berkeley.edu) **
  18. ** **
  19. ** ****************************************************************** */
  20. // $Revision: 1.6 $
  21. // $Date: 2007-05-03 23:03:26 $
  22. // $Source: /usr/local/cvs/OpenSees/SRC/material/nD/PlateFiberMaterial.cpp,v $
  23. //
  24. // Ed "C++" Love
  25. //
  26. // Generic Plate Fiber Material
  27. //
  28. #include <PlateFiberMaterial.h>
  29. #include <Channel.h>
  30. #include <FEM_ObjectBroker.h>
  31. //static vector and matrices
  32. Vector PlateFiberMaterial::stress(5);
  33. Matrix PlateFiberMaterial::tangent(5,5);
  34. //null constructor
  35. PlateFiberMaterial::PlateFiberMaterial() :
  36. NDMaterial(0, ND_TAG_PlateFiberMaterial),
  37. strain(5)
  38. {
  39. }
  40. //full constructor
  41. PlateFiberMaterial::PlateFiberMaterial(
  42. int tag,
  43. NDMaterial &the3DMaterial) :
  44. NDMaterial(tag, ND_TAG_PlateFiberMaterial),
  45. strain(5)
  46. {
  47. theMaterial = the3DMaterial.getCopy("ThreeDimensional");
  48. Tstrain22 = 0.0;
  49. Cstrain22 = 0.0;
  50. }
  51. //destructor
  52. PlateFiberMaterial::~PlateFiberMaterial()
  53. {
  54. delete theMaterial;
  55. }
  56. //make a clone of this material
  57. NDMaterial*
  58. PlateFiberMaterial::getCopy()
  59. {
  60. PlateFiberMaterial *clone; //new instance of this class
  61. clone = new PlateFiberMaterial(this->getTag(),
  62. *theMaterial); //make the copy
  63. clone->Tstrain22 = this->Tstrain22;
  64. clone->Cstrain22 = this->Cstrain22;
  65. return clone;
  66. }
  67. //make a clone of this material
  68. NDMaterial*
  69. PlateFiberMaterial::getCopy(const char *type)
  70. {
  71. return this->getCopy();
  72. }
  73. //send back order of strain in vector form
  74. int
  75. PlateFiberMaterial::getOrder() const
  76. {
  77. return 5;
  78. }
  79. const char*
  80. PlateFiberMaterial::getType() const
  81. {
  82. return "PlateFiber";
  83. }
  84. //swap history variables
  85. int
  86. PlateFiberMaterial::commitState()
  87. {
  88. Cstrain22 = Tstrain22;
  89. return theMaterial->commitState();
  90. }
  91. //revert to last saved state
  92. int
  93. PlateFiberMaterial::revertToLastCommit()
  94. {
  95. Tstrain22 = Cstrain22;
  96. return theMaterial->revertToLastCommit();
  97. }
  98. //revert to start
  99. int
  100. PlateFiberMaterial::revertToStart()
  101. {
  102. this->Tstrain22 = 0.0;
  103. this->Cstrain22 = 0.0;
  104. return theMaterial->revertToStart();
  105. }
  106. //mass per unit volume
  107. double
  108. PlateFiberMaterial::getRho()
  109. {
  110. return theMaterial->getRho();
  111. }
  112. //receive the strain
  113. int
  114. PlateFiberMaterial::setTrialStrain(const Vector &strainFromElement)
  115. {
  116. static const double tolerance = 1.0e-08;
  117. this->strain(0) = strainFromElement(0); //11
  118. this->strain(1) = strainFromElement(1); //22
  119. this->strain(2) = strainFromElement(2); //12
  120. this->strain(3) = strainFromElement(3); //23
  121. this->strain(4) = strainFromElement(4); //31
  122. double norm;
  123. static Vector outOfPlaneStress(1);
  124. static Vector strainIncrement(1);
  125. static Vector threeDstress(6);
  126. static Vector threeDstrain(6);
  127. static Matrix threeDtangent(6,6);
  128. static Vector threeDstressCopy(6);
  129. static Matrix threeDtangentCopy(6,6);
  130. static Matrix dd22(1,1);
  131. int i, j;
  132. int ii, jj;
  133. int count = 0;
  134. //newton loop to solve for out-of-plane strains
  135. do {
  136. //set three dimensional strain
  137. threeDstrain(0) = this->strain(0);
  138. threeDstrain(1) = this->strain(1);
  139. threeDstrain(2) = this->Tstrain22;
  140. threeDstrain(3) = this->strain(2);
  141. threeDstrain(4) = this->strain(3);
  142. threeDstrain(5) = this->strain(4);
  143. if (theMaterial->setTrialStrain(threeDstrain) < 0) {
  144. opserr << "PlateFiberMaterial::setTrialStrain - material failed in setTrialStrain() with strain " << threeDstrain;
  145. return -1;
  146. }
  147. //three dimensional stress
  148. threeDstress = theMaterial->getStress();
  149. //three dimensional tangent
  150. threeDtangent = theMaterial->getTangent();
  151. //NDmaterial strain order = 11, 22, 33, 12, 23, 31
  152. //PlateFiberMaterial strain order = 11, 22, 12, 23, 31, 33
  153. //swap matrix indices to sort out-of-plane components
  154. for (i=0; i<6; i++) {
  155. ii = this->indexMap(i);
  156. threeDstressCopy(ii) = threeDstress(i);
  157. for (j=0; j<6; j++) {
  158. jj = this->indexMap(j);
  159. threeDtangentCopy(ii,jj) = threeDtangent(i,j);
  160. }//end for j
  161. }//end for i
  162. //partitioned stresses and tangent
  163. outOfPlaneStress(0) = threeDstress(2);
  164. dd22(0,0) = threeDtangentCopy(5,5);
  165. //set norm
  166. norm = outOfPlaneStress.Norm();
  167. //int Solve(const Vector &V, Vector &res) const;
  168. //int Solve(const Matrix &M, Matrix &res) const;
  169. //condensation
  170. dd22.Solve(outOfPlaneStress, strainIncrement);
  171. //update out of plane strains
  172. this->Tstrain22 -= strainIncrement(0);
  173. count++;
  174. } while (norm > tolerance && count < 10);
  175. return 0;
  176. }
  177. //send back the strain
  178. const Vector&
  179. PlateFiberMaterial::getStrain()
  180. {
  181. return this->strain;
  182. }
  183. //send back the stress
  184. const Vector&
  185. PlateFiberMaterial::getStress()
  186. {
  187. const Vector &threeDstress = theMaterial->getStress();
  188. static Vector threeDstressCopy(6);
  189. //swap matrix indices to sort out-of-plane components
  190. int i, ii;
  191. for (i=0; i<6; i++) {
  192. ii = this->indexMap(i);
  193. threeDstressCopy(ii) = threeDstress(i);
  194. }//end for i
  195. for (i=0; i<5; i++)
  196. this->stress(i) = threeDstressCopy(i);
  197. return this->stress;
  198. }
  199. //send back the tangent
  200. const Matrix&
  201. PlateFiberMaterial::getTangent()
  202. {
  203. static Matrix dd11(5,5);
  204. static Matrix dd12(5,1);
  205. static Matrix dd21(1,5);
  206. static Matrix dd22(1,1);
  207. static Matrix dd22invdd21(1,5);
  208. static Matrix threeDtangentCopy(6,6);
  209. const Matrix &threeDtangent = theMaterial->getTangent();
  210. //swap matrix indices to sort out-of-plane components
  211. int i,j, ii, jj;
  212. for (i=0; i<6; i++) {
  213. ii = this->indexMap(i);
  214. for (j=0; j<6; j++) {
  215. jj = this->indexMap(j);
  216. threeDtangentCopy(ii,jj) = threeDtangent(i,j);
  217. }//end for j
  218. }//end for i
  219. dd22(0,0) = threeDtangentCopy(5,5);
  220. for (i=0; i<5; i++) {
  221. dd12(i,0) = threeDtangentCopy(i,5);
  222. dd21(0,i) = threeDtangentCopy(5,i);
  223. for (int j=0; j<5; j++)
  224. dd11(i,j) = threeDtangentCopy(i,j);
  225. }//end for i
  226. //int Solve(const Vector &V, Vector &res) const;
  227. //int Solve(const Matrix &M, Matrix &res) const;
  228. //condensation
  229. dd22.Solve(dd21, dd22invdd21);
  230. this->tangent = dd11;
  231. this->tangent -= (dd12*dd22invdd21);
  232. return this->tangent;
  233. }
  234. const Matrix&
  235. PlateFiberMaterial::getInitialTangent()
  236. {
  237. opserr << "PlateFiberMaterial::getInitialTangent() - not yet implemented\n";
  238. return this->getTangent();
  239. }
  240. int
  241. PlateFiberMaterial::indexMap(int i)
  242. {
  243. int ii;
  244. switch (i+1) { //add 1 for standard vector indices
  245. case 1 :
  246. ii = 1;
  247. break;
  248. case 2 :
  249. ii = 2;
  250. break;
  251. case 3 :
  252. ii = 6;
  253. break;
  254. case 4 :
  255. ii = 3;
  256. break;
  257. case 5 :
  258. ii = 4;
  259. break;
  260. case 6 :
  261. ii = 5;
  262. break;
  263. default :
  264. ii = 1;
  265. break;
  266. } //end switch
  267. ii--;
  268. return ii;
  269. }
  270. //print out data
  271. void
  272. PlateFiberMaterial::Print(OPS_Stream &s, int flag)
  273. {
  274. s << "General Plate Fiber Material \n";
  275. s << " Tag: " << this->getTag() << "\n";
  276. s << "using the 3D material : \n";
  277. theMaterial->Print(s, flag);
  278. return;
  279. }
  280. int
  281. PlateFiberMaterial::sendSelf(int commitTag, Channel &theChannel)
  282. {
  283. int res = 0;
  284. // put tag and assocaited materials class and database tags into an id and send it
  285. static ID idData(3);
  286. idData(0) = this->getTag();
  287. idData(1) = theMaterial->getClassTag();
  288. int matDbTag = theMaterial->getDbTag();
  289. if (matDbTag == 0) {
  290. matDbTag = theChannel.getDbTag();
  291. theMaterial->setDbTag(matDbTag);
  292. }
  293. idData(2) = matDbTag;
  294. res = theChannel.sendID(this->getDbTag(), commitTag, idData);
  295. if (res < 0) {
  296. opserr << "PlateFiberMaterial::sendSelf() - failed to send id data\n";
  297. return res;
  298. }
  299. // put the strains in a vector and send it
  300. static Vector vecData(1);
  301. vecData(0) = Cstrain22;
  302. res = theChannel.sendVector(this->getDbTag(), commitTag, vecData);
  303. if (res < 0) {
  304. opserr << "PlateFiberMaterial::sendSelf() - failed to send vector data\n";
  305. return res;
  306. }
  307. // now send the materials data
  308. res = theMaterial->sendSelf(commitTag, theChannel);
  309. if (res < 0)
  310. opserr << "PlateFiberMaterial::sendSelf() - failed to send vector material\n";
  311. return res;
  312. }
  313. int
  314. PlateFiberMaterial::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
  315. {
  316. int res = 0;
  317. // recv an id containg the tag and associated materials class and db tags
  318. static ID idData(3);
  319. res = theChannel.recvID(this->getDbTag(), commitTag, idData);
  320. if (res < 0) {
  321. opserr << "PlateFiberMaterial::sendSelf() - failed to send id data\n";
  322. return res;
  323. }
  324. this->setTag(idData(0));
  325. int matClassTag = idData(1);
  326. // if the associated material has not yet been created or is of the wrong type
  327. // create a new material for recvSelf later
  328. if (theMaterial == 0 || theMaterial->getClassTag() != matClassTag) {
  329. if (theMaterial != 0)
  330. delete theMaterial;
  331. theMaterial = theBroker.getNewNDMaterial(matClassTag);
  332. if (theMaterial == 0) {
  333. opserr << "PlateFiberMaterial::recvSelf() - failed to get a material of type: " << matClassTag << endln;
  334. return -1;
  335. }
  336. }
  337. theMaterial->setDbTag(idData(2));
  338. // recv a vector containing strains and set the strains
  339. static Vector vecData(1);
  340. res = theChannel.recvVector(this->getDbTag(), commitTag, vecData);
  341. if (res < 0) {
  342. opserr << "PlateFiberMaterial::sendSelf() - failed to send vector data\n";
  343. return res;
  344. }
  345. Cstrain22 = vecData(0);
  346. Tstrain22 = Cstrain22;
  347. // now receive the assocaited materials data
  348. res = theMaterial->recvSelf(commitTag, theChannel, theBroker);
  349. if (res < 0)
  350. opserr << "PlateFiberMaterial::sendSelf() - failed to send vector material\n";
  351. return res;
  352. }