32template<
class real_type>
33EllSparseBlockMat<real_type, thrust::host_vector> dx_symm(
int n,
int N, real_type h,
bc bcx)
37 SquareMatrix<real_type> l = create::lilj<real_type>(n);
38 SquareMatrix<real_type> r = create::rirj<real_type>(n);
39 SquareMatrix<real_type> lr = create::lirj<real_type>(n);
40 SquareMatrix<real_type> rl = create::rilj<real_type>(n);
41 SquareMatrix<real_type> d = create::pidxpj<real_type>(n);
42 SquareMatrix<real_type> t = create::pipj_inv<real_type>(n);
45 SquareMatrix< real_type> a = 1./2.*t*(d-d.transpose());
47 SquareMatrix<real_type> a_bound_right(a), a_bound_left(a);
50 a_bound_left += 0.5*t*l;
52 a_bound_left -= 0.5*t*l;
55 a_bound_right -= 0.5*t*r;
57 a_bound_right += 0.5*t*r;
59 a_bound_left = a_bound_right = a;
60 SquareMatrix<real_type> b = t*(1./2.*rl);
61 SquareMatrix<real_type> bp = t*(-1./2.*lr);
71 EllSparseBlockMat<real_type, thrust::host_vector> A(N, N, 3, 5, n);
72 for(
int i=0; i<n; i++)
73 for(
int j=0; j<n; j++)
75 A.data[(0*n+i)*n+j] = bp(i,j);
76 A.data[(1*n+i)*n+j] = a(i,j);
77 A.data[(2*n+i)*n+j] = b(i,j);
78 A.data[(3*n+i)*n+j] = a_bound_left(i,j);
79 A.data[(4*n+i)*n+j] = a_bound_right(i,j);
81 A.data_idx[0*3+0] = 3;
82 A.cols_idx[0*3+0] = 0;
83 A.data_idx[0*3+1] = 2;
84 A.cols_idx[0*3+1] = 1;
85 A.data_idx[0*3+2] = 2;
86 A.cols_idx[0*3+2] = invalid_idx;
87 for(
int i=1; i<N-1; i++)
88 for(
int d=0; d<3; d++)
90 A.data_idx[i*3+d] = d;
91 A.cols_idx[i*3+d] = i+d-1;
93 A.data_idx[(N-1)*3+0] = 0;
94 A.cols_idx[(N-1)*3+0] = N-2;
95 A.data_idx[(N-1)*3+1] = 4;
96 A.cols_idx[(N-1)*3+1] = N-1;
97 A.data_idx[(N-1)*3+2] = 4;
98 A.cols_idx[(N-1)*3+2] = invalid_idx;
104 EllSparseBlockMat<real_type, thrust::host_vector> A(N, N, 3, 3, n);
105 for(
int i=0; i<n; i++)
106 for(
int j=0; j<n; j++)
108 A.data[(0*n+i)*n+j] = bp(i,j);
109 A.data[(1*n+i)*n+j] = a(i,j);
110 A.data[(2*n+i)*n+j] = b(i,j);
112 for(
int i=0; i<N; i++)
113 for(
int d=0; d<3; d++)
115 A.data_idx[i*3+d] = d;
116 A.cols_idx[i*3+d] = (i+d-1+N)%N;
132template<
class real_type>
133EllSparseBlockMat<real_type, thrust::host_vector> dx_plus(
int n,
int N, real_type h,
bc bcx )
137 SquareMatrix<real_type> l = create::lilj<real_type>(n);
138 SquareMatrix<real_type> r = create::rirj<real_type>(n);
139 SquareMatrix<real_type> lr = create::lirj<real_type>(n);
140 SquareMatrix<real_type> rl = create::rilj<real_type>(n);
141 SquareMatrix<real_type> d = create::pidxpj<real_type>(n);
142 SquareMatrix<real_type> t = create::pipj_inv<real_type>(n);
144 SquareMatrix<real_type> a = t*(-l-d.transpose());
146 SquareMatrix<real_type> a_bound_left = a;
147 SquareMatrix<real_type> a_bound_right = a;
149 a_bound_left = t*(-d.transpose());
151 a_bound_right = t*(d);
152 SquareMatrix<real_type> b = t*rl;
161 EllSparseBlockMat<real_type, thrust::host_vector> A(N, N, 2, 4, n);
162 for(
int i=0; i<n; i++)
163 for(
int j=0; j<n; j++)
165 A.data[(0*n+i)*n+j] = a(i,j);
166 A.data[(1*n+i)*n+j] = b(i,j);
167 A.data[(2*n+i)*n+j] = a_bound_left(i,j);
168 A.data[(3*n+i)*n+j] = a_bound_right(i,j);
170 A.data_idx[0*2+0] = 2;
171 A.cols_idx[0*2+0] = 0;
172 A.data_idx[0*2+1] = 1;
173 A.cols_idx[0*2+1] = 1;
174 for(
int i=1; i<N-1; i++)
175 for(
int d=0; d<2; d++)
177 A.data_idx[i*2+d] = d;
178 A.cols_idx[i*2+d] = i+d;
180 A.data_idx[(N-1)*2+0] = 3;
181 A.cols_idx[(N-1)*2+0] = N-1;
182 A.data_idx[(N-1)*2+1] = 3;
183 A.cols_idx[(N-1)*2+1] = invalid_idx;
189 EllSparseBlockMat<real_type, thrust::host_vector> A(N, N, 2, 2, n);
190 for(
int i=0; i<n; i++)
191 for(
int j=0; j<n; j++)
193 A.data[(0*n+i)*n+j] = a(i,j);
194 A.data[(1*n+i)*n+j] = b(i,j);
196 for(
int i=0; i<N; i++)
197 for(
int d=0; d<2; d++)
199 A.data_idx[i*2+d] = d;
200 A.cols_idx[i*2+d] = (i+d+N)%N;
216template<
class real_type>
217EllSparseBlockMat<real_type, thrust::host_vector> dx_minus(
int n,
int N, real_type h,
bc bcx )
220 SquareMatrix<real_type> l = create::lilj<real_type>(n);
221 SquareMatrix<real_type> r = create::rirj<real_type>(n);
222 SquareMatrix<real_type> lr = create::lirj<real_type>(n);
223 SquareMatrix<real_type> rl = create::rilj<real_type>(n);
224 SquareMatrix<real_type> d = create::pidxpj<real_type>(n);
225 SquareMatrix<real_type> t = create::pipj_inv<real_type>(n);
227 SquareMatrix<real_type> a = t*(l+d);
229 SquareMatrix<real_type> a_bound_right = a;
230 SquareMatrix<real_type> a_bound_left = a;
232 a_bound_right = t*(-d.transpose());
235 SquareMatrix<real_type> bp = -t*lr;
245 EllSparseBlockMat<real_type, thrust::host_vector> A(N, N, 2, 4, n);
246 for(
int i=0; i<n; i++)
247 for(
int j=0; j<n; j++)
249 A.data[(0*n+i)*n+j] = bp(i,j);
250 A.data[(1*n+i)*n+j] = a(i,j);
251 A.data[(2*n+i)*n+j] = a_bound_left(i,j);
252 A.data[(3*n+i)*n+j] = a_bound_right(i,j);
254 A.data_idx[0*2+0] = 2;
255 A.cols_idx[0*2+0] = 0;
256 A.data_idx[0*2+1] = 2;
257 A.cols_idx[0*2+1] = invalid_idx;
258 for(
int i=1; i<N-1; i++)
259 for(
int d=0; d<2; d++)
261 A.data_idx[i*2+d] = d;
262 A.cols_idx[i*2+d] = i+d-1;
264 A.data_idx[(N-1)*2+0] = 0;
265 A.cols_idx[(N-1)*2+0] = N-2;
266 A.data_idx[(N-1)*2+1] = 3;
267 A.cols_idx[(N-1)*2+1] = N-1;
273 EllSparseBlockMat<real_type, thrust::host_vector> A(N, N, 2, 2, n);
274 for(
int i=0; i<n; i++)
275 for(
int j=0; j<n; j++)
277 A.data[(0*n+i)*n+j] = bp(i,j);
278 A.data[(1*n+i)*n+j] = a(i,j);
280 for(
int i=0; i<N; i++)
281 for(
int d=0; d<2; d++)
283 A.data_idx[i*2+d] = d;
284 A.cols_idx[i*2+d] = (i+d-1+N)%N;
300template<
class real_type>
301EllSparseBlockMat<real_type, thrust::host_vector>
jump(
int n,
int N, real_type h,
bc bcx)
304 SquareMatrix<real_type> l = create::lilj<real_type>(n);
305 SquareMatrix<real_type> r = create::rirj<real_type>(n);
306 SquareMatrix<real_type> lr = create::lirj<real_type>(n);
307 SquareMatrix<real_type> rl = create::rilj<real_type>(n);
308 SquareMatrix<real_type> a = l+r;
309 SquareMatrix<real_type> a_bound_left = a;
312 SquareMatrix<real_type> a_bound_right = a;
315 SquareMatrix<real_type> b = -rl;
316 SquareMatrix<real_type> bp = -lr;
318 SquareMatrix<real_type> t = create::pipj_inv<real_type>(n);
328 EllSparseBlockMat<real_type, thrust::host_vector> A(N, N, 3, 5, n);
329 for(
int i=0; i<n; i++)
330 for(
int j=0; j<n; j++)
332 A.data[(0*n+i)*n+j] = bp(i,j);
333 A.data[(1*n+i)*n+j] = a(i,j);
334 A.data[(2*n+i)*n+j] = b(i,j);
335 A.data[(3*n+i)*n+j] = a_bound_left(i,j);
336 A.data[(4*n+i)*n+j] = a_bound_right(i,j);
338 A.data_idx[0*3+0] = 3;
339 A.cols_idx[0*3+0] = 0;
340 A.data_idx[0*3+1] = 2;
341 A.cols_idx[0*3+1] = 1;
342 A.data_idx[0*3+2] = 2;
343 A.cols_idx[0*3+2] = invalid_idx;
344 for(
int i=1; i<N-1; i++)
345 for(
int d=0; d<3; d++)
347 A.data_idx[i*3+d] = d;
348 A.cols_idx[i*3+d] = i+d-1;
350 A.data_idx[(N-1)*3+0] = 0;
351 A.cols_idx[(N-1)*3+0] = N-2;
352 A.data_idx[(N-1)*3+1] = 4;
353 A.cols_idx[(N-1)*3+1] = N-1;
354 A.data_idx[(N-1)*3+2] = 4;
355 A.cols_idx[(N-1)*3+2] = invalid_idx;
361 EllSparseBlockMat<real_type, thrust::host_vector> A(N, N, 3, 3, n);
362 for(
int i=0; i<n; i++)
363 for(
int j=0; j<n; j++)
365 A.data[(0*n+i)*n+j] = bp(i,j);
366 A.data[(1*n+i)*n+j] = a(i,j);
367 A.data[(2*n+i)*n+j] = b(i,j);
369 for(
int i=0; i<N; i++)
370 for(
int d=0; d<3; d++)
372 A.data_idx[i*3+d] = d;
373 A.cols_idx[i*3+d] = (i+d-1+N)%N;
390template<
class real_type>
391EllSparseBlockMat<real_type, thrust::host_vector> dx_normed(
int n,
int N, real_type h,
bc bcx,
direction dir )
394 return create::dx_symm(n, N, h, bcx);
396 return create::dx_plus(n, N, h, bcx);
398 return create::dx_minus(n, N, h, bcx);
399 return EllSparseBlockMat<real_type, thrust::host_vector>();
Some utility functions for the dg::evaluate routines.
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
@ NEU_DIR
Neumann on left, Dirichlet on right boundary.
Definition enums.h:19
@ PER
periodic boundaries
Definition enums.h:16
@ NEU
Neumann on both boundaries.
Definition enums.h:20
@ DIR
homogeneous dirichlet boundaries
Definition enums.h:17
@ DIR_NEU
Dirichlet on left, Neumann on right boundary.
Definition enums.h:18
@ backward
backward derivative (cell to the left and current cell)
Definition enums.h:99
@ forward
forward derivative (cell to the right and current cell)
Definition enums.h:98
@ 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...
static std::vector< real_type > backward(unsigned n)
Return backward DLT trafo matrix.
Definition dlt.h:139
static std::vector< real_type > forward(unsigned n)
Return forward DLT trafo matrix.
Definition dlt.h:195
static constexpr int invalid_index
Definition sparseblockmat.h:49
Creation functions for integration weights and their inverse.