4#include <cusp/coo_matrix.h>
5#include <cusp/csr_matrix.h>
32template<
class real_type>
33std::vector<real_type> coefficients( real_type xn,
unsigned n)
35 assert( xn <= 1. && xn >= -1.);
36 std::vector<real_type> px(n);
39 for(
unsigned u=0; u<n; u++)
40 px[u] = (u%2 == 0) ? +1. : -1.;
44 for(
unsigned i=0; i<n; i++)
53 for(
unsigned i=1; i<n-1; i++)
54 px[i+1] = ((real_type)(2*i+1)*xn*px[i]-(real_type)i*px[i-1])/(real_type)(i+1);
61template<
class real_type>
62std::vector<real_type> lagrange( real_type x,
const std::vector<real_type>& xi)
64 unsigned n = xi.size();
65 std::vector<real_type> l( n , 1.);
66 for(
unsigned i=0; i<n; i++)
67 for(
unsigned k=0; k<n; k++)
70 l[i] *= (
x-xi[k])/(xi[i]-xi[k]);
76template<
class real_type>
77std::vector<real_type> choose_1d_abscissas( real_type X,
78 unsigned points_per_line,
const RealGrid1d<real_type>& g,
79 const thrust::host_vector<real_type>& abs,
80 thrust::host_vector<unsigned>& cols)
82 assert( abs.size() >= points_per_line &&
"There must be more points to interpolate\n");
85 real_type xnn = (X-g.x0())/g.h();
86 unsigned n = (unsigned)floor(xnn);
88 if (n==g.N() && bcx !=
dg::PER) {
92 std::vector<real_type> xs( points_per_line, 0);
94 auto it = std::lower_bound( abs.begin()+n*g.n(), abs.begin() + (n+1)*g.n(),
96 cols.resize( points_per_line, 0);
97 switch( points_per_line)
100 if( it == abs.begin())
102 else if( it == abs.end())
103 cols[0] = it - abs.begin() - 1;
106 if ( fabs(X - *it) < fabs( X - *(it-1)))
107 cols[0] = it - abs.begin();
109 cols[0] = it - abs.begin() -1;
112 case 2:
if( it == abs.begin())
117 xs[1] = *(abs.end() -1)-g.lx();;
118 cols[0] = 0, cols[1] = abs.end()-abs.begin()-1;
131 else if( it == abs.end())
135 xs[0] = *(abs.begin())+g.lx();
137 cols[0] = 0, cols[1] = it-abs.begin()-1;
148 cols[0] = it-abs.begin()-1;
155 cols[0] = it - abs.begin() - 1;
159 case 4:
if( it <= abs.begin() +1)
163 xs[0] = *abs.begin(), cols[0] = 0;
164 xs[1] = *(abs.begin()+1), cols[1] = 1;
165 xs[2] = it == abs.begin() ? *(abs.end() -2) : *(abs.begin()+2);
166 cols[2] = it == abs.begin() ? abs.end()-abs.begin() -2 : 2;
167 xs[3] = *(abs.end() -1);
168 cols[3] = abs.end()-abs.begin() -1;
173 xs[0] = *it, xs[1] = *(it+1);
174 xs[2] = *(it+2), xs[3] = *(it+3);
175 cols[0] = 0, cols[1] = 1;
176 cols[2] = 2, cols[3] = 3;
179 else if( it >= abs.end() -1)
183 xs[0] = *abs.begin(), cols[0] = 0;
184 xs[1] = it == abs.end() ? *(abs.begin()+1) : *(abs.end() -3) ;
185 cols[1] = it == abs.end() ? 1 : abs.end()-abs.begin()-3 ;
186 xs[2] = *(abs.end() - 2), cols[2] = abs.end()-abs.begin()-2;
187 xs[3] = *(abs.end() - 1), cols[3] = abs.end()-abs.begin()-1;
192 xs[0] = *(it-4), xs[1] = *(it-3);
193 xs[2] = *(it-2), xs[3] = *(it-1);
194 cols[0] = it - abs.begin() - 4;
202 xs[0] = *(it-2), xs[1] = *(it-1);
203 xs[2] = *(it ), xs[3] = *(it+1);
204 cols[0] = it - abs.begin() - 2;
253template<
class real_type>
255 const thrust::host_vector<real_type>& x,
258 std::string method =
"dg")
260 cusp::array1d<real_type, cusp::host_memory> values;
261 cusp::array1d<int, cusp::host_memory> row_indices;
262 cusp::array1d<int, cusp::host_memory> column_indices;
266 for(
unsigned i=0; i<
x.size(); i++)
269 bool negative =
false;
270 g.
shift( negative, X, bcx);
273 real_type xnn = (X-g.
x0())/g.
h();
274 unsigned n = (unsigned)floor(xnn);
276 real_type xn = 2.*xnn - (real_type)(2*n+1);
283 std::vector<real_type> px = detail::coefficients( xn, g.
n());
285 std::vector<real_type> pxF(px.size(),0);
286 for(
unsigned l=0; l<g.
n(); l++)
287 for(
unsigned k=0; k<g.
n(); k++)
289 unsigned cols = n*g.
n();
290 for (
unsigned l=0; l<g.
n(); l++)
292 row_indices.push_back(i);
293 column_indices.push_back( cols + l);
294 values.push_back(negative ? -pxF[l] : pxF[l]);
300 unsigned points_per_line = 1;
301 if( method ==
"nearest")
303 else if( method ==
"linear")
305 else if( method ==
"cubic")
308 throw std::runtime_error(
"Interpolation method "+method+
" not recognized!\n");
309 thrust::host_vector<real_type> abs = dg::create::abscissas( g);
311 for(
unsigned i=0; i<
x.size(); i++)
314 bool negative =
false;
315 g.
shift( negative, X, bcx);
317 thrust::host_vector<unsigned> cols;
318 std::vector<real_type> xs = detail::choose_1d_abscissas( X,
319 points_per_line, gx, abs, cols);
321 std::vector<real_type> px = detail::lagrange( X, xs);
323 for (
unsigned l=0; l<px.size(); l++)
325 row_indices.push_back(i);
326 column_indices.push_back( cols[l]);
327 values.push_back(negative ? -px[l] : px[l]);
331 cusp::coo_matrix<int, real_type, cusp::host_memory> A(
332 x.size(), g.
size(), values.size());
333 A.row_indices = row_indices;
334 A.column_indices = column_indices;
360template<
class real_type>
362 const thrust::host_vector<real_type>& x,
363 const thrust::host_vector<real_type>& y,
366 std::string method =
"dg")
368 assert(
x.size() ==
y.size());
369 cusp::array1d<real_type, cusp::host_memory> values;
370 cusp::array1d<int, cusp::host_memory> row_indices;
371 cusp::array1d<int, cusp::host_memory> column_indices;
374 std::vector<real_type> gauss_nodesx = g.
dltx().abscissas();
375 std::vector<real_type> gauss_nodesy = g.
dlty().abscissas();
380 for(
int i=0; i<(int)
x.size(); i++)
382 real_type X =
x[i], Y =
y[i];
384 g.
shift( negative,X,Y, bcx, bcy);
387 real_type xnn = (X-g.
x0())/g.
hx();
388 real_type ynn = (Y-g.
y0())/g.
hy();
389 unsigned nn = (unsigned)floor(xnn);
390 unsigned mm = (unsigned)floor(ynn);
392 real_type xn = 2.*xnn - (real_type)(2*nn+1);
393 real_type yn = 2.*ynn - (real_type)(2*mm+1);
404 int idxX =-1, idxY = -1;
405 for(
unsigned k=0; k<g.
nx(); k++)
407 if( fabs( xn - gauss_nodesx[k]) < 1e-14)
408 idxX = nn*g.
nx() + k;
410 for(
unsigned k=0; k<g.
ny(); k++)
412 if( fabs( yn - gauss_nodesy[k]) < 1e-14)
413 idxY = mm*g.
ny() + k;
415 if( idxX < 0 && idxY < 0 )
418 std::vector<real_type> px = detail::coefficients( xn, g.
nx()),
419 py = detail::coefficients( yn, g.
ny());
420 std::vector<real_type> pxF(g.
nx(),0), pyF(g.
ny(), 0);
421 for(
unsigned l=0; l<g.
nx(); l++)
422 for(
unsigned k=0; k<g.
nx(); k++)
423 pxF[l]+= px[k]*forwardx(k,l);
424 for(
unsigned l=0; l<g.
ny(); l++)
425 for(
unsigned k=0; k<g.
ny(); k++)
426 pyF[l]+= py[k]*forwardy(k,l);
428 for(
unsigned k=0; k<g.
ny(); k++)
429 for(
unsigned l=0; l<g.
nx(); l++)
431 row_indices.push_back( i);
432 column_indices.push_back( ((mm*g.
ny()+k)*g.
Nx()+nn)*g.
nx() + l);
433 real_type pxy = pyF[k]*pxF[l];
435 values.push_back( pxy);
437 values.push_back( -pxy);
440 else if ( idxX < 0 && idxY >=0)
442 std::vector<real_type> px = detail::coefficients( xn, g.
nx());
443 std::vector<real_type> pxF(g.
nx(),0);
444 for(
unsigned l=0; l<g.
nx(); l++)
445 for(
unsigned k=0; k<g.
nx(); k++)
446 pxF[l]+= px[k]*forwardx(k,l);
447 for(
unsigned l=0; l<g.
nx(); l++)
449 row_indices.push_back( i);
450 column_indices.push_back( ((idxY)*g.
Nx() + nn)*g.
nx() + l);
452 values.push_back( pxF[l]);
454 values.push_back(-pxF[l]);
458 else if ( idxX >= 0 && idxY < 0)
460 std::vector<real_type> py = detail::coefficients( yn, g.
ny());
461 std::vector<real_type> pyF(g.
ny(),0);
462 for(
unsigned l=0; l<g.
ny(); l++)
463 for(
unsigned k=0; k<g.
ny(); k++)
464 pyF[l]+= py[k]*forwardy(k,l);
465 for(
unsigned k=0; k<g.
ny(); k++)
467 row_indices.push_back(i);
468 column_indices.push_back((mm*g.
ny()+k)*g.
Nx()*g.
nx() + idxX);
470 values.push_back( pyF[k]);
472 values.push_back(-pyF[k]);
478 row_indices.push_back(i);
479 column_indices.push_back(idxY*g.
Nx()*g.
nx() + idxX);
481 values.push_back( 1.);
483 values.push_back(-1.);
490 unsigned points_per_line = 1;
491 if( method ==
"nearest")
493 else if( method ==
"linear")
495 else if( method ==
"cubic")
498 throw std::runtime_error(
"Interpolation method "+method+
" not recognized!\n");
501 thrust::host_vector<real_type> absX = dg::create::abscissas( gx);
502 thrust::host_vector<real_type> absY = dg::create::abscissas( gy);
504 for(
unsigned i=0; i<
x.size(); i++)
506 real_type X =
x[i], Y =
y[i];
507 bool negative =
false;
508 g.
shift( negative, X, Y, bcx, bcy);
510 thrust::host_vector<unsigned> colsX, colsY;
511 std::vector<real_type> xs = detail::choose_1d_abscissas( X,
512 points_per_line, gx, absX, colsX);
513 std::vector<real_type> ys = detail::choose_1d_abscissas( Y,
514 points_per_line, gy, absY, colsY);
517 std::vector<real_type> pxy( points_per_line*points_per_line);
518 std::vector<real_type> px = detail::lagrange( X, xs),
519 py = detail::lagrange( Y, ys);
521 for(
unsigned k=0; k<py.size(); k++)
522 for(
unsigned l=0; l<px.size(); l++)
523 pxy[k*px.size()+l]= py[k]*px[l];
524 for(
unsigned k=0; k<py.size(); k++)
525 for(
unsigned l=0; l<px.size(); l++)
527 if( fabs(pxy[k*px.size() +l]) > 1e-14)
529 row_indices.push_back( i);
530 column_indices.push_back( (colsY[k])*g.
nx()*g.
Nx() +
532 values.push_back( negative ? - pxy[k*px.size()+l]
533 : pxy[k*px.size()+l]);
538 cusp::coo_matrix<int, real_type, cusp::host_memory> A(
x.size(),
539 g.
size(), values.size());
540 A.row_indices = row_indices;
541 A.column_indices = column_indices;
572template<
class real_type>
574 const thrust::host_vector<real_type>& x,
575 const thrust::host_vector<real_type>& y,
576 const thrust::host_vector<real_type>& z,
579 std::string method =
"dg")
581 assert(
x.size() ==
y.size());
582 assert(
y.size() ==
z.size());
583 cusp::array1d<real_type, cusp::host_memory> values;
584 cusp::array1d<int, cusp::host_memory> row_indices;
585 cusp::array1d<int, cusp::host_memory> column_indices;
589 std::vector<real_type> gauss_nodesx = g.
dltx().abscissas();
590 std::vector<real_type> gauss_nodesy = g.
dlty().abscissas();
591 std::vector<real_type> gauss_nodesz = g.
dltz().abscissas();
595 for(
int i=0; i<(int)
x.size(); i++)
597 real_type X =
x[i], Y =
y[i], Z =
z[i];
598 bool negative =
false;
599 g.
shift( negative,X,Y,Z, bcx, bcy, bcz);
602 real_type xnn = (X-g.
x0())/g.
hx();
603 real_type ynn = (Y-g.
y0())/g.
hy();
604 real_type znn = (Z-g.
z0())/g.
hz();
605 unsigned nn = (unsigned)floor(xnn);
606 unsigned mm = (unsigned)floor(ynn);
607 unsigned ll = (unsigned)floor(znn);
609 real_type xn = 2.*xnn - (real_type)(2*nn+1);
610 real_type yn = 2.*ynn - (real_type)(2*mm+1);
611 real_type zn = 2.*znn - (real_type)(2*ll+1);
626 int idxX =-1, idxY = -1, idxZ = -1;
627 for(
unsigned k=0; k<g.
nx(); k++)
629 if( fabs( xn - gauss_nodesx[k]) < 1e-14)
630 idxX = nn*g.
nx() + k;
632 for(
unsigned k=0; k<g.
ny(); k++)
634 if( fabs( yn - gauss_nodesy[k]) < 1e-14)
635 idxY = mm*g.
ny() + k;
637 for(
unsigned k=0; k<g.
nz(); k++)
639 if( fabs( zn - gauss_nodesz[k]) < 1e-14)
640 idxZ = ll*g.
nz() + k;
642 if( idxX >= 0 && idxY >= 0 && idxZ >= 0)
644 row_indices.push_back(i);
645 column_indices.push_back((idxZ*g.
Ny()*g.
ny()+idxY)*g.
Nx()*g.
nx() + idxX);
647 values.push_back( 1.);
649 values.push_back(-1.);
651 else if ( idxX < 0 && idxY >=0 && idxZ >= 0)
653 std::vector<real_type> px = detail::coefficients( xn, g.
nx());
654 std::vector<real_type> pxF(g.
nx(),0);
655 for(
unsigned l=0; l<g.
nx(); l++)
656 for(
unsigned k=0; k<g.
nx(); k++)
657 pxF[l]+= px[k]*forwardx(k,l);
658 for(
unsigned l=0; l<g.
nx(); l++)
660 row_indices.push_back( i);
661 column_indices.push_back( (idxZ*g.
Ny()*g.
ny() +
662 idxY)*g.
Nx()*g.
nx() + nn*g.
nx() + l);
664 values.push_back( pxF[l]);
666 values.push_back(-pxF[l]);
669 else if ( idxX >= 0 && idxY < 0 && idxZ >= 0)
671 std::vector<real_type> py = detail::coefficients( yn, g.
ny());
672 std::vector<real_type> pyF(g.
ny(),0);
673 for(
unsigned l=0; l<g.
ny(); l++)
674 for(
unsigned k=0; k<g.
ny(); k++)
675 pyF[l]+= py[k]*forwardy(k,l);
676 for(
unsigned k=0; k<g.
ny(); k++)
678 row_indices.push_back(i);
679 column_indices.push_back(((idxZ*g.
Ny()+mm)*g.
ny()+k)*g.
Nx()*g.
nx() + idxX);
681 values.push_back( pyF[k]);
683 values.push_back(-pyF[k]);
689 std::vector<real_type> px = detail::coefficients( xn, g.
nx()),
690 py = detail::coefficients( yn, g.
ny()),
691 pz = detail::coefficients( zn, g.
nz());
692 std::vector<real_type> pxF(g.
nx(),0), pyF(g.
ny(), 0), pzF( g.
nz(), 0);
693 for(
unsigned l=0; l<g.
nx(); l++)
694 for(
unsigned k=0; k<g.
nx(); k++)
695 pxF[l]+= px[k]*forwardx(k,l);
696 for(
unsigned l=0; l<g.
ny(); l++)
697 for(
unsigned k=0; k<g.
ny(); k++)
698 pyF[l]+= py[k]*forwardy(k,l);
699 for(
unsigned l=0; l<g.
nz(); l++)
700 for(
unsigned k=0; k<g.
nz(); k++)
701 pzF[l]+= pz[k]*forwardz(k,l);
703 for(
unsigned s=0; s<g.
nz(); s++)
704 for(
unsigned k=0; k<g.
ny(); k++)
705 for(
unsigned l=0; l<g.
nx(); l++)
707 row_indices.push_back( i);
708 column_indices.push_back(
709 ((((ll*g.
nz()+s)*g.
Ny()+mm)*g.
ny()+k)*g.
Nx()+nn)*g.
nx()+l);
710 real_type pxyz = pzF[s]*pyF[k]*pxF[l];
712 values.push_back( pxyz);
714 values.push_back(-pxyz);
721 unsigned points_per_line = 1;
722 if( method ==
"nearest")
724 else if( method ==
"linear")
726 else if( method ==
"cubic")
729 throw std::runtime_error(
"Interpolation method "+method+
" not recognized!\n");
733 thrust::host_vector<real_type> absX = dg::create::abscissas( gx);
734 thrust::host_vector<real_type> absY = dg::create::abscissas( gy);
735 thrust::host_vector<real_type> absZ = dg::create::abscissas( gz);
736 for(
unsigned i=0; i<
x.size(); i++)
738 real_type X =
x[i], Y =
y[i], Z =
z[i];
739 bool negative =
false;
740 g.
shift( negative, X, Y, Z, bcx, bcy, bcz);
742 thrust::host_vector<unsigned> colsX, colsY, colsZ;
743 std::vector<real_type> xs = detail::choose_1d_abscissas( X,
744 points_per_line, gx, absX, colsX);
745 std::vector<real_type> ys = detail::choose_1d_abscissas( Y,
746 points_per_line, gy, absY, colsY);
747 std::vector<real_type> zs = detail::choose_1d_abscissas( Z,
748 points_per_line, gz, absZ, colsZ);
751 std::vector<real_type> pxyz( points_per_line*points_per_line
753 std::vector<real_type> px = detail::lagrange( X, xs),
754 py = detail::lagrange( Y, ys),
755 pz = detail::lagrange( Z, zs);
757 for(
unsigned m=0; m<pz.size(); m++)
758 for(
unsigned k=0; k<py.size(); k++)
759 for(
unsigned l=0; l<px.size(); l++)
760 pxyz[(m*py.size()+k)*px.size()+l]= pz[m]*py[k]*px[l];
761 for(
unsigned m=0; m<pz.size(); m++)
762 for(
unsigned k=0; k<py.size(); k++)
763 for(
unsigned l=0; l<px.size(); l++)
765 if( fabs(pxyz[(m*py.size()+k)*px.size() +l]) > 1e-14)
767 row_indices.push_back( i);
768 column_indices.push_back( ((colsZ[m])*g.
ny()*g.
Ny() +
769 colsY[k])*g.
nx()*g.
Nx() + colsX[l]);
770 values.push_back( negative ?
771 -pxyz[(m*py.size()+k)*px.size()+l]
772 : pxyz[(m*py.size()+k)*px.size()+l] );
777 cusp::coo_matrix<int, real_type, cusp::host_memory> A(
x.size(), g.
size(),
779 A.row_indices = row_indices;
780 A.column_indices = column_indices;
803template<
class real_type>
807 assert( g_new.
x0() >= g_old.
x0());
808 assert( g_new.
x1() <= g_old.
x1());
814template<
class real_type>
818 assert( g_new.
x0() >= g_old.
x0());
819 assert( g_new.
x1() <= g_old.
x1());
820 assert( g_new.
y0() >= g_old.
y0());
821 assert( g_new.
y1() <= g_old.
y1());
830template<
class real_type>
834 assert( g_new.
x0() >= g_old.
x0());
835 assert( g_new.
x1() <= g_old.
x1());
836 assert( g_new.
y0() >= g_old.
y0());
837 assert( g_new.
y1() <= g_old.
y1());
838 assert( g_new.
z0() >= g_old.
z0());
839 assert( g_new.
z1() <= g_old.
z1());
847template<
class real_type>
851 assert( g_new.
x0() >= g_old.
x0());
852 assert( g_new.
x1() <= g_old.
x1());
853 assert( g_new.
y0() >= g_old.
y0());
854 assert( g_new.
y1() <= g_old.
y1());
883template<
class real_type>
886 const thrust::host_vector<real_type>& v,
891 assert( v.size() == g.
size());
892 bool negative =
false;
893 g.
shift( negative,
x, bcx);
897 real_type xnn = (
x-g.
x0())/g.
h();
898 unsigned n = (unsigned)floor(xnn);
901 real_type xn = 2.*xnn - (real_type)(2*n+1);
908 std::vector<real_type> px = create::detail::coefficients( xn, g.
n());
912 std::vector<real_type> pxF(g.
n(),0);
913 for(
unsigned l=0; l<g.
n(); l++)
914 for(
unsigned k=0; k<g.
n(); k++)
916 for(
unsigned k=0; k<g.
n(); k++)
920 unsigned cols = (n)*g.
n();
923 for(
unsigned j=0; j<g.
n(); j++)
926 value -= v[cols + j]*px[j];
928 value += v[cols + j]*px[j];
952template<
class real_type>
955 const thrust::host_vector<real_type>& v,
956 real_type x, real_type y,
960 assert( v.size() == g.
size());
961 bool negative =
false;
962 g.
shift( negative,
x,
y, bcx, bcy);
966 real_type xnn = (
x-g.
x0())/g.
hx();
967 real_type ynn = (
y-g.
y0())/g.
hy();
968 unsigned n = (unsigned)floor(xnn);
969 unsigned m = (unsigned)floor(ynn);
972 real_type xn = 2.*xnn - (real_type)(2*n+1);
973 real_type yn = 2.*ynn - (real_type)(2*m+1);
984 std::vector<real_type> px = create::detail::coefficients( xn, g.
nx()),
985 py = create::detail::coefficients( yn, g.
ny());
990 std::vector<real_type> pxF(g.
nx(),0), pyF(g.
ny(), 0);
991 for(
unsigned l=0; l<g.
nx(); l++)
992 for(
unsigned k=0; k<g.
nx(); k++)
993 pxF[l]+= px[k]*forwardx(k,l);
994 for(
unsigned l=0; l<g.
ny(); l++)
995 for(
unsigned k=0; k<g.
ny(); k++)
996 pyF[l]+= py[k]*forwardy(k,l);
1000 unsigned cols = (m)*g.
Nx()*g.
ny()*g.
nx() + (n)*g.
nx();
1002 real_type value = 0;
1003 for(
unsigned i=0; i<g.
ny(); i++)
1004 for(
unsigned j=0; j<g.
nx(); j++)
1007 value -= v[cols + i*g.
Nx()*g.
nx() + j]*px[j]*py[i];
1009 value += v[cols + i*g.
Nx()*g.
nx() + j]*px[j]*py[i];
Function discretization routines.
Some utility functions for the dg::evaluate routines.
static DG_DEVICE double cooX1d(double x)
Definition: functions.h:38
static DG_DEVICE double cooY2d(double x, double y)
Definition: functions.h:45
static DG_DEVICE double cooZ3d(double x, double y, double z)
Definition: functions.h:49
static DG_DEVICE double cooY3d(double x, double y, double z)
Definition: functions.h:47
static DG_DEVICE double cooX2d(double x, double y)
Definition: functions.h:40
static DG_DEVICE double cooX3d(double x, double y, double z)
Definition: functions.h:42
bc
Switch between boundary conditions.
Definition: enums.h:15
space
Space of DG coefficients.
Definition: enums.h:164
@ PER
periodic boundaries
Definition: enums.h:16
@ NEU
Neumann on both boundaries.
Definition: enums.h:20
@ xspace
Configuration space "nodal values".
Definition: enums.h:166
@ forward
forward derivative (cell to the right and current cell)
Definition: enums.h:98
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
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
real_type interpolate(dg::space sp, const thrust::host_vector< real_type > &v, real_type x, const RealGrid1d< real_type > &g, dg::bc bcx=dg::NEU)
Interpolate a vector on a single point on a 1d Grid.
Definition: interpolation.h:884
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
1D grid
Definition: grid.h:80
real_type h() const
cell size
Definition: grid.h:129
bc bcx() const
boundary conditions
Definition: grid.h:147
unsigned n() const
number of polynomial coefficients
Definition: grid.h:141
const DLT< real_type > & dlt() const
the discrete legendre transformation
Definition: grid.h:197
void shift(bool &negative, real_type &x) const
Shift any point coordinate to a corresponding grid coordinate according to the boundary condition.
Definition: grid.h:214
unsigned size() const
n()*N() (Total number of grid points)
Definition: grid.h:191
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
An abstract base class for two-dimensional grids.
Definition: grid.h:277
const DLT< real_type > & dltx() const
discrete legendre trafo
Definition: grid.h:372
void shift(bool &negative, real_type &x, real_type &y) const
Shift any point coordinate to a corresponding grid coordinate according to the boundary condition.
Definition: grid.h:454
real_type x0() const
Left boundary in x.
Definition: grid.h:288
const DLT< real_type > & dlty() const
discrete legendre transformation in y
Definition: grid.h:374
real_type y1() const
Right boundary in y.
Definition: grid.h:306
real_type hy() const
cell size in y
Definition: grid.h:330
unsigned ny() const
number of polynomial coefficients in y
Definition: grid.h:340
bc bcx() const
boundary conditions in x
Definition: grid.h:358
unsigned size() const
The total number of points.
Definition: grid.h:424
real_type hx() const
cell size in x
Definition: grid.h:324
real_type y0() const
left boundary in y
Definition: grid.h:300
unsigned Nx() const
number of cells in x
Definition: grid.h:346
bc bcy() const
boundary conditions in y
Definition: grid.h:364
real_type x1() const
Right boundary in x.
Definition: grid.h:294
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
unsigned size() const
The total number of points.
Definition: grid.h:670
const DLT< real_type > & dltz() const
discrete legendre transformation in z
Definition: grid.h:658
const DLT< real_type > & dltx() const
discrete legendre transformation in x
Definition: grid.h:654
unsigned nz() const
number of polynomial coefficients in z
Definition: grid.h:616
bc bcz() const
boundary conditions in z
Definition: grid.h:652
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
void shift(bool &negative, real_type &x, real_type &y, real_type &z) const
Shift any point coordinate to a corresponding grid coordinate according to the boundary condition.
Definition: grid.h:710
const DLT< real_type > & dlty() const
discrete legendre transformation in y
Definition: grid.h:656
real_type x0() const
left boundary in x
Definition: grid.h:534
real_type hy() const
cell size in y
Definition: grid.h:598
real_type y1() const
right boundary in y
Definition: grid.h:553
real_type hx() const
cell size in x
Definition: grid.h:592
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
bc bcy() const
boundary conditions in y
Definition: grid.h:646
bc bcx() const
boundary conditions in x
Definition: grid.h:640
real_type hz() const
cell size in z
Definition: grid.h:604
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
Useful typedefs of commonly used types.