Discontinuous Galerkin Library
#include "dg/algorithm.h"
Lowlevel helper functions and classes
Collaboration diagram for Lowlevel helper functions and classes:

Classes

struct  dg::ClonePtr< Cloneable >
 Manager class that invokes the clone() method on the managed ptr when copied. More...
 
struct  dg::Buffer< T >
 a manager class that invokes the copy constructor on the managed ptr when copied (deep copy) More...
 

Functions

template<class Matrix >
Matrix dg::transpose (const Matrix &src)
 Generic matrix transpose method. More...
 
template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx_symm (int n, int N, real_type h, bc bcx)
 Create and assemble a host Matrix for the centered 1d single derivative. More...
 
template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx_plus (int n, int N, real_type h, bc bcx)
 Create and assemble a host Matrix for the forward 1d single derivative. More...
 
template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx_minus (int n, int N, real_type h, bc bcx)
 Create and assemble a host Matrix for the backward 1d single derivative. More...
 
template<class real_type >
EllSparseBlockMat< real_type > dg::create::jump (int n, int N, real_type h, bc bcx)
 Create and assemble a host Matrix for the jump terms in 1d. More...
 
template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx_normed (int n, int N, real_type h, bc bcx, direction dir)
 Create and assemble a host Matrix for normed derivative in 1d. More...
 
template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx (const RealGridX1d< real_type > &g, bc bcx, direction dir=centered)
 Create and assemble a host Matrix for the derivative in 1d. More...
 
template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx (const RealGridX1d< real_type > &g, direction dir=centered)
 Create and assemble a host Matrix for the derivative in 1d. More...
 
template<class real_type >
EllSparseBlockMat< real_type > dg::create::jump (const RealGridX1d< real_type > &g, bc bcx)
 Create and assemble a host Matrix for the jump in 1d. More...
 
template<class real_type >
EllSparseBlockMat< real_type > dg::create::jump (const RealGridX1d< real_type > &g)
 Create and assemble a host Matrix for the jump in 1d. More...
 
template<class real_type >
Operator< real_type > dg::create::delta (unsigned n)
 Create the unit matrix. More...
 
template<class real_type >
Operator< real_type > dg::create::pipj (unsigned n)
 Create the S-matrix. More...
 
template<class real_type >
Operator< real_type > dg::create::pipj_inv (unsigned n)
 Create the T-matrix. More...
 
template<class real_type >
Operator< real_type > dg::create::pidxpj (unsigned n)
 Create the D-matrix. More...
 
template<class real_type >
Operator< real_type > dg::create::rirj (unsigned n)
 Create the R-matrix. More...
 
template<class real_type >
Operator< real_type > dg::create::rilj (unsigned n)
 Create the RL-matrix. More...
 
template<class real_type >
Operator< real_type > dg::create::lirj (unsigned n)
 Create the LR-matrix. More...
 
template<class real_type >
Operator< real_type > dg::create::lilj (unsigned n)
 Create the L-matrix. More...
 
template<class real_type >
Operator< real_type > dg::create::ninj (unsigned n)
 Create the N-matrix. More...
 
template<class real_type >
Operator< real_type > dg::create::weights (const DLT< real_type > &dlt)
 Construct a diagonal operator with weights. More...
 
template<class real_type >
Operator< real_type > dg::create::inv_weights (const DLT< real_type > &dlt)
 Construct a diagonal operator with inverse weights. More...
 
template<class T >
Operator< T > dg::tensorproduct (const Operator< T > &op1, const Operator< T > &op2)
 Form the tensor product between two operators. More...
 
template<class T >
cusp::coo_matrix< int, T, cusp::host_memory > dg::tensorproduct (unsigned N, const Operator< T > &op)
 Tensor product between Identity matrix and an operator. More...
 
template<class T >
cusp::coo_matrix< int, T, cusp::host_memory > dg::sandwich (const Operator< T > &left, const cusp::coo_matrix< int, T, cusp::host_memory > &m, const Operator< T > &right)
 Multiply 1d matrices by diagonal block matrices from left and right. More...
 
template<class T >
cusp::csr_matrix< int, T, cusp::host_memory > dg::tensorproduct (const cusp::csr_matrix< int, T, cusp::host_memory > &lhs, const cusp::csr_matrix< int, T, cusp::host_memory > &rhs)
 \( L\otimes R\) Form the tensor (Kronecker) product between two matrices More...
 

