https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
36template <typename T>
37constexpr std::array<Real, SymmetricRankTwoTensorTempl<T>::N>
39
40namespace MathUtils
41{
42template <>
44template <>
46}
47
48template <typename T>
51{
52 return MooseEnum("autodetect=0 isotropic1=1 diagonal3=3 symmetric6=6", "autodetect");
53}
54
55template <typename T>
57{
58 std::fill(_vals.begin(), _vals.end(), 0.0);
59}
60
61template <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
78template <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
90template <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
104template <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
123template <typename T>
126 const T & S11, const T & S22, const T & S33, const T & S23, const T & S13, const T & S12)
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
138template <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);
148
149template <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
161template <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
171template <typename T>
172void
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");
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;
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 }
215
216template <typename T>
217void
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
255template <typename T>
256void
258{
260 *this = M * (*this);
261}
262
263template <typename T>
266{
267 return *this;
269
271template <typename T>
273SymmetricRankTwoTensorTempl<T>::row(const unsigned int n) const
274{
275 switch (n)
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");
289}
290
291template <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
303template <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] +
317}
318
319template <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));
330
331template <typename T>
337
338template <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
347template <typename T>
350{
351 return a * 2.0;
352}
353
354template <typename T>
359}
360
361template <typename T>
362void
364{
365 for (std::size_t i = 0; i < N; ++i)
366 _vals[i] = 0.0;
367}
368
369template <typename T>
372{
373 for (std::size_t i = 0; i < N; ++i)
374 _vals[i] += a._vals[i];
375 return *this;
376}
377
378template <typename T>
381{
382 for (std::size_t i = 0; i < N; ++i)
383 _vals[i] -= a._vals[i];
384 return *this;
385}
386
387template <typename T>
388template <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
398template <typename T>
399template <typename T2>
405 for (std::size_t i = 0; i < N; ++i)
406 result(i) = _vals[i] - a(i);
407 return result;
409
411template <typename T>
415 return (*this) * -1.0;
416}
417
418template <typename T>
421{
422 for (std::size_t i = 0; i < N; ++i)
423 _vals[i] *= a;
424 return *this;
425}
427template <typename T>
430{
431 for (std::size_t i = 0; i < N; ++i)
432 _vals[i] /= a;
433 return *this;
434}
435
436template <typename T>
437T
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
446template <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
461template <typename T>
465 SymmetricRankTwoTensorTempl<T> deviatoric(*this);
466 deviatoric.addIa(-1.0 / 3.0 * this->tr());
467 return deviatoric;
469
470template <typename 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
478template <typename T>
479T
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
492template <typename T>
498
499template <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
512template <typename T>
513T
515{
516 return tr();
517}
518
519template <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
536template <typename T>
539{
540 return SymmetricRankTwoTensorTempl<T>(1, 1, 1, 0, 0, 0);
541}
542
543template <typename T>
544T
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
555template <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
569template <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
615template <typename T>
616T
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
626template <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
639template <typename T>
640void
642{
643 for (std::size_t i = 0; i < N; ++i)
644 stm << std::setw(15) << _vals[i] << std::endl;
645}
646
647template <typename T>
648void
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
655template <typename T>
656void
658{
659 for (unsigned int i = 0; i < 3; ++i)
660 _vals[i] += a;
661}
662
663template <typename T>
664T
666{
667 T norm = _vals[0] * _vals[0];
668 for (unsigned int i = 1; i < N; ++i)
669 norm += _vals[i] * _vals[i];
670 using std::sqrt;
671 return norm == 0.0 ? 0.0 : sqrt(norm);
672}
673
674template <typename T>
675void
676SymmetricRankTwoTensorTempl<T>::syev(const char *, std::vector<T> &, std::vector<T> &) const
677{
678 mooseError("The syev method is only supported for Real valued tensors");
679}
680
681template <>
682void SymmetricRankTwoTensor::syev(const char * calculation_type,
683 std::vector<Real> & eigvals,
684 std::vector<Real> & a) const;
685
686template <typename T>
687void
689{
691 symmetricEigenvaluesEigenvectors(eigvals, a);
692}
693
694template <>
695void SymmetricRankTwoTensor::symmetricEigenvalues(std::vector<Real> & eigvals) const;
696
697template <typename T>
698void
700 RankTwoTensorTempl<T> &) const
701{
703 "symmetricEigenvaluesEigenvectors is only available for ordered tensor component types");
704}
705
706template <>
707void SymmetricRankTwoTensor::symmetricEigenvaluesEigenvectors(std::vector<Real> & eigvals,
708 RankTwoTensor & eigvecs) const;
709
710template <typename T>
711void
713{
714 MooseRandom::seed(rand_seed);
715}
716
717template <typename T>
720{
721 auto r = [&]() { return (MooseRandom::rand() + offset) * scale; };
722 return SymmetricRankTwoTensorTempl<T>(r(), r(), r(), r(), r(), r());
723}
724
725template <typename T>
728{
730 v(0) * v(0), v(1) * v(1), v(2) * v(2), v(1) * v(2), v(0) * v(2), v(0) * v(1));
731}
732
733template <typename T>
736{
738 for (auto i : make_range(N))
739 for (auto j : make_range(N))
740 result(j) += (*this)(i)*b(i, j);
741 return result;
742}
743
744template <typename T>
745void
747{
748 std::copy(identityCoords.begin(), identityCoords.end(), _vals.begin());
749}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Real scale
Definition MortarUtils.C:62
unsigned int size() const
The number of elements that can currently be stored in the array.
Definition MooseArray.h:259
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
static Real rand()
This method returns the next random number (Real format) from the generator.
Definition MooseRandom.h:50
static void seed(unsigned int seed)
The method seeds the random number generator.
Definition MooseRandom.h:44
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
SymmetricRankFourTensorTempl is designed to handle an N-dimensional fourth order tensor with minor sy...
static SymmetricRankFourTensorTempl< T > rotationMatrix(const TypeTensor< T > &R)
Build a 6x6 rotation matrix MEHRABADI, MORTEZA M.; COWIN, STEPHEN C.
std::array< T, N2 > _vals
The values of the rank-four tensor.
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 is designed to handle the Stress or Strain Tensor for an anisotropic mate...
FillMethod
To fill up the 6 entries in the 2nd-order tensor, fillFromInputVector is called with one of the follo...
T generalSecondInvariant() const
Calculates the second invariant (I2) of a tensor.
libMesh::VectorValue< T > row(const unsigned int n) const
get the specified row of the tensor
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][...
SymmetricRankTwoTensorTempl< T > deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _vals
SymmetricRankTwoTensorTempl< T > dsecondInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.
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 ...
void symmetricEigenvaluesEigenvectors(std::vector< T > &eigvals, RankTwoTensorTempl< T > &eigvecs) const
computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order...
SymmetricRankFourTensorTempl< T > d2secondInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl.
T L2norm() const
Sqrt(_vals[i][j]*_vals[i][j])
void fillFromScalarVariable(const VariableValue &scalar_variable)
fillFromScalarVariable takes FIRST/THIRD/SIXTH order scalar variable to fill in the Rank-2 tensor.
SymmetricRankTwoTensorTempl< T > initialContraction(const SymmetricRankFourTensorTempl< T > &b) const
returns this_ij * b_ijkl
SymmetricRankTwoTensorTempl< T > transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
SymmetricRankFourTensorTempl< T > d2thirdInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl.
SymmetricRankTwoTensorTempl< T > operator-() const
returns -_vals
SymmetricRankTwoTensorTempl< T > dthirdInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
static void initRandom(unsigned int)
This function initializes random seed based on a user-defined number.
static SymmetricRankTwoTensorTempl< T > selfOuterProduct(const TypeVector< T > &)
SymmetricRankTwoTensorTempl<T> from outer product of a vector with itself.
SymmetricRankTwoTensorTempl< T > & operator/=(const T &a)
performs _vals /= a
SymmetricRankTwoTensorTempl< T > & operator*=(const T &a)
performs _vals *= a
static SymmetricRankTwoTensorTempl< T > timesTranspose(const RankTwoTensorTempl< T > &)
return the matrix multiplied with its transpose A*A^T (guaranteed symmetric)
SymmetricRankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator+(const SymmetricRankTwoTensorTempl< T2 > &a) const
returns _vals + a
T doubleContraction(const SymmetricRankTwoTensorTempl< T > &a) const
returns _vals_ij * a_ij (sum on i, j)
SymmetricRankTwoTensorTempl< T > inverse() const
retuns the inverse of the tensor
void addIa(const T &a)
Add identity times a to _vals.
static SymmetricRankTwoTensorTempl< T > genRandomSymmTensor(T, T)
This function generates a random symmetric rank two tensor.
SymmetricRankFourTensorTempl< T > outerProduct(const SymmetricRankTwoTensorTempl< T > &a) const
returns C_ijkl = a_ij * b_kl
SymmetricRankTwoTensorTempl< T > dtrace() const
Denote the _vals[i][j] by A_ij, then this returns d(trace)/dA_ij.
void print(std::ostream &stm=Moose::out) const
Print the rank two tensor.
static MooseEnum fillMethodEnum()
Static method for use in validParams for getting the "fill_method".
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.
SymmetricRankTwoTensorTempl< T > square() const
Returns the matrix squared.
SymmetricRankTwoTensorTempl< T > ddet() const
Denote the _vals[i][j] by A_ij, then this returns d(det)/dA_ij.
SymmetricRankTwoTensorTempl< T > & operator+=(const SymmetricRankTwoTensorTempl< T > &a)
adds a to _vals
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 printReal(std::ostream &stm=Moose::out) const
Print the Real part of the ADReal rank two tensor.
static SymmetricRankTwoTensorTempl< T > plusTranspose(const RankTwoTensorTempl< T > &)
return the matrix plus its transpose A-A^T (guaranteed symmetric)
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 > & operator-=(const SymmetricRankTwoTensorTempl< T > &a)
sets _vals -= a and returns vals
T trace() const
returns the trace of the tensor, ie _vals[i][i] (sum i = 0, 1, 2)
static SymmetricRankTwoTensorTempl fromRawComponents(const T &S11, const T &S22, const T &S33, const T &S23, const T &S13, const T &S12)
static SymmetricRankTwoTensorTempl< T > transposeTimes(const RankTwoTensorTempl< T > &)
return the matrix multiplied with its transpose A^T*A (guaranteed symmetric)
void setToIdentity()
set the tensor to the identity matrix
SymmetricRankTwoTensorTempl()
Default constructor; fills to zero.
void symmetricEigenvalues(std::vector< T > &eigvals) const
computes eigenvalues, assuming tens is symmetric, and places them in ascending order in eigvals
static SymmetricRankTwoTensorTempl initializeSymmetric(const TypeVector< T > &v0, const TypeVector< T > &v1, const TypeVector< T > &v2)
named constructor for initializing symmetrically
void mooseSetToZero< SymmetricRankTwoTensor >(SymmetricRankTwoTensor &v)
Helper function template specialization to set an object to zero.
void mooseSetToZero< ADSymmetricRankTwoTensor >(ADSymmetricRankTwoTensor &v)
Helper function template specialization to set an object to zero.
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
auto raw_value(const Eigen::Map< T > &in)