IFEM  90A354
Public Member Functions | Protected Member Functions | Private Member Functions | Friends | List of all members
SymmTensor Class Reference

Simple class for representing a symmetric second-order tensor. More...

#include <Tensor.h>

Inheritance diagram for SymmTensor:
Inheritance graph
[legend]
Collaboration diagram for SymmTensor:
Collaboration graph
[legend]

Public Member Functions

 SymmTensor (const t_ind nsd, bool with33=false)
 Constructor creating a zero tensor. More...
 
 SymmTensor (const std::vector< Real > &vec)
 Constructor creating a symmetric tensor from a vector.
 
 SymmTensor (const SymmTensor &T)
 Copy constructor.
 
SymmTensoroperator= (Real val)
 Assignment operator.
 
void copy (const SymmTensor &T)
 Copies a symmetric tensor, possibly with dimension change.
 
bool symmetric () const override
 Query whether this tensor is symmetric or not.
 
Tensortranspose () override
 Transposes the symmetric tensor (i.e., does nothing).
 
Tensorsymmetrize () override
 Makes the symmetric tensor symmetric (i.e., does nothing).
 
Real trace () const override
 Returns the trace of the symmetric tensor.
 
Real det () const override
 Returns the determinant of the symmetric tensor.
 
Real inverse (Real tol=Real(0)) override
 Inverts the symmetric tensor. More...
 
SymmTensortransform (const Tensor &T)
 Congruence transformation of a symmetric tensor. More...
 
SymmTensorrightCauchyGreen (const Tensor &F)
 Constructs the right Cauchy-Green tensor from a deformation tensor.
 
SymmTensorouterProd (const Vec3 &u)
 Dyadic (outer) product between two identical vectors.
 
Real L2norm (bool doSqrt=true) const
 Returns the inner-product (L2-norm) of the symmetric tensor.
 
Real vonMises (bool doSqrt=true) const
 Returns the von Mises value of the symmetric tensor. More...
 
bool principal (Vec3 &p, bool sorted=true) const
 Computes the principal values of the symmetric tensor.
 
bool principal (Vec3 &p, Tensor &pdir) const
 Computes the principal values and associated principal directions. More...
 
bool principal (Vec3 &p, Vec3 *pdir, int ndir=0) const
 Computes the principal values and associated principal directions.
 
bool principal (Vec3 &p, SymmTensor *M) const
 Computes the principal values and associated principal directions.
 
std::ostream & print (std::ostream &os, int prec=0) const override
 Prints out the lower triangle of the tensor to an output stream.
 
- Public Member Functions inherited from Tensor
 Tensor (const t_ind nsd, bool identity=false)
 Constructor creating a zero or identity tesnor.
 
 Tensor (const Vec3 &vn, bool vnIsX=false)
 Constructor creating a transformation from a face normal vector. More...
 
 Tensor (const Vec3 &t1, const Vec3 &t2, bool t1isZ=false, bool t2isXZ=false)
 Constructor creating a transformation from two tangent vectors. More...
 
 Tensor (const Vec3 &v1, const Vec3 &v2, const Vec3 &v3)
 Constructor creating a transformation from three unit vectors. More...
 
 Tensor (Real a1, Real a2, Real a3)
 Constructor creating a transformation from three rotation angles. More...
 
 Tensor (const Tensor &T, bool transpose=false)
 Copy constructor, optionally creating the transpose of T.
 
 Tensor (const std::vector< Real > &a, bool transpose=false)
 Constructor copying its content from a one-dimensional array.
 
virtual ~Tensor ()
 Empty destructor.
 
void zero ()
 Sets *this to the 0-tensor.
 
void diag (Real value=Real(1))
 Sets *this to a diagonal tensor with value on the diagonal.
 
void diag (const Vec3 &diagonal)
 Sets *this to a diagonal tensor with given vector as diagonal.
 
 operator const std::vector< Real > & () const
 Type casting to a one-dimensional vector, for referencing.
 
 operator std::vector< Real > & ()
 Type casting to a one-dimensional vector, for assignment.
 
const Realptr () const
 Reference through a pointer.
 
const Realoperator() (t_ind i, t_ind j) const
 Index-1 based component reference.
 
Realoperator() (t_ind i, t_ind j)
 Index-1 based component access.
 
Vec3 operator[] (t_ind i) const
 Index-0 based column reference.
 
Tensoroperator= (const Tensor &T)
 Assignment operator.
 
Tensoroperator= (const std::vector< Real > &val)
 Overloaded assignment operator.
 
Tensoroperator= (Real val)
 Overloaded assignment operator.
 
Tensoroperator+= (const Tensor &T)
 Incrementation operator.
 
Tensoroperator+= (Real val)
 Incrementation operator.
 
Tensoroperator-= (const Tensor &T)
 Decrementation operator.
 
Tensoroperator-= (Real val)
 Decrementation operator.
 
Tensoroperator*= (Real val)
 Scaling operator.
 
Tensoroperator*= (const Tensor &B)
 Post-multiplication with another Tensor.
 
TensorpostMult (const Tensor &B)
 Post-multiplication with another Tensor.
 
TensorpreMult (const Tensor &A)
 Pre-multiplication with another Tensor.
 
Tensorrotate (Real alpha, t_ind axis)
 Rotates the tensor about given coordinate axis.
 