Detailed Description

Function Documentation

◆ delta()

template<class real_type >
Operator< real_type > dg::create::delta ( unsigned  n)

Create the unit matrix.

Parameters
n# of polynomial coefficients
Returns
Operator

◆ dx() [1/2]

template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx ( const RealGridX1d< real_type > &  g,
bc  bcx,
direction  dir = centered 
)

Create and assemble a host Matrix for the derivative in 1d.

Parameters
g1D grid with X-point topology
bcxboundary condition
dirThe direction of the first derivative
Returns
Host Matrix

◆ dx() [2/2]

template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx ( const RealGridX1d< real_type > &  g,
direction  dir = centered 
)

Create and assemble a host Matrix for the derivative in 1d.

Take the boundary condition from the grid

Parameters
g1D grid with X-point topology
dirThe direction of the first derivative
Returns
Host Matrix

◆ dx_minus()

template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx_minus ( int  n,
int  N,
real_type  h,
bc  bcx 
)

Create and assemble a host Matrix for the backward 1d single derivative.

Parameters
nNumber of Legendre nodes per cell
NVector size ( number of cells)
hcell size ( used to compute normalisation)
bcxboundary condition
Returns
Host Matrix

◆ dx_normed()

template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx_normed ( int  n,
int  N,
real_type  h,
bc  bcx,
direction  dir 
)

Create and assemble a host Matrix for normed derivative in 1d.

Parameters
nNumber of Legendre nodes per cell
NVector size ( number of cells)
hcell size ( used to compute normalisation)
bcxboundary condition
dirThe direction of the first derivative
Returns
Host Matrix

◆ dx_plus()

template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx_plus ( int  n,
int  N,
real_type  h,
bc  bcx 
)

Create and assemble a host Matrix for the forward 1d single derivative.

Parameters
nNumber of Legendre nodes per cell
NVector size ( number of cells)
hcell size ( used to compute normalisation)
bcxboundary condition
Returns
Host Matrix

◆ dx_symm()

template<class real_type >
EllSparseBlockMat< real_type > dg::create::dx_symm ( int  n,
int  N,
real_type  h,
bc  bcx 
)

Create and assemble a host Matrix for the centered 1d single derivative.

The matrix isn't symmetric due to the normalisation T.

Parameters
nNumber of Legendre nodes per cell
NVector size ( number of cells)
hcell size (used to compute normalisation)
bcxboundary condition
Returns
Host Matrix

◆ inv_weights()

template<class real_type >
Operator< real_type > dg::create::inv_weights ( const DLT< real_type > &  dlt)

Construct a diagonal operator with inverse weights.

Parameters
dlt
Returns
new operator

◆ jump() [1/3]

template<class real_type >
EllSparseBlockMat< real_type > dg::create::jump ( const RealGridX1d< real_type > &  g)

Create and assemble a host Matrix for the jump in 1d.

Take the boundary condition from the grid

Parameters
g1D grid with X-point topology
Returns
Host Matrix

◆ jump() [2/3]

template<class real_type >
EllSparseBlockMat< real_type > dg::create::jump ( const RealGridX1d< real_type > &  g,
bc  bcx 
)

Create and assemble a host Matrix for the jump in 1d.

Parameters
g1D grid with X-point topology
bcxboundary condition
Returns
Host Matrix

◆ jump() [3/3]

template<class real_type >
EllSparseBlockMat< real_type > dg::create::jump ( int  n,
int  N,
real_type  h,
bc  bcx 
)

Create and assemble a host Matrix for the jump terms in 1d.

Parameters
nNumber of Legendre nodes per cell
NVector size ( number of cells)
hcell size ( used to compute normalisation)
bcxboundary condition
Returns
Host Matrix

◆ lilj()

template<class real_type >
Operator< real_type > dg::create::lilj ( unsigned  n)

Create the L-matrix.

Parameters
n# of polynomial coefficients
Returns
Operator

◆ lirj()

template<class real_type >
Operator< real_type > dg::create::lirj ( unsigned  n)

Create the LR-matrix.

Parameters
n# of polynomial coefficients
Returns
Operator

◆ ninj()

