3#include <cusp/coo_matrix.h>
4#include <cusp/transpose.h>
65template<
class real_type>
66cusp::coo_matrix< int, real_type, cusp::host_memory>
diagonal(
const thrust::host_vector<real_type>&
diagonal)
69 cusp::coo_matrix<int, real_type, cusp::host_memory> W( size, size, size);
70 for(
unsigned i=0; i<size; i++)
72 W.row_indices[i] = W.column_indices[i] = i;
103template<
class real_type>
106 if( g_old.
N() % g_new.
N() != 0) std::cerr <<
"# ATTENTION: you project between incompatible grids!! old N: "<<g_old.
N()<<
" new N: "<<g_new.
N()<<
"\n";
107 if( g_old.
n() < g_new.
n()) std::cerr <<
"# ATTENTION: you project between incompatible grids!! old n: "<<g_old.
n()<<
" new n: "<<g_new.
n()<<
"\n";
109 cusp::coo_matrix<int, real_type, cusp::host_memory> Wf =
111 cusp::coo_matrix<int, real_type, cusp::host_memory> Vc =
113 cusp::coo_matrix<int, real_type, cusp::host_memory> temp =
interpolation( g_old, g_new, method), A;
116 cusp::multiply( A, Wf, temp);
117 cusp::multiply( Vc, temp, A);
118 A.sort_by_row_and_column();
124template<
class real_type>
127 cusp::csr_matrix<int, real_type, cusp::host_memory> projectX =
projection( g_new.
gx(), g_old.
gx(), method);
128 cusp::csr_matrix<int, real_type, cusp::host_memory> projectY =
projection( g_new.
gy(), g_old.
gy(), method);
133template<
class real_type>
136 cusp::csr_matrix<int, real_type, cusp::host_memory> projectX =
projection( g_new.
gx(), g_old.
gx(), method);
137 cusp::csr_matrix<int, real_type, cusp::host_memory> projectY =
projection( g_new.
gy(), g_old.
gy(), method);
138 cusp::csr_matrix<int, real_type, cusp::host_memory> projectZ =
projection( g_new.
gz(), g_old.
gz(), method);
164template<
class real_type>
171 cusp::coo_matrix< int, real_type, cusp::host_memory> P =
create::projection( g_new, g_lcm), Y;
172 cusp::multiply( P, Q, Y);
173 Y.sort_by_row_and_column();
178template<
class real_type>
184 cusp::coo_matrix< int, real_type, cusp::host_memory> P =
create::projection( g_new, g_lcm), Y;
185 cusp::multiply( P, Q, Y);
186 Y.sort_by_row_and_column();
190template<
class real_type>
195 cusp::coo_matrix< int, real_type, cusp::host_memory> P =
create::projection( g_new, g_lcm), Y;
196 cusp::multiply( P, Q, Y);
197 Y.sort_by_row_and_column();
213template<
class real_type>
221 for(
unsigned i=0; i<block.num_entries; i++)
222 op( block.row_indices[i], block.column_indices[i]) = block.values[i];
228template<
class real_type>
237template<
class real_type>
256template<
class real_type>
264 for(
unsigned i=0; i<block.num_entries; i++)
265 op( block.row_indices[i], block.column_indices[i]) = block.values[i];
271template<
class real_type>
281template<
class real_type>
dg::Operator< T > invert(const dg::Operator< T > &in)
Alias for dg::create::inverse. Compute inverse of square matrix.
Definition: operator.h:695
dg::RealGrid1d< double > Grid1d
Definition: grid.h:887
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
cusp::coo_matrix< int, real_type, cusp::host_memory > diagonal(const thrust::host_vector< real_type > &diagonal)
Create a diagonal matrix.
Definition: projection.h:66
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
cusp::coo_matrix< int, real_type, cusp::host_memory > transformation(const aRealTopology3d< real_type > &g_new, const aRealTopology3d< real_type > &g_old)
Create a transformation matrix between two grids.
Definition: projection.h:165
dg::MIHMatrix_t< real_type > projection(const aRealMPITopology2d< real_type > &g_new, const aRealMPITopology2d< real_type > &g_old, std::string method="dg")
Create a projection between two grids.
Definition: mpi_projection.h:247
Operator< T > tensorproduct(const Operator< T > &op1, const Operator< T > &op2)
Form the tensor product between two operators.
Definition: operator_tensor.h:27
T gcd(T a, T b)
Greatest common divisor.
Definition: projection.h:28
T lcm(T a, T b)
Least common multiple.
Definition: projection.h:50
void transpose(unsigned nx, unsigned ny, const ContainerType &in, ContainerType &out)
Transpose vector.
Definition: average_dispatch.h:26
dg::IHMatrix_t< real_type > backproject(const RealGrid1d< real_type > &g)
Create a matrix that projects values to an equidistant grid.
Definition: projection.h:214
dg::IHMatrix_t< real_type > inv_backproject(const RealGrid1d< real_type > &g)
Create a matrix that transforms values from an equidistant grid back to a dg grid.
Definition: projection.h:257
cusp::csr_matrix< int, real_type, cusp::host_memory > IHMatrix_t
Definition: typedefs.h:37
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...
1D grid
Definition: grid.h:80
unsigned n() const
number of polynomial coefficients
Definition: grid.h:141
real_type x1() const
right boundary
Definition: grid.h:117
unsigned N() const
number of cells
Definition: grid.h:135
real_type x0() const
left boundary
Definition: grid.h:111
The simplest implementation of aRealTopology3d.
Definition: grid.h:844
An abstract base class for two-dimensional grids.
Definition: grid.h:277
real_type x0() const
Left boundary in x.
Definition: grid.h:288
real_type y1() const
Right boundary in y.
Definition: grid.h:306
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
real_type y0() const
left boundary in y
Definition: grid.h:300
unsigned Nx() const
number of cells in x
Definition: grid.h:346
real_type x1() const
Right boundary in x.
Definition: grid.h:294
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
real_type y0() const
left boundary in y
Definition: grid.h:547
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
real_type x0() const
left boundary in x
Definition: grid.h:534
real_type y1() const
right boundary in y
Definition: grid.h:553
const RealGrid1d< real_type > & gy() const
The y-axis grid.
Definition: grid.h:662
real_type z0() const
left boundary in z
Definition: grid.h:560
real_type x1() const
right boundary in x
Definition: grid.h:540
unsigned Ny() const
number of points in y
Definition: grid.h:628
real_type z1() const
right boundary in z
Definition: grid.h:566
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
Creation functions for integration weights and their inverse.