47template<
class real_type>
49template<
class real_type>
66template<
class real_type>
84 x0_(
x0), x1_(
x1), f_(
f),
85 n_(
n), Nx_(
N), bcx_(
bcx), dlt_(
n)
87 assert( (
f >= 0) && (
f < 0.5) );
88 assert( fabs(
outer_N() -
f*(real_type)
N) < 1e-14);
99 real_type
x0()
const {
return x0_;}
105 real_type
x1()
const {
return x1_;}
111 real_type
f()
const {
return f_;}
117 real_type
lx()
const {
return x1_-x0_;}
123 real_type
h()
const {
return lx()/(real_type)Nx_;}
129 unsigned N()
const {
return Nx_;}
135 unsigned outer_N()
const {
return (
unsigned)(round(f_*(real_type)Nx_));}
147 unsigned n()
const {
return n_;}
159 unsigned size()
const {
return n_*Nx_;}
165 void display( std::ostream& os = std::cout)
const
167 os <<
"RealGrid parameters are: \n"
170 <<
" inner N = "<<
inner_N()<<
"\n"
171 <<
" outer N = "<<
outer_N()<<
"\n"
173 <<
" x0 = "<<x0_<<
"\n"
174 <<
" x1 = "<<x1_<<
"\n"
175 <<
" lx = "<<
lx()<<
"\n"
176 <<
"Boundary conditions in x are: \n"
177 <<
" "<<
bc2str(bcx_)<<
"\n";
199 real_type xleft = x0_ + f_*
lx();
200 real_type xright = x1_ - f_*
lx();
201 if(
x0 >= xleft &&
x0<xright)
203 if(
x1 > xleft) deltaX = (
x1 -xleft);
204 else deltaX = xright -
x1;
205 unsigned N = floor(deltaX/(xright-xleft));
206 if(
x1 > xright )
x1 -=
N*
lx();
209 else if( x0 < xleft && x1 >=xleft)
210 x1 += (xright-xleft);
211 else if(
x0 >= xright &&
x1 < xright)
212 x1 -= (xright-xleft);
226 if( (
x>=x0_ &&
x <= x1_))
return true;
230 real_type x0_, x1_, f_;
255template<
class real_type>
268 real_type
x0()
const {
return x0_;}
274 real_type
x1()
const {
return x1_;}
280 real_type
y0()
const {
return y0_;}
286 real_type
y1()
const {
return y1_;}
292 real_type
lx()
const {
return x1_-x0_;}
298 real_type
ly()
const {
return y1_-y0_;}
304 real_type
hx()
const {
return lx()/(real_type)Nx_;}
310 real_type
hy()
const {
return ly()/(real_type)Ny_;}
316 real_type
fx()
const {
return fx_;}
322 real_type
fy()
const {
return fy_;}
328 unsigned n()
const {
return n_;}
334 unsigned Nx()
const {
return Nx_;}
346 unsigned outer_Nx()
const {
return (
unsigned)round(fx_*(real_type)Nx_);}
352 unsigned Ny()
const {
return Ny_;}
364 unsigned outer_Ny()
const {
return (
unsigned)round(fy_*(real_type)Ny_);}
394 unsigned size()
const {
return n_*n_*Nx_*Ny_;}
400 void display( std::ostream& os = std::cout)
const
402 os <<
"Grid parameters are: \n"
404 <<
" Nx = "<<Nx_<<
"\n"
407 <<
" Ny = "<<Ny_<<
"\n"
410 <<
" hx = "<<
hx()<<
"\n"
411 <<
" hy = "<<
hy()<<
"\n"
412 <<
" x0 = "<<x0_<<
"\n"
413 <<
" x1 = "<<x1_<<
"\n"
414 <<
" y0 = "<<y0_<<
"\n"
415 <<
" y1 = "<<y1_<<
"\n"
416 <<
" lx = "<<
lx()<<
"\n"
417 <<
" ly = "<<
ly()<<
"\n"
418 <<
"Boundary conditions in x are: \n"
420 <<
"Boundary conditions in y are: \n"
421 <<
" "<<
bc2str(bcy_)<<
"\n";
438 if(
x1 > x0_) deltaX = (
x1 -x0_);
439 else deltaX = x1_ -
x1;
440 unsigned N = floor(deltaX/
lx());
444 if(
x0 < x1_ - fx_*(x1_-x0_) )
447 real_type yleft = y0_ + fy_*
ly();
448 real_type yright = y1_ - fy_*
ly();
449 if(
y0 >= yleft &&
y0<yright)
451 if(
y1 > yleft) deltaY = (
y1 -yleft);
452 else deltaY = yright -
y1;
453 unsigned N = floor(deltaY/(yright-yleft));
454 if(
y1 > yright )
y1 -= N*
ly();
455 if(
y1 < yleft )
y1 += N*
ly();
457 else if( y0 < yleft && y1 >=yleft)
458 y1 += (yright-yleft);
459 else if(
y0 >= yright &&
y1 < yright)
460 y1 -= (yright-yleft);
476 if( (
x>=x0_ &&
x <= x1_) && (
y>=y0_ &&
y <= y1_))
return true;
484 aRealTopologyX2d( real_type
x0, real_type
x1, real_type
y0, real_type
y1, real_type
fx, real_type
fy,
unsigned n,
unsigned Nx,
unsigned Ny,
bc bcx,
bc bcy):
488 assert( (fy_ >= 0.) && (fy_ < 0.5) );
489 assert( (fx_ >= 0.) && (fx_ < 1.) );
490 assert( fabs(
outer_Nx() - fx_*(real_type)
Nx) < 1e-14);
491 assert( fabs(
outer_Ny() - fy_*(real_type)
Ny) < 1e-14);
494 assert( Nx_ > 0 &&
Ny > 0 );
502 real_type x0_, x1_, y0_, y1_;
504 unsigned n_, Nx_, Ny_;
512template<
class real_type>
517 RealGridX2d( real_type
x0, real_type
x1, real_type
y0, real_type
y1, real_type
fx, real_type
fy,
unsigned n,
unsigned Nx,
unsigned Ny,
bc bcx=
PER,
bc bcy=
NEU):
518 aRealTopologyX2d<real_type>(
x0,
x1,
y0,
y1,
fx,
fy,
n,
Nx,
Ny,
bcx,
bcy) { }
539template<
class real_type>
551 real_type
x0()
const {
return x0_;}
557 real_type
x1()
const {
return x1_;}
564 real_type
y0()
const {
return y0_;}
570 real_type
y1()
const {
return y1_;}
577 real_type
z0()
const {
return z0_;}
583 real_type
z1()
const {
return z1_;}
590 real_type
lx()
const {
return x1_-x0_;}
596 real_type
ly()
const {
return y1_-y0_;}
602 real_type
lz()
const {
return z1_-z0_;}
609 real_type
hx()
const {
return lx()/(real_type)Nx_;}
615 real_type
hy()
const {
return ly()/(real_type)Ny_;}
621 real_type
hz()
const {
return lz()/(real_type)Nz_;}
627 real_type
fx()
const {
return fx_;}
633 real_type
fy()
const {
return fy_;}
639 unsigned n()
const {
return n_;}
645 unsigned Nx()
const {
return Nx_;}
657 unsigned outer_Nx()
const {
return (
unsigned)round(fx_*(real_type)Nx_);}
663 unsigned Ny()
const {
return Ny_;}
675 unsigned outer_Ny()
const {
return (
unsigned)round(fy_*(real_type)Ny_);}
681 unsigned Nz()
const {
return Nz_;}
706 return RealGrid3d<real_type>( x0_,x1_,y0_,y1_,z0_,z1_,n_,Nx_,Ny_,Nz_,bcx_,bcy_,bcz_);
719 unsigned size()
const {
return n_*n_*Nx_*Ny_*Nz_;}
725 void display( std::ostream& os = std::cout)
const
727 os <<
"Grid parameters are: \n"
729 <<
" Nx = "<<Nx_<<
"\n"
732 <<
" Ny = "<<Ny_<<
"\n"
735 <<
" Nz = "<<Nz_<<
"\n"
736 <<
" hx = "<<
hx()<<
"\n"
737 <<
" hy = "<<
hy()<<
"\n"
738 <<
" hz = "<<
hz()<<
"\n"
739 <<
" x0 = "<<x0_<<
"\n"
740 <<
" x1 = "<<x1_<<
"\n"
741 <<
" y0 = "<<y0_<<
"\n"
742 <<
" y1 = "<<y1_<<
"\n"
743 <<
" z0 = "<<z0_<<
"\n"
744 <<
" z1 = "<<z1_<<
"\n"
745 <<
" lx = "<<
lx()<<
"\n"
746 <<
" ly = "<<
ly()<<
"\n"
747 <<
" lz = "<<
lz()<<
"\n"
748 <<
"Boundary conditions in x are: \n"
750 <<
"Boundary conditions in y are: \n"
752 <<
"Boundary conditions in z are: \n"
753 <<
" "<<
bc2str(bcz_)<<
"\n";
765 bool contains( real_type x, real_type y, real_type z)
const
767 if( (
x>=x0_ &&
x <= x1_) && (
y>=y0_ &&
y <= y1_) && (
z>=z0_ &&
z<=z1_))
776 aRealTopologyX3d( real_type
x0, real_type
x1, real_type
y0, real_type
y1, real_type
z0, real_type
z1, real_type
fx, real_type
fy,
unsigned n,
unsigned Nx,
unsigned Ny,
unsigned Nz,
bc bcx,
bc bcy,
bc bcz):
780 assert( (fy_ >= 0.) && (fy_ < 0.5) );
781 assert( (fx_ >= 0.) && (fx_ < 1.) );
782 assert( fabs(
outer_Nx() - fx_*(real_type)
Nx) < 1e-14);
783 assert( fabs(
outer_Ny() - fy_*(real_type)
Ny) < 1e-14);
786 assert( Nx_ > 0 &&
Ny > 0); assert(
Nz > 0);
793 real_type x0_, x1_, y0_, y1_, z0_, z1_;
795 unsigned n_, Nx_, Ny_, Nz_;
804template<
class real_type>
809 RealGridX3d( real_type
x0, real_type
x1, real_type
y0, real_type
y1, real_type
z0, real_type
z1, real_type
fx, real_type
fy,
unsigned n,
unsigned Nx,
unsigned Ny,
unsigned Nz,
bc bcx=
PER,
bc bcy=
NEU,
bc bcz=
PER):
810 aRealTopologyX3d<real_type>(
x0,
x1,
y0,
y1,
z0,
z1,
fx,
fy,
n,
Nx,
Ny,
Nz,
bcx,
bcy,
bcz) { }
Struct holding coefficients for Discrete Legendre Transformation (DLT) related operations.
Definition: dlt.h:23
The discrete legendre trafo class.
bc
Switch between boundary conditions.
Definition: enums.h:15
static std::string bc2str(bc bcx)
write a string describing boundary condition to an output stream
Definition: enums.h:37
@ PER
periodic boundaries
Definition: enums.h:16
@ NEU
Neumann on both boundaries.
Definition: enums.h:20
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
1D grid
Definition: grid.h:80
The simplest implementation of aRealTopology2d.
Definition: grid.h:818
The simplest implementation of aRealTopology3d.
Definition: grid.h:844
1D grid for X-point topology
Definition: gridX.h:68
RealGridX1d(real_type x0, real_type x1, real_type f, unsigned n, unsigned N, bc bcx=NEU)
1D X-point grid
Definition: gridX.h:83
unsigned inner_N() const
number of cells in the inner region
Definition: gridX.h:141
const DLT< real_type > & dlt() const
the discrete legendre transformation
Definition: gridX.h:184
bool contains(real_type x) const
Check if the grid contains a point.
Definition: gridX.h:224
bc bcx() const
boundary conditions
Definition: gridX.h:153
real_type value_type
Definition: gridX.h:69
unsigned size() const
the total number of points
Definition: gridX.h:159
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
void shift_topologic(real_type x0, real_type &x1) const
Shifts a point coordinate due to topology.
Definition: gridX.h:195
void display(std::ostream &os=std::cout) const
Display.
Definition: gridX.h:165
real_type x0() const
left boundary
Definition: gridX.h:99
unsigned n() const
number of polynomial coefficients
Definition: gridX.h:147
real_type x1() const
right boundary
Definition: gridX.h:105
real_type f() const
Factor.
Definition: gridX.h:111
thrust::host_vector< real_type > host_vector
The host vector type used by host functions like evaluate.
Definition: gridX.h:71
real_type lx() const
total length of interval
Definition: gridX.h:117
real_type h() const
cell size
Definition: gridX.h:123
RealGrid1d< real_type > grid() const
Definition: gridX.h:185
The simplest implementation of aRealTopologyX2d.
Definition: gridX.h:514
RealGridX2d(const aRealTopologyX2d< real_type > &src)
allow explicit type conversion from any other topology
Definition: gridX.h:520
RealGridX2d(real_type x0, real_type x1, real_type y0, real_type y1, real_type fx, real_type fy, unsigned n, unsigned Nx, unsigned Ny, bc bcx=PER, bc bcy=NEU)
Construct a 2D X-point grid.
Definition: gridX.h:517
The simplest implementation of aRealTopologyX3d.
Definition: gridX.h:806
RealGridX3d(real_type x0, real_type x1, real_type y0, real_type y1, real_type z0, real_type z1, real_type fx, real_type fy, unsigned n, unsigned Nx, unsigned Ny, unsigned Nz, bc bcx=PER, bc bcy=NEU, bc bcz=PER)
Construct a 3D X-point grid.
Definition: gridX.h:809
RealGridX3d(const aRealTopologyX3d< real_type > &src)
allow explicit type conversion from any other topology
Definition: gridX.h:812
A 2D grid class with X-point topology.
Definition: gridX.h:257
thrust::host_vector< real_type > host_vector
The host vector type used by host functions like evaluate.
Definition: gridX.h:260
unsigned size() const
real_typehe total number of points
Definition: gridX.h:394
bool contains(real_type x, real_type y) const
Check if the grid contains a point.
Definition: gridX.h:474
real_type hx() const
cell size in x
Definition: gridX.h:304
real_type y0() const
left boundary in y
Definition: gridX.h:280
bc bcy() const
boundary conditions in y
Definition: gridX.h:376
real_type lx() const
length of x
Definition: gridX.h:292
RealGrid2d< real_type > grid() const
Return a copy without topology.
Definition: gridX.h:382
real_type y1() const
Right boundary in y.
Definition: gridX.h:286
aRealTopologyX2d & operator=(const aRealTopologyX2d &src)=default
unsigned Nx() const
number of cells in x
Definition: gridX.h:334
real_type x1() const
Right boundary in x.
Definition: gridX.h:274
real_type x0() const
Left boundary in x.
Definition: gridX.h:268
void display(std::ostream &os=std::cout) const
Display.
Definition: gridX.h:400
real_type fx() const
partition factor in x
Definition: gridX.h:316
aRealTopologyX2d(real_type x0, real_type x1, real_type y0, real_type y1, real_type fx, real_type fy, unsigned n, unsigned Nx, unsigned Ny, bc bcx, bc bcy)
Construct a 2D X-point grid.
Definition: gridX.h:484
bc bcx() const
boundary conditions in x
Definition: gridX.h:370
unsigned inner_Nx() const
number of topological cells in x
Definition: gridX.h:340
unsigned Ny() const
number of cells in y
Definition: gridX.h:352
real_type ly() const
length of y
Definition: gridX.h:298
real_type fy() const
partition factor in y
Definition: gridX.h:322
unsigned outer_Ny() const
number of cells in one of the outer regions of y
Definition: gridX.h:364
real_type hy() const
cell size in y
Definition: gridX.h:310
unsigned n() const
number of polynomial coefficients in x and y
Definition: gridX.h:328
unsigned outer_Nx() const
number of smooth rows in x
Definition: gridX.h:346
void shift_topologic(real_type x0, real_type y0, real_type &x1, real_type &y1) const
Shifts a point coordinate due to topology.
Definition: gridX.h:434
unsigned inner_Ny() const
number of cells in the inner region of y
Definition: gridX.h:358
aRealTopologyX2d(const aRealTopologyX2d &src)=default
~aRealTopologyX2d()=default
disallow destruction through base class pointer
real_type value_type
Definition: gridX.h:258
const DLT< real_type > & dlt() const
discrete legendre trafo
Definition: gridX.h:388
A 3D grid class with X-point topology.
Definition: gridX.h:541
bc bcx() const
boundary conditions in x
Definition: gridX.h:687
RealGrid3d< real_type > grid() const
Return a copy without topology.
Definition: gridX.h:705
aRealTopologyX3d & operator=(const aRealTopologyX3d &src)=default
unsigned n() const
number of polynomial coefficients in x and y
Definition: gridX.h:639
real_type y1() const
right boundary in y
Definition: gridX.h:570
real_type z1() const
right boundary in z
Definition: gridX.h:583
real_type lz() const
length in z
Definition: gridX.h:602
real_type hx() const
cell size in x
Definition: gridX.h:609
aRealTopologyX3d(real_type x0, real_type x1, real_type y0, real_type y1, real_type z0, real_type z1, real_type fx, real_type fy, unsigned n, unsigned Nx, unsigned Ny, unsigned Nz, bc bcx, bc bcy, bc bcz)
Construct a 3D X-point grid.
Definition: gridX.h:776
void display(std::ostream &os=std::cout) const
Display.
Definition: gridX.h:725
const DLT< real_type > & dlt() const
discrete legendre transformation
Definition: gridX.h:713
real_type fx() const
partition factor in x
Definition: gridX.h:627
unsigned Nz() const
number of points in z
Definition: gridX.h:681
unsigned inner_Ny() const
number of cells in the inner region of y
Definition: gridX.h:669
real_type hy() const
cell size in y
Definition: gridX.h:615
unsigned Ny() const
number of cells in y
Definition: gridX.h:663
real_type hz() const
cell size in z
Definition: gridX.h:621
unsigned Nx() const
number of points in x
Definition: gridX.h:645
bc bcy() const
boundary conditions in y
Definition: gridX.h:693
unsigned size() const
real_typehe total number of points
Definition: gridX.h:719
~aRealTopologyX3d()=default
disallow destruction through base class pointer
real_type z0() const
left boundary in z
Definition: gridX.h:577
real_type y0() const
left boundary in y
Definition: gridX.h:564
thrust::host_vector< real_type > host_vector
The host vector type used by host functions like evaluate.
Definition: gridX.h:544
unsigned inner_Nx() const
number of topological cells in x
Definition: gridX.h:651
real_type value_type
Definition: gridX.h:542
real_type x0() const
left boundary in x
Definition: gridX.h:551
unsigned outer_Ny() const
number of cells in one of the outer regions of y
Definition: gridX.h:675
real_type x1() const
right boundary in x
Definition: gridX.h:557
real_type ly() const
length in y
Definition: gridX.h:596
real_type fy() const
partition factor in y
Definition: gridX.h:633
bc bcz() const
boundary conditions in z
Definition: gridX.h:699
bool contains(real_type x, real_type y, real_type z) const
Check if the grid contains a point.
Definition: gridX.h:765
aRealTopologyX3d(const aRealTopologyX3d &src)=default
real_type lx() const
length in x
Definition: gridX.h:590
unsigned outer_Nx() const
number of smooth rows in x
Definition: gridX.h:657