26 SymTensor() { d11_ = d22_ = d33_ = d12_ = d13_ = d23_ = initVal<T>(); }
34 explicit SymTensor(
const double &i11,
const double &i22=0.0,
const double &i33=0.0,
35 const double &i12=0.0,
const double &i13=0.0,
const double &i23=0.0)
36 : d11_(i11), d22_(i22), d33_(i33), d12_(i12), d13_(i13), d23_(i23) { }
41 bool operator==(
const SymTensor &s)
const;
45 const double &
s11()
const {
return d11_; }
46 const double &
s22()
const {
return d22_; }
47 const double &
s33()
const {
return d33_; }
48 const double &
s12()
const {
return d12_; }
49 const double &
s13()
const {
return d13_; }
50 const double &
s23()
const {
return d23_; }
51 const double &
s21()
const {
return d12_; }
52 const double &
s31()
const {
return d13_; }
53 const double &
s32()
const {
return d23_; }
55 double &
rs11() {
return d11_; }
56 double &
rs22() {
return d22_; }
57 double &
rs33() {
return d33_; }
58 double &
rs12() {
return d12_; }
59 double &
rs13() {
return d13_; }
60 double &
rs23() {
return d23_; }
61 double &
rs21() {
return d12_; }
62 double &
rs31() {
return d13_; }
63 double &
rs32() {
return d23_; }
68 inline const double &operator[](
unsigned int i)
const;
69 inline double &operator[](
unsigned int i);
72 const double &operator()(
unsigned int i,
unsigned int j)
const;
74 double &operator()(
unsigned int i,
unsigned int j);
83 double getTrace()
const {
return d11_+d22_+d33_; }
87 double getI1()
const {
return getTrace(); }
89 double getI2()
const {
return d11_*d22_ + d22_*d33_ + d11_*d33_ - d12_*d12_ - d23_*d23_ - d13_*d13_; }
91 double getI3()
const {
return getDeterminate(); }
95 double getJ2(
SymTensor *dev,
double *I1=
nullptr);
106 double getJ3()
const;
108 double getLode(
double *I1 =
nullptr,
double *J2 =
nullptr,
double *J3 =
nullptr);
110 double getDeterminate()
const;
112 double getNorm2()
const {
return d11_*d11_ + d22_*d22_ + d33_*d33_ + 2.0*(d12_*d12_ + d13_*d13_ + d23_*d23_); }
116 double getTotalMeasure()
const;
123 inline DVect3 operator*(
const DVect3 &input)
const;
124 inline DVect2 operator*(
const DVect2 &input)
const;
125 inline SymTensor operator*(
const double &mul)
const;
126 inline const SymTensor &operator*=(
const double &mul);
127 inline SymTensor operator/(
const double &mul)
const;
128 inline const SymTensor &operator/=(
const double &mul);
133 const SymTensor &operator-=(
const SymTensor &s) { d11_-=s.d11_; d22_-=s.d22_; d33_-=s.d33_; d12_-=s.d12_; d13_-=s.d13_; d23_-=s.d23_;
return *
this; }
141 static SymTensor fromForceNormal(
const DVect3 &normal,
const DVect3 &force);
142 static inline uint32 doubleToSingleComponent(uint32 dof1,uint32 dof2);
144 bool isDiagonal(
double tol = std::numeric_limits<double>::epsilon()*1000.0)
const {
return (abs(d12_) > tol || abs(d13_) > tol || abs(d23_) > tol) ? false :
true; }
145 inline bool isIsotropic(
double tol = std::numeric_limits<double>::epsilon()*1000.0)
const;
146 inline void adjustTrace(
const double &newTrace);
147 inline void incrementDiagonal(
const double &increment) { d11_ += increment; d22_ += increment; d33_ += increment; }
148 inline void rotate(
const DVect3 &rot);
149 inline double maxAbs()
const {
return std::max(std::abs(d11_),std::max(std::abs(d22_),std::max(std::abs(d33_),std::max(std::abs(d12_),std::max(std::abs(d13_),std::abs(d23_)))))); }
150 inline bool zero()
const {
return (d11_==0.0) and (d22_==0.0) and (d33_==0.0) and (d12_==0.0) and (d13_==0.0) and (d23_==0.0); }
182 enum class Type { ThreeDCube, ThreeDJacobi, ZMax, ZMid, ZMin };
198 return (d11_ == s.d11_ && d22_ == s.d22_ &&
199 d33_ == s.d33_ && d12_ == s.d12_ && d13_ == s.d13_ &&
232 return sqrt(I1*I1/3.0 + 2.0*J2);
236 return DVect3(normal.x()*
s11() + normal.y()*
s12() + normal.z()*
s13(),
237 normal.x()*
s21() + normal.y()*
s22() + normal.z()*
s23(),
238 normal.x()*
s31() + normal.y()*
s32() + normal.z()*
s33());
242 return DVect2(normal.x()*
s11() + normal.y()*
s12(),
243 normal.x()*
s21() + normal.y()*
s22());
248 ret.d11_ = d11_ *
mul;
249 ret.d22_ = d22_ *
mul;
250 ret.d33_ = d33_ *
mul;
251 ret.d12_ = d12_ *
mul;
252 ret.d13_ = d13_ *
mul;
253 ret.d23_ = d23_ *
mul;
257inline const SymTensor &SymTensor::operator*=(
const double &
mul) {
267inline SymTensor SymTensor::operator/(
const double &
mul)
const {
269 ret.d11_ = d11_ /
mul;
270 ret.d22_ = d22_ /
mul;
271 ret.d33_ = d33_ /
mul;
272 ret.d12_ = d12_ /
mul;
273 ret.d13_ = d13_ /
mul;
274 ret.d23_ = d23_ /
mul;
278inline const SymTensor &SymTensor::operator/=(
const double &
mul) {
290 ret.d11_ = d11_ + s.d11_;
291 ret.d22_ = d22_ + s.d22_;
292 ret.d33_ = d33_ + s.d33_;
293 ret.d12_ = d12_ + s.d12_;
294 ret.d13_ = d13_ + s.d13_;
295 ret.d23_ = d23_ + s.d23_;
301 ret.d11_ = d11_ - s.d11_;
302 ret.d22_ = d22_ - s.d22_;
303 ret.d33_ = d33_ - s.d33_;
304 ret.d12_ = d12_ - s.d12_;
305 ret.d13_ = d13_ - s.d13_;
306 ret.d23_ = d23_ - s.d23_;
310inline bool SymTensor::isIsotropic(
double tol)
const {
311 double dtol =
std::max(std::max(std::abs(
s11()),std::abs(
s22())),std::abs(
s33())) * tol;
312 if (std::abs(
s11()-
s22()) > dtol)
return false;
313 if (std::abs(
s11()-
s33()) > dtol)
return false;
314 if (std::abs(
s12()) > dtol)
return false;
315 if (std::abs(
s13()) > dtol)
return false;
316 if (std::abs(
s23()) > dtol)
return false;
320inline void SymTensor::adjustTrace(
const double &newTrace) {
321 static constexpr double d1d3 = 1.0 / 3.0;
323 double dx =
s11() -
s22();
324 double dy =
s22() -
s33();
325 double dz =
s33() -
s11();
326 rs11() = (newTrace + dx - dz) * d1d3;
327 rs22() = (newTrace + dy - dx) * d1d3;
328 rs33() = (newTrace + dz - dy) * d1d3;
331inline void SymTensor::rotate(
const DVect3 &rot) {
333 d11_ += 2.0*( copy.s12()*rot.x() + copy.s13()*rot.y());
334 d22_ += 2.0*(-copy.s12()*rot.x() + copy.s23()*rot.z());
335 d33_ += -2.0*( copy.s13()*rot.y() + copy.s23()*rot.z());
336 d12_ += ((copy.s22() - copy.s11())*rot.x() + copy.s23()*rot.x() + copy.s13()*rot.z());
337 d13_ += ( copy.s23()*rot.x() + (copy.s33() - copy.s11())*rot.x() - copy.s12()*rot.z());
338 d23_ += ( -copy.s13()*rot.x() - copy.s12()*rot.x() + (copy.s33() - copy.s22())*rot.z());
347uint32 SymTensor::doubleToSingleComponent(uint32 dof1,uint32 dof2) {
348 dof1 = std::clamp<uint32>(dof1,0,2);
349 dof2 = std::clamp<uint32>(dof2,0,2);
377 BASE_EXPORT string ts(
const SymTensor &s,
int width=0,
char notation =
'\0',
int precision = -1,
char fill =
' ');
2D and 3D cartesian Axes systems.
Class for specifying a particular 3D cartesian axes system, and converting to and from it.
Definition axes.h:121
A symmetric 2nd order tensor.
Definition symtensor.h:22
double & rs31()
Reference access to components, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:62
double & rs22()
Reference access to components, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:56
double & rs13()
Reference access to components, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:59
double & rs11()
Reference access to components, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:55
double getI3() const
Returns the third invariant, or I3.
Definition symtensor.h:91
SymTensor(const double &i11, const double &i22=0.0, const double &i33=0.0, const double &i12=0.0, const double &i13=0.0, const double &i23=0.0)
Definition symtensor.h:34
const SymTensor & operator+=(const SymTensor &s)
+= operator for a SymTensor
Definition symtensor.h:132
double & rs12()
Reference access to components, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:58
const double & s23() const
Component access, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:50
const double & s21() const
Component access, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:51
const double & s22() const
Component access, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:46
double getI1() const
Same as getTrace() - returns the first invariant.
Definition symtensor.h:87
const double & s33() const
Component access, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:47
SymTensor mul(const double &d) const
Returns a SymTensor with every component multiplied by a scalar value.
Definition symtensor.h:130
const double & s13() const
Component access, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:49
double & rs33()
Reference access to components, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:57
bool isDiagonal(double tol=std::numeric_limits< double >::epsilon() *1000.0) const
Determines whether or not the SymTensor is diagonal.
Definition symtensor.h:144
const double & s11() const
Component access, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:45
double getI2() const
Returns the second invariant.
Definition symtensor.h:89
double & rs21()
Reference access to components, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:61
double getTrace() const
Returns the trace of the tensor (11+22+33). I1.
Definition symtensor.h:83
const double & s31() const
Component access, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:52
double & rs23()
Reference access to components, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:60
SymTensor(const SymTensor &s)
Copy constructor.
Definition symtensor.h:31
double getJ2() const
Returns the second invariant of the deviatoric – J2.
Definition symtensor.cpp:156
SymTensor()
Default constructor, no data initialization.
Definition symtensor.h:28
double & rs32()
Reference access to components, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:63
double getNorm2() const
Returns a scalar norm (magnitude) value for the tensor, can be used for tolerance checking,...
Definition symtensor.h:112
SymTensor getDeviatoric() const
Returns the deviatoric tensor.
Definition symtensor.h:85
const double & s12() const
Component access, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:48
const double & s32() const
Component access, note that s12 is equivalent to s21 (for instance).
Definition symtensor.h:53
SymTensor eigenvalue and direction helper class.
Definition symtensor.h:168
BASE_EXPORT SymTensorInfo()
Default constructor.
Definition symtensor.h:172
BASE_EXPORT const SymTensorInfo & operator=(const SymTensorInfo &si)
Equality operator.
Definition symtensor.cpp:559
const SymTensor & operator=(const SymTensor &s)
Assignment operator.
Definition symtensor.h:187
double getTotalMeasure() const
Definition symtensor.h:229
bool operator==(const SymTensor &s) const
Equality operator.
Definition symtensor.h:197
#define BASE_EXPORT
Definition basedef.h:24
const double & operator[](unsigned int i) const
Allows Index access to tensor components.
Definition symtensor.h:203
DVect3 operator*(const DVect3 &input) const
Performs the linear mapping represented by the tensor on the vector input.
Definition symtensor.h:235
constexpr Vector2< T > max(const Vector2< T > &v1, const Vector2< T > &v2)
Template specialization for max, min.
Definition vect.h:433