Loading...
Searching...
No Matches
Tensor2D< Cmpt > Class Template Reference

A templated (2 x 2) tensor of objects of <T> derived from VectorSpace. More...

#include <Tensor2D.H>

Inheritance diagram for Tensor2D< Cmpt >:
Collaboration diagram for Tensor2D< Cmpt >:

Public Types

enum  components { XX , XY , YX , YY }
 Component labeling enumeration. More...
typedef Tensor2D< label > labelType
 Equivalent type of labels used for valid component indexing.
Public Types inherited from VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >
typedef VectorSpace< Tensor2D< Cmpt >, Cmpt, Ncmpts > vsType
 VectorSpace type.
typedef Cmpt cmptType
 Component type.
typedef Cmpt magType
 Magnitude type.
typedef direction size_type
 The type to represent the size of a VectorSpace.
typedef Cmpt * iterator
 Random access iterator for traversing VectorSpace.
typedef const Cmpt * const_iterator
 Random access iterator for traversing VectorSpace.

Public Member Functions

 Tensor2D ()=default
 Default construct.
 Tensor2D (const Tensor2D &)=default
 Copy construct.
Tensor2Doperator= (const Tensor2D &)=default
 Copy assignment.
 Tensor2D (Foam::zero)
 Construct initialized to zero.
 Tensor2D (const VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 > &vs)
 Construct given VectorSpace.
 Tensor2D (const SymmTensor2D< Cmpt > &st)
 Construct given SymmTensor2D.
 Tensor2D (const SphericalTensor2D< Cmpt > &st)
 Construct given SphericalTensor2D.
 Tensor2D (const Vector2D< Cmpt > &x, const Vector2D< Cmpt > &y)
 Construct given the two row vectors.
 Tensor2D (const Cmpt txx, const Cmpt txy, const Cmpt tyx, const Cmpt tyy)
 Construct given the four components.
 Tensor2D (Istream &is)
 Construct from Istream.
const Cmpt & xx () const noexcept
const Cmpt & xy () const noexcept
const Cmpt & yx () const noexcept
const Cmpt & yy () const noexcept
Cmpt & xx () noexcept
Cmpt & xy () noexcept
Cmpt & yx () noexcept
Cmpt & yy () noexcept
Vector2D< Cmpt > cx () const
 Extract vector for column 0.
Vector2D< Cmpt > cy () const
 Extract vector for column 1.
template<direction Idx>
Vector2D< Cmpt > col () const
 Extract vector for given column: compile-time check of index.
Vector2D< Cmpt > col (const direction c) const
 Extract vector for given column (0,1): runtime check of index.
template<direction Idx>
void col (const Vector2D< Cmpt > &v)
 Set values of given column: compile-time check of index.
void col (const direction c, const Vector2D< Cmpt > &v)
 Set values of given column (0,1): runtime check of index.
void cols (const Vector2D< Cmpt > &x, const Vector2D< Cmpt > &y)
 Set column values.
Vector2D< Cmpt > x () const
 Extract vector for row 0.
Vector2D< Cmpt > y () const
 Extract vector for row 1.
template<direction Idx>
Vector2D< Cmpt > row () const
 Extract vector for given row: compile-time check of index.
Vector2D< Cmpt > row (const direction r) const
 Extract vector for given row (0,1): runtime check of index.
template<direction Idx>
void row (const Vector2D< Cmpt > &v)
 Set values of given row: compile-time check of index.
void row (const direction r, const Vector2D< Cmpt > &v)
 Set values of given row (0,1): compile-time check of index.
void rows (const Vector2D< Cmpt > &x, const Vector2D< Cmpt > &y)
 Set row values.
Vector2D< Cmpt > diag () const
 Extract the diagonal as a vector.
void diag (const Vector2D< Cmpt > &v)
 Set values of the diagonal.
scalar diagSqr () const
 The L2-norm squared of the diagonal.
Tensor2D< Cmpt > T () const
 Return non-Hermitian transpose.
Cmpt det () const
 The determinate.
Tensor2D< Cmpt > adjunct () const
 Return adjunct matrix (transpose of cofactor matrix).
Tensor2D< Cmpt > cof () const
 Return cofactor matrix (transpose of adjunct matrix).
Tensor2D< Cmpt > inv () const
 Return inverse.
Tensor2D< Cmpt > inner (const Tensor2D< Cmpt > &t2) const
 Inner-product of this with another Tensor2D.
Tensor2D< Cmpt > schur (const Tensor2D< Cmpt > &t2) const
 Schur-product of this with another Tensor2D.
void operator= (const SymmTensor2D< Cmpt > &)
 Copy assign from SymmTensor2D.
void operator= (const SphericalTensor2D< Cmpt > &)
 Copy assign from SphericalTensor2D.
Vector2D< Cmpt > vectorComponent (const direction cmpt) const
 Deprecated(2018-12) Return vector for given row (0,1).
template<Foam::direction Idx>
Foam::Vector2D< Cmpt > col () const
template<Foam::direction Idx>
Foam::Vector2D< Cmpt > row () const
Public Member Functions inherited from VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >
const Foam::VectorSpace< Tensor2D< Cmpt >, Cmpt, Ncmpts >::template ConstBlock< SubVector, BStart > block () const
 VectorSpace ()=default
 Default construct.
const Cmpt & component (const direction) const
void replace (const direction, const Cmpt &)
const Cmpt * cdata () const noexcept
 Return const pointer to the first data element.
Cmpt * data () noexcept
 Return pointer to the first data element.
void fill (const Cmpt &s)
 Assign all components to given value.
const Cmpt & operator[] (const direction) const
void operator= (const VectorSpace< Tensor2D< Cmpt >, Cmpt, Ncmpts > &)
void operator+= (const VectorSpace< Tensor2D< Cmpt >, Cmpt, Ncmpts > &)
void operator-= (const VectorSpace< Tensor2D< Cmpt >, Cmpt, Ncmpts > &)
void operator*= (const scalar)
void operator/= (const scalar)
iterator begin () noexcept
 Return an iterator (pointer) to begin of VectorSpace.
const_iterator cbegin () const noexcept
 Return const_iterator (const pointer) to begin of VectorSpace.
iterator end () noexcept
 Return an iterator (pointer) to end of VectorSpace.
const_iterator cend () const noexcept
 Return const_iterator (const pointer) to end of VectorSpace.

Static Public Attributes

static constexpr direction rank = 2
 Rank of Tensor2D is 2.
static const Tensor2D I
Static Public Attributes inherited from VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >
static constexpr direction dim
 Dimensionality of space.
static constexpr direction nComponents
 Number of components in this vector space.
static constexpr direction mRows
static constexpr direction nCols
static const char *const typeName
static const char *const componentNames []
static const Tensor2D< Cmpt > zero
static const Tensor2D< Cmpt > one
static const Tensor2D< Cmpt > max
static const Tensor2D< Cmpt > min
static const Tensor2D< Cmpt > rootMax
static const Tensor2D< Cmpt > rootMin

Additional Inherited Members

Static Public Member Functions inherited from VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >
static constexpr direction size () noexcept
 The number of elements in the VectorSpace = Ncmpts.
static Tensor2D< Cmpt > uniform (const Cmpt &s)
 Return a VectorSpace with all elements = s.
Public Attributes inherited from VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >
Cmpt v_ [Ncmpts]
 The components of this vector space.

Detailed Description

template<class Cmpt>
class Foam::Tensor2D< Cmpt >

A templated (2 x 2) tensor of objects of <T> derived from VectorSpace.

Source files

Definition at line 52 of file Tensor2D.H.

Member Typedef Documentation

◆ labelType

template<class Cmpt>
typedef Tensor2D<label> labelType

Equivalent type of labels used for valid component indexing.

Definition at line 63 of file Tensor2D.H.

Member Enumeration Documentation

◆ components

template<class Cmpt>
enum components

Component labeling enumeration.

Enumerator
XX 
XY 
YX 
YY 

Definition at line 82 of file Tensor2D.H.

Constructor & Destructor Documentation

◆ Tensor2D() [1/9]

template<class Cmpt>
Tensor2D ( )
default

Default construct.