TensorouterProd (const Vec3 &a, const Vec3 &b)
 Dyadic (outer) product between two vectors.
 
Real innerProd (const Tensor &T) const
 Returns the inner-product of *this and the given tensor.
 
t_ind dim () const
 Returns the dimension of this tensor.
 
size_t size () const
 Returns the size of this tensor.
 
bool equal (const Tensor &T, Real tol=Real(1.0e-6)) const
 Query whether this tensor equals another within given tolerance.
 
bool isZero (Real tol=Real(1.0e-6)) const
 Query whether this tensor is zero within given tolerance.
 
Tensorshift (short int idx=1)
 Performs a cyclic permutation of the tensor columns.
 
Vec3 rotVec () const
 Returns the rotation angles corresponding to the tensor.
 

Protected Member Functions

t_ind index (t_ind i, t_ind j) const override
 Returns a 0-based array index for the given tensor indices. More...
 

Private Member Functions

bool redim (const t_ind nsd, bool with33=false)
 Resets the number of spatial dimensions of the tensor. More...
 

Friends

SymmTensor operator+ (const SymmTensor &T, Real a)
 Adding a scaled unit tensor to a symmetric tensor.
 
SymmTensor operator- (const SymmTensor &T, Real a)
 Subtracting a scaled unit tensor from a symmetric tensor.
 
SymmTensor operator* (Real a, const SymmTensor &T)
 Multiplication between a scalar and a symmetric tensor.
 
SymmTensor operator* (const SymmTensor &A, const SymmTensor &B)
 Multiplication between two symmetric tensors.
 

Additional Inherited Members

- Protected Types inherited from Tensor
using t_ind = unsigned short int
 Tensor index type (for convenience)
 
- Protected Attributes inherited from Tensor
const t_ind n
 Number of spatial dimensions for the tensor.
 
std::vector< Realv
 The actual tensor component values.
 

Detailed Description

Simple class for representing a symmetric second-order tensor.

Constructor & Destructor Documentation

◆ SymmTensor()

SymmTensor::SymmTensor ( const t_ind  nsd,
bool  with33 = false 
)
explicit

Constructor creating a zero tensor.

Parameters
[in]nsdThe tensor dimension (1, 2 or 3)
[in]with33If true and nsd = 2, include the 33 term also

The combination nsd = 2 and with33 = true results in a 2D tensor with the 33-term as the forth component. This is typically used to represent the symmetric stress tensor in 2D plane strain models, where the \(\sigma_{zz}\) component is nonzero.

References redim().

Member Function Documentation

◆ index()

t_ind SymmTensor::index ( t_ind  i,
t_ind  j 
) const
inlineoverrideprotectedvirtual

Returns a 0-based array index for the given tensor indices.

Symmetric 3D tensors are assumed stored with the following order: s11, s22, s33, s12, s23, s13. Symmetric 2D tensors have the order s11, s22, s12 and if the 33 component is included: s11, s22, s33, s12.

Reimplemented from Tensor.

References Tensor::n, and Tensor::v.

◆ inverse()

Real SymmTensor::inverse ( Real  tol = Real(0))
overridevirtual

Inverts the symmetric tensor.

Parameters
[in]tolDivision by zero tolerance
Returns
Determinant of the tensor

Reimplemented from Tensor.

References det(), Tensor::n, Real, and Tensor::v.

◆ principal()

bool SymmTensor::principal ( Vec3 p,
Tensor pdir 
) const

Computes the principal values and associated principal directions.

This version is only for 3D tensors. It is a re-implementation of the Fortran-77 subroutine EIGS3D from FENRIS by Kjell Magne Mathisen (2010). The eigenvectors are stored as columns of the Tensor object pdir.

Note
The computed eigenvalues are not necessarily sorted from largest to the smallest (like for the LAPACK version).

References Vec3::asum(), Tensor::diag(), epsZ, Tensor::n, Real, and Tensor::v.

◆ redim()

bool SymmTensor::redim ( const t_ind  nsd,
bool  with33 = false 
)
private

Resets the number of spatial dimensions of the tensor.

Parameters
[in]nsdThe new tensor dimension
[in]with33If true and nsd = 2, include the 33 term also
Returns
true if the dimension was changed, otherwise false

This method is private because the tensor dimension is not supposed to be changed by the application. It is only for internal use.

References Tensor::n, Real, and Tensor::v.

Referenced by copy(), rightCauchyGreen(), and SymmTensor().

◆ transform()

SymmTensor & SymmTensor::transform ( const Tensor T)

Congruence transformation of a symmetric tensor.

Perform the triple matrix product

\[{\bf A} = {\bf T A T}^T\]

where A = *this

References Tensor::dim(), Tensor::n, Real, Tensor::symmetric(), and Tensor::v.

◆ vonMises()

Real SymmTensor::vonMises ( bool  doSqrt = true) const

Returns the von Mises value of the symmetric tensor.

The von Mises value of a symmetric 3D (stress) tensor is defined as follows:

\[ s_{\rm vm} = \sqrt{ s_{11}(s_{11}-s_{22}) + s_{22}(s_{22}-s_{33}) + s_{33}(s_{33}-s_{11}) + 3(s_{12}^2 + s_{23}^2 + s_{31}^2)} \]

References Tensor::n, and Tensor::v.


The documentation for this class was generated from the following files: