Discontinuous Galerkin Library
#include "dg/algorithm.h"

\( v^i = T^{ij} w_j\) More...

Collaboration diagram for Tensor-Vector operations:

Functions

template<class ContainerType0 , class ContainerType1 >
void dg::tensor::scal (SparseTensor< ContainerType0 > &t, const ContainerType1 &mu)
 \( t^{ij} = \mu t^{ij} \ \forall i,j \) More...
 
template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerTypeM , class ContainerType3 , class ContainerType4 >
void dg::tensor::multiply2d (const ContainerTypeL &lambda, const SparseTensor< ContainerType0 > &t, const ContainerType1 &in0, const ContainerType2 &in1, const ContainerTypeM &mu, ContainerType3 &out0, ContainerType4 &out1)
 \( w^i = \sum_{i=0}^1 \lambda t^{ij}v_j + \mu w^i \text{ for } i\in \{0,1\}\) More...
 
template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerTypeM , class ContainerType4 , class ContainerType5 , class ContainerType6 >
void dg::tensor::multiply3d (const ContainerTypeL &lambda, const SparseTensor< ContainerType0 > &t, const ContainerType1 &in0, const ContainerType2 &in1, const ContainerType3 &in2, const ContainerTypeM &mu, ContainerType4 &out0, ContainerType5 &out1, ContainerType6 &out2)
 \( w^i = \sum_{i=0}^2\lambda t^{ij}v_j + \mu w^i \text{ for } i\in \{0,1,2\}\) More...
 
template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerTypeM , class ContainerType3 , class ContainerType4 >
void dg::tensor::inv_multiply2d (const ContainerTypeL &lambda, const SparseTensor< ContainerType0 > &t, const ContainerType1 &in0, const ContainerType2 &in1, const ContainerTypeM &mu, ContainerType3 &out0, ContainerType4 &out1)
 \( v_j = \sum_{i=0}^1\lambda (t^{-1})_{ji}w^i + \mu v_j \text{ for } i\in \{0,1\}\) More...
 
template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerTypeM , class ContainerType4 , class ContainerType5 , class ContainerType6 >
void dg::tensor::inv_multiply3d (const ContainerTypeL &lambda, const SparseTensor< ContainerType0 > &t, const ContainerType1 &in0, const ContainerType2 &in1, const ContainerType3 &in2, const ContainerTypeM &mu, ContainerType4 &out0, ContainerType5 &out1, ContainerType6 &out2)
 \( v_j = \sum_{i=0}^2\lambda(t^{-1})_{ji}w^i + \mu v_j \text{ for } i\in \{0,1,2\}\)i More...
 
template<class ContainerType >
ContainerType dg::tensor::determinant2d (const SparseTensor< ContainerType > &t)
 \(\det_{2d}( t)\) More...
 
template<class ContainerType >
ContainerType dg::tensor::determinant (const SparseTensor< ContainerType > &t)
 \(\det( t)\) More...
 
template<class ContainerType >
ContainerType dg::tensor::volume2d (const SparseTensor< ContainerType > &t)
 \( \sqrt{\det_{2d}(t)}^{-1}\) More...
 
template<class ContainerType >
ContainerType dg::tensor::volume (const SparseTensor< ContainerType > &t)
 \( \sqrt{\det(t)}^{-1}\) More...
 
template<class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerType4 >
void dg::tensor::multiply2d (const SparseTensor< ContainerType0 > &t, const ContainerType1 &in0, const ContainerType2 &in1, ContainerType3 &out0, ContainerType4 &out1)
 \( w^i = \sum_{i=0}^1 t^{ij}v_j \text{ for } i\in \{0,1\}\) More...
 
template<class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerType4 , class ContainerType5 , class ContainerType6 >
void dg::tensor::multiply3d (const SparseTensor< ContainerType0 > &t, const ContainerType1 &in0, const ContainerType2 &in1, const ContainerType3 &in2, ContainerType4 &out0, ContainerType5 &out1, ContainerType6 &out2)
 \( w^i = \sum_{i=0}^2 t^{ij}v_j \text{ for } i\in \{0,1,2\}\) More...
 
template<class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerType4 >
void dg::tensor::inv_multiply2d (const SparseTensor< ContainerType0 > &t, const ContainerType1 &in0, const ContainerType2 &in1, ContainerType3 &out0, ContainerType4 &out1)
 \( v_j = \sum_{i=0}^1(t^{-1})_{ji}w^i \text{ for } i\in \{0,1\}\) More...
 
template<class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerType4 , class ContainerType5 , class ContainerType6 >
void dg::tensor::inv_multiply3d (const SparseTensor< ContainerType0 > &t, const ContainerType1 &in0, const ContainerType2 &in1, const ContainerType3 &in2, ContainerType4 &out0, ContainerType5 &out1, ContainerType6 &out2)
 \( v_j = \sum_{i=0}^2(t^{-1})_{ji}w^i \text{ for } i\in \{0,1,2\}\)i More...
 
template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerTypeM , class ContainerType4 , class ContainerType5 >
void dg::tensor::scalar_product2d (get_value_type< ContainerType0 > alpha, const ContainerTypeL &lambda, const ContainerType0 &v0, const ContainerType1 &v1, const SparseTensor< ContainerType2 > &t, const ContainerTypeM &mu, const ContainerType3 &w0, const ContainerType4 &w1, get_value_type< ContainerType0 > beta, ContainerType5 &y)
 \( y = \alpha \lambda\mu \sum_{i=0}^1 v_it^{ij}w_j + \beta y \text{ for } i\in \{0,1\}\) More...
 
template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerTypeM , class ContainerType4 , class ContainerType5 , class ContainerType6 , class ContainerType7 >
void dg::tensor::scalar_product3d (get_value_type< ContainerType0 > alpha, const ContainerTypeL &lambda, const ContainerType0 &v0, const ContainerType1 &v1, const ContainerType2 &v2, const SparseTensor< ContainerType3 > &t, const ContainerTypeM &mu, const ContainerType4 &w0, const ContainerType5 &w1, const ContainerType6 &w2, get_value_type< ContainerType0 > beta, ContainerType7 &y)
 \( y = \alpha \lambda\mu \sum_{i=0}^2 v_it^{ij}w_j + \beta y \text{ for } i\in \{0,1,2\}\) More...
 

Detailed Description

\( v^i = T^{ij} w_j\)

Although a tensor needs a topology to be well-defined mathematically, we do not need a grid to perform basic operations computationally. This is why the tensor operations can appear already in Level 1 of this library.

Function Documentation

◆ determinant()

template<class ContainerType >
ContainerType dg::tensor::determinant ( const SparseTensor< ContainerType > &  t)

\(\det( t)\)

Compute the determinant of a 3d tensor: \( \det(t) := t_{00}t_{11}t_{22} + t_{01}t_{12}t_{20} + \ldots - t_{22}t_{10}t_{01}\).

Parameters
tthe input tensor
Returns
the determinant of t
Note
This function is just a shortcut for a call to dg::blas1::evaluate with dg::TensorDeterminant3d
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ determinant2d()

template<class ContainerType >
ContainerType dg::tensor::determinant2d ( const SparseTensor< ContainerType > &  t)

\(\det_{2d}( t)\)

Compute the minor determinant of a tensor \( \det_{2d}(t) := t_{00}t_{01}-t_{10}t_{11}\).

Parameters
tthe input tensor
Returns
the upper left minor determinant of t
Note
This function is just a shortcut for a call to dg::blas1::evaluate with dg::TensorDeterminant2d
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ inv_multiply2d() [1/2]

template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerTypeM , class ContainerType3 , class ContainerType4 >
void dg::tensor::inv_multiply2d ( const ContainerTypeL &  lambda,
const SparseTensor< ContainerType0 > &  t,
const ContainerType1 &  in0,
const ContainerType2 &  in1,
const ContainerTypeM &  mu,
ContainerType3 &  out0,
ContainerType4 &  out1 
)

\( v_j = \sum_{i=0}^1\lambda (t^{-1})_{ji}w^i + \mu v_j \text{ for } i\in \{0,1\}\)

