Reference documentation for deal.II version 8.5.0
SymmetricTensor< rank, dim, Number > Class Template Reference

#include <deal.II/base/symmetric_tensor.h>

Inheritance diagram for SymmetricTensor< rank, dim, Number >:
[legend]

## Public Member Functions

SymmetricTensor ()

SymmetricTensor (const Tensor< 2, dim, Number > &t)

SymmetricTensor (const Number(&array)[n_independent_components])

template<typename OtherNumber >
SymmetricTensor (const SymmetricTensor< rank, dim, OtherNumber > &initializer)

SymmetricTensoroperator= (const Number d)

operator Tensor< rank, dim, Number > () const

bool operator== (const SymmetricTensor &) const

bool operator!= (const SymmetricTensor &) const

SymmetricTensoroperator+= (const SymmetricTensor &)

SymmetricTensoroperator-= (const SymmetricTensor &)

SymmetricTensoroperator*= (const Number factor)

SymmetricTensoroperator/= (const Number factor)

SymmetricTensor operator+ (const SymmetricTensor &s) const

SymmetricTensor operator- (const SymmetricTensor &s) const

SymmetricTensor operator- () const

internal::SymmetricTensorAccessors::double_contraction_result< rank, 2, dim, Number >::type operator* (const SymmetricTensor< 2, dim, Number > &s) const

internal::SymmetricTensorAccessors::double_contraction_result< rank, 4, dim, Number >::type operator* (const SymmetricTensor< 4, dim, Number > &s) const

Number & operator() (const TableIndices< rank > &indices)

Number operator() (const TableIndices< rank > &indices) const

internal::SymmetricTensorAccessors::Accessor< rank, dim, true, rank-1, Number > operator[] (const unsigned int row) const

internal::SymmetricTensorAccessors::Accessor< rank, dim, false, rank-1, Number > operator[] (const unsigned int row)

Number operator[] (const TableIndices< rank > &indices) const

Number & operator[] (const TableIndices< rank > &indices)

Number access_raw_entry (const unsigned int unrolled_index) const

Number & access_raw_entry (const unsigned int unrolled_index)

numbers::NumberTraits< Number >::real_type norm () const

void clear ()

template<class Archive >
void serialize (Archive &ar, const unsigned int version)

## Static Public Member Functions

static unsigned int component_to_unrolled_index (const TableIndices< rank > &indices)

static TableIndices< rank > unrolled_to_component_indices (const unsigned int i)

static std::size_t memory_consumption ()

## Static Public Attributes

static const unsigned int dimension = dim

static const unsigned int n_independent_components

## Private Types

typedef internal::SymmetricTensorAccessors::StorageType< rank, dim, Number > base_tensor_descriptor

typedef base_tensor_descriptor::base_tensor_type base_tensor_type

## Private Attributes

base_tensor_type data

## Friends

template<int , int , typename >
class SymmetricTensor

template<int dim2, typename Number2 >
Number2 trace (const SymmetricTensor< 2, dim2, Number2 > &d)

template<int dim2, typename Number2 >
SymmetricTensor< 2, dim2, Number2 > unit_symmetric_tensor ()

template<int dim2, typename Number2 >
SymmetricTensor< 4, dim2, Number2 > deviator_tensor ()

template<int dim2, typename Number2 >
SymmetricTensor< 4, dim2, Number2 > identity_tensor ()

## Related Functions

(Note that these are not member functions.)

template<int rank, int dim, typename Number >
SymmetricTensor< rank, dim, Number > sum (const SymmetricTensor< rank, dim, Number > &local, const MPI_Comm &mpi_communicator)

template<int dim, typename Number , typename T >

template<int dim, typename Number , typename T >

template<int dim, typename Number , typename T >

template<int dim, typename Number , typename T >

template<int rank, int dim, typename Number , typename OtherNumber >
Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator+ (const SymmetricTensor< rank, dim, Number > &left, const Tensor< rank, dim, OtherNumber > &right)

template<int rank, int dim, typename Number , typename OtherNumber >
Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator+ (const Tensor< rank, dim, Number > &left, const SymmetricTensor< rank, dim, OtherNumber > &right)

template<int rank, int dim, typename Number , typename OtherNumber >
Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator- (const SymmetricTensor< rank, dim, Number > &left, const Tensor< rank, dim, OtherNumber > &right)

template<int rank, int dim, typename Number , typename OtherNumber >
Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator- (const Tensor< rank, dim, Number > &left, const SymmetricTensor< rank, dim, OtherNumber > &right)

template<int dim, typename Number >
Number determinant (const SymmetricTensor< 2, dim, Number > &t)

template<int dim, typename Number >
Number third_invariant (const SymmetricTensor< 2, dim, Number > &t)

template<int dim, typename Number >
Number trace (const SymmetricTensor< 2, dim, Number > &d)

template<int dim, typename Number >
Number first_invariant (const SymmetricTensor< 2, dim, Number > &t)

template<typename Number >
Number second_invariant (const SymmetricTensor< 2, 1, Number > &)

template<typename Number >
Number second_invariant (const SymmetricTensor< 2, 2, Number > &t)

template<typename Number >
Number second_invariant (const SymmetricTensor< 2, 3, Number > &t)

template<int rank, int dim, typename Number >
SymmetricTensor< rank, dim, Number > transpose (const SymmetricTensor< rank, dim, Number > &t)

template<int dim, typename Number >
SymmetricTensor< 2, dim, Number > deviator (const SymmetricTensor< 2, dim, Number > &t)

template<int dim, typename Number >
SymmetricTensor< 2, dim, Number > invert (const SymmetricTensor< 2, dim, Number > &)

template<int dim, typename Number >
SymmetricTensor< 4, dim, Number > invert (const SymmetricTensor< 4, dim, Number > &t)

template<>
SymmetricTensor< 4, 3, double > invert (const SymmetricTensor< 4, 3, double > &t)

