28template<
class real_type>
29CooSparseBlockMat<real_type> save_outer_values(EllSparseBlockMat<real_type>& in,
const NNCH<real_type>& c)
32 CooSparseBlockMat<real_type> out( in.num_rows, 6, in.n, in.left_size, in.right_size);
33 int index = in.data.size()/ in.n/in.n;
34 thrust::host_vector<real_type> data_element(in.n*in.n, 0),
zero(data_element);
36 for(
int i=0; i<in.num_rows; i++)
37 for(
int d=0; d<in.blocks_per_line; d++)
39 if( in.cols_idx[i*in.blocks_per_line+d]==-1)
41 for(
int k=0; k<in.blocks_per_line; k++)
43 for(
int j=0; j<in.n*in.n; j++)
44 data_element[j] = in.data[ in.data_idx[i*in.blocks_per_line+k]*in.n*in.n + j];
45 int col = c.map_index( in.cols_idx[i*in.blocks_per_line+k]);
46 out.add_value( i, col, data_element);
47 in.data_idx[i*in.blocks_per_line+k] = index;
48 in.cols_idx[i*in.blocks_per_line+k] = 0;
52 if( in.cols_idx[i*in.blocks_per_line+d]==in.num_cols)
54 for(
int k=0; k<in.blocks_per_line; k++)
56 for(
int j=0; j<in.n*in.n; j++)
57 data_element[j] = in.data[ in.data_idx[i*in.blocks_per_line+k]*in.n*in.n + j];
59 int col = c.map_index( in.cols_idx[i*in.blocks_per_line+k]);
60 out.add_value( i, col, data_element);
61 in.data_idx[i*in.blocks_per_line+k] = index;
62 in.cols_idx[i*in.blocks_per_line+k] = in.num_cols-1;
69 in.data.insert( in.data.end(),
zero.begin(),
zero.end());
88template<
class real_type>
89EllSparseBlockMat<real_type> distribute_rows(
const EllSparseBlockMat<real_type>& src,
int coord,
const int* howmany)
93 EllSparseBlockMat<real_type> temp(src);
94 temp.set_left_size( temp.left_size/howmany[0]);
95 temp.set_right_size( temp.right_size/howmany[2]);
98 assert( src.num_rows == src.num_cols);
99 int chunk_size = src.num_rows/howmany[1];
100 EllSparseBlockMat<real_type> temp(chunk_size, chunk_size, src.blocks_per_line, src.data.size()/(src.n*src.n), src.n);
101 temp.set_left_size( src.left_size/howmany[0]);
102 temp.set_right_size( src.right_size/howmany[2]);
104 for(
unsigned i=0; i<src.data.size(); i++)
105 temp.data[i] = src.data[i];
107 for(
unsigned i=0; i<temp.cols_idx.size(); i++)
109 temp.data_idx[i] = src.data_idx[ coord*(chunk_size*src.blocks_per_line)+i];
110 temp.cols_idx[i] = src.cols_idx[ coord*(chunk_size*src.blocks_per_line)+i];
113 if( coord==0 && i/src.blocks_per_line == 0 && temp.cols_idx[i] == src.num_cols-1) temp.cols_idx[i] = -1;
115 if( coord==(howmany[1]-1)&& (int)i/src.blocks_per_line == temp.num_rows-1 && temp.cols_idx[i] == 0) temp.cols_idx[i] = src.num_cols;
118 temp.cols_idx[i] = (temp.cols_idx[i] - coord*chunk_size );
139template<
class real_type>
143 unsigned vector_dimensions[] = {(unsigned)(g.
nx()*g.
local().Nx()), (
unsigned)(g.
ny()*g.
local().Ny()), 1};
146 MPI_Cartdim_get( comm, &ndims);
148 int dims[ndims], periods[ndims], coords[ndims];
149 MPI_Cart_get( comm, ndims, dims, periods, coords);
151 int howmany[] = {dims[1], dims[0], 1};
169template<
class real_type>
173 unsigned vector_dimensions[] = {(unsigned)(g.
nx()*g.
local().Nx()), (
unsigned)(g.
ny()*g.
local().Ny()), 1};
176 MPI_Cartdim_get( comm, &ndims);
178 int dims[ndims], periods[ndims], coords[ndims];
179 MPI_Cart_get( comm, ndims, dims, periods, coords);
181 int howmany[] = {1, dims[1], dims[0]};
197template<
class real_type>
201 unsigned vector_dimensions[] = {(unsigned)(g.
nx()*g.
local().Nx()), (
unsigned)(g.
ny()*g.
local().Ny()), 1};
204 MPI_Cartdim_get( comm, &ndims);
206 int dims[ndims], periods[ndims], coords[ndims];
207 MPI_Cart_get( comm, ndims, dims, periods, coords);
209 int howmany[] = {dims[1], dims[0], 1};
224template<
class real_type>
228 unsigned vector_dimensions[] = {(unsigned)(g.
nx()*g.
local().Nx()), (
unsigned)(g.
ny()*g.
local().Ny()), 1};
231 MPI_Cartdim_get( comm, &ndims);
233 int dims[ndims], periods[ndims], coords[ndims];
234 MPI_Cart_get( comm, ndims, dims, periods, coords);
236 int howmany[] = {1, dims[1], dims[0]};
253template<
class real_type>
257 unsigned vector_dimensions[] = {(unsigned)(g.
nx()*g.
local().Nx()), (
unsigned)(g.
ny()*g.
local().Ny()), (
unsigned)(g.
nz()*g.
local().Nz())};
260 MPI_Cartdim_get( comm, &ndims);
262 int dims[ndims], periods[ndims], coords[ndims];
263 MPI_Cart_get( comm, ndims, dims, periods, coords);
265 int howmany[] = {dims[2]*dims[1], dims[0], 1};
281template<
class real_type>
285 unsigned vector_dimensions[] = {(unsigned)(g.
nx()*g.
local().Nx()), (
unsigned)(g.
ny()*g.
local().Ny()), (
unsigned)(g.
nz()*g.
local().Nz())};
288 MPI_Cartdim_get( comm, &ndims);
290 int dims[ndims], periods[ndims], coords[ndims];
291 MPI_Cart_get( comm, ndims, dims, periods, coords);
293 int howmany[] = {dims[2], dims[1], dims[0]};
309template<
class real_type>
313 unsigned vector_dimensions[] = {(unsigned)(g.
nx()*g.
local().Nx()), (
unsigned)(g.
ny()*g.
local().Ny()), (
unsigned)(g.
nz()*g.
local().Nz())};
316 MPI_Cartdim_get( comm, &ndims);
318 int dims[ndims], periods[ndims], coords[ndims];
319 MPI_Cart_get( comm, ndims, dims, periods, coords);
321 int howmany[] = {1, dims[2], dims[1]*dims[0]};
337template<
class real_type>
341 unsigned vector_dimensions[] = {(unsigned)(g.
nx()*g.
local().Nx()), (
unsigned)(g.
ny()*g.
local().Ny()), (
unsigned)(g.
nz()*g.
local().Nz())};
344 MPI_Cartdim_get( comm, &ndims);
346 int dims[ndims], periods[ndims], coords[ndims];
347 MPI_Cart_get( comm, ndims, dims, periods, coords);
349 int howmany[] = {dims[2]*dims[1], dims[0], 1};
365template<
class real_type>
369 unsigned vector_dimensions[] = {(unsigned)(g.
nx()*g.
local().Nx()), (
unsigned)(g.
ny()*g.
local().Ny()), (
unsigned)(g.
nz()*g.
local().Nz())};
372 MPI_Cartdim_get( comm, &ndims);
374 int dims[ndims], periods[ndims], coords[ndims];
375 MPI_Cart_get( comm, ndims, dims, periods, coords);
377 int howmany[] = {dims[2], dims[1], dims[0]};
392template<
class real_type>
396 unsigned vector_dimensions[] = {(unsigned)(g.
nx()*g.
local().Nx()), (
unsigned)(g.
ny()*g.
local().Ny()), (
unsigned)(g.
nz()*g.
local().Nz())};
399 MPI_Cartdim_get( comm, &ndims);
401 int dims[ndims], periods[ndims], coords[ndims];
402 MPI_Cart_get( comm, ndims, dims, periods, coords);
404 int howmany[] = {1, dims[2], dims[1]*dims[0]};
420template<
class real_type>
423 return dx( g, g.
bcx(), dir);
434template<
class real_type>
437 return dx( g, g.
bcx(), dir);
446template<
class real_type>
459template<
class real_type>
473template<
class real_type>
476 return dy( g, g.
bcy(), dir);
487template<
class real_type>
490 return dy( g, g.
bcy(), dir);
500template<
class real_type>
513template<
class real_type>
527template<
class real_type>
530 return dz( g, g.
bcz(), dir);
540template<
class real_type>
Convenience functions to create 2D derivatives.
Some utility functions for the dg::evaluate routines.
static DG_DEVICE double zero(double x)
Definition: functions.h:29
EllSparseBlockMat< real_type > dz(const aRealTopology3d< real_type > &g, bc bcz, direction dir=centered)
Create 3d derivative in z-direction.
Definition: derivatives.h:308
EllSparseBlockMat< real_type > dx(const aRealTopology2d< real_type > &g, bc bcx, direction dir=centered)
Create 2d derivative in x-direction.
Definition: derivatives.h:33
EllSparseBlockMat< real_type > jumpZ(const aRealTopology3d< real_type > &g, bc bcz)
Matrix that contains jump terms in Z direction in 3D.
Definition: derivatives.h:190
bc
Switch between boundary conditions.
Definition: enums.h:15
EllSparseBlockMat< real_type > jumpX(const aRealTopology2d< real_type > &g, bc bcx)
Matrix that contains 2d jump terms in X direction.
Definition: derivatives.h:95
EllSparseBlockMat< real_type > dy(const aRealTopology2d< real_type > &g, bc bcy, direction dir=centered)
Create 2d derivative in y-direction.
Definition: derivatives.h:65
direction
Direction of a discrete derivative.
Definition: enums.h:97
EllSparseBlockMat< real_type > jumpY(const aRealTopology2d< real_type > &g, bc bcy)
Matrix that contains 2d jump terms in Y direction.
Definition: derivatives.h:112
@ centered
centered derivative (cell to the left and right and current cell)
Definition: enums.h:100
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
Coo Sparse Block Matrix format.
Definition: sparseblockmat.h:179
Ell Sparse Block Matrix format.
Definition: sparseblockmat.h:46
Communicator for asynchronous nearest neighbor communication.
Definition: mpi_vector.h:181
Distributed memory matrix class, asynchronous communication.
Definition: mpi_matrix.h:65
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
bc bcy() const
global y boundary
Definition: mpi_grid.h:132
unsigned nx() const
number of polynomial coefficients in x
Definition: mpi_grid.h:106
unsigned ny() const
number of polynomial coefficients in y
Definition: mpi_grid.h:108
MPI_Comm communicator() const
Return mpi cartesian communicator that is used in this grid.
Definition: mpi_grid.h:138
const RealGrid2d< real_type > & global() const
Return the global non-MPI grid.
Definition: mpi_grid.h:262
bc bcx() const
global x boundary
Definition: mpi_grid.h:126
3D MPI Grid class
Definition: mpi_grid.h:329
bc bcz() const
global z boundary
Definition: mpi_grid.h:454
unsigned nz() const
number of polynomial coefficients in z
Definition: mpi_grid.h:418
MPI_Comm communicator() const
Return mpi cartesian communicator that is used in this grid.
Definition: mpi_grid.h:459
bc bcy() const
global y boundary
Definition: mpi_grid.h:448
const RealGrid3d< real_type > & global() const
Return the global non-MPI grid.
Definition: mpi_grid.h:562
bc bcx() const
global x boundary
Definition: mpi_grid.h:442
unsigned ny() const
number of polynomial coefficients in y
Definition: mpi_grid.h:416
const RealGrid3d< real_type > & local() const
Return a non-MPI grid local for the calling process.
Definition: mpi_grid.h:560
unsigned nx() const
number of polynomial coefficients in x
Definition: mpi_grid.h:414