Referenced by adjunct(), inner(), schur(), T(), Tensor2D(), Tensor2D(), and Tensor2D().

Here is the caller graph for this function:

◆ Tensor2D() [2/9]

template<class Cmpt>
Tensor2D ( const Tensor2D< Cmpt > & )
default

Copy construct.

◆ Tensor2D() [3/9]

template<class Cmpt>
Tensor2D ( Foam::zero )
inline

Construct initialized to zero.

Definition at line 25 of file Tensor2DI.H.

References Tensor2D(), and VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::zero.

Here is the call graph for this function:

◆ Tensor2D() [4/9]

template<class Cmpt>
Tensor2D ( const VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 > & vs)
inline

Construct given VectorSpace.

Definition at line 32 of file Tensor2DI.H.

References Tensor2D(), and VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::VectorSpace().

Here is the call graph for this function:

◆ Tensor2D() [5/9]

template<class Cmpt>
Tensor2D ( const SymmTensor2D< Cmpt > & st)
inline

Construct given SymmTensor2D.

Definition at line 42 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, XX, SymmTensor2D< Cmpt >::xx(), XY, SymmTensor2D< Cmpt >::xy(), YX, YY, and SymmTensor2D< Cmpt >::yy().

Here is the call graph for this function:

◆ Tensor2D() [6/9]

template<class Cmpt>
Tensor2D ( const SphericalTensor2D< Cmpt > & st)
inline

Construct given SphericalTensor2D.

Definition at line 50 of file Tensor2DI.H.

References SphericalTensor2D< Cmpt >::ii(), VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, XX, XY, YX, YY, and Foam::Zero.

Here is the call graph for this function:

◆ Tensor2D() [7/9]

template<class Cmpt>
Tensor2D ( const Vector2D< Cmpt > & x,
const Vector2D< Cmpt > & y )
inline

Construct given the two row vectors.

Definition at line 58 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, x(), XX, XY, y(), YX, and YY.

Here is the call graph for this function:

◆ Tensor2D() [8/9]

template<class Cmpt>
Tensor2D ( const Cmpt txx,
const Cmpt txy,
const Cmpt tyx,
const Cmpt tyy )
inline

Construct given the four components.

Definition at line 70 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, XX, XY, YX, and YY.

◆ Tensor2D() [9/9]

template<class Cmpt>
Tensor2D ( Istream & is)
inlineexplicit

Construct from Istream.

Definition at line 82 of file Tensor2DI.H.

References Tensor2D().

Here is the call graph for this function:

Member Function Documentation

◆ operator=() [1/3]

template<class Cmpt>
Tensor2D & operator= ( const Tensor2D< Cmpt > & )
default

Copy assignment.

◆ xx() [1/2]

◆ xy() [1/2]

◆ yx() [1/2]

◆ yy() [1/2]

◆ xx() [2/2]

template<class Cmpt>
Cmpt & xx ( )
inlinenoexcept

Definition at line 158 of file Tensor2D.H.

◆ xy() [2/2]

template<class Cmpt>
Cmpt & xy ( )
inlinenoexcept

Definition at line 159 of file Tensor2D.H.

◆ yx() [2/2]

template<class Cmpt>
Cmpt & yx ( )
inlinenoexcept

Definition at line 160 of file Tensor2D.H.

◆ yy() [2/2]

template<class Cmpt>
Cmpt & yy ( )
inlinenoexcept

Definition at line 161 of file Tensor2D.H.

◆ cx()

template<class Cmpt>
Foam::Vector2D< Cmpt > cx ( ) const
inline

Extract vector for column 0.

Definition at line 104 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, XX, and YX.

Referenced by col().

Here is the caller graph for this function:

◆ cy()

template<class Cmpt>
Foam::Vector2D< Cmpt > cy ( ) const
inline

Extract vector for column 1.

Definition at line 110 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, XY, and YY.

Referenced by col().

Here is the caller graph for this function:

◆ col() [1/5]

template<class Cmpt>
template<direction Idx>
Vector2D< Cmpt > col ( ) const
inline

Extract vector for given column: compile-time check of index.

Referenced by col().

Here is the caller graph for this function:

◆ col() [2/5]

