42template<
class real_type,
size_t Nd>
93template<
class real_type,
size_t Nd>
106 constexpr static unsigned ndim() {
return Nd;}
128 int dims[Nd], periods[Nd], coords[Nd];
129 mpi_cart_get( m_comm, Nd, dims, periods, coords);
130 real_type global_x0 = m_g.p(u);
131 real_type global_hx = m_g.h(u);
132 thrust::host_vector<real_type> abs(m_l.shape(u));
134 auto idx = increment( partition( m_g.N(u), dims[u]));
135 for(
unsigned i=0; i<m_l.N(u); i++)
137 for(
unsigned j=0; j<m_l.n(u); j++)
139 unsigned coord = idx[coords[u]] + i;
140 real_type xmiddle = DG_FMA( global_hx, (real_type)(coord), global_x0);
141 real_type h2 = global_hx/2.;
142 real_type absj = 1.+aa[j];
143 abs[i*m_l.n(u)+j] = DG_FMA( h2, absj, xmiddle);
160 throw Error(
Message(
_ping_)<<
"u>Nd not allowed! You typed: "<<u<<
" while Nd is "<<Nd);
161 thrust::host_vector<real_type> v( m_l.shape(u));
163 real_type hu = m_g.h(u);
164 for(
unsigned i=0; i<m_l.N(u); i++)
165 for(
unsigned j=0; j<m_l.n(u); j++)
166 v[i*m_l.n(u) + j] = hu/2.*ww[j];
176 std::array<host_vector,Nd> abs;
177 for(
unsigned u=0; u<Nd; u++)
183 std::array<host_vector,Nd> w;
184 for(
unsigned u=0; u<Nd; u++)
189 std::array<real_type,Nd>
get_p()
const{
193 std::array<real_type,Nd>
get_q()
const{
197 std::array<real_type,Nd>
get_l()
const{
201 std::array<real_type,Nd>
get_h()
const{
205 std::array<unsigned, Nd>
get_N()
const
210 std::array<unsigned, Nd>
get_n()
const
221 std::array<MPI_Comm, Nd>
get_comms()
const {
return m_comms;}
224 real_type
p(
unsigned u=0)
const {
return m_g.p(u);}
226 real_type
q(
unsigned u=0)
const {
return m_g.q(u);}
228 real_type
h(
unsigned u=0)
const {
return m_g.h(u);}
230 real_type
l(
unsigned u=0)
const {
return m_g.l(u);}
232 unsigned n(
unsigned u=0)
const {
return m_g.n(u);}
234 unsigned N(
unsigned u=0)
const {
return m_g.N(u);}
236 dg::bc bc(
unsigned u=0)
const {
return m_g.bc(u);}
243 MPI_Comm
comm(
unsigned u)
const {
return m_comms.at(u);}
245 template<
size_t Md = Nd>
246 std::enable_if_t<Md==1,MPI_Comm>
comm()
const {
return m_comms.at(0);}
263 template<
size_t Md = Nd>
275 throw Error(
Message(
_ping_)<<
"u>Nd not allowed! You typed: "<<u<<
" while Nd is "<<Nd);
291 template<
size_t Md = Nd>
292 real_type
x0()
const {
return m_g.x0();}
294 template<
size_t Md = Nd>
295 real_type
x1()
const {
return m_g.x1();}
297 template<
size_t Md = Nd>
298 real_type
y0()
const {
return m_g.y0();}
300 template<
size_t Md = Nd>
301 real_type
y1()
const {
return m_g.y1();}
303 template<
size_t Md = Nd>
304 real_type
z0()
const {
return m_g.z0();}
306 template<
size_t Md = Nd>
307 real_type
z1()
const {
return m_g.z1();}
310 template<
size_t Md = Nd>
311 real_type
lx()
const {
return m_g.lx();}
313 template<
size_t Md = Nd>
314 real_type
ly()
const {
return m_g.ly();}
316 template<
size_t Md = Nd>
317 real_type
lz()
const {
return m_g.lz();}
320 template<
size_t Md = Nd>
321 real_type
hx()
const {
return m_g.hx();}
323 template<
size_t Md = Nd>
324 real_type
hy()
const {
return m_g.hy();}
326 template<
size_t Md = Nd>
327 real_type
hz()
const {
return m_g.hz();}
330 template<
size_t Md = Nd>
331 unsigned nx()
const {
return m_g.nx();}
333 template<
size_t Md = Nd>
334 unsigned ny()
const {
return m_g.ny();}
336 template<
size_t Md = Nd>
337 unsigned nz()
const {
return m_g.nz();}
340 template<
size_t Md = Nd>
341 unsigned Nx()
const {
return m_g.Nx();}
343 template<
size_t Md = Nd>
344 unsigned Ny()
const {
return m_g.Ny();}
346 template<
size_t Md = Nd>
347 unsigned Nz()
const {
return m_g.Nz();}
350 template<
size_t Md = Nd>
353 template<
size_t Md = Nd>
356 template<
size_t Md = Nd>
360 template<
size_t Md = Nd>
362 static_assert( Nd > 0);
366 template<
size_t Md = Nd>
368 static_assert( Nd > 1);
372 template<
size_t Md = Nd>
374 static_assert( Nd > 2);
380 template<
size_t Md = Nd>
383 auto Ns = m_g.get_N();
384 Ns[0] = round(fx*(real_type)m_g.N(0));
385 Ns[1] = round(fy*(real_type)m_g.N(1));
386 if( fx != 1 or fy != 1)
387 set( m_g.get_n(), Ns);
390 template<
size_t Md = Nd>
391 std::enable_if_t<(Md == 1),
void>
set(
unsigned new_n,
unsigned new_Nx)
393 set(std::array{new_n}, std::array{new_Nx});
396 template<
size_t Md = Nd>
397 std::enable_if_t<(Md == 2),
void>
set(
unsigned new_n,
unsigned new_Nx,
400 set(std::array{new_n,new_n}, std::array{new_Nx,new_Ny});
403 template<
size_t Md = Nd>
404 std::enable_if_t<(Md == 3),
void>
set(
unsigned new_n,
unsigned new_Nx,
405 unsigned new_Ny,
unsigned new_Nz)
407 set(std::array{new_n,new_n,1u}, std::array{new_Nx,new_Ny,new_Nz});
410 void set(
unsigned new_n, std::array<unsigned,Nd> new_N)
412 std::array<unsigned , Nd> tmp;
413 for(
unsigned u=0; u<Nd; u++)
418 void set_axis(
unsigned coord,
unsigned new_n ,
unsigned new_N)
420 auto n = m_g.get_n(),
N = m_g.get_N();
426 void set( std::array<unsigned,Nd> new_n, std::array<unsigned,Nd> new_N)
428 if( new_n==m_g.get_n() && new_N == m_g.get_N())
433 void set_pq( std::array<real_type,Nd> new_p, std::array<real_type,Nd> new_q)
448 unsigned size()
const {
return m_g.size();}
461 void display( std::ostream& os = std::cout)
const
463 os <<
"GLOBAL GRID \n";
465 os <<
"LOCAL GRID \n";
470 template<
size_t Md = Nd>
471 std::enable_if_t<(Md == 1),
bool>
contains( real_type x)
const
473 return m_g.contains(
x);
477 template<
class Vector>
478 bool contains(
const Vector& x)
const {
return m_g.contains(
x);}
496 if( localIdx < 0 || localIdx >= (
int)m_g.size())
return false;
498 int dims[Nd], periods[Nd], coords[Nd];
499 if( mpi_cart_get( m_comm, Nd, dims, periods, coords) != MPI_SUCCESS)
502 if( mpi_cart_coords( m_comm, rank, Nd, coords) != MPI_SUCCESS)
505 int current = localIdx;
506 for(
unsigned u=0; u<Nd; u++)
508 auto idx = increment(partition( m_g.N(u), dims[u]));
509 unsigned shapeu = (idx[coords[u]+1] - idx[coords[u]])*m_g.n(u);
510 int lIdx = current %shapeu;
511 current = current / shapeu;
512 gIdx[u] = lIdx + idx[coords[u]]*m_g.n(u);
514 globalIdx = gIdx[int(Nd)-1];
515 for(
int u=
int(Nd)-2; u>=0; u--)
516 globalIdx = globalIdx*m_g.shape(u) + gIdx[u];
534 if( globalIdx < 0 || globalIdx >= (
int)m_g.size())
return false;
536 int dims[Nd], periods[Nd], coords[Nd];
537 if( dg::mpi_cart_get( m_comm, Nd, dims, periods, coords) != MPI_SUCCESS)
540 int lIdx[Nd] = {0}, local_shape[Nd] = {0};
541 int current = globalIdx;
544 for(
unsigned u=0; u<Nd; u++)
546 int gIdx = current%(m_g.shape(u));
547 current = current / (m_g.shape(u));
548 auto idx = increment(partition( m_g.N(u), dims[u]));
550 for(
unsigned c=0; c<idx.size()-1; c++)
551 if(
unsigned(gIdx)< idx[c+1]*m_g.n(u))
554 lIdx[u] = gIdx - idx[c]*m_g.n(u);
555 local_shape[u] = (idx[c+1]-idx[c])*m_g.n(u);
559 localIdx = lIdx[int(Nd)-1];
560 for(
int u=
int(Nd)-2; u>=0; u--)
561 localIdx = localIdx*local_shape[u] + lIdx[u];
563 if( mpi_cart_rank( m_comm, coords, &rank) == MPI_SUCCESS )
578 std::array<unsigned, Nd>
start()
const
580 int dims[Nd], periods[Nd], coords[Nd];
581 mpi_cart_get( m_comm, Nd, dims, periods, coords);
582 std::array<unsigned, Nd>
start;
583 for(
unsigned u=0;u<Nd; u++)
585 auto idx = increment(partition( m_g.N(u), dims[u]));
586 start[Nd-1-u] = idx[coords[u]]*m_g.n(u);
598 std::array<unsigned, Nd>
count()
const {
return m_l.count(); }
619 std::array<unsigned,Nd> n, std::array<unsigned,Nd>
N,
620 std::array<dg::bc,Nd> bcs, std::array<MPI_Comm, Nd> comms) :
621 m_g(
p,
q,
n,
N,bcs), m_comms(comms)
625 for (
unsigned u=0; u<Nd;u++)
627 mpi_cartdim_get( m_comms[u], &ndims);
628 assert( (
unsigned)ndims == 1);
631 mpi_cartdim_get( m_comm, &ndims);
632 assert( (
unsigned)ndims == Nd);
635 int dims[Nd], periods[Nd], coords[Nd];
636 mpi_cart_get( m_comm, Nd, dims, periods, coords);
637 for(
unsigned u=0;u<Nd; u++)
639 auto idx = increment(partition( m_g.N(u), dims[u]));
640 N[u] = idx[coords[u]+1]-idx[coords[u]] ;
642 p[u] = m_g.p(u) + m_g.h(u)*idx[coords[u]];
643 q[u] = m_g.p(u) + m_g.h(u)*idx[coords[u] +1];
645 if( coords[u] == dims[u]-1)
648 m_l = {
p,
q, m_g.get_n(),
N, m_g.get_bc()};
653 std::array<RealGrid<real_type,1>,Nd> globals, locals;
654 for(
unsigned u=0; u<Nd; u++)
656 globals[u] = axes[u].global();
657 locals[u] = axes[u].local();
658 m_comms[u] = axes[u].communicator();
670 virtual void do_set(std::array<unsigned,Nd> new_n, std::array<unsigned,Nd> new_N) =0;
672 virtual void do_set_pq( std::array<real_type, Nd> new_p, std::array<real_type,Nd> new_q) =0;
674 virtual void do_set( std::array<dg::bc, Nd> new_bcs) =0;
706 void check_periods( std::array<dg::bc, Nd>
bc)
const
708 if constexpr ( Nd > 0)
710 int rank, dims[Nd], periods[Nd], coords[Nd];
711 mpi_cart_get( m_comm, Nd, dims, periods, coords);
712 MPI_Comm_rank( m_comm, &rank);
715 for(
unsigned u=0; u<Nd; u++)
717 if(
bc[u] ==
dg::PER) assert( periods[u] ==
true);
718 else assert( periods[u] ==
false);
723 std::vector<unsigned> partition(
unsigned N,
unsigned r)
const
726 std::vector<unsigned> points(r,
N/r );
727 for(
unsigned u=0; u<
N%r; u++)
732 std::vector<unsigned> increment(
const std::vector<unsigned>& partition)
const
737 std::vector<unsigned> inc( partition.size()+1, 0);
738 for(
unsigned u=0; u<inc.size(); u++)
739 for(
unsigned k=0; k<u; k++)
740 inc[u] += partition[k];
744 RealGrid<real_type, Nd> m_g, m_l;
745 std::array<MPI_Comm, Nd> m_comms;
751template<
class real_type,
size_t Nd>
754 if constexpr ( Nd > 0)
756 m_g.set(new_n, new_N);
757 int dims[Nd], periods[Nd], coords[Nd];
758 mpi_cart_get( m_comm, Nd, dims, periods, coords);
759 std::array<unsigned, Nd> N;
760 for(
unsigned u=0;u<Nd; u++)
762 auto idx = increment(partition( m_g.N(u), dims[u]));
763 N[u] = idx[coords[u]+1]-idx[coords[u]] ;
769template<
class real_type,
size_t Nd>
772 if constexpr ( Nd > 0)
775 int dims[Nd], periods[Nd], coords[Nd];
776 mpi_cart_get( m_comm, Nd, dims, periods, coords);
777 std::array<real_type,Nd> p, q;
778 for(
unsigned u=0;u<Nd; u++)
780 auto idx = increment(partition( m_g.N(u), dims[u]));
781 p[u] = m_g.p(u) + m_g.h(u)*idx[coords[u]];
782 q[u] = m_g.p(u) + m_g.h(u)*idx[coords[u] +1];
787template<
class real_type,
size_t Nd>
802template<
class real_type,
size_t Nd>
807 template<
size_t Md = Nd>
814 template<
size_t Md = Nd>
821 template<
size_t Md = Nd>
823 unsigned n,
unsigned Nx,
unsigned Ny, MPI_Comm
comm):
825 {
x0,
y0},{
x1,
y1},{n,n},{
Nx,
Ny},{
dg::PER,
dg::PER},
832 template<
size_t Md = Nd>
837 {
x0,
y0},{
x1,
y1},{n,n},{
Nx,
Ny},{
bcx,
bcy},
842 template<
size_t Md = Nd>
844 real_type
z0, real_type
z1,
unsigned n,
unsigned Nx,
unsigned Ny,
845 unsigned Nz, MPI_Comm
comm):
847 {
x0,
y0,
z0},{
x1,
y1,
z1},{n,n,1},{
Nx,
Ny,
Nz},{
dg::PER,
dg::PER,
dg::PER},
854 template<
size_t Md = Nd>
856 real_type
z0, real_type
z1,
unsigned n,
unsigned Nx,
unsigned Ny,
859 {
x0,
y0,
z0},{
x1,
y1,
z1},{n,n,1},{
Nx,
Ny,
Nz},{
bcx,
bcy,
bcz},
873 template<
class ...Grid1ds>
879 std::array<unsigned,Nd> n, std::array<unsigned,Nd>
N,
880 std::array<dg::bc,Nd> bcs, std::array<MPI_Comm,Nd> comms) :
889 virtual void do_set( std::array<unsigned,Nd> new_n, std::array<unsigned,Nd> new_N)
override final{
892 virtual void do_set_pq( std::array<real_type,Nd> new_x0, std::array<real_type,Nd> new_x1)
override final{
895 virtual void do_set( std::array<dg::bc,Nd> new_bcs)
override final{
class intended for the use in throw statements
Definition exceptions.h:83
small class holding a stringstream
Definition exceptions.h:29
#define _ping_
Definition exceptions.h:12
bc
Switch between boundary conditions.
Definition enums.h:15
@ PER
periodic boundaries
Definition enums.h:16
dg::RealMPIGrid< double, 1 > MPIGrid1d
Definition mpi_grid.h:903
dg::aRealMPITopology< double, 2 > aMPITopology2d
Definition mpi_grid.h:908
dg::aRealMPITopology< double, 3 > aMPITopology3d
Definition mpi_grid.h:909
dg::RealMPIGrid< double, 3 > MPIGrid3d
Definition mpi_grid.h:905
dg::RealMPIGrid< double, 0 > MPIGrid0d
Definition mpi_grid.h:902
dg::RealMPIGrid< double, 2 > MPIGrid2d
Definition mpi_grid.h:904
std::array< MPI_Comm, Nd > mpi_cart_split_as(MPI_Comm comm)
Same as mpi_cart_split but different return type.
Definition mpi_kron.h:282
MPI_Comm mpi_cart_kron(std::vector< MPI_Comm > comms)
Form a (transposed) Kronecker product among Cartesian communicators.
Definition mpi_kron.h:184
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
static std::vector< real_type > abscissas(unsigned n)
Return Gauss-Legendre nodes on the interval [-1,1].
Definition dlt.h:27
static std::vector< real_type > weights(unsigned n)
Return Gauss-Legendre weights.
Definition dlt.h:83
A simple wrapper around a container object and an MPI_Comm.
Definition mpi_vector.h:37
The simplest implementation of aRealTopology.
Definition grid.h:710
The simplest implementation of aRealMPITopology3d.
Definition mpi_grid.h:804
RealMPIGrid()=default
construct an empty grid this leaves the access functions undefined
RealMPIGrid(std::array< real_type, Nd > p, std::array< real_type, Nd > q, std::array< unsigned, Nd > n, std::array< unsigned, Nd > N, std::array< dg::bc, Nd > bcs, std::array< MPI_Comm, Nd > comms)
Construct a topology directly from points and dimensions.
Definition mpi_grid.h:878
RealMPIGrid(real_type x0, real_type x1, real_type y0, real_type y1, real_type z0, real_type z1, unsigned n, unsigned Nx, unsigned Ny, unsigned Nz, MPI_Comm comm)
Construct with equal polynomial coefficients.
Definition mpi_grid.h:843
RealMPIGrid(const std::array< RealMPIGrid< real_type, 1 >, Nd > &axes)
Construct a topology as the product of 1d axes grids.
Definition mpi_grid.h:864
RealMPIGrid(real_type x0, real_type x1, unsigned n, unsigned Nx, dg::bc bcx, MPI_Comm comm)
1D grid
Definition mpi_grid.h:815
RealMPIGrid(const aRealMPITopology< real_type, Nd > &src)
Definition mpi_grid.h:886
RealMPIGrid(const RealMPIGrid< real_type, 1 > &g0, const Grid1ds &...gs)
Construct from given 1d grids Equivalent to RealMPIGrid( std::array{g0,gs...})
Definition mpi_grid.h:874
RealMPIGrid(real_type x0, real_type x1, real_type y0, real_type y1, real_type z0, real_type z1, unsigned n, unsigned Nx, unsigned Ny, unsigned Nz, dg::bc bcx, dg::bc bcy, dg::bc bcz, MPI_Comm comm)
Construct with equal polynomial coefficients.
Definition mpi_grid.h:855
RealMPIGrid(real_type x0, real_type x1, real_type y0, real_type y1, unsigned n, unsigned Nx, unsigned Ny, MPI_Comm comm)
Construct with equal polynomial coefficients.
Definition mpi_grid.h:822
RealMPIGrid(real_type x0, real_type x1, real_type y0, real_type y1, unsigned n, unsigned Nx, unsigned Ny, dg::bc bcx, dg::bc bcy, MPI_Comm comm)
Construct with equal polynomial coefficients.
Definition mpi_grid.h:833
RealMPIGrid(real_type x0, real_type x1, unsigned n, unsigned N, MPI_Comm comm)
Definition mpi_grid.h:808
An abstract base class for MPI distributed Nd-dimensional dG grids.
Definition mpi_grid.h:95
std::array< real_type, Nd > get_h() const
Get grid constant for all axes.
Definition mpi_grid.h:201
std::array< real_type, Nd > get_p() const
Get left boundary point .
Definition mpi_grid.h:189
std::enable_if_t<(Md==3), void > set(unsigned new_n, unsigned new_Nx, unsigned new_Ny, unsigned new_Nz)
Set n and N in a 3-dimensional grid.
Definition mpi_grid.h:404
std::array< host_vector, Nd > get_abscissas() const
Construct abscissas for all axes.
Definition mpi_grid.h:175
virtual void do_set(std::array< dg::bc, Nd > new_bcs)=0
Reset the boundary conditions of the grid.
std::enable_if_t<(Md >=2), void > multiplyCellNumbers(real_type fx, real_type fy)
Multiply the number of cells in the first two dimensions with a given factor.
Definition mpi_grid.h:381
std::array< unsigned, Nd > count() const
Count vector in C-order for dg::file::MPINcHyperslab.
Definition mpi_grid.h:598
real_type l(unsigned u=0) const
Get grid length for axis u.
Definition mpi_grid.h:230
real_type hz() const
Equivalent to h(2)
Definition mpi_grid.h:327
RealMPIGrid< real_type, 1 > gz() const
Equivalent to grid(2)
Definition mpi_grid.h:373
std::enable_if_t<(Md==1), bool > contains(real_type x) const
Check if the grid contains a point.
Definition mpi_grid.h:471
void set_axis(unsigned coord, unsigned new_n, unsigned new_N)
Set n and N for axis coord.
Definition mpi_grid.h:418
MPI_Comm comm(unsigned u) const
Get 1d Cartesian communicator for axis u.
Definition mpi_grid.h:243
std::array< real_type, Nd > get_l() const
Get grid length for all axes.
Definition mpi_grid.h:197
void set(std::array< unsigned, Nd > new_n, std::array< unsigned, Nd > new_N)
Set the number of polynomials and cells.
Definition mpi_grid.h:426
unsigned Ny() const
Equivalent to N(1)
Definition mpi_grid.h:344
dg::bc bcx() const
Equivalent to bc(0)
Definition mpi_grid.h:351
dg::bc bcy() const
Equivalent to bc(1)
Definition mpi_grid.h:354
std::array< unsigned, Nd > get_shape() const
the total number of points of an axis
Definition mpi_grid.h:171
unsigned shape(unsigned u=0) const
the total number of points of an axis
Definition mpi_grid.h:111
real_type z1() const
Equivalent to q(2)
Definition mpi_grid.h:307
aRealMPITopology()=default
default constructor
std::array< host_vector, Nd > get_weights() const
Construct weights for all axes.
Definition mpi_grid.h:182
~aRealMPITopology()=default
disallow deletion through base class pointer
dg::bc bc(unsigned u=0) const
Get boundary condition for axis u.
Definition mpi_grid.h:236
void set(unsigned new_n, std::array< unsigned, Nd > new_N)
Same as set( {new_n, new_n,...}, new_N);
Definition mpi_grid.h:410
aRealMPITopology(const std::array< RealMPIGrid< real_type, 1 >, Nd > &axes)
Construct a topology as the product of 1d axes grids.
Definition mpi_grid.h:651
unsigned n(unsigned u=0) const
Get number of polynomial coefficients for axis u.
Definition mpi_grid.h:232
RealMPIGrid< real_type, 1 > axis(unsigned u) const
An alias for "grid".
Definition mpi_grid.h:278
aRealMPITopology(std::array< real_type, Nd > p, std::array< real_type, Nd > q, std::array< unsigned, Nd > n, std::array< unsigned, Nd > N, std::array< dg::bc, Nd > bcs, std::array< MPI_Comm, Nd > comms)
Construct a topology directly from points and dimensions.
Definition mpi_grid.h:618
std::array< unsigned, Nd > start() const
The global start coordinate in C-order of dg::file::MPINcHyperslab that the local grid represents.
Definition mpi_grid.h:578
dg::bc bcz() const
Equivalent to bc(2)
Definition mpi_grid.h:357
unsigned size() const
The total global number of points.
Definition mpi_grid.h:448
std::enable_if_t< Md==1, MPI_Comm > comm() const
Equivalent to comm(0)
Definition mpi_grid.h:246
unsigned local_size() const
The total local number of points.
Definition mpi_grid.h:453
unsigned Nx() const
Equivalent to N(0)
Definition mpi_grid.h:341
bool contains(const Vector &x) const
Check if the grid contains a point.
Definition mpi_grid.h:478
real_type y0() const
Equivalent to p(2)
Definition mpi_grid.h:298
const RealGrid< real_type, Nd > & global() const
The global grid as a shared memory grid.
Definition mpi_grid.h:288
host_vector weights(unsigned u=0) const
Get the weights of the u axis.
Definition mpi_grid.h:157
unsigned N(unsigned u=0) const
Get number of cells for axis u.
Definition mpi_grid.h:234
real_type ly() const
Equivalent to l(1)
Definition mpi_grid.h:314
virtual void do_set(std::array< unsigned, Nd > new_n, std::array< unsigned, Nd > new_N)=0
Set the number of polynomials and cells.
std::array< real_type, Nd > get_q() const
Get right boundary point .
Definition mpi_grid.h:193
static constexpr unsigned ndim()
Dimensionality == Nd.
Definition mpi_grid.h:106
real_type value_type
value type of abscissas and weights
Definition mpi_grid.h:99
real_type y1() const
Equivalent to q(0)
Definition mpi_grid.h:301
virtual void do_set_pq(std::array< real_type, Nd > new_p, std::array< real_type, Nd > new_q)=0
Reset the boundaries of the grid.
std::array< MPI_Comm, Nd > get_comms() const
Get 1d Cartesian communicator for all axes.
Definition mpi_grid.h:221
MPI_Comm communicator() const
Return Nd dimensional MPI cartesian communicator that is used in this grid.
Definition mpi_grid.h:257
real_type lx() const
Equivalent to l(0)
Definition mpi_grid.h:311
std::enable_if_t<(Md==1), void > set(unsigned new_n, unsigned new_Nx)
Set n and N in a 1-dimensional grid.
Definition mpi_grid.h:391
std::enable_if_t<(Md >=2), MPI_Comm > get_perp_comm() const
MPI Cartesian communicator in the first two dimensions (x and y)
Definition mpi_grid.h:264
host_vector abscissas(unsigned u=0) const
Get the grid abscissas of the u axis.
Definition mpi_grid.h:124
real_type hy() const
Equivalent to h(1)
Definition mpi_grid.h:324
RealMPIGrid< real_type, 1 > gy() const
Equivalent to grid(1)
Definition mpi_grid.h:367
real_type h(unsigned u=0) const
Get grid constant for axis u.
Definition mpi_grid.h:228
real_type z0() const
Equivalent to q(1)
Definition mpi_grid.h:304
std::array< dg::bc, Nd > get_bc() const
Get boundary condition for all axes.
Definition mpi_grid.h:215
RealMPIGrid< real_type, 1 > gx() const
Equivalent to grid(0)
Definition mpi_grid.h:361
std::array< unsigned, Nd > get_n() const
Get number of polynomial coefficients for all axes.
Definition mpi_grid.h:210
void display(std::ostream &os=std::cout) const
Display global and local grid paramters.
Definition mpi_grid.h:461
real_type x0() const
Equivalent to p(0)
Definition mpi_grid.h:292
real_type lz() const
Equivalent to l(2)
Definition mpi_grid.h:317
void set_pq(std::array< real_type, Nd > new_p, std::array< real_type, Nd > new_q)
Reset the boundaries of the grid.
Definition mpi_grid.h:433
aRealMPITopology(const aRealMPITopology &src)=default
real_type hx() const
Equivalent to h(0)
Definition mpi_grid.h:321
aRealMPITopology & operator=(const aRealMPITopology &src)=default
std::array< unsigned, Nd > get_N() const
Get number of cells for all axes.
Definition mpi_grid.h:205
unsigned nx() const
Equivalent to n(0)
Definition mpi_grid.h:331
unsigned Nz() const
Equivalent to N(2)
Definition mpi_grid.h:347
bool global2localIdx(int globalIdx, int &localIdx, int &rank) const
Convert the global index of a vector to a local index and the rank of the containing process.
Definition mpi_grid.h:531
const RealGrid< real_type, Nd > & local() const
The local grid as a shared memory grid.
Definition mpi_grid.h:283
RealMPIGrid< real_type, 1 > grid(unsigned u) const
Get axis u as a 1d grid.
Definition mpi_grid.h:271
void set_bcs(std::array< dg::bc, Nd > new_bcs)
Reset the boundary conditions of the grid.
Definition mpi_grid.h:438
std::enable_if_t<(Md==2), void > set(unsigned new_n, unsigned new_Nx, unsigned new_Ny)
Set n and N in a 2-dimensional grid.
Definition mpi_grid.h:397
real_type p(unsigned u=0) const
Get left boundary point for axis u.
Definition mpi_grid.h:224
real_type q(unsigned u=0) const
Get right boundary point for axis u.
Definition mpi_grid.h:226
real_type x1() const
Equivalent to p(1)
Definition mpi_grid.h:295
unsigned ny() const
Equivalent to n(1)
Definition mpi_grid.h:334
bool local2globalIdx(int localIdx, int rank, int &globalIdx) const
Convert the index of a local vector and the rank of the containing process to a global index.
Definition mpi_grid.h:491
unsigned nz() const
Equivalent to n(2)
Definition mpi_grid.h:337