template<int dim, typename Number >
SymmetricTensor< 4, dim, Number > outer_product (const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)

template<int dim, typename Number >
SymmetricTensor< 2, dim, Number > symmetrize (const Tensor< 2, dim, Number > &t)

template<int rank, int dim, typename Number >
SymmetricTensor< rank, dim, Number > operator* (const SymmetricTensor< rank, dim, Number > &t, const Number factor)

template<int rank, int dim, typename Number >
SymmetricTensor< rank, dim, Number > operator* (const Number factor, const SymmetricTensor< rank, dim, Number > &t)

template<int rank, int dim, typename Number >
SymmetricTensor< rank, dim, Number > operator/ (const SymmetricTensor< rank, dim, Number > &t, const Number factor)

template<int rank, int dim>
SymmetricTensor< rank, dim > operator* (const SymmetricTensor< rank, dim > &t, const double factor)

template<int rank, int dim>
SymmetricTensor< rank, dim > operator* (const double factor, const SymmetricTensor< rank, dim > &t)

template<int rank, int dim>
SymmetricTensor< rank, dim > operator/ (const SymmetricTensor< rank, dim > &t, const double factor)

template<int dim, typename Number >
Number scalar_product (const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)

template<int dim, typename Number >
Number scalar_product (const SymmetricTensor< 2, dim, Number > &t1, const Tensor< 2, dim, Number > &t2)

template<int dim, typename Number >
Number scalar_product (const Tensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)

template<typename Number >
void double_contract (SymmetricTensor< 2, 1, Number > &tmp, const SymmetricTensor< 4, 1, Number > &t, const SymmetricTensor< 2, 1, Number > &s)

template<typename Number >
void double_contract (SymmetricTensor< 2, 1, Number > &tmp, const SymmetricTensor< 2, 1, Number > &s, const SymmetricTensor< 4, 1, Number > &t)

template<typename Number >
void double_contract (SymmetricTensor< 2, 2, Number > &tmp, const SymmetricTensor< 4, 2, Number > &t, const SymmetricTensor< 2, 2, Number > &s)

template<typename Number >
void double_contract (SymmetricTensor< 2, 2, Number > &tmp, const SymmetricTensor< 2, 2, Number > &s, const SymmetricTensor< 4, 2, Number > &t)

template<typename Number >
void double_contract (SymmetricTensor< 2, 3, Number > &tmp, const SymmetricTensor< 4, 3, Number > &t, const SymmetricTensor< 2, 3, Number > &s)

template<typename Number >
void double_contract (SymmetricTensor< 2, 3, Number > &tmp, const SymmetricTensor< 2, 3, Number > &s, const SymmetricTensor< 4, 3, Number > &t)

template<int dim, typename Number >
Tensor< 1, dim, Number > operator* (const SymmetricTensor< 2, dim, Number > &src1, const Tensor< 1, dim, Number > &src2)

template<int dim, typename Number >
Tensor< 1, dim, Number > operator* (const Tensor< 1, dim, Number > &src1, const SymmetricTensor< 2, dim, Number > &src2)

template<int dim, typename Number >
std::ostream & operator<< (std::ostream &out, const SymmetricTensor< 2, dim, Number > &t)

template<int dim, typename Number >
std::ostream & operator<< (std::ostream &out, const SymmetricTensor< 4, dim, Number > &t)

## Detailed Description

### template<int rank, int dim, typename Number> class SymmetricTensor< rank, dim, Number >

Provide a class that stores symmetric tensors of rank 2,4,... efficiently, i.e. only store those off-diagonal elements of the full tensor that are not redundant. For example, for symmetric 2x2 tensors, this would be the elements 11, 22, and 12, while the element 21 is equal to the 12 element.

Using this class for symmetric tensors of rank 2 has advantages over matrices in many cases since the dimension is known to the compiler as well as the location of the data. It is therefore possible to produce far more efficient code than for matrices with runtime-dependent dimension. It is also more efficient than using the more general Tensor class, since fewer elements are stored, and the class automatically makes sure that the tensor represents a symmetric object.

For tensors of higher rank, the savings in storage are even higher. For example for the 3x3x3x3 tensors of rank 4, only 36 instead of the full 81 entries have to be stored.

While the definition of a symmetric rank-2 tensor is obvious, tensors of rank 4 are considered symmetric if they are operators mapping symmetric rank-2 tensors onto symmetric rank-2 tensors. This entails certain symmetry properties on the elements in their 4-dimensional index space, in particular that Cijkl=Cjikl=Cijlk. However, it does not imply the relation Cijkl=Cklij. Consequently, symmetric tensors of rank 4 as understood here are only tensors that map symmetric tensors onto symmetric tensors, but they do not necessarily induce a symmetric scalar product a:C:b=b:C:a or even a positive (semi-)definite form a:C:a, where a,b are symmetric rank-2 tensors and the colon indicates the common double-index contraction that acts as a product for symmetric tensors.

Symmetric tensors are most often used in structural and fluid mechanics, where strains and stresses are usually symmetric tensors, and the stress-strain relationship is given by a symmetric rank-4 tensor.

Note
Symmetric tensors only exist with even numbers of indices. In other words, the only objects that you can use are SymmetricTensor<2,dim>, SymmetricTensor<4,dim>, etc, but SymmetricTensor<1,dim> and SymmetricTensor<3,dim> do not exist and their use will most likely lead to compiler errors.

### Accessing elements

The elements of a tensor t can be accessed using the bracket operator, i.e. for a tensor of rank 4, t[0][1][0][1] accesses the element t0101. This access can be used for both reading and writing (if the tensor is non-constant at least). You may also perform other operations on it, although that may lead to confusing situations because several elements of the tensor are stored at the same location. For example, for a rank-2 tensor that is assumed to be zero at the beginning, writing t[0][1]+=1; t[1][0]+=1; will lead to the same element being increased by one twice, because even though the accesses use different indices, the elements that are accessed are symmetric and therefore stored at the same location. It may therefore be useful in application programs to restrict operations on individual elements to simple reads or writes.

