Discontinuous Galerkin Library
#include "dg/algorithm.h"
Loading...
Searching...
No Matches
dg::CooSparseBlockMat< real_type, Vector > Struct Template Reference

Coo Sparse Block Matrix format. More...

Public Member Functions

 CooSparseBlockMat ()=default
 default constructor does nothing
 
 CooSparseBlockMat (int num_block_rows, int num_block_cols, int n, int left_size, int right_size)
 Allocate storage.
 
template<class other_real_type , template< class > class Other_Vector>
 CooSparseBlockMat (const CooSparseBlockMat< other_real_type, Other_Vector > &src)
 
void add_value (int row, int col, const Vector< real_type > &element)
 Convenience function to assemble the matrix.
 
void add_value (int row, int col, int data)
 Convenience function to assemble the matrix.
 
int total_num_rows () const
 total number of rows is num_rows*n*left_size*right_size
 
int total_num_cols () const
 total number of columns is num_cols*n*left_size*right_size
 
template<class value_type >
void symv (SharedVectorTag, SerialTag, value_type alpha, const value_type **x, value_type beta, value_type *RESTRICT y) const
 Apply the matrix to a vector.
 
template<class value_type >
void symv (SharedVectorTag, CudaTag, value_type alpha, const value_type **x, value_type beta, value_type *y) const
 
void display (std::ostream &os=std::cout, bool show_data=false) const
 Display internal data to a stream.
 

Public Attributes

Vector< real_type > data
 The data array is of size n*n*num_different_blocks and contains the blocks.
 
Vector< int > cols_idx
 is of size num_entries and contains the column indices
 
Vector< int > rows_idx
 is of size num_entries and contains the row indices
 
Vector< int > data_idx
 is of size num_entries and contains indices into the data array
 
int num_rows
 number of rows
 
