26 SymTensor() { d11_ = d22_ = d33_ = d12_ = d13_ = d23_ = initVal<T>(); }
31 SymTensor(
const SymTensor &s) {
operator=(s); }
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) { }
38 const SymTensor &
operator=(
const SymTensor &s);
41 bool operator==(
const SymTensor &s)
const;
42 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_; }
85 SymTensor getDeviatoric()
const {
double p=getTrace()/3.0;
return SymTensor(d11_-p, d22_-p, d33_-p, d12_, d13_, d23_); }
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;
118 SymTensor toGlobal(
const Axes3D &a)
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);
130 SymTensor mul(
const double &d)
const { SymTensor ret(d11_*d,d22_*d,d33_*d,d12_*d,d13_*d,d23_*d);
return ret; }
132 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; }
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; }
134 inline SymTensor operator+(
const SymTensor &s)
const;
135 inline SymTensor operator-(
const SymTensor &s)
const;
137 static SymTensor fromPrincipal(
const DVect3 &prin,
const Axes3D &axes);
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 void adjustTrace(
const double &newTrace);
146 inline void incrementDiagonal(
const double &increment) { d11_ += increment; d22_ += increment; d33_ += increment; }
147 inline void rotate(
const DVect3 &rot);
148 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_)))))); }
168 friend class SymTensor;
180 enum class Type { ThreeDCube, ThreeDJacobi, ZMax, ZMid, ZMin };
185 inline const SymTensor &SymTensor::operator=(
const SymTensor &s) {
195 inline bool SymTensor::operator==(
const SymTensor &s)
const {
196 return (d11_ == s.d11_ && d22_ == s.d22_ &&
197 d33_ == s.d33_ && d12_ == s.d12_ && d13_ == s.d13_ &&
201 inline const double &SymTensor::operator[](
unsigned int i)
const {
214 inline double &SymTensor::operator[](
unsigned int i) {
227 inline double SymTensor::getTotalMeasure()
const {
228 double I1 = getTrace();
230 return sqrt(I1*I1/3.0 + 2.0*J2);
233 inline DVect3 SymTensor::operator*(
const DVect3 &normal)
const {
234 return DVect3(normal.x()*s11() + normal.y()*s12() + normal.z()*s13(),
235 normal.x()*s21() + normal.y()*s22() + normal.z()*s23(),
236 normal.x()*s31() + normal.y()*s32() + normal.z()*s33());
239 inline DVect2 SymTensor::operator*(
const DVect2 &normal)
const {
240 return DVect2(normal.x()*s11() + normal.y()*s12(),
241 normal.x()*s21() + normal.y()*s22());
244 inline SymTensor SymTensor::operator*(
const double &mul)
const {
246 ret.d11_ = d11_ * mul;
247 ret.d22_ = d22_ * mul;
248 ret.d33_ = d33_ * mul;
249 ret.d12_ = d12_ * mul;
250 ret.d13_ = d13_ * mul;
251 ret.d23_ = d23_ * mul;
255 inline const SymTensor &SymTensor::operator*=(
const double &mul) {
265 inline SymTensor SymTensor::operator/(
const double &mul)
const {
267 ret.d11_ = d11_ / mul;
268 ret.d22_ = d22_ / mul;
269 ret.d33_ = d33_ / mul;
270 ret.d12_ = d12_ / mul;
271 ret.d13_ = d13_ / mul;
272 ret.d23_ = d23_ / mul;
276 inline const SymTensor &SymTensor::operator/=(
const double &mul) {
286 inline SymTensor SymTensor::operator+(
const SymTensor &s)
const {
288 ret.d11_ = d11_ + s.d11_;
289 ret.d22_ = d22_ + s.d22_;
290 ret.d33_ = d33_ + s.d33_;
291 ret.d12_ = d12_ + s.d12_;
292 ret.d13_ = d13_ + s.d13_;
293 ret.d23_ = d23_ + s.d23_;
297 inline SymTensor SymTensor::operator-(
const SymTensor &s)
const {
299 ret.d11_ = d11_ - s.d11_;
300 ret.d22_ = d22_ - s.d22_;
301 ret.d33_ = d33_ - s.d33_;
302 ret.d12_ = d12_ - s.d12_;
303 ret.d13_ = d13_ - s.d13_;
304 ret.d23_ = d23_ - s.d23_;
308 inline void SymTensor::adjustTrace(
const double &newTrace) {
309 static constexpr
double d1d3 = 1.0 / 3.0;
311 double dx = s11() - s22();
312 double dy = s22() - s33();
313 double dz = s33() - s11();
314 rs11() = (newTrace + dx - dz) * d1d3;
315 rs22() = (newTrace + dy - dx) * d1d3;
316 rs33() = (newTrace + dz - dy) * d1d3;
319 inline void SymTensor::rotate(
const DVect3 &rot) {
320 SymTensor copy(*
this);
321 d11_ += 2.0*( copy.s12()*rot.x() + copy.s13()*rot.y());
322 d22_ += 2.0*(-copy.s12()*rot.x() + copy.s23()*rot.z());
323 d33_ += -2.0*( copy.s13()*rot.y() + copy.s23()*rot.z());
324 d12_ += ((copy.s22() - copy.s11())*rot.x() + copy.s23()*rot.x() + copy.s13()*rot.z());
325 d13_ += ( copy.s23()*rot.x() + (copy.s33() - copy.s11())*rot.x() - copy.s12()*rot.z());
326 d23_ += ( -copy.s13()*rot.x() - copy.s12()*rot.x() + (copy.s33() - copy.s22())*rot.z());
335 uint32 SymTensor::doubleToSingleComponent(uint32 dof1,uint32 dof2) {
336 dof1 = std::clamp<uint32>(dof1,0,2);
337 dof2 = std::clamp<uint32>(dof2,0,2);
365 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
SymTensor eigenvalue and direction helper class.
Definition: symtensor.h:166
BASE_EXPORT SymTensorInfo()
Default constructor.
Definition: symtensor.h:170
BASE_EXPORT Axes3D getAxes() const
Returns eigen directions (minimum, intermediate, maximum).
Definition: symtensor.cpp:567
BASE_EXPORT SymTensor resolve(const DVect3 &prin) const
Regenerates full tensor from info + principal directions.
Definition: symtensor.cpp:574
BASE_EXPORT const SymTensorInfo & operator=(const SymTensorInfo &si)
Equality operator.
Definition: symtensor.cpp:561
constexpr Vector2< T > operator*(const Matrix< T, 2, 2 > &m, const Vector2< T > &v)
Definition: matrix.h:987
#define BASE_EXPORT
Definition: basedef.h:24
PUSHWARNING VSWARNING(26495) VSWARNING(4702) class BASE_EXPORT SymTensor
A symmetric 2nd order tensor.
Definition: symtensor.h:20