Definition at line 42 of file mpi.h.

## Member Typedef Documentation

template<int rank, int dim, typename Number>
 typedef internal::SymmetricTensorAccessors::StorageType SymmetricTensor< rank, dim, Number >::base_tensor_descriptor
private

A structure that describes properties of the base tensor.

Definition at line 790 of file symmetric_tensor.h.

template<int rank, int dim, typename Number>
 typedef base_tensor_descriptor::base_tensor_type SymmetricTensor< rank, dim, Number >::base_tensor_type
private

Data storage type for a symmetric tensor.

Definition at line 795 of file symmetric_tensor.h.

## Constructor & Destructor Documentation

template<int rank, int dim, typename Number>
 SymmetricTensor< rank, dim, Number >::SymmetricTensor ( )

Default constructor. Creates a tensor with all entries equal to zero.

template<int rank, int dim, typename Number>
 SymmetricTensor< rank, dim, Number >::SymmetricTensor ( const Tensor< 2, dim, Number > & t )

Constructor. Generate a symmetric tensor from a general one. Assumes that t is already symmetric, and in debug mode this is in fact checked. Note that no provision is made to assure that the tensor is symmetric only up to round-off error: if the incoming tensor is not exactly symmetric, then an exception is thrown. If you know that incoming tensor is symmetric only up to round-off, then you may want to call the symmetrize function first. If you aren't sure, it is good practice to check before calling symmetrize.

template<int rank, int dim, typename Number>
 SymmetricTensor< rank, dim, Number >::SymmetricTensor ( const Number(&) array[n_independent_components] )

A constructor that creates a symmetric tensor from an array holding its independent elements. Using this constructor assumes that the caller knows the order in which elements are stored in symmetric tensors; its use is therefore discouraged, but if you think you want to use it anyway you can query the order of elements using the unrolled_index() function.

This constructor is currently only implemented for symmetric tensors of rank 2.

The size of the array passed is equal to SymmetricTensor<rank,dim>::n_independent_component; the reason for using the object from the internal namespace is to work around bugs in some older compilers.

template<int rank, int dim, typename Number>
template<typename OtherNumber >
 SymmetricTensor< rank, dim, Number >::SymmetricTensor ( const SymmetricTensor< rank, dim, OtherNumber > & initializer )
explicit

Copy constructor from tensors with different underlying scalar type. This obviously requires that the OtherNumber type is convertible to Number.

## Member Function Documentation

template<int rank, int dim, typename Number>
 SymmetricTensor& SymmetricTensor< rank, dim, Number >::operator= ( const Number d )

This operator assigns a scalar to a tensor. To avoid confusion with what exactly it means to assign a scalar value to a tensor, zero is the only value allowed for d, allowing the intuitive notation t=0 to reset all elements of the tensor to zero.

template<int rank, int dim, typename Number>
 SymmetricTensor< rank, dim, Number >::operator Tensor< rank, dim, Number > ( ) const

Convert the present symmetric tensor into a full tensor with the same elements, but using the different storage scheme of full tensors.

template<int rank, int dim, typename Number>
 bool SymmetricTensor< rank, dim, Number >::operator== ( const SymmetricTensor< rank, dim, Number > & ) const

Test for equality of two tensors.

template<int rank, int dim, typename Number>
 bool SymmetricTensor< rank, dim, Number >::operator!= ( const SymmetricTensor< rank, dim, Number > & ) const

Test for inequality of two tensors.

template<int rank, int dim, typename Number>
 SymmetricTensor& SymmetricTensor< rank, dim, Number >::operator+= ( const SymmetricTensor< rank, dim, Number > & )

template<int rank, int dim, typename Number>
 SymmetricTensor& SymmetricTensor< rank, dim, Number >::operator-= ( const SymmetricTensor< rank, dim, Number > & )

Subtract another tensor.

template<int rank, int dim, typename Number>
 SymmetricTensor& SymmetricTensor< rank, dim, Number >::operator*= ( const Number factor )

Scale the tensor by factor, i.e. multiply all components by factor.

template<int rank, int dim, typename Number>
 SymmetricTensor& SymmetricTensor< rank, dim, Number >::operator/= ( const Number factor )

Scale the vector by 1/factor.

template<int rank, int dim, typename Number>
 SymmetricTensor SymmetricTensor< rank, dim, Number >::operator+ ( const SymmetricTensor< rank, dim, Number > & s ) const

Add two tensors. If possible, you should use operator += instead since this does not need the creation of a temporary.

template<int rank, int dim, typename Number>
 SymmetricTensor SymmetricTensor< rank, dim, Number >::operator- ( const SymmetricTensor< rank, dim, Number > & s ) const

Subtract two tensors. If possible, you should use operator -= instead since this does not need the creation of a temporary.

template<int rank, int dim, typename Number>
 SymmetricTensor SymmetricTensor< rank, dim, Number >::operator- ( ) const

Unary minus operator. Negate all entries of a tensor.

template<int rank, int dim, typename Number>
 internal::SymmetricTensorAccessors::double_contraction_result::type SymmetricTensor< rank, dim, Number >::operator* ( const SymmetricTensor< 2, dim, Number > & s ) const

Product between the present symmetric tensor and a tensor of rank 2. For example, if the present object is also a rank-2 tensor, then this is the scalar-product double contraction aijbij over all indices i,j. In this case, the return value evaluates to a single scalar. While it is possible to define other scalar product (and associated induced norms), this one seems to be the most appropriate one.

If the present object is a rank-4 tensor, then the result is a rank-2 tensor, i.e., the operation contracts over the last two indices of the present object and the indices of the argument, and the result is a tensor of rank 2.