int num_cols
 number of columns (never actually used with pointer approach
 
int num_entries
 number of entries in the matrix
 
int n
 each block has size n*n
 
int left_size
 size of the left Kronecker delta
 
int right_size
 size of the right Kronecker delta (is e.g 1 for a x - derivative)
 

Friends

template<class other_real_type , template< class > class Other_Vector>
class CooSparseBlockMat
 

Detailed Description

template<class real_type, template< class > class Vector>
struct dg::CooSparseBlockMat< real_type, Vector >

Coo Sparse Block Matrix format.

The basis for this format is the well-known coordinate sparse matrix format. Instead of a values array we use an index array with indices into a data array that contains the actual blocks. This safes storage if the number of nonrecurrent blocks is small.

\[ M = \begin{pmatrix} A & & B& & & \\ & C & & & & \\ & & & & & \\ & A & & & B & C \end{pmatrix} \rightarrow \text{data}=(A,B,C)\quad \text{rows_idx} = ( 0,0,1,3,3,3) \quad\text{cols_idx} = (0,2,1,1,4,5) \]

where \(A,\ B,\ C,\ 0\) are \(n\times n\) block matrices. The matrix M in this example has num_rows=4, num_cols=6, num_entries=6.

The indices and blocks are those of a one-dimensional problem. When we want to apply the matrix to a multidimensional vector we can multiply it by Kronecker deltas of the form

\[ 1_\mathrm{left}\otimes M \otimes 1_\mathrm{right}\]

where \( 1\) are diagonal matrices of variable size and \( M\) is our one-dimensional matrix.

Note
This matrix type is used for the computation of boundary points in an mpi - distributed EllSparseBlockMat

Constructor & Destructor Documentation

◆ CooSparseBlockMat() [1/3]

template<class real_type , template< class > class Vector>
dg::CooSparseBlockMat< real_type, Vector >::CooSparseBlockMat ( )
default

default constructor does nothing

◆ CooSparseBlockMat() [2/3]

template<class real_type , template< class > class Vector>
dg::CooSparseBlockMat< real_type, Vector >::CooSparseBlockMat ( int num_block_rows,
int num_block_cols,
int n,
int left_size,
int right_size )
inline

Allocate storage.

Parameters
num_block_rowsnumber of rows. Each row contains blocks.
num_block_colsnumber of columns.
neach block is of size nxn
left_sizesize of the left_size Kronecker delta
right_sizesize of the right_size Kronecker delta

◆ CooSparseBlockMat() [3/3]

template<class real_type , template< class > class Vector>
template<class other_real_type , template< class > class Other_Vector>
dg::CooSparseBlockMat< real_type, Vector >::CooSparseBlockMat ( const CooSparseBlockMat< other_real_type, Other_Vector > & src)
inline

Member Function Documentation

◆ add_value() [1/2]

template<class real_type , template< class > class Vector>
void dg::CooSparseBlockMat< real_type, Vector >::add_value ( int row,
int col,
const Vector< real_type > & element )
inline

Convenience function to assemble the matrix.

appends the given matrix entry to the existing matrix

Parameters
rowblock row
colblock column
elementnew block

◆ add_value() [2/2]

template<class real_type , template< class > class Vector>
void dg::CooSparseBlockMat< real_type, Vector >::add_value ( int row,
int col,
int data )
inline

Convenience function to assemble the matrix.

Parameters
rowblock row
colblock column
datablock index into the data array

◆ display()

template<class real_type , template< class > class Vector>
void dg::CooSparseBlockMat< real_type, Vector >::display ( std::ostream & os = std::cout,
bool show_data = false ) const

Display internal data to a stream.

Parameters
osthe output stream
show_dataif true, displays the whole data vector

◆ symv() [1/2]

template<class real_type , template< class > class Vector>
template<class value_type >
void dg::CooSparseBlockMat< real_type, Vector >::symv ( SharedVectorTag ,
CudaTag ,
value_type alpha,
const value_type ** x,
value_type beta,
value_type * y ) const
inline

◆ symv() [2/2]

template<class real_type , template< class > class Vector>
template<class value_type >
void dg::CooSparseBlockMat< real_type, Vector >::symv ( SharedVectorTag ,
SerialTag ,
value_type alpha,
const value_type ** x,
value_type beta,
value_type *RESTRICT y ) const
inline

Apply the matrix to a vector.

Parameters
alphamultiplies input
xinput
betapremultiplies output (cannot be anything other than 1, the given value is ignored)
youtput may not alias input
Attention
beta == 1 (anything else is ignored)

◆ total_num_cols()

template<class real_type , template< class > class Vector>
int dg::CooSparseBlockMat< real_type, Vector >::total_num_cols ( ) const
inline

total number of columns is num_cols*n*left_size*right_size

◆ total_num_rows()

template<class real_type , template< class > class Vector>
int dg::CooSparseBlockMat< real_type, Vector >::total_num_rows ( ) const
inline

total number of rows is num_rows*n*left_size*right_size

Friends And Related Symbol Documentation

◆ CooSparseBlockMat

template<class real_type , template< class > class Vector>
template<class other_real_type , template< class > class Other_Vector>
friend class CooSparseBlockMat
friend

Member Data Documentation

◆ cols_idx

template<class real_type , template< class > class Vector>
Vector<int> dg::CooSparseBlockMat< real_type, Vector >::cols_idx

is of size num_entries and contains the column indices

◆ data

template<class real_type , template< class > class Vector>
Vector<real_type> dg::CooSparseBlockMat< real_type, Vector >::data

The data array is of size n*n*num_different_blocks and contains the blocks.

◆ data_idx

template<class real_type , template< class > class Vector>
Vector<int> dg::CooSparseBlockMat< real_type, Vector >::data_idx

is of size num_entries and contains indices into the data array

◆ left_size

template<class real_type , template< class > class Vector>
int dg::CooSparseBlockMat< real_type, Vector >::left_size

size of the left Kronecker delta

◆ n

template<class real_type , template< class > class Vector>
int dg::CooSparseBlockMat< real_type, Vector >::n

each block has size n*n

◆ num_cols

template<class real_type , template< class > class Vector>
int dg::CooSparseBlockMat< real_type, Vector >::num_cols

number of columns (never actually used with pointer approach

◆ num_entries

template<class real_type , template< class > class Vector>
int dg::CooSparseBlockMat< real_type, Vector >::num_entries

number of entries in the matrix

◆ num_rows

template<class real_type , template< class > class Vector>
int dg::CooSparseBlockMat< real_type, Vector >::num_rows

number of rows

◆ right_size

template<class real_type , template< class > class Vector>
int dg::CooSparseBlockMat< real_type, Vector >::right_size

size of the right Kronecker delta (is e.g 1 for a x - derivative)

◆ rows_idx

template<class real_type , template< class > class Vector>
Vector<int> dg::CooSparseBlockMat< real_type, Vector >::rows_idx

is of size num_entries and contains the row indices


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