https://mooseframework.inl.gov
SymmetricRankTwoTensorImplementation.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 
10 #pragma once
11 
12 #include "SymmetricRankTwoTensor.h"
13 
14 // MOOSE includes
15 #include "MooseEnum.h"
16 #include "ColumnMajorMatrix.h"
17 #include "MooseRandom.h"
19 #include "Conversion.h"
20 #include "MooseArray.h"
21 #include "MathUtils.h"
22 
23 #include "libmesh/libmesh.h"
24 #include "libmesh/vector_value.h"
25 #include "libmesh/utility.h"
26 
27 // PETSc includes
28 #include <petscblaslapack.h>
29 
30 // C++ includes/sqrt
31 #include <iomanip>
32 #include <ostream>
33 #include <vector>
34 #include <array>
35 
36 template <typename T>
39 
40 namespace MathUtils
41 {
42 template <>
44 template <>
46 }
47 
48 template <typename T>
51 {
52  return MooseEnum("autodetect=0 isotropic1=1 diagonal3=3 symmetric6=6", "autodetect");
53 }
54 
55 template <typename T>
57 {
58  std::fill(_vals.begin(), _vals.end(), 0.0);
59 }
60 
61 template <typename T>
63 {
64  switch (init)
65  {
66  case initNone:
67  break;
68 
69  case initIdentity:
70  setToIdentity();
71  break;
72 
73  default:
74  mooseError("Unknown SymmetricRankTwoTensorTempl initialization pattern.");
75  }
76 }
77 
78 template <typename T>
80  const T & S11, const T & S22, const T & S33, const T & S23, const T & S13, const T & S12)
81 {
82  _vals[0] = S11;
83  _vals[1] = S22;
84  _vals[2] = S33;
85  _vals[3] = mandelFactor(3) * S23;
86  _vals[4] = mandelFactor(4) * S13;
87  _vals[5] = mandelFactor(5) * S12;
88 }
89 
90 template <typename T>
92 {
93  return RankTwoTensorTempl<T>(_vals[0],
94  _vals[5] / mandelFactor(5),
95  _vals[4] / mandelFactor(4),
96  _vals[5] / mandelFactor(5),
97  _vals[1],
98  _vals[3] / mandelFactor(3),
99  _vals[4] / mandelFactor(4),
100  _vals[3] / mandelFactor(3),
101  _vals[2]);
102 }
103 
104 template <typename T>
106  const T & S21,
107  const T & S31,
108  const T & S12,
109  const T & S22,
110  const T & S32,
111  const T & S13,
112  const T & S23,
113  const T & S33)
114 {
115  _vals[0] = S11;
116  _vals[1] = S22;
117  _vals[2] = S33;
118  _vals[3] = (S23 + S32) / mandelFactor(3);
119  _vals[4] = (S13 + S31) / mandelFactor(4);
120  _vals[5] = (S12 + S21) / mandelFactor(5);
121 }
122 
123 template <typename T>
126  const T & S11, const T & S22, const T & S33, const T & S23, const T & S13, const T & S12)
127 {
129  ret._vals[0] = S11;
130  ret._vals[1] = S22;
131  ret._vals[2] = S33;
132  ret._vals[3] = S23;
133  ret._vals[4] = S13;
134  ret._vals[5] = S12;
135  return ret;
136 }
137 
138 template <typename T>
140 {
141  _vals[0] = a(0, 0);
142  _vals[1] = a(1, 1);
143  _vals[2] = a(2, 2);
144  _vals[3] = (a(1, 2) + a(2, 1)) / mandelFactor(3);
145  _vals[4] = (a(0, 2) + a(2, 0)) / mandelFactor(4);
146  _vals[5] = (a(0, 1) + a(1, 0)) / mandelFactor(5);
147 }
148 
149 template <typename T>
151 {
152  _vals[0] = a(0, 0);
153  _vals[1] = a(1, 1);
154  _vals[2] = a(2, 2);
155  _vals[3] = (a(1, 2) + a(2, 1)) / mandelFactor(3);
156  _vals[4] = (a(0, 2) + a(2, 0)) / mandelFactor(4);
157  _vals[5] = (a(0, 1) + a(1, 0)) / mandelFactor(5);
158 }
159 
161 template <typename T>
164  const TypeVector<T> & v1,
165  const TypeVector<T> & v2)
166 {
168  v0(0), v1(0), v2(0), v0(1), v1(1), v2(1), v0(2), v1(2), v2(2));
169 }
170 
171 template <typename T>
172 void
174  FillMethod fill_method)
175 {
176  if (fill_method != autodetect && fill_method != input.size())
177  mooseError("Expected an input vector size of ",
178  fill_method,
179  " to fill the SymmetricRankTwoTensorTempl");
180 
181  switch (input.size())
182  {
183  case 1:
184  _vals[0] = input[0];
185  _vals[1] = input[0];
186  _vals[2] = input[0];
187  _vals[3] = 0.0;
188  _vals[4] = 0.0;
189  _vals[5] = 0.0;
190  break;
191 
192  case 3:
193  _vals[0] = input[0];
194  _vals[1] = input[1];
195  _vals[2] = input[2];
196  _vals[3] = 0.0;
197  _vals[4] = 0.0;
198  _vals[5] = 0.0;
199  break;
200 
201  case 6:
202  _vals[0] = input[0];
203  _vals[1] = input[1];
204  _vals[2] = input[2];
205  _vals[3] = mandelFactor(3) * input[3];
206  _vals[4] = mandelFactor(4) * input[4];
207  _vals[5] = mandelFactor(5) * input[5];
208  break;
209 
210  default:
211  mooseError("Please check the number of entries in the input vector for building "
212  "a SymmetricRankTwoTensorTempl. It must be 1, 3, 6");
213  }
214 }
215 
216 template <typename T>
217 void
219 {
220  switch (scalar_variable.size())
221  {
222  case 1:
223  _vals[0] = scalar_variable[0];
224  _vals[1] = 0.0;
225  _vals[2] = 0.0;
226  _vals[3] = 0.0;
227  _vals[4] = 0.0;
228  _vals[5] = 0.0;
229  break;
230 
231  case 3:
232  _vals[0] = scalar_variable[0];
233  _vals[1] = scalar_variable[1];
234  _vals[2] = 0.0;
235  _vals[3] = 0.0;
236  _vals[4] = 0.0;
237  _vals[5] = mandelFactor(5) * scalar_variable[2];
238  break;
239 
240  case 6:
241  _vals[0] = scalar_variable[0];
242  _vals[1] = scalar_variable[1];
243  _vals[2] = scalar_variable[2];
244  _vals[3] = mandelFactor(3) * scalar_variable[3];
245  _vals[4] = mandelFactor(4) * scalar_variable[4];
246  _vals[5] = mandelFactor(5) * scalar_variable[5];
247  break;
248 
249  default:
250  mooseError("Only FIRST, THIRD, or SIXTH order scalar variable can be used to build "
251  "a SymmetricRankTwoTensorTempl.");
252  }
253 }
254 
255 template <typename T>
256 void
258 {
260  *this = M * (*this);
261 }
262 
263 template <typename T>
266 {
267  return *this;
268 }
269 
271 template <typename T>
273 SymmetricRankTwoTensorTempl<T>::row(const unsigned int n) const
274 {
275  switch (n)
276  {
277  case 0:
279  _vals[0], _vals[5] / mandelFactor(5), _vals[4] / mandelFactor(4));
280  case 1:
282  _vals[5] / mandelFactor(5), _vals[1], _vals[3] / mandelFactor(3));
283  case 2:
285  _vals[4] / mandelFactor(4), _vals[3] / mandelFactor(3), _vals[2]);
286  default:
287  mooseError("Invalid row");
288  }
289 }
290 
291 template <typename T>
294 {
295  return SymmetricRankTwoTensorTempl<T>(a(0, 0) * a(0, 0) + a(0, 1) * a(0, 1) + a(0, 2) * a(0, 2),
296  a(1, 0) * a(1, 0) + a(1, 1) * a(1, 1) + a(1, 2) * a(1, 2),
297  a(2, 0) * a(2, 0) + a(2, 1) * a(2, 1) + a(2, 2) * a(2, 2),
298  a(1, 0) * a(2, 0) + a(1, 1) * a(2, 1) + a(1, 2) * a(2, 2),
299  a(0, 0) * a(2, 0) + a(0, 1) * a(2, 1) + a(0, 2) * a(2, 2),
300  a(0, 0) * a(1, 0) + a(0, 1) * a(1, 1) + a(0, 2) * a(1, 2));
301 }
302 
303 template <typename T>
306 {
308  a._vals[0] * a._vals[0] + a._vals[4] * a._vals[4] / 2.0 + a._vals[5] * a._vals[5] / 2.0,
309  a._vals[1] * a._vals[1] + a._vals[3] * a._vals[3] / 2.0 + a._vals[5] * a._vals[5] / 2.0,
310  a._vals[2] * a._vals[2] + a._vals[3] * a._vals[3] / 2.0 + a._vals[4] * a._vals[4] / 2.0,
311  a._vals[1] * a._vals[3] + a._vals[2] * a._vals[3] +
312  a._vals[4] * a._vals[5] / MathUtils::sqrt2,
313  a._vals[0] * a._vals[4] + a._vals[2] * a._vals[4] +
314  a._vals[3] * a._vals[5] / MathUtils::sqrt2,
315  a._vals[0] * a._vals[5] + a._vals[1] * a._vals[5] +
316  a._vals[3] * a._vals[4] / MathUtils::sqrt2);
317 }
318 
319 template <typename T>
322 {
323  return SymmetricRankTwoTensorTempl<T>(a(0, 0) * a(0, 0) + a(1, 0) * a(1, 0) + a(2, 0) * a(2, 0),
324  a(0, 1) * a(0, 1) + a(1, 1) * a(1, 1) + a(2, 1) * a(2, 1),
325  a(0, 2) * a(0, 2) + a(1, 2) * a(1, 2) + a(2, 2) * a(2, 2),
326  a(0, 1) * a(0, 2) + a(1, 1) * a(1, 2) + a(2, 1) * a(2, 2),
327  a(0, 0) * a(0, 2) + a(1, 0) * a(1, 2) + a(2, 0) * a(2, 2),
328  a(0, 0) * a(0, 1) + a(1, 0) * a(1, 1) + a(2, 0) * a(2, 1));
329 }
330 
331 template <typename T>
334 {
335  return timesTranspose(a);
336 }
337 
338 template <typename T>
341 {
343  a(0, 0), a(0, 1), a(0, 2), a(1, 0), a(1, 1), a(1, 2), a(2, 0), a(2, 1), a(2, 2)) *
344  2.0;
345 }
346 
347 template <typename T>
350 {
351  return a * 2.0;
352 }
353 
354 template <typename T>
357 {
359 }
360 
361 template <typename T>
362 void
364 {
365  for (std::size_t i = 0; i < N; ++i)
366  _vals[i] = 0.0;
367 }
368 
369 template <typename T>
372 {
373  for (std::size_t i = 0; i < N; ++i)
374  _vals[i] += a._vals[i];
375  return *this;
376 }
377 
378 template <typename T>
381 {
382  for (std::size_t i = 0; i < N; ++i)
383  _vals[i] -= a._vals[i];
384  return *this;
385 }
386 
387 template <typename T>
388 template <typename T2>
391 {
393  for (std::size_t i = 0; i < N; ++i)
394  result(i) = _vals[i] + a(i);
395  return result;
396 }
397 
398 template <typename T>
399 template <typename T2>
402 {
405  for (std::size_t i = 0; i < N; ++i)
406  result(i) = _vals[i] - a(i);
407  return result;
408 }
409 
411 template <typename T>
414 {
415  return (*this) * -1.0;
416 }
417 
418 template <typename T>
421 {
422  for (std::size_t i = 0; i < N; ++i)
423  _vals[i] *= a;
424  return *this;
425 }
426 
427 template <typename T>
430 {
431  for (std::size_t i = 0; i < N; ++i)
432  _vals[i] /= a;
433  return *this;
434 }
435 
436 template <typename T>
437 T
439 {
440  T sum = 0;
441  for (unsigned int i = 0; i < N; ++i)
442  sum += _vals[i] * b._vals[i];
443  return sum;
444 }
445 
446 template <typename T>
449 {
451  unsigned int index = 0;
452  for (unsigned int i = 0; i < N; ++i)
453  {
454  const T & a = _vals[i];
455  for (unsigned int j = 0; j < N; ++j)
456  result._vals[index++] = a * b._vals[j];
457  }
458  return result;
459 }
460 
461 template <typename T>
464 {
465  SymmetricRankTwoTensorTempl<T> deviatoric(*this);
466  deviatoric.addIa(-1.0 / 3.0 * this->tr());
467  return deviatoric;
468 }
469 
470 template <typename T>
471 T
473 {
474  return _vals[0] * _vals[1] + _vals[0] * _vals[2] + _vals[1] * _vals[2] -
475  (_vals[3] * _vals[3] + _vals[4] * _vals[4] + _vals[5] * _vals[5]) / 2.0;
476 }
477 
478 template <typename T>
479 T
481 {
482  T result;
483  result = Utility::pow<2>(_vals[0] - _vals[1]) / 6.0;
484  result += Utility::pow<2>(_vals[0] - _vals[2]) / 6.0;
485  result += Utility::pow<2>(_vals[1] - _vals[2]) / 6.0;
486  result += Utility::pow<2>(_vals[5]) / 2.0;
487  result += Utility::pow<2>(_vals[4]) / 2.0;
488  result += Utility::pow<2>(_vals[3]) / 2.0;
489  return result;
490 }
491 
492 template <typename T>
495 {
496  return SymmetricRankTwoTensorTempl<T>::plusTranspose(deviatoric()) * 0.5;
497 }
498 
499 template <typename T>
502 {
504 
505  for (auto i : make_range(N))
506  for (auto j : make_range(N))
507  result(i, j) = 0.5 * (i == j) + 0.5 * (i == j) - (1.0 / 3.0) * (i < 3) * (j < 3);
508 
509  return result;
510 }
511 
512 template <typename T>
513 T
515 {
516  return tr();
517 }
518 
519 template <typename T>
522 {
523  const auto d = det();
524  if (d == 0.0)
525  mooseException("Matrix not invertible");
527  _vals[2] * _vals[1] - _vals[3] * _vals[3] / 2.0,
528  _vals[2] * _vals[0] - _vals[4] * _vals[4] / 2.0,
529  _vals[0] * _vals[1] - _vals[5] * _vals[5] / 2.0,
530  _vals[5] * _vals[4] / 2.0 - _vals[0] * _vals[3] / MathUtils::sqrt2,
531  _vals[5] * _vals[3] / 2.0 - _vals[4] * _vals[1] / MathUtils::sqrt2,
532  _vals[4] * _vals[3] / 2.0 - _vals[2] * _vals[5] / MathUtils::sqrt2);
533  return inv * 1.0 / d;
534 }
535 
536 template <typename T>
539 {
540  return SymmetricRankTwoTensorTempl<T>(1, 1, 1, 0, 0, 0);
541 }
542 
543 template <typename T>
544 T
546 {
547  const auto s = SymmetricRankTwoTensorTempl<T>::plusTranspose(deviatoric()) * 0.5;
548  return s(0) * (s(1) * s(2) - s(3) / MathUtils::sqrt2 * s(3) / MathUtils::sqrt2) -
549  s(5) / MathUtils::sqrt2 *
550  (s(5) / MathUtils::sqrt2 * s(2) - s(3) / MathUtils::sqrt2 * s(4) / MathUtils::sqrt2) +
551  s(4) / MathUtils::sqrt2 *
552  (s(5) / MathUtils::sqrt2 * s(3) / MathUtils::sqrt2 - s(1) * s(4) / MathUtils::sqrt2);
553 }
554 
555 template <typename T>
558 {
559  const auto s = SymmetricRankTwoTensorTempl<T>::plusTranspose(deviatoric()) * 0.5;
560  const T s3 = secondInvariant() / 3.0;
561  return SymmetricRankTwoTensorTempl<T>(s(1) * s(2) - s(3) * s(3) / 2.0 + s3,
562  s(0) * s(2) - s(4) * s(4) / 2.0 + s3,
563  s(0) * s(1) - s(5) * s(5) / 2.0 + s3,
564  s(5) * s(4) / 2.0 - s(0) * s(3) / MathUtils::sqrt2,
565  s(5) * s(3) / 2.0 - s(1) * s(4) / MathUtils::sqrt2,
566  s(4) * s(3) / 2.0 - s(5) * s(2) / MathUtils::sqrt2);
567 }
568 
569 template <typename T>
572 {
573  const auto s = SymmetricRankTwoTensorTempl<T>::plusTranspose(deviatoric()) * 0.5;
574 
576  for (auto i : make_range(N))
577  for (auto j : make_range(N))
578  d2(i, j) = Real(i < 3) * s(j) / 3.0 / (j < 3 ? 1 : MathUtils::sqrt2) +
579  Real(j < 3) * s(i) / 3.0 / (i < 3 ? 1 : MathUtils::sqrt2);
580 
581  d2(0, 1) += s(2);
582  d2(0, 2) += s(1);
583  d2(0, 3) -= s(3) / MathUtils::sqrt2;
584 
585  d2(1, 0) += s(2);
586  d2(1, 2) += s(0);
587  d2(1, 4) -= s(4) / MathUtils::sqrt2;
588 
589  d2(2, 0) += s(1);
590  d2(2, 1) += s(0);
591  d2(2, 5) -= s(5) / MathUtils::sqrt2;
592 
593  d2(3, 0) -= s(3) / MathUtils::sqrt2;
594  d2(3, 3) -= s(0) / 2.0;
595  d2(3, 4) += s(5) / 2.0 / MathUtils::sqrt2;
596  d2(3, 5) += s(4) / 2.0 / MathUtils::sqrt2;
597 
598  d2(4, 1) -= s(4) / MathUtils::sqrt2;
599  d2(4, 3) += s(5) / 2.0 / MathUtils::sqrt2;
600  d2(4, 4) -= s(1) / 2.0;
601  d2(4, 5) += s(3) / 2.0 / MathUtils::sqrt2;
602 
603  d2(5, 2) -= s(5) / MathUtils::sqrt2;
604  d2(5, 3) += s(4) / 2.0 / MathUtils::sqrt2;
605  d2(5, 4) += s(3) / 2.0 / MathUtils::sqrt2;
606  d2(5, 5) -= s(2) / 2.0;
607 
608  for (auto i : make_range(N))
609  for (auto j : make_range(N))
611 
612  return d2;
613 }
614 
615 template <typename T>
616 T
618 {
619  return _vals[0] * (_vals[2] * _vals[1] - _vals[3] * _vals[3] / 2.0) -
620  _vals[5] / MathUtils::sqrt2 *
621  (_vals[2] * _vals[5] / MathUtils::sqrt2 - _vals[3] * _vals[4] / 2.0) +
622  _vals[4] / MathUtils::sqrt2 *
623  (_vals[3] * _vals[5] / 2.0 - _vals[1] * _vals[4] / MathUtils::sqrt2);
624 }
625 
626 template <typename T>
629 {
631  _vals[2] * _vals[1] - _vals[3] * _vals[3] / 2.0,
632  _vals[0] * _vals[2] - _vals[4] * _vals[4] / 2.0,
633  _vals[0] * _vals[1] - _vals[5] * _vals[5] / 2.0,
634  _vals[4] * _vals[5] / 2.0 - _vals[0] * _vals[3] / MathUtils::sqrt2,
635  _vals[5] * _vals[3] / 2.0 - _vals[4] * _vals[1] / MathUtils::sqrt2,
636  _vals[4] * _vals[3] / 2.0 - _vals[5] * _vals[2] / MathUtils::sqrt2);
637 }
638 
639 template <typename T>
640 void
641 SymmetricRankTwoTensorTempl<T>::print(std::ostream & stm) const
642 {
643  for (std::size_t i = 0; i < N; ++i)
644  stm << std::setw(15) << _vals[i] << std::endl;
645 }
646 
647 template <typename T>
648 void
650 {
651  for (std::size_t i = 0; i < N; ++i)
652  stm << std::setw(15) << MetaPhysicL::raw_value(_vals[i]) << std::endl;
653 }
654 
655 template <typename T>
656 void
658 {
659  for (unsigned int i = 0; i < 3; ++i)
660  _vals[i] += a;
661 }
662 
663 template <typename T>
664 T
666 {
667  T norm = _vals[0] * _vals[0];
668  for (unsigned int i = 1; i < N; ++i)
669  norm += _vals[i] * _vals[i];
670  return norm == 0.0 ? 0.0 : std::sqrt(norm);
671 }
672 
673 template <typename T>
674 void
675 SymmetricRankTwoTensorTempl<T>::syev(const char *, std::vector<T> &, std::vector<T> &) const
676 {
677  mooseError("The syev method is only supported for Real valued tensors");
678 }
679 
680 template <>
681 void SymmetricRankTwoTensor::syev(const char * calculation_type,
682  std::vector<Real> & eigvals,
683  std::vector<Real> & a) const;
684 
685 template <typename T>
686 void
688 {
690  symmetricEigenvaluesEigenvectors(eigvals, a);
691 }
692 
693 template <>
694 void SymmetricRankTwoTensor::symmetricEigenvalues(std::vector<Real> & eigvals) const;
695 
696 template <typename T>
697 void
699  RankTwoTensorTempl<T> &) const
700 {
701  mooseError(
702  "symmetricEigenvaluesEigenvectors is only available for ordered tensor component types");
703 }
704 
705 template <>
706 void SymmetricRankTwoTensor::symmetricEigenvaluesEigenvectors(std::vector<Real> & eigvals,
707  RankTwoTensor & eigvecs) const;
708 
709 template <typename T>
710 void
712 {
713  MooseRandom::seed(rand_seed);
714 }
715 
716 template <typename T>
719 {
720  auto r = [&]() { return (MooseRandom::rand() + offset) * scale; };
721  return SymmetricRankTwoTensorTempl<T>(r(), r(), r(), r(), r(), r());
722 }
723 
724 template <typename T>
727 {
729  v(0) * v(0), v(1) * v(1), v(2) * v(2), v(1) * v(2), v(0) * v(2), v(0) * v(1));
730 }
731 
732 template <typename T>
735 {
737  for (auto i : make_range(N))
738  for (auto j : make_range(N))
739  result(j) += (*this)(i)*b(i, j);
740  return result;
741 }
742 
743 template <typename T>
744 void
746 {
747  std::copy(identityCoords.begin(), identityCoords.end(), _vals.begin());
748 }
SymmetricRankTwoTensorTempl< T > dsecondInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.
std::array< T, N2 > _vals
The values of the rank-four tensor.
void fillFromScalarVariable(const VariableValue &scalar_variable)
fillFromScalarVariable takes FIRST/THIRD/SIXTH order scalar variable to fill in the Rank-2 tensor...
static SymmetricRankTwoTensorTempl< T > timesTranspose(const RankTwoTensorTempl< T > &)
return the matrix multiplied with its transpose A*A^T (guaranteed symmetric)
SymmetricRankTwoTensorTempl< T > & operator*=(const T &a)
performs _vals *= a
FillMethod
To fill up the 6 entries in the 2nd-order tensor, fillFromInputVector is called with one of the follo...
T thirdInvariant() const
Denote the _vals[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns det(S + S...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
void scale(MeshBase &mesh, const Real xs, const Real ys=0., const Real zs=0.)
void addIa(const T &a)
Add identity times a to _vals.
void printReal(std::ostream &stm=Moose::out) const
Print the Real part of the ADReal rank two tensor.
T generalSecondInvariant() const
Calculates the second invariant (I2) of a tensor.
SymmetricRankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator+(const SymmetricRankTwoTensorTempl< T2 > &a) const
returns _vals + a
SymmetricRankFourTensorTempl< T > d2thirdInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl.
void rotate(const TypeTensor< T > &R)
rotates the tensor data given a rank two tensor rotation tensor _vals[i][j] = R_ij * R_jl * _vals[k][...
static void initRandom(unsigned int)
This function initializes random seed based on a user-defined number.
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:73
static SymmetricRankTwoTensorTempl< T > transposeTimes(const RankTwoTensorTempl< T > &)
return the matrix multiplied with its transpose A^T*A (guaranteed symmetric)
T trace() const
returns the trace of the tensor, ie _vals[i][i] (sum i = 0, 1, 2)
void symmetricEigenvaluesEigenvectors(std::vector< T > &eigvals, RankTwoTensorTempl< T > &eigvecs) const
computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order...
static constexpr Real mandelFactor(unsigned int i, unsigned int j)
returns the 1, sqrt(2), or 2 prefactor in the Mandel notation for the indices i,j ranging from 0-5...
SymmetricRankTwoTensorTempl< T > ddet() const
Denote the _vals[i][j] by A_ij, then this returns d(det)/dA_ij.
SymmetricRankFourTensorTempl< T > d2secondInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl.
static SymmetricRankFourTensorTempl< T > rotationMatrix(const TypeTensor< T > &R)
Build a 6x6 rotation matrix MEHRABADI, MORTEZA M.
SymmetricRankTwoTensorTempl< T > initialContraction(const SymmetricRankFourTensorTempl< T > &b) const
returns this_ij * b_ijkl
void fillFromInputVector(const std::vector< T > &input, FillMethod fill_method=autodetect)
fillFromInputVector takes 1, 3, or 6 inputs to fill in the symmmetric Rank-2 tensor.
void print(std::ostream &stm=Moose::out) const
Print the rank two tensor.
T secondInvariant() const
Denote the _vals[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns (S_ij + S_ji)*(S_i...
SymmetricRankTwoTensorTempl< T > square() const
Returns the matrix squared.
SymmetricRankTwoTensorTempl()
Default constructor; fills to zero.
T L2norm() const
Sqrt(_vals[i][j]*_vals[i][j])
SymmetricRankTwoTensorTempl is designed to handle the Stress or Strain Tensor for an anisotropic mate...
void init(triangulateio &t)
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
auto norm(const T &a) -> decltype(std::abs(a))
SymmetricRankTwoTensorTempl< T > deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _vals
T doubleContraction(const SymmetricRankTwoTensorTempl< T > &a) const
returns _vals_ij * a_ij (sum on i, j)
SymmetricRankTwoTensorTempl< T > & operator/=(const T &a)
performs _vals /= a
SymmetricRankTwoTensorTempl< T > dthirdInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
void setToIdentity()
set the tensor to the identity matrix
OutputTools< Real >::VariableValue VariableValue
Definition: MooseTypes.h:314
static SymmetricRankTwoTensorTempl< T > selfOuterProduct(const TypeVector< T > &)
SymmetricRankTwoTensorTempl<T> from outer product of a vector with itself.
void symmetricEigenvalues(std::vector< T > &eigvals) const
computes eigenvalues, assuming tens is symmetric, and places them in ascending order in eigvals ...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SymmetricRankTwoTensorTempl< T > & operator-=(const SymmetricRankTwoTensorTempl< T > &a)
sets _vals -= a and returns vals
static SymmetricRankTwoTensorTempl< T > genRandomSymmTensor(T, T)
This function generates a random symmetric rank two tensor.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
static SymmetricRankTwoTensorTempl< T > plusTranspose(const RankTwoTensorTempl< T > &)
return the matrix plus its transpose A-A^T (guaranteed symmetric)
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:87
static void seed(unsigned int seed)
The method seeds the random number generator.
Definition: MooseRandom.h:44
SymmetricRankTwoTensorTempl< T > dtrace() const
Denote the _vals[i][j] by A_ij, then this returns d(trace)/dA_ij.
static MooseEnum fillMethodEnum()
Static method for use in validParams for getting the "fill_method".
static SymmetricRankTwoTensorTempl initializeSymmetric(const TypeVector< T > &v0, const TypeVector< T > &v1, const TypeVector< T > &v2)
named constructor for initializing symmetrically
SymmetricRankFourTensorTempl is designed to handle an N-dimensional fourth order tensor with minor sy...
IntRange< T > make_range(T beg, T end)
static Real rand()
This method returns the next random number (Real format) from the generator.
Definition: MooseRandom.h:50
void mooseSetToZero< SymmetricRankTwoTensor >(SymmetricRankTwoTensor &v)
Helper function template specialization to set an object to zero.
void syev(const char *calculation_type, std::vector< T > &eigvals, std::vector< T > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _vals: (1) the eigenvalues (if ...
SymmetricRankFourTensorTempl< T > outerProduct(const SymmetricRankTwoTensorTempl< T > &a) const
returns C_ijkl = a_ij * b_kl
void mooseSetToZero< ADSymmetricRankTwoTensor >(ADSymmetricRankTwoTensor &v)
Helper function template specialization to set an object to zero.
SymmetricRankTwoTensorTempl< T > & operator+=(const SymmetricRankTwoTensorTempl< T > &a)
adds a to _vals
libMesh::VectorValue< T > row(const unsigned int n) const
get the specified row of the tensor
static SymmetricRankTwoTensorTempl fromRawComponents(const T &S11, const T &S22, const T &S33, const T &S23, const T &S13, const T &S12)
SymmetricRankTwoTensorTempl< T > transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
static constexpr Real sqrt2
std::sqrt is not constexpr, so we add sqrt(2) as a constant (used in Mandel notation) ...
Definition: MathUtils.h:25
SymmetricRankTwoTensorTempl< T > operator-() const
returns -_vals
void zero()
Set all components to zero.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template pow< 2 >(tan(_arg))+1.0) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(sqrt
SymmetricRankTwoTensorTempl< T > inverse() const
retuns the inverse of the tensor