Note that the multiplication operator for symmetric tensors is defined to be a double contraction over two indices, while it is defined as a single contraction over only one index for regular Tensor objects. For symmetric tensors it therefore acts in a way that is commonly denoted by a "colon multiplication" in the mathematical literature.

There are global functions double_contract that do the same work as this operator, but rather than returning the result as a return value, they write it into the first argument to the function.

template<int rank, int dim, typename Number>
 internal::SymmetricTensorAccessors::double_contraction_result::type SymmetricTensor< rank, dim, Number >::operator* ( const SymmetricTensor< 4, dim, Number > & s ) const

Contraction over two indices of the present object with the rank-4 symmetric tensor given as argument.

template<int rank, int dim, typename Number>
 Number& SymmetricTensor< rank, dim, Number >::operator() ( const TableIndices< rank > & indices )

Return a read-write reference to the indicated element.

template<int rank, int dim, typename Number>
 Number SymmetricTensor< rank, dim, Number >::operator() ( const TableIndices< rank > & indices ) const

Return an element by value.

template<int rank, int dim, typename Number>
 internal::SymmetricTensorAccessors::Accessor SymmetricTensor< rank, dim, Number >::operator[] ( const unsigned int row ) const

Access the elements of a row of this symmetric tensor. This function is called for constant tensors.

template<int rank, int dim, typename Number>
 internal::SymmetricTensorAccessors::Accessor SymmetricTensor< rank, dim, Number >::operator[] ( const unsigned int row )

Access the elements of a row of this symmetric tensor. This function is called for non-constant tensors.

template<int rank, int dim, typename Number>
 Number SymmetricTensor< rank, dim, Number >::operator[] ( const TableIndices< rank > & indices ) const

Return an element by value.

Exactly the same as operator().

template<int rank, int dim, typename Number>
 Number& SymmetricTensor< rank, dim, Number >::operator[] ( const TableIndices< rank > & indices )

Return a read-write reference to the indicated element.

Exactly the same as operator().

template<int rank, int dim, typename Number>
 Number SymmetricTensor< rank, dim, Number >::access_raw_entry ( const unsigned int unrolled_index ) const

Access to an element according to unrolled index. The function s.access_raw_entry(unrolled_index) does the same as s[s.unrolled_to_component_indices(i)], but more efficiently.

template<int rank, int dim, typename Number>
 Number& SymmetricTensor< rank, dim, Number >::access_raw_entry ( const unsigned int unrolled_index )

Access to an element according to unrolled index. The function s.access_raw_entry(unrolled_index) does the same as s[s.unrolled_to_component_indices(i)], but more efficiently.

template<int rank, int dim, typename Number>
 numbers::NumberTraits::real_type SymmetricTensor< rank, dim, Number >::norm ( ) const

Return the Frobenius-norm of a tensor, i.e. the square root of the sum of squares of all entries. This norm is induced by the scalar product defined above for two symmetric tensors. Note that it includes all entries of the tensor, counting symmetry, not only the unique ones (for example, for rank-2 tensors, this norm includes adding up the squares of upper right as well as lower left entries, not just one of them, although they are equal for symmetric tensors).

template<int rank, int dim, typename Number>
 static unsigned int SymmetricTensor< rank, dim, Number >::component_to_unrolled_index ( const TableIndices< rank > & indices )
static

Tensors can be unrolled by simply pasting all elements into one long vector, but for this an order of elements has to be defined. For symmetric tensors, this function returns which index within the range [0,n_independent_components) the given entry in a symmetric tensor has.

template<int rank, int dim, typename Number>
 static TableIndices SymmetricTensor< rank, dim, Number >::unrolled_to_component_indices ( const unsigned int i )
static

The opposite of the previous function: given an index $$i$$ in the unrolled form of the tensor, return what set of indices $$(k,l)$$ (for rank-2 tensors) or $$(k,l,m,n)$$ (for rank-4 tensors) corresponds to it.

template<int rank, int dim, typename Number>
 void SymmetricTensor< rank, dim, Number >::clear ( )

Reset all values to zero.

Note that this is partly inconsistent with the semantics of the clear() member functions of the standard library containers and of several other classes within deal.II, which not only reset the values of stored elements to zero, but release all memory and return the object into a virginial state. However, since the size of objects of the present type is determined by its template parameters, resizing is not an option, and indeed the state where all elements have a zero value is the state right after construction of such an object.

template<int rank, int dim, typename Number>
 static std::size_t SymmetricTensor< rank, dim, Number >::memory_consumption ( )
static

Determine an estimate for the memory consumption (in bytes) of this object.

template<int rank, int dim, typename Number>
template<class Archive >
 void SymmetricTensor< rank, dim, Number >::serialize ( Archive & ar, const unsigned int version )

Read or write the data of this object to or from a stream for the purpose of serialization

## Friends And Related Function Documentation

template<int rank, int dim, typename Number>
template<int , int , typename >
 friend class SymmetricTensor
friend

Make all other symmetric tensors friends.

Definition at line 805 of file symmetric_tensor.h.

template<int rank, int dim, typename Number>
template<int dim2, typename Number2 >
 Number2 trace ( const SymmetricTensor< 2, dim2, Number2 > & d )
friend

Make a few more functions friends.

template<int rank, int dim, typename Number>
template<int dim2, typename Number2 >
 SymmetricTensor< 2, dim > unit_symmetric_tensor ( )
friend

Return a unit symmetric tensor of rank 2, i.e., the dim-by-dim identity matrix.

Return a unit symmetric tensor of rank 2, i.e., the dim-by-dim identity matrix. This specialization of the function uses double as the data type for the elements.

Definition at line 2366 of file symmetric_tensor.h.

template<int rank, int dim, typename Number>
template<int dim2, typename Number2 >
 SymmetricTensor< 4, dim > deviator_tensor ( )
friend

