3#include <thrust/host_vector.h>
34template <
class MatrixType,
class ContainerType>
44 MultiMatrix(
int dimension): inter_(dimension), temp_(dimension-1 > 0 ? dimension-1 : 0 ){}
46 template<
class OtherMatrix,
class OtherContainer,
class ... Params>
49 unsigned dimsT = src.
get_temp().size();
50 inter_.resize( dimsM);
52 for(
unsigned i=0; i<dimsM; i++)
54 for(
unsigned i=0; i<dimsT; i++)
58 template<
class ...Params>
64 template<
class ContainerType0,
class ContainerType1>
65 void symv(
const ContainerType0& x, ContainerType1& y)
const{
symv( 1.,
x,0,
y);}
66 template<
class ContainerType0,
class ContainerType1>
69 int dims = inter_.size();
76 for(
int i=1; i<dims-1; i++)
80 std::vector<Buffer<ContainerType> >&
get_temp(){
return temp_;}
81 const std::vector<Buffer<ContainerType> >&
get_temp()
const{
return temp_;}
83 const std::vector<MatrixType>&
get_matrices()
const{
return inter_;}
85 std::vector<MatrixType > inter_;
86 std::vector<Buffer<ContainerType> > temp_;
90template <
class M,
class V>
91struct TensorTraits<MultiMatrix<M, V> >
100template<
class real_type>
106 matrix.get_matrices()[0] = right;
107 matrix.get_matrices()[1] = left;
109 matrix.get_temp()[0] = Buffer<dg::HVec_t<real_type>>(vec);
112template<
class real_type>
119template<
class real_type>
123 matrix.get_matrices()[0] = right;
124 matrix.get_matrices()[1] = left;
125 thrust::host_vector<real_type> vec( right.
inner_matrix().total_num_rows());
126 matrix.get_temp()[0] = Buffer<dg::MHVec_t<real_type>>({vec, left.
collective().communicator()});
129template<
class real_type>
133 unsigned right_size = in.num_rows*in.n*in.right_size;
169template<
class real_type>
177 for(
unsigned k=0; k<multiplyNx*multiplyn; k++)
178 for(
unsigned i=0; i<n; i++)
179 for(
unsigned j=0; j<n; j++)
180 iX.
data[(k*n+i)*n+j] = interpolX.values[(k*n+i)*n+j];
181 for(
unsigned i=0; i<multiplyNx*multiplyn*t.
N(); i++)
183 iX.
cols_idx[i] = i/(multiplyNx*multiplyn);
184 iX.
data_idx[i] = i%(multiplyNx*multiplyn);
206template<
class real_type>
209 if( t.
N()%divideNx != 0)
throw Error(
Message(
_ping_)<<
"Nx and divideNx don't match: Nx: " << t.
N()<<
" divideNx "<< (
unsigned)divideNx);
210 if( t.
n()%dividen != 0)
throw Error(
Message(
_ping_)<<
"n and dividen don't match: n: " << t.
n()<<
" dividen "<< (
unsigned)dividen);
211 unsigned n=t.
n()/dividen;
216 cusp::coo_matrix<int, real_type, cusp::host_memory> projectX, tmp;
221 for(
unsigned k=0; k<divideNx; k++)
222 for(
unsigned l=0; l<dividen; l++)
223 for(
unsigned i=0; i<n; i++)
224 for(
unsigned j=0; j<n; j++)
226 pX.
data[((k*dividen+l)*n+i)*n+j] = projectX.values[((i*divideNx+k)*dividen + l)*n+j];
227 pX.
data[((k*dividen+l)*n+i)*n+j] *= v1d[i]*w1d[l*n+j];
229 for(
unsigned i=0; i<t.
N()/divideNx; i++)
230 for(
unsigned d=0; d<divideNx*dividen; d++)
232 pX.
cols_idx[i*divideNx*dividen+d] = i*divideNx*dividen+d;
233 pX.
data_idx[i*divideNx*dividen+d] = d;
261template<
class real_type>
265 if( opx.
size() != t.
n())
268 for(
unsigned i=0; i<t.
N(); i++)
278template<
class real_type>
284 trafo.set_left_size ( t.
ny()*t.
Ny());
288 trafo.set_right_size ( t.
nx()*t.
Nx());
294template<
class real_type>
300 trafo.set_left_size ( t.
ny()*t.
Ny());
304 trafo.set_right_size ( t.
nx()*t.
Nx());
310template<
class real_type>
316 trafo.set_left_size ( t.
ny()*t.
Ny());
320 trafo.set_right_size ( t.
nx()*t.
Nx());
326template<
class real_type>
332 trafo.set_left_size ( t.
ny()*t.
Ny()*t.
nz()*t.
Nz());
338 trafo.set_left_size ( t.
nz()*t.
Nz());
339 trafo.set_right_size ( t.
nx()*t.
Nx());
343 trafo.set_right_size ( t.
nx()*t.
Nx()*t.
ny()*t.
Ny());
349template<
class real_type>
355 trafo.set_left_size ( t.
ny()*t.
Ny()*t.
nz()*t.
Nz());
361 trafo.set_left_size ( t.
nz()*t.
Nz());
362 trafo.set_right_size ( t.
nx()*t.
Nx());
366 trafo.set_right_size ( t.
nx()*t.
Nx()*t.
ny()*t.
Ny());
372template<
class real_type>
378 trafo.set_left_size ( t.
ny()*t.
Ny()*t.
nz()*t.
Nz());
384 trafo.set_left_size ( t.
nz()*t.
Nz());
385 trafo.set_right_size ( t.
nx()*t.
Nx());
389 trafo.set_right_size ( t.
nx()*t.
Nx()*t.
ny()*t.
Ny());
398template<
class real_type>
409template<
class real_type>
416template<
class real_type>
423template<
class real_type>
431template<
class real_type>
438template<
class real_type>
445template<
class real_type>
454template<
class Topology>
455auto fast_interpolation(
const Topology& t,
unsigned multiplyn,
unsigned multiplyNx,
unsigned multiplyNy)
459 dg::detail::set_right_size( interY, interX);
460 return dg::detail::multiply( interY, interX);
465template<
class Topology>
466auto fast_projection(
const Topology& t,
unsigned dividen,
unsigned divideNx,
unsigned divideNy)
470 dg::detail::set_right_size( interY, interX);
471 return dg::detail::multiply( interY, interX);
475template<
class Topology>
480 return dg::detail::multiply( interY, interX);
496template<
class real_type>
499 thrust::host_vector<real_type> out(in.size(), 0);
501 g.
dlty().forward(), g);
class intended for the use in throw statements
Definition: exceptions.h:83
small class holding a stringstream
Definition: exceptions.h:29
unsigned size() const
Size n of the Operator.
Definition: operator.h:113
const std::vector< value_type > & data() const
access underlying data
Definition: operator.h:130
#define _ping_
Definition: exceptions.h:12
void assign(const from_ContainerType &from, ContainerType &to, Params &&... ps)
Generic way to assign the contents of a from_ContainerType object to a ContainerType object optionall...
Definition: blas1.h:665
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
Definition: blas2.h:287
coo3d
3d contra- and covariant coordinates
Definition: enums.h:177
direction
Direction of a discrete derivative.
Definition: enums.h:97
@ forward
forward derivative (cell to the right and current cell)
Definition: enums.h:98
MPI_Vector< thrust::host_vector< real_type > > weights(const aRealMPITopology2d< real_type > &g)
Nodal weight coefficients.
Definition: mpi_weights.h:22
MPI_Vector< thrust::host_vector< real_type > > inv_weights(const aRealMPITopology2d< real_type > &g)
inverse nodal weight coefficients
Definition: mpi_weights.h:29
dg::HMatrix_t< real_type > fast_transform(dg::Operator< real_type > opx, const RealGrid1d< real_type > &t)
Create a block-diagonal matrix.
Definition: fast_interpolation.h:262
dg::HMatrix_t< real_type > fast_interpolation(const RealGrid1d< real_type > &t, unsigned multiplyn, unsigned multiplyNx)
Create interpolation matrix for integer multipliers.
Definition: fast_interpolation.h:170
cusp::coo_matrix< int, real_type, cusp::host_memory > interpolation(const thrust::host_vector< real_type > &x, const RealGrid1d< real_type > &g, dg::bc bcx=dg::NEU, std::string method="dg")
Create interpolation matrix.
Definition: interpolation.h:254
dg::HMatrix_t< real_type > fast_projection(const RealGrid1d< real_type > &t, unsigned dividen, unsigned divideNx)
Create projecton matrix for integer dividers.
Definition: fast_interpolation.h:207
thrust::host_vector< real_type > forward_transform(const thrust::host_vector< real_type > &in, const aRealTopology2d< real_type > &g)
Transform a vector from dg::xspace (nodal values) to dg::lspace (modal values)
Definition: fast_interpolation.h:497
void transpose(unsigned nx, unsigned ny, const ContainerType &in, ContainerType &out)
Transpose vector.
Definition: average_dispatch.h:26
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
Definition: tensor_traits.h:38
thrust::host_vector< T > HVec_t
Host Vector.
Definition: typedefs.h:18
thrust::host_vector< double > HVec
Host Vector.
Definition: typedefs.h:19
1D, 2D and 3D interpolation matrix creation functions
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
Creation of projection matrices.
Coo Sparse Block Matrix format.
Definition: sparseblockmat.h:179
Ell Sparse Block Matrix format.
Definition: sparseblockmat.h:46
int total_num_cols() const
total number of columns is num_cols*n*left_size*right_size
Definition: sparseblockmat.h:82
thrust::host_vector< int > data_idx
has the same size as cols_idx and contains indices into the data array, i.e. the block number
Definition: sparseblockmat.h:128
int num_rows
number of block rows, each row contains blocks
Definition: sparseblockmat.h:130
void set_right_size(int new_right_size)
Set right_size = new_right_size; set_default_range();
Definition: sparseblockmat.h:110
thrust::host_vector< value_type > data
The data array is of size n*n*num_different_blocks and contains the blocks. The first block is contai...
Definition: sparseblockmat.h:126
int total_num_rows() const
total number of rows is num_rows*n*left_size*right_size
Definition: sparseblockmat.h:78
thrust::host_vector< int > cols_idx
is of size num_rows*num_blocks_per_line and contains the column indices % n into the vector
Definition: sparseblockmat.h:127
int n
each block has size n*n
Definition: sparseblockmat.h:133
int right_size
size of the right Kronecker delta (is e.g 1 for a x - derivative)
Definition: sparseblockmat.h:135
mpi Vector class
Definition: mpi_vector.h:32
Struct that applies given matrices one after the other.
Definition: fast_interpolation.h:36
MultiMatrix(const MultiMatrix< OtherMatrix, OtherContainer > &src, Params &&... ps)
Definition: fast_interpolation.h:47
void symv(real_type alpha, const ContainerType0 &x, real_type beta, ContainerType1 &y) const
Definition: fast_interpolation.h:67
std::vector< Buffer< ContainerType > > & get_temp()
Definition: fast_interpolation.h:80
void construct(Params &&...ps)
Definition: fast_interpolation.h:59
std::vector< MatrixType > & get_matrices()
Definition: fast_interpolation.h:82
get_value_type< ContainerType > real_type
Definition: fast_interpolation.h:37
const std::vector< Buffer< ContainerType > > & get_temp() const
Definition: fast_interpolation.h:81
const std::vector< MatrixType > & get_matrices() const
Definition: fast_interpolation.h:83
void symv(const ContainerType0 &x, ContainerType1 &y) const
Definition: fast_interpolation.h:65
MultiMatrix()
Definition: fast_interpolation.h:38
MultiMatrix(int dimension)
reserve space for dimension matrices and dimension-1 ContainerTypes
Definition: fast_interpolation.h:44
Communicator for asynchronous nearest neighbor communication.
Definition: mpi_vector.h:181
1D grid
Definition: grid.h:80
unsigned n() const
number of polynomial coefficients
Definition: grid.h:141
unsigned N() const
number of cells
Definition: grid.h:135
Distributed memory matrix class, asynchronous communication.
Definition: mpi_matrix.h:65
const LocalMatrixInner & inner_matrix() const
Read access to the inner matrix.
Definition: mpi_matrix.h:96
const LocalMatrixOuter & outer_matrix() const
Read access to the outer matrix.
Definition: mpi_matrix.h:100
const Collective & collective() const
Read access to the communication object.
Definition: mpi_matrix.h:104
NotATensorTag tensor_category
Definition: tensor_traits.h:33
void value_type
Definition: tensor_traits.h:32
2D MPI abstract grid class
Definition: mpi_grid.h:45
const RealGrid2d< real_type > & local() const
Return a non-MPI grid local for the calling process.
Definition: mpi_grid.h:252
MPI_Comm communicator() const
Return mpi cartesian communicator that is used in this grid.
Definition: mpi_grid.h:138
3D MPI Grid class
Definition: mpi_grid.h:329
MPI_Comm communicator() const
Return mpi cartesian communicator that is used in this grid.
Definition: mpi_grid.h:459
const RealGrid3d< real_type > & local() const
Return a non-MPI grid local for the calling process.
Definition: mpi_grid.h:560
An abstract base class for two-dimensional grids.
Definition: grid.h:277
const DLT< real_type > & dltx() const
discrete legendre trafo
Definition: grid.h:372
const DLT< real_type > & dlty() const
discrete legendre transformation in y
Definition: grid.h:374
const RealGrid1d< real_type > & gy() const
The y-axis grid.
Definition: grid.h:379
unsigned ny() const
number of polynomial coefficients in y
Definition: grid.h:340
unsigned Nx() const
number of cells in x
Definition: grid.h:346
const RealGrid1d< real_type > & gx() const
The x-axis grid.
Definition: grid.h:377
unsigned nx() const
number of polynomial coefficients in x
Definition: grid.h:338
unsigned Ny() const
number of cells in y
Definition: grid.h:352
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
unsigned nz() const
number of polynomial coefficients in z
Definition: grid.h:616
unsigned Nx() const
number of points in x
Definition: grid.h:622
unsigned ny() const
number of polynomial coefficients in y
Definition: grid.h:614
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
unsigned Ny() const
number of points in y
Definition: grid.h:628
unsigned Nz() const
number of points in z
Definition: grid.h:634
unsigned nx() const
number of polynomial coefficients in x
Definition: grid.h:612
Useful typedefs of commonly used types.