SPH
Public Member Functions | Static Public Member Functions | Friends | List of all members
TracelessTensor Class Reference

Symmetric traceless 2nd order tensor. More...

#include <TracelessTensor.h>

Public Member Functions

INLINE TracelessTensor ()=default
 
INLINE TracelessTensor (const TracelessTensor &other)=default
 
INLINE TracelessTensor (const SymmetricTensor &other)
 Construct traceless tensor using other tensor (not traceless in general). More...
 
INLINE TracelessTensor (const Float value)
 Initialize all components of the tensor to given value, excluding last element of the diagonal, which is computed to keep the trace zero. More...
 
INLINE TracelessTensor (const Float xx, const Float yy, const Float xy, const Float xz, const Float yz)
 Initialize tensor given 5 independent components. More...
 
INLINE TracelessTensor (const Vector &v0, const Vector &v1, const Vector &v2)
 Construct tensor given three vectors as rows. More...
 
INLINE TracelessTensoroperator= (const TracelessTensor &other)
 
INLINE TracelessTensoroperator= (const SymmetricTensor &other)
 
INLINE operator SymmetricTensor () const
 Conversion to ordinary SymmetricTensor. More...
 
INLINE Vector row (const int idx) const
 Returns a row of the matrix. More...
 
INLINE Vector diagonal () const
 Returns diagonal of the matrix. More...
 
INLINE Vector offDiagonal () const
 Returns off-diagonal elements of the matrix. More...
 
INLINE Float operator() (const int rowIdx, const int colIdx) const
 Returns a given element of the matrix. More...
 
INLINE Vector operator* (const Vector &v) const
 Applies the tensor on given vector. More...
 
INLINE TracelessTensoroperator+= (const TracelessTensor &other)
 
INLINE TracelessTensoroperator-= (const TracelessTensor &other)
 
INLINE TracelessTensoroperator*= (const Float value)
 
INLINE TracelessTensoroperator/= (const Float value)
 
INLINE TracelessTensor operator- () const
 
INLINE bool operator== (const TracelessTensor &other) const
 
INLINE bool operator!= (const TracelessTensor &other) const
 

Static Public Member Functions

static INLINE TracelessTensor null ()
 Returns a tensor with all zeros. More...
 

Friends

template<typename T >
Float minElement (const T &t)
 Returns minimum element, simply the value iself by default. More...
 
template<typename T >
Float maxElement (const T &t)
 Returns maximum element, simply the value iself by default. More...
 
template<typename T >
auto abs (const T &t)
 
template<typename T >
sqrtInv (const T &t)
 
template<typename T >
constexpr friend T min (const T &t1, const T &t2)
 Minimum & Maximum value. More...
 
template<typename T >
constexpr friend T max (const T &t1, const T &t2)
 
template<typename T >
clamp (const T &t, const Interval &range)
 
template<typename T >
constexpr friend auto less (const T &t1, const T &t2)
 Compares two objects of the same time component-wise. More...
 
INLINE friend TracelessTensor operator* (const TracelessTensor &t, const Float v)
 Multiplies the tensor by a scalar. More...
 
INLINE friend TracelessTensor operator* (const Float v, const TracelessTensor &t)
 
INLINE friend TracelessTensor operator/ (const TracelessTensor &t, const Float v)
 Divides a tensor by a scalar. More...
 
INLINE friend TracelessTensor operator+ (const TracelessTensor &t1, const TracelessTensor &t2)
 
INLINE friend TracelessTensor operator- (const TracelessTensor &t1, const TracelessTensor &t2)
 
INLINE friend bool operator== (const TracelessTensor &t1, const SymmetricTensor &t2)
 
INLINE friend bool operator== (const SymmetricTensor &t1, const TracelessTensor &t2)
 
INLINE friend bool operator!= (const TracelessTensor &t1, const SymmetricTensor &t2)
 
INLINE friend bool operator!= (const SymmetricTensor &t1, const TracelessTensor &t2)
 
std::ostream & operator<< (std::ostream &stream, const TracelessTensor &t)
 

Detailed Description

Symmetric traceless 2nd order tensor.

Only the independenct components of the tensor are stored, the other components are computed on the fly, thus ensuring the tensor will always be symmetric and traceless.