Return the tensor of rank 4 that, when multiplied by a symmetric rank 2 tensor t returns the deviator $$\textrm{dev}\ t$$. It is the operator representation of the linear deviator operator.

For every tensor t, there holds the identity deviator(t)==deviator_tensor<dim>()*t, up to numerical round-off. The reason this operator representation is provided is that one sometimes needs to invert operators like identity_tensor<dim>() + delta_t*deviator_tensor<dim>() or similar.

Return the tensor of rank 4 that, when multiplied by a symmetric rank 2 tensor t returns the deviator dev t. It is the operator representation of the linear deviator operator.

For every tensor t, there holds the identity deviator(t)==deviator_tensor<dim>()*t, up to numerical round-off. The reason this operator representation is provided is that one sometimes needs to invert operators like identity_tensor<dim>() + delta_t*deviator_tensor<dim>() or similar.

Definition at line 2426 of file symmetric_tensor.h.

template<int rank, int dim, typename Number>
template<int dim2, typename Number2 >
 SymmetricTensor< 4, dim > identity_tensor ( )
friend

Return the fourth-order symmetric identity tensor which maps symmetric second-order tensors to themselves.

Note that this tensor, even though it is the identity, has a somewhat funny form, and in particular does not only consist of zeros and ones. For example, for dim=2, the identity tensor has all zero entries except for id[0][0][0][0]=id[1][1][1][1]=1 and id[0][1][0][1]=id[0][1][1][0]=id[1][0][0][1]=id[1][0][1][0]=1/2. To see why this factor of 1/2 is necessary, consider computing A=Id : B. For the element a_01 we have a_01=id_0100 b_00 + id_0111 b_11 + id_0101 b_01 + id_0110 b_10. On the other hand, we need to have a_01=b_01, and symmetry implies b_01=b_10, leading to a_01=(id_0101+id_0110) b_01, or, again by symmetry, id_0101=id_0110=1/2. Similar considerations hold for the three- dimensional case.

This issue is also explained in the introduction to step-44.

Return the tensor of rank 4 that, when multiplied by a symmetric rank 2 tensor t returns the deviator dev t. It is the operator representation of the linear deviator operator.

Note that this tensor, even though it is the identity, has a somewhat funny form, and in particular does not only consist of zeros and ones. For example, for dim=2, the identity tensor has all zero entries except for id[0][0][0][0]=id[1][1][1][1]=1 and id[0][1][0][1]=id[0][1][1][0]=id[1][0][0][1]=id[1][0][1][0]=1/2. To see why this factor of 1/2 is necessary, consider computing A=Id . B. For the element a_01 we have a_01=id_0100 b_00 + id_0111 b_11 + id_0101 b_01 + id_0110 b_10. On the other hand, we need to have a_01=b_01, and symmetry implies b_01=b_10, leading to a_01=(id_0101+id_0110) b_01, or, again by symmetry, id_0101=id_0110=1/2. Similar considerations hold for the three- dimensional case.

Definition at line 2499 of file symmetric_tensor.h.

template<int rank, int dim, typename Number >
 SymmetricTensor< rank, dim, Number > sum ( const SymmetricTensor< rank, dim, Number > & local, const MPI_Comm & mpi_communicator )
related

Perform an MPI sum of the entries of a symmetric tensor.

template<int dim, typename Number , typename T >
related

Compute the scalar product $$a:b=\sum_{i,j} a_{ij}b_{ij}$$ between two tensors $$a,b$$ of rank 2. We don't use operator* for this operation since the product between two tensors is usually assumed to be the contraction over the last index of the first tensor and the first index of the second tensor, for example $$(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$$.

Definition at line 91 of file sacado_product_type.h.

template<int dim, typename Number , typename T >
related

Compute the scalar product $$a:b=\sum_{i,j} a_{ij}b_{ij}$$ between two tensors $$a,b$$ of rank 2. We don't use operator* for this operation since the product between two tensors is usually assumed to be the contraction over the last index of the first tensor and the first index of the second tensor, for example $$(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$$.

Definition at line 114 of file sacado_product_type.h.

template<int dim, typename Number , typename T >
related

Compute the scalar product $$a:b=\sum_{i,j} a_{ij}b_{ij}$$ between two tensors $$a,b$$ of rank 2. We don't use operator* for this operation since the product between two tensors is usually assumed to be the contraction over the last index of the first tensor and the first index of the second tensor, for example $$(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$$.

Definition at line 133 of file sacado_product_type.h.

template<int dim, typename Number , typename T >
related

Compute the scalar product $$a:b=\sum_{i,j} a_{ij}b_{ij}$$ between two tensors $$a,b$$ of rank 2. We don't use operator* for this operation since the product between two tensors is usually assumed to be the contraction over the last index of the first tensor and the first index of the second tensor, for example $$(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$$.

Definition at line 156 of file sacado_product_type.h.

template<int rank, int dim, typename Number , typename OtherNumber >
 Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator+ ( const SymmetricTensor< rank, dim, Number > & left, const Tensor< rank, dim, OtherNumber > & right )
related

Addition of a SymmetricTensor and a general Tensor of equal rank. The result is a general Tensor.

Definition at line 2090 of file symmetric_tensor.h.

template<int rank, int dim, typename Number , typename OtherNumber >
 Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator+ ( const Tensor< rank, dim, Number > & left, const SymmetricTensor< rank, dim, OtherNumber > & right )
related

Addition of a general Tensor with a SymmetricTensor of equal rank. The result is a general Tensor.

Definition at line 2106 of file symmetric_tensor.h.

template<int rank, int dim, typename Number , typename OtherNumber >
 Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator- ( const SymmetricTensor< rank, dim, Number > & left, const Tensor< rank, dim, OtherNumber > & right )
related

Subtraction of a SymmetricTensor and a general Tensor of equal rank. The result is a general Tensor.

Definition at line 2122 of file symmetric_tensor.h.

