www.mooseframework.org
SymmAnisotropicElasticityTensor.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include <cmath>
12 #include <ostream>
13 
15  : SymmElasticityTensor(false),
16  _dmat(9, 9),
17  _qdmat(9, 9),
18  _dt(6, 6),
19  _qdt(6, 6),
20  _r(3, 3),
21  _q(9, 9),
22  _qt(9, 9),
23  _euler_angle(3),
24  _trans_d6_to_d9(9, 6),
25  //_transpose_trans_d6_to_d9(6,9),
26  _trans_d9_to_d6(6, 9),
27  //_transpose_trans_d9_to_d6(9,6),
28  _c11(0),
29  _c12(0),
30  _c44(0)
31 {
32  // form_transformation_t_matrix();
33 }
34 
36  bool all_21)
37  : SymmElasticityTensor(false),
38  _dmat(9, 9),
39  _qdmat(9, 9),
40  _dt(6, 6),
41  _qdt(6, 6),
42  _r(3, 3),
43  _q(9, 9),
44  _qt(9, 9),
45  _euler_angle(3),
46  _trans_d6_to_d9(9, 6),
47  //_transpose_trans_d6_to_d9(6,9),
48  _trans_d9_to_d6(6, 9),
49  //_transpose_trans_d9_to_d6(9,6),
50  _c11(0),
51  _c12(0),
52  _c44(0)
53 {
54  // test the input vector length to make sure it's correct
55  if ((all_21 == true && init_list.size() != 21) || (all_21 == false && init_list.size() != 9))
56  mooseError("Please correct the number of entries in the stiffness input.");
57 
58  if (all_21 == true)
59  {
60  for (int i = 0; i < 21; i++)
61  _val[i] = init_list[i];
62  }
63  else
64  {
65  _val[0] = init_list[0]; // C1111
66  _val[1] = init_list[1]; // C1122
67  _val[2] = init_list[2]; // C1133
68  _val[6] = init_list[3]; // C2222
69  _val[7] = init_list[4]; // C2233
70  _val[11] = init_list[5]; // C3333
71  _val[15] = init_list[6]; // C2323
72  _val[18] = init_list[7]; // C1313
73  _val[20] = init_list[8]; // C1212
74  }
75 
76  // form_transformation_t_matrix();
77 }
78 
81  : SymmElasticityTensor(false)
82 {
83  *this = a;
84 }
85 
86 void
88 {
89  _euler_angle[0] = a1;
90 }
91 
92 void
94 {
95  _euler_angle[1] = a2;
96 }
97 
98 void
100 {
101  _euler_angle[2] = a3;
102 }
103 
104 Real
106 {
107  return _euler_angle[0];
108 }
109 
110 Real
112 {
113  return _euler_angle[1];
114 }
115 
116 Real
118 {
119  return _euler_angle[2];
120 }
121 
122 void
124 {
125  _c11 = c11;
126  _val[0] = _val[6] = _val[11] = _c11;
127 }
128 
129 void
131 {
132  _c12 = c12;
133  _val[1] = _val[2] = _val[7] = _c12;
134 }
135 
136 void
138 {
139  _c44 = c44;
140  _val[15] = _val[18] = _val[20] = _c44;
141 }
142 
143 void
144 SymmAnisotropicElasticityTensor::rotate(const Real a1, const Real a2, const Real a3)
145 {
146  setFirstEulerAngle(a1);
148  setThirdEulerAngle(a3);
149 
150  // pulled from calculateEntries to sub in the initialize_anisotropic_material_dt_matrix() call
151  // calculateEntries(0);
152 
153  form_r_matrix();
158 
159  unsigned count(0);
160 
161  for (int j(0); j < 6; ++j)
162  {
163  for (int i(j); i < 6; ++i)
164  {
165  _val[count++] = _dt(i, j);
166  }
167  }
168 }
169 
170 void
172 {
173  Real phi1 = _euler_angle[0] * (libMesh::pi / 180.0);
174  Real phi = _euler_angle[1] * (libMesh::pi / 180.0);
175  Real phi2 = _euler_angle[2] * (libMesh::pi / 180.0);
176 
177  Real cp1 = std::cos(phi1);
178  Real cp2 = std::cos(phi2);
179  Real cp = std::cos(phi);
180 
181  Real sp1 = std::sin(phi1);
182  Real sp2 = std::sin(phi2);
183  Real sp = std::sin(phi);
184 
185  _r(0, 0) = cp1 * cp2 - sp1 * sp2 * cp;
186  _r(0, 1) = sp1 * cp2 + cp1 * sp2 * cp;
187  _r(0, 2) = sp2 * sp;
188  _r(1, 0) = -cp1 * sp2 - sp1 * cp2 * cp;
189  _r(1, 1) = -sp1 * sp2 + cp1 * cp2 * cp;
190  _r(1, 2) = cp2 * sp;
191  _r(2, 0) = sp1 * sp;
192  _r(2, 1) = -cp1 * sp;
193  _r(2, 2) = cp;
194 }
195 
196 // this is now obsolete
197 void
199 {
200  // This function initializes the 6 x 6 material Dt matrix for a cubic material
201 
202  _dt(0, 0) = _dt(1, 1) = _dt(2, 2) = _c11;
203  _dt(0, 1) = _dt(0, 2) = _dt(1, 0) = _dt(2, 0) = _dt(1, 2) = _dt(2, 1) = _c12;
204  // beware the factor of two here
205  _dt(3, 3) = _dt(4, 4) = _dt(5, 5) = 2 * _c44;
206 }
207 
208 // this is now obsolete
209 void
211 {
212  // This function initializes the 6 x 6 material Dt matrix for an anisotropic material
213 
214  int k = 0;
215  for (int i = 0; i < 6; i++)
216  {
217  for (int j = i; j < 6; j++)
218  {
219  _dt(i, j) = _dt(j, i) = _val[k++];
220  }
221  }
222 }
223 
224 void
226 {
227 
228  for (int i = 0; i < 3; ++i)
229  for (int j = 0; j < 3; ++j)
230  for (int k = 0; k < 3; ++k)
231  for (int l = 0; l < 3; ++l)
232  _q(((i * 3) + k), ((j * 3) + l)) = _r(i, j) * _r(k, l);
233 
234  /*for (int p = 0; p < 9; ++p)
235  for (int q = 0; q < 9; ++q)
236  _qt(q,p) = _q(p,q);*/
237 }
238 
239 void
241 {
242  // Forms to two kinds of transformation matrix
243  // TransD6toD9 transfroms Dt[6][6] to Dmat[9][9]
244  // TransD9toD6 transforms Dmat[9][9] to Dt[6][6]
245 
246  // Real sqrt2 = std::sqrt(2.0);
247  // Real a = 1/sqrt2;
248  Real a = 1.0;
249 
250  _trans_d6_to_d9(0, 0) = _trans_d6_to_d9(4, 1) = _trans_d6_to_d9(8, 2) = 1.0;
251  _trans_d6_to_d9(1, 3) = _trans_d6_to_d9(3, 3) = a;
252  _trans_d6_to_d9(5, 4) = _trans_d6_to_d9(7, 4) = a;
253  _trans_d6_to_d9(2, 5) = _trans_d6_to_d9(6, 5) = a;
254 
255  /*for (int i = 0; i < 9; ++i)
256  {
257  for (int j = 0; j < 6; ++j)
258  {
259  _transpose_trans_d6_to_d9(j,i) = _trans_d6_to_d9(i,j);
260  }
261  }*/
262 
263  _trans_d9_to_d6(0, 0) = _trans_d9_to_d6(1, 4) = _trans_d9_to_d6(2, 8) = 1.0;
264  // _trans_d9_to_d6(3,3) = _trans_d9_to_d6(4,7) = _trans_d9_to_d6(5,6) = sqrt2;
265  _trans_d9_to_d6(3, 3) = _trans_d9_to_d6(4, 7) = _trans_d9_to_d6(5, 6) = 1.0;
266 
267  /*for (int i = 0; i < 6; ++i)
268  {
269  for (int j = 0; j < 9; ++j)
270  {
271  _transpose_trans_d9_to_d6(j,i) = _trans_d9_to_d6(i,j);
272  }
273  }*/
274 }
275 
276 void
278 {
279 
280  // THIS TRANSFORMATION IS VALID ONLY WHEN THE INCOMING MATRIX HAS NOT BEEN ROTATED
281 
282  // The function makes use of TransD6toD9 matrix to transfrom
283  // Dt[6][6] to Dmat[9][9]
284  // Dmat = T * Dt * TT
285 
286  // DenseMatrix<Real> outputMatrix(9,6);
287 
288  // outputMatrix = _trans_d6_to_d9;
289  // outputMatrix.right_multiply(_dt);
290 
291  //_dmat = outputMatrix;
292  //_dmat.right_multiply_transpose(_trans_d6_to_d9);
293 
294  // Use the plug-and-chug functions given in SymmElasticityTensor
295  // to take the existing _val[] and put them into the 9x9 _dmat matrix.
296  SymmElasticityTensor temp_dt;
297  copyValues(temp_dt);
298 
299  ColumnMajorMatrix temp_dmat = temp_dt.columnMajorMatrix9x9();
300 
301  for (unsigned j(0); j < 9; ++j)
302  {
303  for (unsigned i(0); i < 9; ++i)
304  {
305  _dmat(i, j) = temp_dmat(i, j);
306  }
307  }
308 }
309 
310 void
312 {
313  // The function makes use of TransD6toD9 matrix to transfrom
314  // QDmat[9][9] to Dt[6][6]
315  // Dt = TT * QDmat * T
316 
317  // DenseMatrix<Real> outputMatrix(6,9);
318 
319  // outputMatrix = _trans_d9_to_d6;
320  // outputMatrix.right_multiply(_qdmat);
321  // _dt = outputMatrix;
322  // _dt.right_multiply(_transpose_trans_d9_to_d6);
323 
324  // The transformation below is general and should work whether or not the
325  // incoming tensor has been rotated.
326 
327  ColumnMajorMatrix tmp(9, 9);
328  for (unsigned j(0); j < 9; ++j)
329  {
330  for (unsigned i(0); i < 9; ++i)
331  {
332  tmp(i, j) = _qdmat(i, j);
333  }
334  }
335 
337  fred.convertFrom9x9(tmp);
338  ColumnMajorMatrix wilma = fred.columnMajorMatrix6x6();
339  for (unsigned j(0); j < 6; ++j)
340  {
341  for (unsigned i(0); i < 6; ++i)
342  {
343  _dt(i, j) = wilma(i, j);
344  }
345  }
346 }
347 
348 void
350 {
351  // The function makes use of Q matrix to rotate
352  // Dmat[9][9] to QDmat[9][9]
353  // QDmat = QT * Dmat * Q
354 
355  DenseMatrix<Real> outputMatrix(9, 9);
356 
357  _q.get_transpose(outputMatrix);
358  outputMatrix.right_multiply(_dmat);
359 
360  _qdmat = outputMatrix;
361  _qdmat.right_multiply(_q);
362 }
363 
364 void
366 {
367 
368  // The following four lines of code force the calculateEntries function to be useful
369  // only for CUBIC ANISOTROPIC materials.
370  zero();
374 
375  form_r_matrix();
376  // initialize_material_anisotropic_dt_matrix();
378  // form_transformation_t_matrix();
382 
383  unsigned count(0);
384 
385  for (int j(0); j < 6; ++j)
386  {
387  for (int i(j); i < 6; ++i)
388  {
389  _val[count++] = _dt(i, j);
390  }
391  }
392 }
393 
394 void
396 {
397  printf("\nSymmAnisotropicElasticityTensor::show_dt_matrix()\n");
398 
399  for (int j = 0; j < 6; ++j)
400  {
401  printf(" ");
402  for (int i = 0; i < 6; ++i)
403  {
404  printf("%12.4f ", _dt(i, j));
405  }
406  printf("\n");
407  }
408 }
409 
410 void
412 {
413  printf("\nSymmAnisotropicElasticityTensor::show_r_matrix() Euler angles are (%f, %f, %f)\n",
414  _euler_angle[0],
415  _euler_angle[1],
416  _euler_angle[2]);
417 
418  for (int j = 0; j < 3; ++j)
419  {
420  printf(" ");
421  for (int i = 0; i < 3; ++i)
422  {
423  printf("%8.4f ", _r(i, j));
424  }
425  printf("\n");
426  }
427 }
SymmAnisotropicElasticityTensor::_r
DenseMatrix< Real > _r
Definition: SymmAnisotropicElasticityTensor.h:93
SymmElasticityTensor::convertFrom9x9
void convertFrom9x9(const ColumnMajorMatrix &cmm)
Definition: SymmElasticityTensor.C:158
SymmAnisotropicElasticityTensor::_c44
Real _c44
Definition: SymmAnisotropicElasticityTensor.h:104
SymmAnisotropicElasticityTensor::show_dt_matrix
void show_dt_matrix()
Definition: SymmAnisotropicElasticityTensor.C:395
SymmAnisotropicElasticityTensor::initialize_material_dt_matrix
void initialize_material_dt_matrix()
Definition: SymmAnisotropicElasticityTensor.C:198
SymmAnisotropicElasticityTensor::setMaterialConstantc12
void setMaterialConstantc12(const Real c12)
Set the material constant c22; assumes cubic material.
Definition: SymmAnisotropicElasticityTensor.C:130
SymmElasticityTensor::copyValues
void copyValues(SymmElasticityTensor &rhs) const
Definition: SymmElasticityTensor.h:70
SymmAnisotropicElasticityTensor::_dt
DenseMatrix< Real > _dt
Definition: SymmAnisotropicElasticityTensor.h:91
SymmAnisotropicElasticityTensor::setThirdEulerAngle
void setThirdEulerAngle(const Real a3)
Set the third euler angle.
Definition: SymmAnisotropicElasticityTensor.C:99
SymmAnisotropicElasticityTensor::_qdmat
DenseMatrix< Real > _qdmat
Definition: SymmAnisotropicElasticityTensor.h:90
SymmAnisotropicElasticityTensor::rotate
virtual void rotate(const Real a1, const Real a2, const Real a3)
Perform rotation around three axes.
Definition: SymmAnisotropicElasticityTensor.C:144
SymmAnisotropicElasticityTensor::form_transformation_t_matrix
void form_transformation_t_matrix()
Definition: SymmAnisotropicElasticityTensor.C:240
SymmAnisotropicElasticityTensor::SymmAnisotropicElasticityTensor
SymmAnisotropicElasticityTensor()
Definition: SymmAnisotropicElasticityTensor.C:14
SymmElasticityTensor
This class defines a basic set of capabilities any elasticity tensor should have.
Definition: SymmElasticityTensor.h:55
SymmAnisotropicElasticityTensor
Definition: SymmAnisotropicElasticityTensor.h:14
SymmAnisotropicElasticityTensor::setFirstEulerAngle
void setFirstEulerAngle(const Real a1)
Set the first euler angle.
Definition: SymmAnisotropicElasticityTensor.C:87
SymmAnisotropicElasticityTensor::show_r_matrix
void show_r_matrix()
Definition: SymmAnisotropicElasticityTensor.C:411
SymmAnisotropicElasticityTensor::form_rotational_q_matrix
void form_rotational_q_matrix()
Definition: SymmAnisotropicElasticityTensor.C:225
SymmAnisotropicElasticityTensor::form_transformed_material_dmat_matrix
void form_transformed_material_dmat_matrix()
Definition: SymmAnisotropicElasticityTensor.C:277
SymmAnisotropicElasticityTensor::_c12
Real _c12
Definition: SymmAnisotropicElasticityTensor.h:104
SymmAnisotropicElasticityTensor::setMaterialConstantc44
void setMaterialConstantc44(const Real c44)
Set the material constant c44; assumes cubic material.
Definition: SymmAnisotropicElasticityTensor.C:137
SymmAnisotropicElasticityTensor::initialize_anisotropic_material_dt_matrix
void initialize_anisotropic_material_dt_matrix()
Definition: SymmAnisotropicElasticityTensor.C:210
SymmAnisotropicElasticityTensor::setSecondEulerAngle
void setSecondEulerAngle(const Real a2)
Set the second euler angle.
Definition: SymmAnisotropicElasticityTensor.C:93
SymmAnisotropicElasticityTensor::_euler_angle
std::vector< Real > _euler_angle
Definition: SymmAnisotropicElasticityTensor.h:96
SymmElasticityTensor::zero
void zero()
Definition: SymmElasticityTensor.h:134
SymmAnisotropicElasticityTensor::form_r_matrix
void form_r_matrix()
Definition: SymmAnisotropicElasticityTensor.C:171
SymmAnisotropicElasticityTensor::_trans_d6_to_d9
DenseMatrix< Real > _trans_d6_to_d9
Definition: SymmAnisotropicElasticityTensor.h:98
SymmElasticityTensor::columnMajorMatrix6x6
ColumnMajorMatrix columnMajorMatrix6x6() const
Definition: SymmElasticityTensor.C:230
SymmAnisotropicElasticityTensor::secondEulerAngle
Real secondEulerAngle()
Definition: SymmAnisotropicElasticityTensor.C:111
SymmAnisotropicElasticityTensor::_dmat
DenseMatrix< Real > _dmat
Definition: SymmAnisotropicElasticityTensor.h:89
SymmAnisotropicElasticityTensor::thirdEulerAngle
Real thirdEulerAngle()
Definition: SymmAnisotropicElasticityTensor.C:117
SymmAnisotropicElasticityTensor::calculateEntries
virtual void calculateEntries(unsigned int qp)
Fill in the matrix.
Definition: SymmAnisotropicElasticityTensor.C:365
SymmAnisotropicElasticityTensor::firstEulerAngle
Real firstEulerAngle()
Definition: SymmAnisotropicElasticityTensor.C:105
SymmAnisotropicElasticityTensor::_c11
Real _c11
Definition: SymmAnisotropicElasticityTensor.h:104
SymmAnisotropicElasticityTensor::setMaterialConstantc11
void setMaterialConstantc11(const Real c11)
Set the material constant c11; assumes cubic material.
Definition: SymmAnisotropicElasticityTensor.C:123
SymmAnisotropicElasticityTensor::_trans_d9_to_d6
DenseMatrix< Real > _trans_d9_to_d6
Definition: SymmAnisotropicElasticityTensor.h:101
SymmAnisotropicElasticityTensor::_q
DenseMatrix< Real > _q
Definition: SymmAnisotropicElasticityTensor.h:94
SymmElasticityTensor::_val
Real _val[21]
Definition: SymmElasticityTensor.h:188
SymmAnisotropicElasticityTensor::form_transformed_material_dt_matrix
void form_transformed_material_dt_matrix()
Definition: SymmAnisotropicElasticityTensor.C:311
SymmAnisotropicElasticityTensor::form_rotated_material_qdmat_matrix
void form_rotated_material_qdmat_matrix()
Definition: SymmAnisotropicElasticityTensor.C:349
SymmElasticityTensor::columnMajorMatrix9x9
ColumnMajorMatrix columnMajorMatrix9x9() const
Definition: SymmElasticityTensor.C:245
SymmAnisotropicElasticityTensor.h