template<class real_type >
Operator< real_type > dg::create::ninj ( unsigned  n)

Create the N-matrix.

Parameters
n# of polynomial coefficients
Returns
Operator

◆ pidxpj()

template<class real_type >
Operator< real_type > dg::create::pidxpj ( unsigned  n)

Create the D-matrix.

Parameters
n# of polynomial coefficients
Returns
Operator

◆ pipj()

template<class real_type >
Operator< real_type > dg::create::pipj ( unsigned  n)

Create the S-matrix.

Parameters
n# of polynomial coefficients
Returns
Operator

◆ pipj_inv()

template<class real_type >
Operator< real_type > dg::create::pipj_inv ( unsigned  n)

Create the T-matrix.

Parameters
n# of polynomial coefficients
Returns
Operator

◆ rilj()

template<class real_type >
Operator< real_type > dg::create::rilj ( unsigned  n)

Create the RL-matrix.

Parameters
n# of polynomial coefficients
Returns
Operator

◆ rirj()

template<class real_type >
Operator< real_type > dg::create::rirj ( unsigned  n)

Create the R-matrix.

Parameters
n# of polynomial coefficients
Returns
Operator

◆ sandwich()

template<class T >
cusp::coo_matrix< int, T, cusp::host_memory > dg::sandwich ( const Operator< T > &  left,
const cusp::coo_matrix< int, T, cusp::host_memory > &  m,
const Operator< T > &  right 
)

Multiply 1d matrices by diagonal block matrices from left and right.

computes (1xleft)m(1xright)

Template Parameters
Tvalue type
Parameters
leftThe left hand side
mThe matrix
rightThe right hand side
Returns
A newly allocated cusp matrix

◆ tensorproduct() [1/3]

template<class T >
cusp::csr_matrix< int, T, cusp::host_memory > dg::tensorproduct ( const cusp::csr_matrix< int, T, cusp::host_memory > &  lhs,
const cusp::csr_matrix< int, T, cusp::host_memory > &  rhs 
)

\( L\otimes R\) Form the tensor (Kronecker) product between two matrices

The Kronecker product is formed by the triplets \(I = k n_r+l\), \( J = i N_r +j \), \( M_{IJ} = L_{ki}R_{lj}\)

Note
This function is "order preserving" in the sense that the order of row and column entries of lhs and rhs are preserved in the output. This is important for stencil computations.
Template Parameters
Tvalue type
Parameters
lhsThe left hand side matrix (duplicate entries lead to duplicate entries in result)
rhsThe right hand side matrix (duplicate entries lead to duplicate entries in result)
Returns
newly allocated cusp matrix containing the tensor product
Note
use cusp::add and cusp::multiply to add and multiply matrices.

◆ tensorproduct() [2/3]

template<class T >
Operator< T > dg::tensorproduct ( const Operator< T > &  op1,
const Operator< T > &  op2 
)

Form the tensor product between two operators.

Computes C_{ijkl} = op1_{ij}op2_{kl}

Template Parameters
TThe value type
Parameters
op1The left hand side
op2The right hand side
Returns
The tensor product

◆ tensorproduct() [3/3]

template<class T >
cusp::coo_matrix< int, T, cusp::host_memory > dg::tensorproduct ( unsigned  N,
const Operator< T > &  op 
)

Tensor product between Identity matrix and an operator.

\[ M = \begin{pmatrix} op & & & & & \\ & op & & & & \\ & & op & & & \\ & & & op & & \\ & & &...& & \end{pmatrix} \]

Can be used to create tensors that operate on each dg-vector entry

Template Parameters
Tvalue type
Parameters
NSize of the identity (=number of times op is repeated in the matrix)
opThe Operator
Returns
A newly allocated cusp matrix (of size N*op.size() )
See also
fast_transform

◆ transpose()

template<class Matrix >
Matrix dg::transpose ( const Matrix &  src)

Generic matrix transpose method.

Template Parameters
Matrixone of
  • any cusp matrix
  • any MPIDistMatrix with a cusp matrix as template parameter
Parameters
srcthe marix to transpose
Returns
the matrix that acts as the transpose of src

◆ weights()

template<class real_type >
Operator< real_type > dg::create::weights ( const DLT< real_type > &  dlt)

Construct a diagonal operator with weights.

Parameters
dlt
Returns
new operator