template<int rank, int dim, typename Number , typename OtherNumber >
 Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator- ( const Tensor< rank, dim, Number > & left, const SymmetricTensor< rank, dim, OtherNumber > & right )
related

Subtraction of a general Tensor with a SymmetricTensor of equal rank. The result is a general Tensor.

Definition at line 2138 of file symmetric_tensor.h.

template<int dim, typename Number >
 Number determinant ( const SymmetricTensor< 2, dim, Number > & t )
related

Compute the determinant of a tensor or rank 2. The determinant is also commonly referred to as the third invariant of rank-2 tensors.

For a one-dimensional tensor, the determinant equals the only element and is therefore equivalent to the trace.

For greater notational simplicity, there is also a third_invariant function that returns the determinant of a tensor.

Definition at line 2161 of file symmetric_tensor.h.

template<int dim, typename Number >
 Number third_invariant ( const SymmetricTensor< 2, dim, Number > & t )
related

Compute the determinant of a tensor or rank 2. This function therefore computes the same value as the determinant() functions and is only provided for greater notational simplicity (since there are also functions first_invariant() and second_invariant()).

Definition at line 2200 of file symmetric_tensor.h.

template<int dim, typename Number >
 Number trace ( const SymmetricTensor< 2, dim, Number > & d )
related

Compute and return the trace of a tensor of rank 2, i.e. the sum of its diagonal entries. The trace is the first invariant of a rank-2 tensor.

Definition at line 2215 of file symmetric_tensor.h.

template<int dim, typename Number >
 Number first_invariant ( const SymmetricTensor< 2, dim, Number > & t )
related

Compute the trace of a tensor or rank 2. This function therefore computes the same value as the trace() functions and is only provided for greater notational simplicity (since there are also functions second_invariant() and third_invariant()).

Definition at line 2235 of file symmetric_tensor.h.

template<typename Number >
 Number second_invariant ( const SymmetricTensor< 2, 1, Number > & )
related

Compute the second invariant of a tensor of rank 2. The second invariant of a tensor $$\sigma$$ is defined as $$II(\sigma) = \frac 12 \left[ (\text{trace}\ \sigma)^2 -\text{trace}\ (\sigma^2) \right]$$.

For the kind of arguments to this function, i.e., a rank-2 tensor of size 1, the result is simply zero.

Definition at line 2255 of file symmetric_tensor.h.

template<typename Number >
 Number second_invariant ( const SymmetricTensor< 2, 2, Number > & t )
related

Compute the second invariant of a tensor of rank 2. The second invariant of a tensor $$\sigma$$ is defined as $$II(\sigma) = \frac 12 \left[ (\text{trace}\ \sigma)^2 -\text{trace}\ (\sigma^2) \right]$$.

For the kind of arguments to this function, i.e., a rank-2 tensor of size 2, the result is (counting indices starting at one) $$II(\sigma) = \frac 12 \left[ (\sigma_{11} + \sigma_{22})^2 -(\sigma_{11}^2+2\sigma_{12}^2+\sigma_{22}^2) \right] = \sigma_{11}\sigma_{22} - \sigma_{12}^2$$. As expected, for the $$2\times 2$$ symmetric tensors this function handles, this equals the determinant of the tensor. (This is so because for $$2\times 2$$ symmetric tensors, there really are only two invariants, so the second and third invariant are the same; the determinant is the third invariant.)

Definition at line 2284 of file symmetric_tensor.h.

template<typename Number >
 Number second_invariant ( const SymmetricTensor< 2, 3, Number > & t )
related

Compute the second invariant of a tensor of rank 2. The second invariant of a tensor $$\sigma$$ is defined as $$II(\sigma) = \frac 12 \left[ (\text{trace}\ \sigma)^2 -\text{trace}\ (\sigma^2) \right]$$.

Definition at line 2302 of file symmetric_tensor.h.

template<int rank, int dim, typename Number >
 SymmetricTensor< rank, dim, Number > transpose ( const SymmetricTensor< rank, dim, Number > & t )
related

Return the transpose of the given symmetric tensor. Since we are working with symmetric objects, the transpose is of course the same as the original tensor. This function mainly exists for compatibility with the Tensor class.

Definition at line 2323 of file symmetric_tensor.h.

template<int dim, typename Number >
 SymmetricTensor< 2, dim, Number > deviator ( const SymmetricTensor< 2, dim, Number > & t )
related

Compute the deviator of a symmetric tensor, which is defined as dev[s] = s - 1/dim*tr[s]*I, where I is the identity operator. This quantity equals the original tensor minus its contractive or dilative component and refers to the shear in, for example, elasticity.

Definition at line 2342 of file symmetric_tensor.h.

template<int dim, typename Number >
 SymmetricTensor< 2, dim, Number > invert ( const SymmetricTensor< 2, dim, Number > & )
related

Invert a symmetric rank-2 tensor.

Note
If a tensor is not invertible, then the result is unspecified, but will likely contain the results of a division by zero or a very small number at the very least.

Definition at line 2566 of file symmetric_tensor.h.

template<int dim, typename Number >
 SymmetricTensor< 4, dim, Number > invert ( const SymmetricTensor< 4, dim, Number > & t )
related

Invert a symmetric rank-4 tensor. Since symmetric rank-4 tensors are mappings from and to symmetric rank-2 tensors, they can have an inverse. This function computes it, if it exists, for the case that the dimension equals either 1 or 2.

If a tensor is not invertible, then the result is unspecified, but will likely contain the results of a division by zero or a very small number at the very least.

Definition at line 2680 of file symmetric_tensor.h.

 SymmetricTensor< 4, 3, double > invert ( const SymmetricTensor< 4, 3, double > & t )
related

Invert a symmetric rank-4 tensor. Since symmetric rank-4 tensors are mappings from and to symmetric rank-2 tensors, they can have an inverse. This function computes it, if it exists, for the case that the dimension equals 3.