Definition at line 16 of file TracelessTensor.h.

Constructor & Destructor Documentation

◆ TracelessTensor() [1/6]

INLINE TracelessTensor::TracelessTensor ( )
default

◆ TracelessTensor() [2/6]

INLINE TracelessTensor::TracelessTensor ( const TracelessTensor other)
default

◆ TracelessTensor() [3/6]

INLINE TracelessTensor::TracelessTensor ( const SymmetricTensor other)
inlineexplicit

Construct traceless tensor using other tensor (not traceless in general).

"Tracelessness" of the tensor is checked by assert.

Definition at line 59 of file TracelessTensor.h.

◆ TracelessTensor() [4/6]

INLINE TracelessTensor::TracelessTensor ( const Float  value)
inlineexplicit

Initialize all components of the tensor to given value, excluding last element of the diagonal, which is computed to keep the trace zero.

This constructor is mainly used to create null tensor; for non-zero values should be used sparingly.

Definition at line 73 of file TracelessTensor.h.

◆ TracelessTensor() [5/6]

INLINE TracelessTensor::TracelessTensor ( const Float  xx,
const Float  yy,
const Float  xy,
const Float  xz,
const Float  yz 
)
inline

Initialize tensor given 5 independent components.

Definition at line 78 of file TracelessTensor.h.

◆ TracelessTensor() [6/6]

INLINE TracelessTensor::TracelessTensor ( const Vector v0,
const Vector v1,
const Vector v2 
)
inline

Construct tensor given three vectors as rows.

Matrix represented by the vectors MUST be symmetric and traceless, checked by assert.

Definition at line 85 of file TracelessTensor.h.

Member Function Documentation

◆ diagonal()

INLINE Vector TracelessTensor::diagonal ( ) const
inline

Returns diagonal of the matrix.

Definition at line 126 of file TracelessTensor.h.

◆ null()

static INLINE TracelessTensor TracelessTensor::null ( )
inlinestatic

Returns a tensor with all zeros.

Definition at line 243 of file TracelessTensor.h.

◆ offDiagonal()

INLINE Vector TracelessTensor::offDiagonal ( ) const
inline

Returns off-diagonal elements of the matrix.

Definition at line 131 of file TracelessTensor.h.

◆ operator SymmetricTensor()

INLINE TracelessTensor::operator SymmetricTensor ( ) const
inlineexplicit

Conversion to ordinary SymmetricTensor.

Definition at line 106 of file TracelessTensor.h.

◆ operator!=()

INLINE bool TracelessTensor::operator!= ( const TracelessTensor other) const
inline

Definition at line 230 of file TracelessTensor.h.

◆ operator()()

INLINE Float TracelessTensor::operator() ( const int  rowIdx,
const int  colIdx 
) const
inline

Returns a given element of the matrix.

Does NOT returns a reference last element of diagonal is always computed from others and is not stored in the object.

Definition at line 139 of file TracelessTensor.h.

◆ operator*()

INLINE Vector TracelessTensor::operator* ( const Vector v) const
inline

Applies the tensor on given vector.

Definition at line 159 of file TracelessTensor.h.

◆ operator*=()

INLINE TracelessTensor& TracelessTensor::operator*= ( const Float  value)
inline

Definition at line 202 of file TracelessTensor.h.

◆ operator+=()

INLINE TracelessTensor& TracelessTensor::operator+= ( const TracelessTensor other)
inline

Definition at line 190 of file TracelessTensor.h.

◆ operator-()

INLINE TracelessTensor TracelessTensor::operator- ( ) const
inline

Definition at line 214 of file TracelessTensor.h.

◆ operator-=()

INLINE TracelessTensor& TracelessTensor::operator-= ( const TracelessTensor other)
inline

Definition at line 196 of file TracelessTensor.h.

◆ operator/=()

INLINE TracelessTensor& TracelessTensor::operator/= ( const Float  value)
inline

Definition at line 208 of file TracelessTensor.h.

◆ operator=() [1/2]

INLINE TracelessTensor& TracelessTensor::operator= ( const SymmetricTensor other)
inline

Definition at line 100 of file TracelessTensor.h.

◆ operator=() [2/2]

INLINE TracelessTensor& TracelessTensor::operator= ( const TracelessTensor other)
inline

