OpenWalnut  1.5.0dev
Public Member Functions | List of all members
WTensorSym< order, dim, Data_T > Class Template Reference

Implements a symmetric tensor that has the same number of components in every direction. More...

#include <WTensorSym.h>

+ Inheritance diagram for WTensorSym< order, dim, Data_T >:
+ Collaboration diagram for WTensorSym< order, dim, Data_T >:

Public Member Functions

 WTensorSym ()
 Default constructor of the symmetric tensor. More...
 
 WTensorSym (const WValue< Data_T > &data)
 Constructs and initializes the symmetrical Tensor with a WValue. More...
 
 WTensorSym (const boost::array< Data_T, WTensorBaseSym< order, dim, Data_T >::dataSize > &data)
 Constructs and initializes the symmetrical Tensor with a boost array. More...
 
Data_T evaluateSphericalFunction (WValue< Data_T > const &gradient) const
 Evaluate - for a given gradient - the spherical function represented by this symmetric tensor. More...
 
Data_T evaluateSphericalFunction (WMatrixFixed< Data_T, 3, 1 > const &gradient) const
 Evaluate - for a given gradient - the spherical function represented by this symmetric tensor. More...
 

Detailed Description

template<std::size_t order, std::size_t dim, typename Data_T = double>
class WTensorSym< order, dim, Data_T >

Implements a symmetric tensor that has the same number of components in every direction.

A symmetric tensor has the same value for every permutation of the indices.

For example, t(i,j) = t(j,i) for a tensor of order 2, and t(i,j,k) = t(j,i,k) = t(i,k,j) = t(j,k,i) = t(k,i,j) = t(k,j,i) for a tensor of order 3.

Template Parameters
orderThe order of the tensor.
dimThe dimension of the tensor, i.e. the number of components in each direction.
Data_TThe datatype of the components, double by default.
Note
The dimension may never be 0.
The type Data_T may not throw exceptions on construction, destruction or during any assignment operator.

Access to specific elements of the tensor can be achieved in 2 ways:

Note
The datatype of the array or std::vector can be any type castable to std::size_t.
There is no bounds checking for the array version of operator [].
Operator () is not supported for orders larger than 6.

This class optimizes memory usage. For example, for a symmetric tensor of order 2 and dimension 3, only 6 values (instead of 9) need to be stored. However, there is additional memory overhead per class (i.e. per allocation of the template parameters), which is of constant size and thus does not depend on the number of instances.

Usage and operators are the same as with WTensor. Note that changes to an element t(i,j,k,...) also change every element whose indices are a permutation of i,j,k... .

See also
WTensor

Definition at line 72 of file WTensorSym.h.

Constructor & Destructor Documentation

◆ WTensorSym() [1/3]

template<std::size_t order, std::size_t dim, typename Data_T >
WTensorSym< order, dim, Data_T >::WTensorSym

Default constructor of the symmetric tensor.

Definition at line 134 of file WTensorSym.h.

◆ WTensorSym() [2/3]

template<std::size_t order, std::size_t dim, typename Data_T >
WTensorSym< order, dim, Data_T >::WTensorSym ( const WValue< Data_T > &  data)
explicit

Constructs and initializes the symmetrical Tensor with a WValue.

Note
The same ordering as for the data member is required.
Parameters
dataThe components in same ordering as for the data member m_data is required, (
See also
m_data).

Definition at line 140 of file WTensorSym.h.

◆ WTensorSym() [3/3]

template<std::size_t order, std::size_t dim, typename Data_T >
WTensorSym< order, dim, Data_T >::WTensorSym ( const boost::array< Data_T, WTensorBaseSym< order, dim, Data_T >::dataSize > &  data)
explicit

Constructs and initializes the symmetrical Tensor with a boost array.

Note
The same ordering as for the data member is required.
Parameters
dataThe components in same ordering as for the data member m_data is required, (
See also
m_data).

Definition at line 146 of file WTensorSym.h.

Member Function Documentation

◆ evaluateSphericalFunction() [1/2]

template<std::size_t order, std::size_t dim, typename Data_T >
Data_T WTensorSym< order, dim, Data_T >::evaluateSphericalFunction ( WMatrixFixed< Data_T, 3, 1 > const &  gradient) const

Evaluate - for a given gradient - the spherical function represented by this symmetric tensor.

Template Parameters
Thetype that stores the gradient, must implement operator [].
Parameters
gradientThe normalized vector that represents the gradient direction.
Note
If the gradient is not normalized, the result is undefined.

Thanks to CHeine for the idea for this algorithm.

Returns
The function value on the sphere for this tensor and the given gradient.

Definition at line 160 of file WTensorSym.h.

References WRecursiveTensorEvaluation< Data_T, k, n, N, m >::evaluate().

+ Here is the call graph for this function:

◆ evaluateSphericalFunction() [2/2]

template<std::size_t order, std::size_t dim, typename Data_T >
Data_T WTensorSym< order, dim, Data_T >::evaluateSphericalFunction ( WValue< Data_T > const &  gradient) const

Evaluate - for a given gradient - the spherical function represented by this symmetric tensor.

Template Parameters
Thetype that stores the gradient, must implement operator [].
Parameters
gradientThe normalized vector that represents the gradient direction.
Note
If the gradient is not normalized, the result is undefined.

Thanks to CHeine for the idea for this algorithm.

Returns
The function value on the sphere for this tensor and the given gradient.

Definition at line 152 of file WTensorSym.h.

References WRecursiveTensorEvaluation< Data_T, k, n, N, m >::evaluate().

Referenced by WTensorSymTest::testEvaluateSphericalFunction().

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

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