www.mooseframework.org
MaterialTensorCalculatorTools.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
11 {
12 
13 Real
14 component(const SymmTensor & symm_tensor, unsigned int index)
15 {
16  return symm_tensor.component(index);
17 }
18 
19 Real
20 component(const SymmTensor & symm_tensor, unsigned int index, RealVectorValue & direction)
21 {
22  direction.zero();
23  if (index < 3)
24  direction(index) = 1.0;
25 
26  else if (index == 3) // xy
27  {
28  direction(0) = std::sqrt(0.5);
29  direction(1) = direction(0);
30  }
31  else if (index == 4) // yz
32  {
33  direction(1) = std::sqrt(0.5);
34  direction(2) = direction(1);
35  }
36  else if (index == 5) // zx
37  {
38  direction(0) = std::sqrt(0.5);
39  direction(2) = direction(0);
40  }
41  return symm_tensor.component(index);
42 }
43 
44 Real
45 vonMisesStress(const SymmTensor & symm_stress)
46 {
47  Real value = std::pow(symm_stress.xx() - symm_stress.yy(), 2) +
48  std::pow(symm_stress.yy() - symm_stress.zz(), 2) +
49  std::pow(symm_stress.zz() - symm_stress.xx(), 2) +
50  6 * (std::pow(symm_stress.xy(), 2) + std::pow(symm_stress.yz(), 2) +
51  std::pow(symm_stress.zx(), 2));
52  return std::sqrt(value / 2.0);
53 }
54 
55 Real
56 effectiveStrain(const SymmTensor & symm_strain)
57 {
58  return std::sqrt(2.0 / 3.0 * symm_strain.doubleContraction(symm_strain));
59 }
60 
61 Real
62 hydrostatic(const SymmTensor & symm_tensor)
63 {
64  return symm_tensor.trace() / 3.0;
65 }
66 
67 Real
68 volumetricStrain(const SymmTensor & symm_strain)
69 {
70  Real value = symm_strain.trace();
71  value += symm_strain.xx() * symm_strain.yy() + symm_strain.yy() * symm_strain.zz() +
72  symm_strain.zz() * symm_strain.xx() +
73  symm_strain.xx() * symm_strain.yy() * symm_strain.zz();
74  return value;
75 }
76 
77 Real
78 firstInvariant(const SymmTensor & symm_tensor)
79 {
80  return symm_tensor.trace();
81 }
82 
83 Real
84 secondInvariant(const SymmTensor & symm_tensor)
85 {
86  Real value = symm_tensor.xx() * symm_tensor.yy() + symm_tensor.yy() * symm_tensor.zz() +
87  symm_tensor.zz() * symm_tensor.xx() - symm_tensor.xy() * symm_tensor.xy() -
88  symm_tensor.yz() * symm_tensor.yz() - symm_tensor.zx() * symm_tensor.zx();
89 
90  return value;
91 }
92 
93 Real
94 thirdInvariant(const SymmTensor & symm_tensor)
95 {
96  Real val = 0.0;
97  val = symm_tensor.xx() * symm_tensor.yy() * symm_tensor.zz() -
98  symm_tensor.xx() * symm_tensor.yz() * symm_tensor.yz() +
99  symm_tensor.xy() * symm_tensor.yz() * symm_tensor.zx() -
100  symm_tensor.xy() * symm_tensor.xy() * symm_tensor.zz() +
101  symm_tensor.zx() * symm_tensor.xy() * symm_tensor.yz() -
102  symm_tensor.zx() * symm_tensor.yy() * symm_tensor.zx();
103 
104  return val;
105 }
106 
107 Real
108 maxPrincipal(const SymmTensor & symm_tensor, RealVectorValue & direction)
109 {
110  Real val = calcPrincipalValues(symm_tensor, (LIBMESH_DIM - 1), direction);
111  return val;
112 }
113 
114 Real
115 midPrincipal(const SymmTensor & symm_tensor, RealVectorValue & direction)
116 {
117  Real val = calcPrincipalValues(symm_tensor, 1, direction);
118  return val;
119 }
120 
121 Real
122 minPrincipal(const SymmTensor & symm_tensor, RealVectorValue & direction)
123 {
124  Real val = calcPrincipalValues(symm_tensor, 0, direction);
125  return val;
126 }
127 
128 // The functions below for maxPrinciple, midPrinciple and minPrinciple are
129 // deprecated. They will be replaced with the correctly spelled versions.
130 
131 Real
132 maxPrinciple(const SymmTensor & symm_tensor, RealVectorValue & direction)
133 {
134  Real val = calcPrincipalValues(symm_tensor, (LIBMESH_DIM - 1), direction);
135  return val;
136 }
137 
138 Real
139 midPrinciple(const SymmTensor & symm_tensor, RealVectorValue & direction)
140 {
141  Real val = calcPrincipalValues(symm_tensor, 1, direction);
142  return val;
143 }
144 
145 Real
146 minPrinciple(const SymmTensor & symm_tensor, RealVectorValue & direction)
147 {
148  Real val = calcPrincipalValues(symm_tensor, 0, direction);
149  return val;
150 }
151 
152 Real
153 calcPrincipalValues(const SymmTensor & symm_tensor, unsigned int index, RealVectorValue & direction)
154 {
155  ColumnMajorMatrix eval(3, 1);
156  ColumnMajorMatrix evec(3, 3);
157  symm_tensor.columnMajorMatrix().eigen(eval, evec);
158  // Eigen computes low to high. We want high first.
159  direction(0) = evec(0, index);
160  direction(1) = evec(1, index);
161  direction(2) = evec(2, index);
162  return eval(index);
163 }
164 
165 Real
166 axialStress(const SymmTensor & symm_stress,
167  const Point & point1,
168  const Point & point2,
169  RealVectorValue & direction)
170 {
171  Point axis = point2 - point1;
172  axis /= axis.norm();
173 
174  // Calculate the stress in the direction of the axis specifed by the user
175  Real axial_stress = 0.0;
176  for (unsigned int i = 0; i < 3; ++i)
177  {
178  for (unsigned int j = 0; j < 3; ++j)
179  axial_stress += axis(j) * symm_stress(j, i) * axis(i);
180  }
181  direction = axis;
182  return axial_stress;
183 }
184 
185 Real
186 hoopStress(const SymmTensor & symm_stress,
187  const Point & point1,
188  const Point & point2,
189  const Point & curr_point,
190  RealVectorValue & direction)
191 {
192  // Calculate the cross of the normal to the axis of rotation from the current
193  // location and the axis of rotation
194  Point xp;
195  normalPositionVector(point1, point2, curr_point, xp);
196 
197  Point axis_rotation = point2 - point1;
198  Point yp = axis_rotation / axis_rotation.norm();
199  Point zp = xp.cross(yp);
200 
201  // Calculate the scalar value of the hoop stress
202  Real hoop_stress = 0.0;
203  for (unsigned int i = 0; i < 3; ++i)
204  {
205  for (unsigned int j = 0; j < 3; ++j)
206  hoop_stress += zp(j) * symm_stress(j, i) * zp(i);
207  }
208  direction = zp;
209  return hoop_stress;
210 }
211 
212 Real
213 radialStress(const SymmTensor & symm_stress,
214  const Point & point1,
215  const Point & point2,
216  const Point & curr_point,
217  RealVectorValue & direction)
218 {
219  Point radial_norm;
220  normalPositionVector(point1, point2, curr_point, radial_norm);
221 
222  // Compute the scalar stress component in the direciton of the normal vector from the
223  // user-defined axis of rotation.
224  Real radial_stress = 0.0;
225  for (unsigned int i = 0; i < 3; ++i)
226  {
227  for (unsigned int j = 0; j < 3; ++j)
228  radial_stress += radial_norm(j) * symm_stress(j, i) * radial_norm(i);
229  }
230  direction = radial_norm;
231  return radial_stress;
232 }
233 
234 void
235 normalPositionVector(const Point & point1,
236  const Point & point2,
237  const Point & curr_point,
238  Point & normalPosition)
239 {
240  // Find the nearest point on the axis of rotation (defined by point2 - point1)
241  // to the current position, e.g. the normal to the axis of rotation at the
242  // current position
243  Point axis_rotation = point2 - point1;
244  Point positionWRTpoint1 = point1 - curr_point;
245  Real projection = (axis_rotation * positionWRTpoint1) / axis_rotation.norm_sq();
246  Point normal = point1 - projection * axis_rotation;
247 
248  // Calculate the direction normal to the plane formed by the axis of rotation
249  // and the normal to the axis of rotation from the current position.
250  normalPosition = curr_point - normal;
251  normalPosition /= normalPosition.norm();
252 }
253 
254 Real
255 directionValueTensor(const SymmTensor & symm_tensor, const RealVectorValue & input_direction)
256 {
257  Real tensor_value_in_direction = 0.0;
258  for (unsigned int i = 0; i < 3; ++i)
259  {
260  for (unsigned int j = 0; j < 3; ++j)
261  tensor_value_in_direction += input_direction(j) * symm_tensor(j, i) * input_direction(i);
262  }
263  return tensor_value_in_direction;
264 }
265 
266 Real
267 triaxialityStress(const SymmTensor & symm_stress)
268 {
269  Real val = hydrostatic(symm_stress) / vonMisesStress(symm_stress);
270  return val;
271 }
272 }
Real minPrincipal(const SymmTensor &symm_tensor, RealVectorValue &direction)
Real midPrincipal(const SymmTensor &symm_tensor, RealVectorValue &direction)
Real midPrinciple(const SymmTensor &symm_tensor, RealVectorValue &direction)
Real yy() const
Definition: SymmTensor.h:130
Real minPrinciple(const SymmTensor &symm_tensor, RealVectorValue &direction)
Real volumetricStrain(const SymmTensor &symm_strain)
Real calcPrincipalValues(const SymmTensor &symm_tensor, unsigned int index, RealVectorValue &direction)
Real hydrostatic(const SymmTensor &symm_tensor)
Real hoopStress(const SymmTensor &symm_stress, const Point &point1, const Point &point2, const Point &curr_point, RealVectorValue &direction)
Real xx() const
Definition: SymmTensor.h:129
Real maxPrincipal(const SymmTensor &symm_tensor, RealVectorValue &direction)
Real component(const SymmTensor &symm_tensor, unsigned int index)
Real effectiveStrain(const SymmTensor &symm_strain)
Real radialStress(const SymmTensor &symm_stress, const Point &point1, const Point &point2, const Point &curr_point, RealVectorValue &direction)
ColumnMajorMatrix columnMajorMatrix() const
Definition: SymmTensor.h:423
Real triaxialityStress(const SymmTensor &symm_stress)
Real zz() const
Definition: SymmTensor.h:131
Real secondInvariant(const SymmTensor &symm_tensor)
Real vonMisesStress(const SymmTensor &symm_stress)
Real trace() const
Definition: SymmTensor.h:95
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
Real xy() const
Definition: SymmTensor.h:132
void normalPositionVector(const Point &point1, const Point &point2, const Point &curr_point, Point &normalPosition)
Real yz() const
Definition: SymmTensor.h:133
Real zx() const
Definition: SymmTensor.h:134
Real firstInvariant(const SymmTensor &symm_tensor)
Real doubleContraction(const SymmTensor &rhs) const
Definition: SymmTensor.h:257
Real thirdInvariant(const SymmTensor &symm_tensor)
Real maxPrinciple(const SymmTensor &symm_tensor, RealVectorValue &direction)
Real axialStress(const SymmTensor &symm_stress, const Point &point1, const Point &point2, RealVectorValue &direction)
Real component(unsigned int i) const
Definition: SymmTensor.h:97
Real directionValueTensor(const SymmTensor &symm_tensor, const RealVectorValue &input_direction)