If a tensor is not invertible, then the result is unspecified, but will likely contain the results of a division by zero or a very small number at the very least.

template<int dim, typename Number >
 SymmetricTensor< 4, dim, Number > outer_product ( const SymmetricTensor< 2, dim, Number > & t1, const SymmetricTensor< 2, dim, Number > & t2 )
related

Return the tensor of rank 4 that is the outer product of the two tensors given as arguments, i.e. the result $$T=t1 \otimes t2$$ satisfies T phi = t1 (t2 : phi) for all symmetric tensors phi.

For example, the deviator tensor can be computed as identity_tensor<dim,Number>() - 1/d*outer_product(unit_symmetric_tensor<dim,Number>(), unit_symmetric_tensor<dim,Number>()), since the (double) contraction with the unit tensor yields the trace of a symmetric tensor.

Definition at line 2796 of file symmetric_tensor.h.

template<int dim, typename Number >
 SymmetricTensor< 2, dim, Number > symmetrize ( const Tensor< 2, dim, Number > & t )
related

Return the symmetrized version of a full rank-2 tensor, i.e. (t+transpose(t))/2, as a symmetric rank-2 tensor. This is the version for general dimensions.

Definition at line 2824 of file symmetric_tensor.h.

template<int rank, int dim, typename Number >
 SymmetricTensor< rank, dim, Number > operator* ( const SymmetricTensor< rank, dim, Number > & t, const Number factor )
related

Multiplication of a symmetric tensor of general rank with a scalar from the right. This version of the operator is used if the scalar has the same data type as is used to store the elements of the symmetric tensor.

Definition at line 2847 of file symmetric_tensor.h.

template<int rank, int dim, typename Number >
 SymmetricTensor< rank, dim, Number > operator* ( const Number factor, const SymmetricTensor< rank, dim, Number > & t )
related

Multiplication of a symmetric tensor of general rank with a scalar from the left. This version of the operator is used if the scalar has the same data type as is used to store the elements of the symmetric tensor.

Definition at line 2867 of file symmetric_tensor.h.

template<int rank, int dim, typename Number >
 SymmetricTensor< rank, dim, Number > operator/ ( const SymmetricTensor< rank, dim, Number > & t, const Number factor )
related

Division of a symmetric tensor of general rank by a scalar.

Definition at line 2974 of file symmetric_tensor.h.

template<int rank, int dim>
 SymmetricTensor< rank, dim > operator* ( const SymmetricTensor< rank, dim > & t, const double factor )
related

Multiplication of a symmetric tensor of general rank with a scalar from the right.

Definition at line 2993 of file symmetric_tensor.h.

template<int rank, int dim>
 SymmetricTensor< rank, dim > operator* ( const double factor, const SymmetricTensor< rank, dim > & t )
related

Multiplication of a symmetric tensor of general rank with a scalar from the left.

Definition at line 3012 of file symmetric_tensor.h.

template<int rank, int dim>
 SymmetricTensor< rank, dim > operator/ ( const SymmetricTensor< rank, dim > & t, const double factor )
related

Division of a symmetric tensor of general rank by a scalar.

Definition at line 3030 of file symmetric_tensor.h.

template<int dim, typename Number >
 Number scalar_product ( const SymmetricTensor< 2, dim, Number > & t1, const SymmetricTensor< 2, dim, Number > & t2 )
related

Compute the scalar product $$a:b=\sum_{i,j} a_{ij}b_{ij}$$ between two tensors $$a,b$$ of rank 2. In the current case where both arguments are symmetric tensors, this is equivalent to calling the expression t1*t2 which uses the overloaded operator* between two symmetric tensors of rank 2.

Definition at line 3050 of file symmetric_tensor.h.

template<int dim, typename Number >
 Number scalar_product ( const SymmetricTensor< 2, dim, Number > & t1, const Tensor< 2, dim, Number > & t2 )
related

Compute the scalar product $$a:b=\sum_{i,j} a_{ij}b_{ij}$$ between two tensors $$a,b$$ of rank 2. We don't use operator* for this operation since the product between two tensors is usually assumed to be the contraction over the last index of the first tensor and the first index of the second tensor, for example $$(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$$.

Definition at line 3069 of file symmetric_tensor.h.

template<int dim, typename Number >
 Number scalar_product ( const Tensor< 2, dim, Number > & t1, const SymmetricTensor< 2, dim, Number > & t2 )
related

Compute the scalar product $$a:b=\sum_{i,j} a_{ij}b_{ij}$$ between two tensors $$a,b$$ of rank 2. We don't use operator* for this operation since the product between two tensors is usually assumed to be the contraction over the last index of the first tensor and the first index of the second tensor, for example $$(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$$.

Definition at line 3092 of file symmetric_tensor.h.

template<typename Number >
 void double_contract ( SymmetricTensor< 2, 1, Number > & tmp, const SymmetricTensor< 4, 1, Number > & t, const SymmetricTensor< 2, 1, Number > & s )
related

Double contraction between a rank-4 and a rank-2 symmetric tensor, resulting in the symmetric tensor of rank 2 that is given as first argument to this function. This operation is the symmetric tensor analogon of a matrix-vector multiplication.

This function does the same as the member operator* of the SymmetricTensor class. It should not be used, however, since the member operator has knowledge of the actual data storage format and is at least 2 orders of magnitude faster. This function mostly exists for compatibility purposes with the general tensor class.

Definition at line 3117 of file symmetric_tensor.h.

template<typename Number >
 void double_contract ( SymmetricTensor< 2, 1, Number > & tmp, const SymmetricTensor< 2, 1, Number > & s, const SymmetricTensor< 4, 1, Number > & t )
related

Double contraction between a rank-4 and a rank-2 symmetric tensor, resulting in the symmetric tensor of rank 2 that is given as first argument to this function. This operation is the symmetric tensor analogon of a matrix-vector multiplication.