Multiply the inverse of a tensor t with a vector in 2d. Ignore the 3rd dimension in t. The inverse of t is computed inplace.

Parameters
tinput Tensor
lambda(input) (may be a vector or an actual number like 0 or 1)
in0(input) first component of w (may alias out0)
in1(input) second component of w (may alias out1)
mu(input) (may be a vector or an actual number like 0 or 1)
out0(output) first component of v (may alias in0)
out1(output) second component of v (may alias in1)
Note
This function is just a shortcut for a call to dg::blas1::subroutine with dg::InverseTensorMultiply2d
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ inv_multiply2d() [2/2]

template<class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerType4 >
void dg::tensor::inv_multiply2d ( const SparseTensor< ContainerType0 > &  t,
const ContainerType1 &  in0,
const ContainerType2 &  in1,
ContainerType3 &  out0,
ContainerType4 &  out1 
)

\( v_j = \sum_{i=0}^1(t^{-1})_{ji}w^i \text{ for } i\in \{0,1\}\)

Multiply the inverse of a tensor t with a vector in 2d. Ignore the 3rd dimension in t. The inverse of t is computed inplace.

Parameters
tinput Tensor
in0(input) first component of w (may alias out0)
in1(input) second component of w (may alias out1)
out0(output) first component of v (may alias in0)
out1(output) second component of v (may alias in1)
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ inv_multiply3d() [1/2]

template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerTypeM , class ContainerType4 , class ContainerType5 , class ContainerType6 >
void dg::tensor::inv_multiply3d ( const ContainerTypeL &  lambda,
const SparseTensor< ContainerType0 > &  t,
const ContainerType1 &  in0,
const ContainerType2 &  in1,
const ContainerType3 &  in2,
const ContainerTypeM &  mu,
ContainerType4 &  out0,
ContainerType5 &  out1,
ContainerType6 &  out2 
)

\( v_j = \sum_{i=0}^2\lambda(t^{-1})_{ji}w^i + \mu v_j \text{ for } i\in \{0,1,2\}\)i

Multiply the inverse of a tensor with a vector in 3d. The inverse of t is computed inplace.

Parameters
tinput Tensor
lambda(input) (may be a vector or an actual number like 0 or 1)
in0(input) first component of w (may alias out0)
in1(input) second component of w (may alias out1)
in2(input) third component of w (may alias out2)
mu(input) (may be a vector or an actual number like 0 or 1)
out0(output) first component of v (may alias in0)
out1(output) second component of v (may alias in1)
out2(output) third component of v (may alias in2)
Note
This function is just a shortcut for a call to dg::blas1::subroutine with dg::InverseTensorMultiply3d
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ inv_multiply3d() [2/2]

template<class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerType4 , class ContainerType5 , class ContainerType6 >
void dg::tensor::inv_multiply3d ( const SparseTensor< ContainerType0 > &  t,
const ContainerType1 &  in0,
const ContainerType2 &  in1,
const ContainerType3 &  in2,
ContainerType4 &  out0,
ContainerType5 &  out1,
ContainerType6 &  out2 
)

\( v_j = \sum_{i=0}^2(t^{-1})_{ji}w^i \text{ for } i\in \{0,1,2\}\)i

Multiply the inverse of a tensor with a vector in 3d. The inverse of t is computed inplace.

Parameters
tinput Tensor
in0(input) first component of w (may alias out0)
in1(input) second component of w (may alias out1)
in2(input) third component of w (may alias out2)
out0(output) first component of v (may alias in0)
out1(output) second component of v (may alias in1)
out2(output) third component of v (may alias in2)
Note
This function is just a shortcut for a call to dg::blas1::subroutine with the appropriate functor
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ multiply2d() [1/2]

template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerTypeM , class ContainerType3 , class ContainerType4 >
void dg::tensor::multiply2d ( const ContainerTypeL &  lambda,
const SparseTensor< ContainerType0 > &  t,
const ContainerType1 &  in0,
const ContainerType2 &  in1,
const ContainerTypeM &  mu,
ContainerType3 &  out0,
ContainerType4 &  out1 
)