template<class Cmpt>
Foam::Vector2D< Cmpt > col ( const direction c) const
inline

Extract vector for given column (0,1): runtime check of index.

Definition at line 129 of file Tensor2DI.H.

References Foam::abort(), cx(), cy(), Foam::FatalError, FatalErrorInFunction, and Foam::Zero.

Here is the call graph for this function:

◆ col() [3/5]

template<class Cmpt>
template<Foam::direction Idx>
void col ( const Vector2D< Cmpt > & v)
inline

Set values of given column: compile-time check of index.

Definition at line 174 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, Vector2D< Cmpt >::x(), XX, XY, Vector2D< Cmpt >::y(), YX, and YY.

Here is the call graph for this function:

◆ col() [4/5]

template<class Cmpt>
void col ( const direction c,
const Vector2D< Cmpt > & v )
inline

Set values of given column (0,1): runtime check of index.

Definition at line 233 of file Tensor2DI.H.

References Foam::abort(), col(), Foam::FatalError, and FatalErrorInFunction.

Here is the call graph for this function:

◆ cols()

template<class Cmpt>
void cols ( const Vector2D< Cmpt > & x,
const Vector2D< Cmpt > & y )
inline

Set column values.

Definition at line 209 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, x(), XX, XY, y(), YX, and YY.

Here is the call graph for this function:

◆ x()

template<class Cmpt>
Foam::Vector2D< Cmpt > x ( ) const
inline

Extract vector for row 0.

Definition at line 91 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, XX, and XY.

Referenced by cols(), triSurfaceTools::curvatures(), rows(), and Tensor2D().

Here is the caller graph for this function:

◆ y()

template<class Cmpt>
Foam::Vector2D< Cmpt > y ( ) const
inline

Extract vector for row 1.

Definition at line 97 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, YX, and YY.

Referenced by cols(), triSurfaceTools::curvatures(), rows(), and Tensor2D().

Here is the caller graph for this function:

◆ row() [1/5]

template<class Cmpt>
template<direction Idx>
Vector2D< Cmpt > row ( ) const
inline

Extract vector for given row: compile-time check of index.

Referenced by row(), and Tensor2D< scalar >::vectorComponent().

Here is the caller graph for this function:

◆ row() [2/5]

template<class Cmpt>
Foam::Vector2D< Cmpt > row ( const direction r) const
inline

Extract vector for given row (0,1): runtime check of index.

Definition at line 157 of file Tensor2DI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, x, y, and Foam::Zero.

Here is the call graph for this function:

◆ row() [3/5]

template<class Cmpt>
template<Foam::direction Idx>
void row ( const Vector2D< Cmpt > & v)
inline

Set values of given row: compile-time check of index.

Definition at line 193 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, Vector2D< Cmpt >::x(), XX, XY, Vector2D< Cmpt >::y(), YX, and YY.

Here is the call graph for this function:

◆ row() [4/5]

template<class Cmpt>
void row ( const direction r,
const Vector2D< Cmpt > & v )
inline

Set values of given row (0,1): compile-time check of index.

Definition at line 251 of file Tensor2DI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and row().

Here is the call graph for this function:

◆ rows()

template<class Cmpt>
void rows ( const Vector2D< Cmpt > & x,
const Vector2D< Cmpt > & y )
inline

Set row values.

Definition at line 221 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, x(), XX, XY, y(), YX, and YY.

Here is the call graph for this function:

◆ diag() [1/2]

template<class Cmpt>
Foam::Vector2D< Cmpt > diag ( ) const
inline

Extract the diagonal as a vector.

Definition at line 269 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, XX, and YY.

◆ diag() [2/2]

template<class Cmpt>
void diag ( const Vector2D< Cmpt > & v)
inline

Set values of the diagonal.

Definition at line 276 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, Vector2D< Cmpt >::x(), XX, Vector2D< Cmpt >::y(), and YY.

Here is the call graph for this function:

◆ diagSqr()

template<class Cmpt>
Foam::scalar diagSqr ( ) const
inline

The L2-norm squared of the diagonal.

Definition at line 283 of file Tensor2DI.H.

References Foam::magSqr(), xx(), and yy().

