Public Member Functions | |
SymmetricTensor () | |
SymmetricTensor (const Tensor< 2, dim > &t) | |
SymmetricTensor (const double(&array)[internal::SymmetricTensorAccessors::StorageType< rank, dim >::n_independent_components]) | |
SymmetricTensor & | operator= (const SymmetricTensor &) |
SymmetricTensor & | operator= (const double d) |
operator Tensor< rank, dim > () const | |
bool | operator== (const SymmetricTensor &) const |
bool | operator!= (const SymmetricTensor &) const |
SymmetricTensor & | operator+= (const SymmetricTensor &) |
SymmetricTensor & | operator-= (const SymmetricTensor &) |
SymmetricTensor & | operator*= (const double factor) |
SymmetricTensor & | operator/= (const double factor) |
SymmetricTensor | operator+ (const SymmetricTensor &s) const |
SymmetricTensor | operator- (const SymmetricTensor &s) const |
SymmetricTensor | operator- () const |
internal::SymmetricTensorAccessors::double_contraction_result < rank, 2, dim >::type | operator* (const SymmetricTensor< 2, dim > &s) const |
internal::SymmetricTensorAccessors::double_contraction_result < rank, 4, dim >::type | operator* (const SymmetricTensor< 4, dim > &s) const |
double & | operator() (const TableIndices< rank > &indices) |
double | operator() (const TableIndices< rank > &indices) const |
internal::SymmetricTensorAccessors::Accessor < rank, dim, true, rank-1 > | operator[] (const unsigned int row) const |
internal::SymmetricTensorAccessors::Accessor < rank, dim, false, rank-1 > | operator[] (const unsigned int row) |
double | norm () const |
void | clear () |
Static Public Member Functions | |
static unsigned int | 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 > | base_tensor_descriptor |
typedef base_tensor_descriptor::base_tensor_type | base_tensor_type |
Private Attributes | |
base_tensor_type | data |
Friends | |
class | SymmetricTensor |
template<int dim2> | |
double | trace (const SymmetricTensor< 2, dim2 > &d) |
template<int dim2> | |
double | determinant (const SymmetricTensor< 2, dim2 > &t) |
template<int dim2> | |
SymmetricTensor< 2, dim2 > | deviator (const SymmetricTensor< 2, dim2 > &t) |
template<int dim2> | |
SymmetricTensor< 2, dim2 > | unit_symmetric_tensor () |
template<int dim2> | |
SymmetricTensor< 4, dim2 > | deviator_tensor () |
template<int dim2> | |
SymmetricTensor< 4, dim2 > | identity_tensor () |
template<int dim2> | |
SymmetricTensor< 4, dim2 > | invert (const SymmetricTensor< 4, dim2 > &) |
Related Functions | |
(Note that these are not member functions.) | |
template<int dim> | |
double | third_invariant (const SymmetricTensor< 2, dim > &t) |
template<int dim> | |
double | first_invariant (const SymmetricTensor< 2, dim > &t) |
template<int dim> | |
double | second_invariant (const SymmetricTensor< 2, dim > &t) |
template<int rank, int dim> | |
SymmetricTensor< rank, dim > | transpose (const SymmetricTensor< rank, dim > &t) |
template<int dim> | |
SymmetricTensor< 4, dim > | outer_product (const SymmetricTensor< 2, dim > &t1, const SymmetricTensor< 2, dim > &t2) |
SymmetricTensor< 2, 1 > | symmetrize (const Tensor< 2, 1 > &t) |
SymmetricTensor< 2, 2 > | symmetrize (const Tensor< 2, 2 > &t) |
SymmetricTensor< 2, 3 > | symmetrize (const Tensor< 2, 3 > &t) |
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) |
void | double_contract (SymmetricTensor< 2, 1 > &tmp, const SymmetricTensor< 4, 1 > &t, const SymmetricTensor< 2, 1 > &s) |
template<int dim> | |
std::ostream & | operator<< (std::ostream &out, const SymmetricTensor< 2, dim > &t) |
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 less 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 that 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.
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.
typedef internal::SymmetricTensorAccessors::StorageType<rank,dim> SymmetricTensor< rank, dim >::base_tensor_descriptor [private] |
A structure that describes properties of the base tensor.
typedef base_tensor_descriptor::base_tensor_type SymmetricTensor< rank, dim >::base_tensor_type [private] |
Data storage type for a symmetric tensor.
SymmetricTensor< rank, dim >::SymmetricTensor | ( | ) |
Default constructor. Creates a zero tensor.
SymmetricTensor< rank, dim >::SymmetricTensor | ( | const Tensor< 2, dim > & | 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
.
SymmetricTensor< rank, dim >::SymmetricTensor | ( | const double(&) | array[internal::SymmetricTensorAccessors::StorageType< rank, dim >::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.
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.
SymmetricTensor& SymmetricTensor< rank, dim >::operator= | ( | const SymmetricTensor< rank, dim > & | ) |
Assignment operator.
SymmetricTensor& SymmetricTensor< rank, dim >::operator= | ( | const double | 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.
SymmetricTensor< rank, dim >::operator Tensor< rank, dim > | ( | ) | const |
Convert the present symmetric tensor into a full tensor with the same elements, but using the different storage scheme of full tensors.
bool SymmetricTensor< rank, dim >::operator== | ( | const SymmetricTensor< rank, dim > & | ) | const |
Test for equality of two tensors.
bool SymmetricTensor< rank, dim >::operator!= | ( | const SymmetricTensor< rank, dim > & | ) | const |
Test for inequality of two tensors.
SymmetricTensor& SymmetricTensor< rank, dim >::operator+= | ( | const SymmetricTensor< rank, dim > & | ) |
Add another tensor.
SymmetricTensor& SymmetricTensor< rank, dim >::operator-= | ( | const SymmetricTensor< rank, dim > & | ) |
Subtract another tensor.
SymmetricTensor& SymmetricTensor< rank, dim >::operator*= | ( | const double | factor | ) |
Scale the tensor by factor
, i.e. multiply all components by factor
.
SymmetricTensor& SymmetricTensor< rank, dim >::operator/= | ( | const double | factor | ) |
Scale the vector by 1/factor
.
SymmetricTensor SymmetricTensor< rank, dim >::operator+ | ( | const SymmetricTensor< rank, dim > & | s | ) | const |
Add two tensors. If possible, you should use operator +=
instead since this does not need the creation of a temporary.
SymmetricTensor SymmetricTensor< rank, dim >::operator- | ( | const SymmetricTensor< rank, dim > & | s | ) | const |
Subtract two tensors. If possible, you should use operator -=
instead since this does not need the creation of a temporary.
SymmetricTensor SymmetricTensor< rank, dim >::operator- | ( | ) | const |
Unary minus operator. Negate all entries of a tensor.
internal::SymmetricTensorAccessors::double_contraction_result<rank,2,dim>::type SymmetricTensor< rank, dim >::operator* | ( | const SymmetricTensor< 2, dim > & | 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, the the result is a rank-2 tensor, 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 symmetrict 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 mathematica 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.
internal::SymmetricTensorAccessors::double_contraction_result<rank,4,dim>::type SymmetricTensor< rank, dim >::operator* | ( | const SymmetricTensor< 4, dim > & | s | ) | const |
Contraction over two indices of the present object with the rank-4 symmetric tensor given as argument.
double& SymmetricTensor< rank, dim >::operator() | ( | const TableIndices< rank > & | indices | ) |
Return a read-write reference to the indicated element.
double SymmetricTensor< rank, dim >::operator() | ( | const TableIndices< rank > & | indices | ) | const |
Return the value of the indicated element as a read-only reference.
We return the requested value as a constant reference rather than by value since this object may hold data types that may be large, and we don't know here whether copying is expensive or not.
internal::SymmetricTensorAccessors::Accessor<rank,dim,true,rank-1> SymmetricTensor< rank, dim >::operator[] | ( | const unsigned int | row | ) | const |
Access the elements of a row of this symmetric tensor. This function is called for constant tensors.
internal::SymmetricTensorAccessors::Accessor<rank,dim,false,rank-1> SymmetricTensor< rank, dim >::operator[] | ( | const unsigned int | row | ) |
Access the elements of a row of this symmetric tensor. This function is called for non-constant tensors.
double SymmetricTensor< rank, dim >::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).
void SymmetricTensor< rank, dim >::clear | ( | ) |
Reset all values to zero.
Note that this is partly inconsistent with the semantics of the clear()
member functions of the STL 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.
static unsigned int SymmetricTensor< rank, dim >::memory_consumption | ( | ) | [static] |
Determine an estimate for the memory consumption (in bytes) of this object.
friend class SymmetricTensor [friend] |
Make all other symmetric tensors friends.
double trace | ( | const SymmetricTensor< 2, dim2 > & | d | ) | [friend] |
Make a few more functions friends.
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.
Compute and return the trace of a tensor of rank 2, i.e. the sum of its diagonal entries.
double determinant | ( | const SymmetricTensor< 2, dim2 > & | t | ) | [friend] |
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 the present case of one-dimensional tensors, 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.
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 greater notational simplicity, there is also a third_invariant
function that returns the determinant of a tensor.
Compute the determinant of a tensor of arbitrary rank and dimension one. Since this is a number, the return value is, of course, the number itself.
Compute the determinant of a tensor of rank one and dimension one. Since this is a number, the return value is, of course, the number itself.
Compute the determinant of a tensor or rank 2, here for dim==2
.
Compute the determinant of a tensor or rank 2, here for dim==3
.
SymmetricTensor< 2, dim > deviator | ( | const SymmetricTensor< 2, dim2 > & | t | ) | [friend] |
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.
SymmetricTensor< 2, 3 > unit_symmetric_tensor< 3 > | ( | ) | [friend] |
Return a unit symmetric tensor of rank 2 and dimension 1.
Return a unit symmetric tensor of rank 2 and dimension 2.
Return a unit symmetric tensor of rank 2 and dimension 3.
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 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.
SymmetricTensor< 4, dim > identity_tensor | ( | ) | [friend] |
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.
Tensor< 2, dim > invert | ( | const SymmetricTensor< 4, dim2 > & | t | ) | [friend] |
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 1.
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.
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 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.
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.
Compute and return the inverse of the given tensor. Since the compiler can perform the return value optimization, and since the size of the return object is known, it is acceptable to return the result by value, rather than by reference as a parameter.
double third_invariant | ( | const SymmetricTensor< 2, dim > & | 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
).
References determinant().
double first_invariant | ( | const SymmetricTensor< 2, dim > & | t | ) | [related] |
double second_invariant | ( | const SymmetricTensor< 2, dim > & | t | ) | [related] |
Compute the second invariant a tensor or rank 2. The second invariant is defined as I2 = 1/2[ (trace sigma)^2 - trace (sigma^2) ]
.
References trace().
Tensor< 2, dim > transpose | ( | const SymmetricTensor< rank, dim > & | 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.
Return the transpose of the given tensor. Since the compiler can perform the return value optimization, and since the size of the return object is known, it is acceptable to return the result by value, rather than by reference as a parameter. Note that there are specializations of this function for dim==1,2,3
.
SymmetricTensor< 4, dim > outer_product | ( | const SymmetricTensor< 2, dim > & | t1, | |
const SymmetricTensor< 2, dim > & | t2 | |||
) | [related] |
Return the tensor of rank 4 that is the outer product of the two tensors given as arguments, i.e. the result satisfies
T phi = t1 (t2 : phi)
for all symmetric tensors phi
.
For example, the deviator tensor can be computed as identity_tensor<dim>() - 1/d*outer_product(unit_symmetric_tensor<dim>(), unit_symmetric_tensor<dim>())
, since the (double) contraction with the unit tensor yields the trace of a symmetric tensor.
SymmetricTensor< 2, 1 > symmetrize | ( | const Tensor< 2, 1 > & | 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 dim==1.
SymmetricTensor< 2, 2 > symmetrize | ( | const Tensor< 2, 2 > & | 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 dim==2.
SymmetricTensor< 2, 3 > symmetrize | ( | const Tensor< 2, 3 > & | 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 dim==3.
Tensor< rank, dim > operator* | ( | const SymmetricTensor< rank, dim > & | t, | |
const double | factor | |||
) | [related] |
Multiplication of a symmetric tensor of general rank with a scalar double from the right.
Multiplication of a tensor of general rank with a scalar double from the right.
Tensor< rank, dim > operator* | ( | const double | factor, | |
const SymmetricTensor< rank, dim > & | t | |||
) | [related] |
Multiplication of a symmetric tensor of general rank with a scalar double from the left.
Multiplication of a tensor of general rank with a scalar double from the left.
Tensor< rank, dim > operator/ | ( | const SymmetricTensor< rank, dim > & | t, | |
const double | factor | |||
) | [related] |
Division of a symmetric tensor of general rank by a scalar double.
Division of a tensor of general rank by a scalar double.
void double_contract | ( | SymmetricTensor< 2, 1 > & | tmp, | |
const SymmetricTensor< 4, 1 > & | t, | |||
const SymmetricTensor< 2, 1 > & | 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.
Contract the last two indices of src1
with the two indices src2
, creating a rank-2 tensor. This is the matrix-vector product analog operation between tensors of rank 4 and rank 2.
std::ostream & operator<< | ( | std::ostream & | out, | |
const SymmetricTensor< 2, dim > & | 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.
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.
Output operator for tensors. Print the elements consecutively, with a space in between, two spaces between rank 1 subtensors, three between rank 2 and so on.
Output operator for tensors of rank 1 and dimension 1. This is implemented specialized from the general template in order to avoid a compiler warning that the loop is empty.
<1,dim>
const unsigned int SymmetricTensor< rank, dim >::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.
const unsigned int SymmetricTensor< rank, dim >::n_independent_components [static] |
internal::SymmetricTensorAccessors::StorageType<rank,dim>:: n_independent_components
An integer denoting the number of independent components that fully describe a symmetric tensor. In space dimensions, this number equals
for symmetric tensors of rank 2.
base_tensor_type SymmetricTensor< rank, dim >::data [private] |
The place where we store the data of the tensor.