This function does the same as the member operator* of the SymmetricTensor class. It should not be used, however, since the member operator has knowledge of the actual data storage format and is at least 2 orders of magnitude faster. This function mostly exists for compatibility purposes with the general tensor class.

Definition at line 3144 of file symmetric_tensor.h.

template<typename Number >
 void double_contract ( SymmetricTensor< 2, 2, Number > & tmp, const SymmetricTensor< 4, 2, Number > & t, const SymmetricTensor< 2, 2, Number > & s )
related

Double contraction between a rank-4 and a rank-2 symmetric tensor, resulting in the symmetric tensor of rank 2 that is given as first argument to this function. This operation is the symmetric tensor analogon of a matrix-vector multiplication.

This function does the same as the member operator* of the SymmetricTensor class. It should not be used, however, since the member operator has knowledge of the actual data storage format and is at least 2 orders of magnitude faster. This function mostly exists for compatibility purposes with the general tensor class.

Definition at line 3170 of file symmetric_tensor.h.

template<typename Number >
 void double_contract ( SymmetricTensor< 2, 2, Number > & tmp, const SymmetricTensor< 2, 2, Number > & s, const SymmetricTensor< 4, 2, Number > & t )
related

Double contraction between a rank-4 and a rank-2 symmetric tensor, resulting in the symmetric tensor of rank 2 that is given as first argument to this function. This operation is the symmetric tensor analogon of a matrix-vector multiplication.

This function does the same as the member operator* of the SymmetricTensor class. It should not be used, however, since the member operator has knowledge of the actual data storage format and is at least 2 orders of magnitude faster. This function mostly exists for compatibility purposes with the general tensor class.

Definition at line 3203 of file symmetric_tensor.h.

template<typename Number >
 void double_contract ( SymmetricTensor< 2, 3, Number > & tmp, const SymmetricTensor< 4, 3, Number > & t, const SymmetricTensor< 2, 3, Number > & s )
related

Double contraction between a rank-4 and a rank-2 symmetric tensor, resulting in the symmetric tensor of rank 2 that is given as first argument to this function. This operation is the symmetric tensor analogon of a matrix-vector multiplication.

This function does the same as the member operator* of the SymmetricTensor class. It should not be used, however, since the member operator has knowledge of the actual data storage format and is at least 2 orders of magnitude faster. This function mostly exists for compatibility purposes with the general tensor class.

Definition at line 3236 of file symmetric_tensor.h.

template<typename Number >
 void double_contract ( SymmetricTensor< 2, 3, Number > & tmp, const SymmetricTensor< 2, 3, Number > & s, const SymmetricTensor< 4, 3, Number > & t )
related

Double contraction between a rank-4 and a rank-2 symmetric tensor, resulting in the symmetric tensor of rank 2 that is given as first argument to this function. This operation is the symmetric tensor analogon of a matrix-vector multiplication.

This function does the same as the member operator* of the SymmetricTensor class. It should not be used, however, since the member operator has knowledge of the actual data storage format and is at least 2 orders of magnitude faster. This function mostly exists for compatibility purposes with the general tensor class.

Definition at line 3272 of file symmetric_tensor.h.

template<int dim, typename Number >
 Tensor< 1, dim, Number > operator* ( const SymmetricTensor< 2, dim, Number > & src1, const Tensor< 1, dim, Number > & src2 )
related

Multiply a symmetric rank-2 tensor (i.e., a matrix) by a rank-1 tensor (i.e., a vector). The result is a rank-1 tensor (i.e., a vector).

Definition at line 3299 of file symmetric_tensor.h.

template<int dim, typename Number >
 Tensor< 1, dim, Number > operator* ( const Tensor< 1, dim, Number > & src1, const SymmetricTensor< 2, dim, Number > & src2 )
related

Multiply a rank-1 tensor (i.e., a vector) by a symmetric rank-2 tensor (i.e., a matrix). The result is a rank-1 tensor (i.e., a vector).

Definition at line 3319 of file symmetric_tensor.h.

template<int dim, typename Number >
 std::ostream & operator<< ( std::ostream & out, const SymmetricTensor< 2, dim, Number > & t )
related

Output operator for symmetric tensors of rank 2. Print the elements consecutively, with a space in between, two spaces between rank 1 subtensors, three between rank 2 and so on. No special amends are made to represents the symmetry in the output, for example by outputting only the unique entries.

Definition at line 3338 of file symmetric_tensor.h.

template<int dim, typename Number >
 std::ostream & operator<< ( std::ostream & out, const SymmetricTensor< 4, dim, Number > & t )
related

Output operator for symmetric tensors of rank 4. Print the elements consecutively, with a space in between, two spaces between rank 1 subtensors, three between rank 2 and so on. No special amends are made to represents the symmetry in the output, for example by outputting only the unique entries.

Definition at line 3366 of file symmetric_tensor.h.

## Member Data Documentation

template<int rank, int dim, typename Number>
 const unsigned int SymmetricTensor< rank, dim, Number >::dimension = dim
static

Provide a way to get the dimension of an object without explicit knowledge of it's data type. Implementation is this way instead of providing a function dimension() because now it is possible to get the dimension at compile time without the expansion and preevaluation of an inlined function; the compiler may therefore produce more efficient code and you may use this value to declare other data types.

Definition at line 519 of file symmetric_tensor.h.

template<int rank, int dim, typename Number>
 const unsigned int SymmetricTensor< rank, dim, Number >::n_independent_components
static
Initial value:

An integer denoting the number of independent components that fully describe a symmetric tensor. In $$d$$ space dimensions, this number equals $$\frac 12 (d^2+d)$$ for symmetric tensors of rank 2.

Definition at line 527 of file symmetric_tensor.h.

template<int rank, int dim, typename Number>
 base_tensor_type SymmetricTensor< rank, dim, Number >::data
private

The place where we store the data of the tensor.

Definition at line 800 of file symmetric_tensor.h.

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