\( w^i = \sum_{i=0}^1 \lambda t^{ij}v_j + \mu w^i \text{ for } i\in \{0,1\}\)

Multiply a tensor with a vector in 2d. Ignore the 3rd dimension in t.

Parameters
tinput Tensor
lambda(input)
in0(input) first component of v (may alias out0)
in1(input) second component of v (may alias out1)
mu(input)
out0(output) first component of w (may alias in0)
out1(output) second component of w (may alias in1)
Note
This function is just a shortcut for a call to dg::blas1::subroutine with dg::TensorMultiply2d
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ multiply2d() [2/2]

template<class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerType4 >
void dg::tensor::multiply2d ( const SparseTensor< ContainerType0 > &  t,
const ContainerType1 &  in0,
const ContainerType2 &  in1,
ContainerType3 &  out0,
ContainerType4 &  out1 
)

\( w^i = \sum_{i=0}^1 t^{ij}v_j \text{ for } i\in \{0,1\}\)

Multiply a tensor with a vector in 2d. Ignore the 3rd dimension in t.

Parameters
tinput Tensor
in0(input) first component of v (may alias out0)
in1(input) second component of v (may alias out1)
out0(output) first component of w (may alias in0)
out1(output) second component of w (may alias in1)
Note
This function is just a shortcut for a call to dg::blas1::subroutine with the appropriate functor
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ multiply3d() [1/2]

template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerTypeM , class ContainerType4 , class ContainerType5 , class ContainerType6 >
void dg::tensor::multiply3d ( const ContainerTypeL &  lambda,
const SparseTensor< ContainerType0 > &  t,
const ContainerType1 &  in0,
const ContainerType2 &  in1,
const ContainerType3 &  in2,
const ContainerTypeM &  mu,
ContainerType4 &  out0,
ContainerType5 &  out1,
ContainerType6 &  out2 
)

\( w^i = \sum_{i=0}^2\lambda t^{ij}v_j + \mu w^i \text{ for } i\in \{0,1,2\}\)

Multiply a tensor with a vector in 3d.

Parameters
tinput Tensor
lambda(input) (may be a vector or an actual number like 0 or 1)
in0(input) first component of v (may alias out0)
in1(input) second component of v (may alias out1)
in2(input) third component of v (may alias out2)
mu(input) (may be a vector or an actual number like 0 or 1)
out0(output) first component of w (may alias in0)
out1(output) second component of w (may alias in1)
out2(output) third component of w (may alias in2)
Note
This function is just a shortcut for a call to dg::blas1::subroutine with dg::TensorMultiply3d
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ multiply3d() [2/2]

template<class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerType4 , class ContainerType5 , class ContainerType6 >
void dg::tensor::multiply3d ( const SparseTensor< ContainerType0 > &  t,
const ContainerType1 &  in0,
const ContainerType2 &  in1,
const ContainerType3 &  in2,
ContainerType4 &  out0,
ContainerType5 &  out1,
ContainerType6 &  out2 
)

\( w^i = \sum_{i=0}^2 t^{ij}v_j \text{ for } i\in \{0,1,2\}\)

Multiply a tensor with a vector in 3d.

Parameters
tinput Tensor
in0(input) first component of v (may alias out0)
in1(input) second component of v (may alias out1)
in2(input) third component of v (may alias out2)
out0(output) first component of w (may alias in0)
out1(output) second component of w (may alias in1)
out2(output) third component of w (may alias in2)
Note
This function is just a shortcut for a call to dg::blas1::subroutine with the appropriate functor
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ scal()

template<class ContainerType0 , class ContainerType1 >
void dg::tensor::scal ( SparseTensor< ContainerType0 > &  t,
const ContainerType1 &  mu 
)

\( t^{ij} = \mu t^{ij} \ \forall i,j \)

Scale tensor with a Scalar or a Vector

Parameters
tinput (contains result on output)
muall elements in t are scaled with mu
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ scalar_product2d()