Here is the call graph for this function:

◆ T()

template<class Cmpt>
Foam::Tensor2D< Cmpt > T ( ) const
inline

Return non-Hermitian transpose.

Definition at line 296 of file Tensor2DI.H.

References Tensor2D(), xx(), xy(), yx(), and yy().

Here is the call graph for this function:

◆ det()

template<class Cmpt>
Cmpt det ( ) const
inline

The determinate.

Definition at line 307 of file Tensor2DI.H.

References xx(), xy(), yx(), and yy().

Referenced by Foam::det().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ adjunct()

template<class Cmpt>
Foam::Tensor2D< Cmpt > adjunct ( ) const
inline

Return adjunct matrix (transpose of cofactor matrix).

Definition at line 314 of file Tensor2DI.H.

References Tensor2D(), xx(), xy(), yx(), and yy().

Referenced by cof(), Foam::inv(), and inv().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cof()

template<class Cmpt>
Foam::Tensor2D< Cmpt > cof ( ) const
inline

Return cofactor matrix (transpose of adjunct matrix).

Definition at line 325 of file Tensor2DI.H.

References adjunct().

Referenced by Foam::cof().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inv()

template<class Cmpt>
Foam::Tensor2D< Cmpt > inv ( ) const
inline

Return inverse.

Definition at line 364 of file Tensor2DI.H.

References Foam::abort(), adjunct(), Foam::det(), Foam::FatalError, FatalErrorInFunction, Foam::mag(), and Foam::nl.

Referenced by Foam::inv().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inner()

template<class Cmpt>
Foam::Tensor2D< Cmpt > inner ( const Tensor2D< Cmpt > & t2) const
inline

Inner-product of this with another Tensor2D.

Definition at line 333 of file Tensor2DI.H.

References Tensor2D(), xx(), xy(), yx(), and yy().

Referenced by Foam::operator&().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schur()

template<class Cmpt>
Foam::Tensor2D< Cmpt > schur ( const Tensor2D< Cmpt > & t2) const
inline

Schur-product of this with another Tensor2D.

Definition at line 350 of file Tensor2DI.H.

References Tensor2D(), xx(), xy(), yx(), and yy().

Here is the call graph for this function:

◆ operator=() [2/3]

template<class Cmpt>
void operator= ( const SymmTensor2D< Cmpt > & st)
inline

Copy assign from SymmTensor2D.

Definition at line 385 of file Tensor2DI.H.

References VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, XX, SymmTensor2D< Cmpt >::xx(), XY, SymmTensor2D< Cmpt >::xy(), YX, YY, and SymmTensor2D< Cmpt >::yy().

Here is the call graph for this function:

◆ operator=() [3/3]

template<class Cmpt>
void operator= ( const SphericalTensor2D< Cmpt > & st)
inline

Copy assign from SphericalTensor2D.

Definition at line 393 of file Tensor2DI.H.

References SphericalTensor2D< Cmpt >::ii(), VectorSpace< Tensor2D< Cmpt >, Cmpt, 4 >::v_, XX, XY, YX, YY, and Foam::Zero.

Here is the call graph for this function:

◆ vectorComponent()

template<class Cmpt>
Vector2D< Cmpt > vectorComponent ( const direction cmpt) const
inline

Deprecated(2018-12) Return vector for given row (0,1).

Deprecated
(2018-12) use row() method

Definition at line 321 of file Tensor2D.H.

◆ col() [5/5]

template<class Cmpt>
template<Foam::direction Idx>
Foam::Vector2D< Cmpt > col ( ) const
inline

Definition at line 118 of file Tensor2DI.H.

◆ row() [5/5]

template<class Cmpt>
template<Foam::direction Idx>
Foam::Vector2D< Cmpt > row ( ) const
inline

Definition at line 146 of file Tensor2DI.H.

Member Data Documentation

◆ rank

template<class Cmpt>
direction rank = 2
staticconstexpr

Rank of Tensor2D is 2.

Definition at line 71 of file Tensor2D.H.

◆ I

template<class Cmpt>
const Tensor2D I
static

Definition at line 76 of file Tensor2D.H.


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