1#ifndef _DG_XSPACELIB_CUH_
2#define _DG_XSPACELIB_CUH_
4#include <thrust/host_vector.h>
6#include <cusp/coo_matrix.h>
41 const cusp::csr_matrix< int, T, cusp::host_memory>& lhs,
42 const cusp::csr_matrix< int, T, cusp::host_memory>& rhs)
45 int num_rows = lhs.num_rows*rhs.num_rows;
46 int num_cols = lhs.num_cols*rhs.num_cols;
47 int num_entries = lhs.num_entries* rhs.num_entries;
49 cusp::csr_matrix<int, T, cusp::host_memory> A(num_rows, num_cols, num_entries);
53 for(
unsigned i=0; i<lhs.num_rows; i++)
54 for(
unsigned j=0; j<rhs.num_rows; j++)
56 int num_entries_in_row =
57 (lhs.row_offsets[i+1] - lhs.row_offsets[i])*
58 (rhs.row_offsets[j+1] - rhs.row_offsets[j]);
59 A.row_offsets[i*rhs.num_rows+j+1] =
60 A.row_offsets[i*rhs.num_rows+j] + num_entries_in_row;
61 for(
int k=lhs.row_offsets[i]; k<lhs.row_offsets[i+1]; k++)
62 for(
int l=rhs.row_offsets[j]; l<rhs.row_offsets[j+1]; l++)
64 A.column_indices[counter] =
65 lhs.column_indices[k]*rhs.num_cols + rhs.column_indices[l];
66 A.values[counter] = lhs.values[k]*rhs.values[l];
86template<
class real_type>
98template<
class real_type>
108template<
class real_type>
128template<
class real_type>
139template<
class real_type>
149template<
class real_type>
The discrete legendre trafo class.
@ backward
backward derivative (cell to the left and current cell)
Definition: enums.h:99
@ forward
forward derivative (cell to the right and current cell)
Definition: enums.h:98
dg::Operator< T > invert(const dg::Operator< T > &in)
Alias for dg::create::inverse. Compute inverse of square matrix.
Definition: operator.h:695
Operator< T > tensorproduct(const Operator< T > &op1, const Operator< T > &op2)
Form the tensor product between two operators.
Definition: operator_tensor.h:27
dg::IHMatrix_t< real_type > backscatter(const RealGrid1d< real_type > &g)
Create a matrix that interpolates values to an equidistant grid ready for visualisation.
Definition: xspacelib.h:87
dg::IHMatrix_t< real_type > inv_backscatter(const RealGrid1d< real_type > &g)
Create a matrix that transforms values from an equidistant grid back to a dg grid.
Definition: xspacelib.h:129
cusp::csr_matrix< int, real_type, cusp::host_memory > IHMatrix_t
Definition: typedefs.h:37
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
1D grid
Definition: grid.h:80
const DLT< real_type > & dlt() const
the discrete legendre transformation
Definition: grid.h:197
unsigned N() const
number of cells
Definition: grid.h:135
An abstract base class for two-dimensional grids.
Definition: grid.h:277
const RealGrid1d< real_type > & gy() const
The y-axis grid.
Definition: grid.h:379
const RealGrid1d< real_type > & gx() const
The x-axis grid.
Definition: grid.h:377
An abstract base class for three-dimensional grids.
Definition: grid.h:523
const RealGrid1d< real_type > & gz() const
The z-axis grid.
Definition: grid.h:664
const RealGrid1d< real_type > & gx() const
The x-axis grid.
Definition: grid.h:660
const RealGrid1d< real_type > & gy() const
The y-axis grid.
Definition: grid.h:662
Useful typedefs of commonly used types.