Discontinuous Galerkin Library
#include "dg/algorithm.h"
Loading...
Searching...
No Matches
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 auto grid = g.grid();
33 if( g.outer_N() == 0) return dx_normed( grid.n(), grid.N(), grid.h(), dg::PER, dir);
34 EllSparseBlockMat<real_type, thrust::host_vector> DX = dx_normed( grid.n(), grid.N(), grid.h(), bcx, dir);
35 for( int i=0; i<DX.blocks_per_line; i++)
36 {
37 if( DX.cols_idx[DX.blocks_per_line*(g.outer_N()-1)+i] == (int)g.outer_N())
38 DX.cols_idx[DX.blocks_per_line*(g.outer_N()-1)+i] += g.inner_N();
39 if( DX.cols_idx[DX.blocks_per_line*(g.outer_N())+i] == (int)g.outer_N()-1)
40 DX.cols_idx[DX.blocks_per_line*(g.outer_N())+i] += g.inner_N();
41 if( DX.cols_idx[DX.blocks_per_line*(g.N()-g.outer_N()-1)+i] == (int)(g.N()-g.outer_N()))
42 DX.cols_idx[DX.blocks_per_line*(g.N()-g.outer_N()-1)+i] -= g.inner_N();
43 if( DX.cols_idx[DX.blocks_per_line*(g.N()-g.outer_N())+i] == (int)(g.N()-g.outer_N()-1))
44 DX.cols_idx[DX.blocks_per_line*(g.N()-g.outer_N())+i] -= g.inner_N();
45 }
46 return DX;
47}
48
59template<class real_type>
73template<class real_type>
75{
76 if( g.outer_N() == 0) return jump( g.n(), g.N(), g.h(), dg::PER);
78 for( int i=0; i<J.blocks_per_line; i++)
79 {
80 if( J.cols_idx[J.blocks_per_line*(g.outer_N()-1)+i] == (int)g.outer_N())
81 J.cols_idx[J.blocks_per_line*(g.outer_N()-1)+i] += g.inner_N();
82 if( J.cols_idx[J.blocks_per_line*(g.outer_N())+i] == (int)g.outer_N()-1)
83 J.cols_idx[J.blocks_per_line*(g.outer_N())+i] += g.inner_N();
84 if( J.cols_idx[J.blocks_per_line*(g.N()-g.outer_N()-1)+i] == (int)(g.N()-g.outer_N()))
85 J.cols_idx[J.blocks_per_line*(g.N()-g.outer_N()-1)+i] -= g.inner_N();
86 if( J.cols_idx[J.blocks_per_line*(g.N()-g.outer_N())+i] == (int)(g.N()-g.outer_N()-1))
87 J.cols_idx[J.blocks_per_line*(g.N()-g.outer_N())+i] -= g.inner_N();
88 }
89 return J;
90}
100template<class real_type>
105
107} //namespace create
108} //namespace dg
109
Simple 1d derivatives.
base X-point topology classes
auto dx(const Topology &g, dg::bc bc, dg::direction dir=centered)
Definition derivativesT.h:14
EllSparseBlockMat< real_type, thrust::host_vector > jump(unsigned coord, const aRealTopology< real_type, Nd > &g, dg::bc bc)
Create a jump matrix along given coordinate.
Definition derivatives.h:70
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
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:174
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:169
1D grid for X-point topology
Definition gridX.h:68
unsigned inner_N() const
number of cells in the inner region
Definition gridX.h:148
bc bcx() const
boundary conditions
Definition gridX.h:160
unsigned outer_N() const
number of cells in one of the outer regions
Definition gridX.h:142
unsigned N() const
number of cells
Definition gridX.h:136
unsigned n() const
number of polynomial coefficients
Definition gridX.h:154
RealGrid< real_type, 1 > grid() const
Definition gridX.h:186
real_type h() const
cell size
Definition gridX.h:130