template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerTypeM , class ContainerType4 , class ContainerType5 >
void dg::tensor::scalar_product2d ( get_value_type< ContainerType0 >  alpha,
const ContainerTypeL &  lambda,
const ContainerType0 &  v0,
const ContainerType1 &  v1,
const SparseTensor< ContainerType2 > &  t,
const ContainerTypeM &  mu,
const ContainerType3 &  w0,
const ContainerType4 &  w1,
get_value_type< ContainerType0 >  beta,
ContainerType5 &  y 
)

\( y = \alpha \lambda\mu \sum_{i=0}^1 v_it^{ij}w_j + \beta y \text{ for } i\in \{0,1\}\)

Ignore the 3rd dimension in t.

Parameters
alphascalar input prefactor
lambdasecond input prefactor
v0(input) first component of v (may alias w0)
v1(input) second component of v (may alias w1)
tinput Tensor
muthird input prefactor
w0(input) first component of w (may alias v0)
w1(input) second component of w (may alias v1)
betascalar output prefactor
y(output)
Note
This function is just a shortcut for a call to dg::blas1::evaluate with dg::TensorDot2d
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ scalar_product3d()

template<class ContainerTypeL , class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 , class ContainerTypeM , class ContainerType4 , class ContainerType5 , class ContainerType6 , class ContainerType7 >
void dg::tensor::scalar_product3d ( get_value_type< ContainerType0 >  alpha,
const ContainerTypeL &  lambda,
const ContainerType0 &  v0,
const ContainerType1 &  v1,
const ContainerType2 &  v2,
const SparseTensor< ContainerType3 > &  t,
const ContainerTypeM &  mu,
const ContainerType4 &  w0,
const ContainerType5 &  w1,
const ContainerType6 &  w2,
get_value_type< ContainerType0 >  beta,
ContainerType7 &  y 
)

\( y = \alpha \lambda\mu \sum_{i=0}^2 v_it^{ij}w_j + \beta y \text{ for } i\in \{0,1,2\}\)

Parameters
alphascalar input prefactor
lambdasecond input prefactor
v0(input) first component of v (may alias w0)
v1(input) second component of v (may alias w1)
v2(input) third component of v (may alias w1)
tinput Tensor
muthird input prefactor
w0(input) first component of w (may alias v0)
w1(input) second component of w (may alias v1)
w2(input) third component of w (may alias v1)
betascalar output prefactor
y(output)
Note
This function is just a shortcut for a call to dg::blas1::evaluate with dg::TensorDot3d
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ volume()

template<class ContainerType >
ContainerType dg::tensor::volume ( const SparseTensor< ContainerType > &  t)

\( \sqrt{\det(t)}^{-1}\)

Compute the sqrt of the inverse determinant of a 3d tensor. This is a convenience function that is equivalent to

ContainerType vol=determinant(t);
void transform(const ContainerType1 &x, ContainerType &y, UnaryOp op)
Definition: blas1.h:524
ContainerType determinant(const SparseTensor< ContainerType > &t)
Definition: multiply.h:349
Definition: functors.h:124
Note
The function is called volume because when you apply it to the inverse metric tensor of our grids then you obtain the volume

\[ \sqrt{g} = 1 / \sqrt{ \det( g^{-1})}\]

ContainerType vol = dg::tensor::volume( g.metric());
ContainerType volume(const SparseTensor< ContainerType > &t)
Definition: multiply.h:406
Parameters
tthe input tensor
Returns
the inverse square root of the determinant of t
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

◆ volume2d()

template<class ContainerType >
ContainerType dg::tensor::volume2d ( const SparseTensor< ContainerType > &  t)

\( \sqrt{\det_{2d}(t)}^{-1}\)

Compute the sqrt of the inverse minor determinant of a tensor. This is a convenience function that is equivalent to

ContainerType vol=determinant2d(t);
ContainerType determinant2d(const SparseTensor< ContainerType > &t)
Definition: multiply.h:329
Note
The function is called volume because when you apply it to the inverse metric tensor of our grids then you obtain the volume

\[ \sqrt{g} = 1 / \sqrt{ \det( g^{-1})}\]

ContainerType vol = volume2d( g.metric());
ContainerType volume2d(const SparseTensor< ContainerType > &t)
Definition: multiply.h:379
Parameters
tthe input tensor
Returns
the inverse square root of the determinant of t
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system