Definition at line 94 of file TracelessTensor.h.

◆ operator==()

INLINE bool TracelessTensor::operator== ( const TracelessTensor other) const
inline

Definition at line 218 of file TracelessTensor.h.

◆ row()

INLINE Vector TracelessTensor::row ( const int  idx) const
inline

Returns a row of the matrix.

Definition at line 111 of file TracelessTensor.h.

Friends And Related Function Documentation

◆ abs

template<typename T >
auto abs ( const T &  t)
friend

Computes absolute value.

Note
Return type must be auto as abs(TracelessTensor) != TracelessTensor

Definition at line 276 of file MathUtils.h.

◆ clamp

template<typename T >
T clamp ( const T &  t,
const Interval range 
)
friend

Overload of clamp method using range instead of lower and upper bound as values. Can be used by other Floats by specializing the method

Definition at line 120 of file Interval.h.

◆ less

template<typename T >
constexpr friend auto less ( const T &  t1,
const T &  t2 
)
friend

Compares two objects of the same time component-wise.

Returns object containing components 0 or 1, depending whether components of the first objects are smaller than components of the second object.

Note
The return type can be generally different if the mask cannot be represented using type T.

Definition at line 53 of file Generic.h.

◆ max

template<typename T >
constexpr friend T max ( const T &  t1,
const T &  t2 
)
friend

Definition at line 20 of file MathBasic.h.

◆ maxElement

template<typename T >
Float maxElement ( const T &  t)
friend

Returns maximum element, simply the value iself by default.

This function is intended for vectors and tensors, function for float is only for writing generic code.

Definition at line 29 of file Generic.h.

◆ min

template<typename T >
constexpr friend T min ( const T &  t1,
const T &  t2 
)
friend

Minimum & Maximum value.

Definition at line 15 of file MathBasic.h.

◆ minElement

template<typename T >
Float minElement ( const T &  t)
friend

Returns minimum element, simply the value iself by default.

This function is intended for vectors and tensors, function for float is only for writing generic code.

Definition at line 37 of file Generic.h.

◆ operator!= [1/2]

INLINE friend bool operator!= ( const SymmetricTensor t1,
const TracelessTensor t2 
)
friend

Definition at line 238 of file TracelessTensor.h.

◆ operator!= [2/2]

INLINE friend bool operator!= ( const TracelessTensor t1,
const SymmetricTensor t2 
)
friend

Definition at line 234 of file TracelessTensor.h.

◆ operator* [1/2]

INLINE friend TracelessTensor operator* ( const Float  v,
const TracelessTensor t 
)
friend

Definition at line 170 of file TracelessTensor.h.

◆ operator* [2/2]

INLINE friend TracelessTensor operator* ( const TracelessTensor t,
const Float  v 
)
friend

Multiplies the tensor by a scalar.

Definition at line 166 of file TracelessTensor.h.

◆ operator+

INLINE friend TracelessTensor operator+ ( const TracelessTensor t1,
const TracelessTensor t2 
)
friend
Note
product of two traceless tensor is NOT generally a traceless tensor

Definition at line 182 of file TracelessTensor.h.

◆ operator-

INLINE friend TracelessTensor operator- ( const TracelessTensor t1,
const TracelessTensor t2 
)
friend

Definition at line 186 of file TracelessTensor.h.

◆ operator/

INLINE friend TracelessTensor operator/ ( const TracelessTensor t,
const Float  v 
)
friend

Divides a tensor by a scalar.

Definition at line 175 of file TracelessTensor.h.

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const TracelessTensor t 
)
friend

Definition at line 247 of file TracelessTensor.h.

◆ operator== [1/2]

INLINE friend bool operator== ( const SymmetricTensor t1,
const TracelessTensor t2 
)
friend

Definition at line 226 of file TracelessTensor.h.

◆ operator== [2/2]

INLINE friend bool operator== ( const TracelessTensor t1,
const SymmetricTensor t2 
)
friend

Definition at line 222 of file TracelessTensor.h.

◆ sqrtInv

template<typename T >
T sqrtInv ( const T &  t)
friend

Returns an approximate value of inverse square root.

Template Parameters
ItersNumber of iterations of the algorithm. Higher value = more accurate result.

Definition at line 44 of file MathUtils.h.


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