Discontinuous Galerkin Library
#include "dg/algorithm.h"
dxX.h
Go to the documentation of this file.
1#pragma once
2
3#include <cassert>
4
5#include "gridX.h"
6#include "dx.h"
7#include "weightsX.h"
9
13namespace dg
14{
15namespace create
16{
19
29template<class real_type>
31{
32 if( g.outer_N() == 0) return dx( g.grid(), dg::PER, dir);
33 EllSparseBlockMat<real_type> DX = dx( g.grid(), bcx, dir);
34 for( int i=0; i<DX.blocks_per_line; i++)
35 {
36 if( DX.cols_idx[DX.blocks_per_line*(g.outer_N()-1)+i] == (int)g.outer_N())
37 DX.cols_idx[DX.blocks_per_line*(g.outer_N()-1)+i] += g.inner_N();
38 if( DX.cols_idx[DX.blocks_per_line*(g.outer_N())+i] == (int)g.outer_N()-1)
39 DX.cols_idx[DX.blocks_per_line*(g.outer_N())+i] += g.inner_N();
40 if( DX.cols_idx[DX.blocks_per_line*(g.N()-g.outer_N()-1)+i] == (int)(g.N()-g.outer_N()))
41 DX.cols_idx[DX.blocks_per_line*(g.N()-g.outer_N()-1)+i] -= g.inner_N();
42 if( DX.cols_idx[DX.blocks_per_line*(g.N()-g.outer_N())+i] == (int)(g.N()-g.outer_N()-1))
43 DX.cols_idx[DX.blocks_per_line*(g.N()-g.outer_N())+i] -= g.inner_N();
44 }
45 return DX;
46}
47
58template<class real_type>
60{
61 return dx( g, g.bcx(), dir);
62}
72template<class real_type>
74{
75 if( g.outer_N() == 0) return jump( g.n(), g.N(), g.h(), dg::PER);
76 EllSparseBlockMat<real_type> J = jump( g.n(),g.N(),g.h(), bcx);
77 for( int i=0; i<J.blocks_per_line; i++)
78 {
79 if( J.cols_idx[J.blocks_per_line*(g.outer_N()-1)+i] == (int)g.outer_N())
80 J.cols_idx[J.blocks_per_line*(g.outer_N()-1)+i] += g.inner_N();
81 if( J.cols_idx[J.blocks_per_line*(g.outer_N())+i] == (int)g.outer_N()-1)
82 J.cols_idx[J.blocks_per_line*(g.outer_N())+i] += g.inner_N();
83 if( J.cols_idx[J.blocks_per_line*(g.N()-g.outer_N()-1)+i] == (int)(g.N()-g.outer_N()))
84 J.cols_idx[J.blocks_per_line*(g.N()-g.outer_N()-1)+i] -= g.inner_N();
85 if( J.cols_idx[J.blocks_per_line*(g.N()-g.outer_N())+i] == (int)(g.N()-g.outer_N()-1))
86 J.cols_idx[J.blocks_per_line*(g.N()-g.outer_N())+i] -= g.inner_N();
87 }
88 return J;
89}
99template<class real_type>
101{
102 return jump( g, g.bcx());
103}
104
106} //namespace create
107} //namespace dg
108
Simple 1d derivatives.
base X-point topology classes
EllSparseBlockMat< real_type > dx(const aRealTopology2d< real_type > &g, bc bcx, direction dir=centered)
Create 2d derivative in x-direction.
Definition: derivatives.h:33
bc
Switch between boundary conditions.
Definition: enums.h:15
direction
Direction of a discrete derivative.
Definition: enums.h:97
@ PER
periodic boundaries
Definition: enums.h:16
@ centered
centered derivative (cell to the left and right and current cell)
Definition: enums.h:100
EllSparseBlockMat< real_type > jump(int n, int N, real_type h, bc bcx)
Create and assemble a host Matrix for the jump terms in 1d.
Definition: dx.h:310
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
Ell Sparse Block Matrix format.
Definition: sparseblockmat.h:46
int blocks_per_line
number of blocks in each line
Definition: sparseblockmat.h:132
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
1D grid for X-point topology
Definition: gridX.h:68
unsigned inner_N() const
number of cells in the inner region
Definition: gridX.h:141
bc bcx() const
boundary conditions
Definition: gridX.h:153
unsigned outer_N() const
number of cells in one of the outer regions
Definition: gridX.h:135
unsigned N() const
number of cells
Definition: gridX.h:129
unsigned n() const
number of polynomial coefficients
Definition: gridX.h:147
real_type h() const
cell size
Definition: gridX.h:123
RealGrid1d< real_type > grid() const
Definition: gridX.h:185
Creation functions for integration weights and their inverse on X-point topology.