Discontinuous Galerkin Library
#include "dg/algorithm.h"
mpi_grid.h
Go to the documentation of this file.
1#pragma once
2
3#include <cmath>
5#include "dg/enums.h"
6#include "grid.h"
7
12namespace dg
13{
14
25template<class real_type>
26struct RealMPIGrid2d;
27template<class real_type>
28struct RealMPIGrid3d;
30
31
43template<class real_type>
45{
46 using value_type = real_type;
50
56 real_type x0() const { return g.x0();}
62 real_type x1() const { return g.x1(); }
68 real_type y0() const { return g.y0();}
74 real_type y1() const { return g.y1();}
80 real_type lx() const {return g.lx();}
86 real_type ly() const {return g.ly();}
92 real_type hx() const {return g.hx();}
98 real_type hy() const {return g.hy();}
104 unsigned n() const {return g.n();}
106 unsigned nx() const {return g.nx();}
108 unsigned ny() const {return g.ny();}
114 unsigned Nx() const { return g.Nx();}
120 unsigned Ny() const { return g.Ny();}
126 bc bcx() const {return g.bcx();}
132 bc bcy() const {return g.bcy();}
138 MPI_Comm communicator() const{return comm;}
140 const DLT<real_type>& dltx() const{return g.dltx();}
142 const DLT<real_type>& dlty() const{return g.dlty();}
147 unsigned size() const { return g.size();}
152 unsigned local_size() const { return l.size();}
158 void display( std::ostream& os = std::cout) const
159 {
160 os << "GLOBAL GRID \n";
161 g.display();
162 os << "LOCAL GRID \n";
163 l.display();
164 }
165
174 int pidOf( real_type x, real_type y) const;
182 void multiplyCellNumbers( real_type fx, real_type fy){
183 if( fx != 1 || fy != 1)
184 do_set(nx(), round(fx*(real_type)Nx()), ny(), round(fy*(real_type)Ny()));
185 }
187 void set( unsigned new_n, unsigned new_Nx, unsigned new_Ny) {
188 set( new_n, new_Nx, new_n, new_Ny);
189 }
191 void set( unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny) {
192 check_division( new_Nx, new_Ny, g.bcx(), g.bcy());
193 if( new_nx == nx() && new_Nx == Nx() && new_ny == ny() && new_Ny == Ny())
194 return;
195 do_set( new_nx,new_Nx,new_ny,new_Ny);
196 }
205 bool local2globalIdx( int localIdx, int PID, int& globalIdx)const
206 {
207 if( localIdx < 0 || localIdx >= (int)size()) return -1;
208 int coords[2];
209 if( MPI_Cart_coords( comm, PID, 2, coords) != MPI_SUCCESS)
210 return false;
211 int lIdx0 = localIdx %(l.nx()*l.Nx());
212 int lIdx1 = localIdx /(l.nx()*l.Nx());
213 int gIdx0 = coords[0]*l.nx()*l.Nx()+lIdx0;
214 int gIdx1 = coords[1]*l.ny()*l.Ny()+lIdx1;
215 globalIdx = gIdx1*g.nx()*g.Nx() + gIdx0;
216 return true;
217 }
226 bool global2localIdx( int globalIdx, int& localIdx, int& PID)const
227 {
228 if( globalIdx < 0 || globalIdx >= (int)g.size()) return -1;
229 int coords[2];
230 int gIdx0 = globalIdx%(g.nx()*g.Nx());
231 int gIdx1 = globalIdx/(g.nx()*g.Nx());
232 coords[0] = gIdx0/(l.nx()*l.Nx());
233 coords[1] = gIdx1/(l.ny()*l.Ny());
234 int lIdx0 = gIdx0%(l.nx()*l.Nx());
235 int lIdx1 = gIdx1%(l.ny()*l.Ny());
236 localIdx = lIdx1*l.nx()*l.Nx() + lIdx0;
237 if( MPI_Cart_rank( comm, coords, &PID) == MPI_SUCCESS )
238 return true;
239 else
240 {
241 std::cout<<"Failed "<<PID<<"\n";
242 return false;
243 }
244 }
252 const RealGrid2d<real_type>& local() const {return l;}
262 const RealGrid2d<real_type>& global() const {return g;}
263 protected:
266
269 aRealMPITopology2d( RealGrid1d<real_type> gx, RealGrid1d<real_type> gy, MPI_Comm comm): g( gx, gy), l(gx, gy), comm(comm){
270 check_division( gx.N(), gy.N(), gx.bcx(), gy.bcx());
271 update_local();
272 }
278 virtual void do_set( unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny)=0;
279 private:
280 void check_division( unsigned Nx, unsigned Ny, bc bcx, bc bcy)
281 {
282 int rank, dims[2], periods[2], coords[2];
283 MPI_Cart_get( comm, 2, dims, periods, coords);
284 MPI_Comm_rank( comm, &rank);
285 if( rank == 0)
286 {
287 if(Nx%dims[0]!=0)
288 std::cerr << "Nx "<<Nx<<" npx "<<dims[0]<<std::endl;
289 assert( Nx%dims[0] == 0);
290 if(Ny%dims[1]!=0)
291 std::cerr << "Ny "<<Ny<<" npy "<<dims[1]<<std::endl;
292 assert( Ny%dims[1] == 0);
293 if( bcx == dg::PER) assert( periods[0] == true);
294 else assert( periods[0] == false);
295 if( bcy == dg::PER) assert( periods[1] == true);
296 else assert( periods[1] == false);
297 }
298 }
299 void update_local(){
300 int dims[2], periods[2], coords[2];
301 MPI_Cart_get( comm, 2, dims, periods, coords);
302 real_type x0 = g.x0() + g.lx()/(real_type)dims[0]*(real_type)coords[0];
303 real_type x1 = g.x0() + g.lx()/(real_type)dims[0]*(real_type)(coords[0]+1);
304 if( coords[0] == dims[0]-1)
305 x1 = g.x1();
306 real_type y0 = g.y0() + g.ly()/(real_type)dims[1]*(real_type)coords[1];
307 real_type y1 = g.y0() + g.ly()/(real_type)dims[1]*(real_type)(coords[1]+1);
308 if( coords[1] == dims[1]-1)
309 y1 = g.y1();
310 unsigned Nx = g.Nx()/dims[0];
311 unsigned Ny = g.Ny()/dims[1];
313 { x0, x1, g.nx(), Nx, g.bcx()},
314 { y0, y1, g.ny(), Ny, g.bcy()});
315 }
316 RealGrid2d<real_type> g, l; //global and local grid
317 MPI_Comm comm; //just an integer...
318};
319
320
327template<class real_type>
329{
330 using value_type = real_type;
334
340 real_type x0() const { return g.x0();}
346 real_type x1() const { return g.x1();}
352 real_type y0() const { return g.y0();}
358 real_type y1() const { return g.y1();}
364 real_type z0() const { return g.z0();}
370 real_type z1() const { return g.z1();}
376 real_type lx() const {return g.lx();}
382 real_type ly() const {return g.ly();}
388 real_type lz() const {return g.lz();}
394 real_type hx() const {return g.hx();}
400 real_type hy() const {return g.hy();}
406 real_type hz() const {return g.hz();}
412 unsigned n() const {return g.n();}
414 unsigned nx() const {return g.nx();}
416 unsigned ny() const {return g.ny();}
418 unsigned nz() const {return g.nz();}
424 unsigned Nx() const { return g.Nx();}
430 unsigned Ny() const { return g.Ny();}
436 unsigned Nz() const { return g.Nz();}
442 bc bcx() const {return g.bcx();}
448 bc bcy() const {return g.bcy();}
454 bc bcz() const {return g.bcz();}
459 MPI_Comm communicator() const{return comm;}
464 MPI_Comm get_perp_comm() const {return planeComm;}
470 const DLT<real_type>& dlt() const{return g.dlt();}
471 const DLT<real_type>& dltx() const{return g.dltx();}
472 const DLT<real_type>& dlty() const{return g.dlty();}
473 const DLT<real_type>& dltz() const{return g.dltz();}
478 unsigned size() const { return g.size();}
483 unsigned local_size() const { return l.size();}
489 void display( std::ostream& os = std::cout) const
490 {
491 os << "GLOBAL GRID \n";
492 g.display();
493 os << "LOCAL GRID \n";
494 l.display();
495 }
505 int pidOf( real_type x, real_type y, real_type z) const;
507 void multiplyCellNumbers( real_type fx, real_type fy){
508 if( fx != 1 || fy != 1)
509 do_set(nx(), round(fx*(real_type)Nx()), ny(),
510 round(fy*(real_type)Ny()), nz(), Nz());
511 }
513 void set( unsigned new_n, unsigned new_Nx, unsigned new_Ny, unsigned new_Nz) {
514 set(new_n,new_Nx,new_n,new_Ny,1,new_Nz);
515 }
517 void set( unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny, unsigned new_nz, unsigned new_Nz) {
518 check_division( new_Nx,new_Ny,new_Nz,g.bcx(),g.bcy(),g.bcz());
519 if( new_nx == nx() && new_Nx == Nx() && new_ny == ny() && new_Ny == Ny() && new_nz == nz() && new_Nz == Nz())
520 return;
521 do_set(new_nx,new_Nx,new_ny,new_Ny,new_nz,new_Nz);
522 }
524 bool local2globalIdx( int localIdx, int PID, int& globalIdx)const
525 {
526 if( localIdx < 0 || localIdx >= (int)size()) return false;
527 int coords[3];
528 if( MPI_Cart_coords( comm, PID, 3, coords) != MPI_SUCCESS)
529 return false;
530 int lIdx0 = localIdx %(l.nx()*l.Nx());
531 int lIdx1 = (localIdx /(l.nx()*l.Nx())) % (l.ny()*l.Ny());
532 int lIdx2 = localIdx / (l.nx()*l.ny()*l.Nx()*l.Ny());
533 int gIdx0 = coords[0]*l.nx()*l.Nx()+lIdx0;
534 int gIdx1 = coords[1]*l.ny()*l.Ny()+lIdx1;
535 int gIdx2 = coords[2]*l.nz()*l.Nz()+lIdx2;
536 globalIdx = (gIdx2*g.ny()*g.Ny() + gIdx1)*g.nx()*g.Nx() + gIdx0;
537 return true;
538 }
540 bool global2localIdx( int globalIdx, int& localIdx, int& PID)const
541 {
542 if( globalIdx < 0 || globalIdx >= (int)g.size()) return false;
543 int coords[3];
544 int gIdx0 = globalIdx%(g.nx()*g.Nx());
545 int gIdx1 = (globalIdx/(g.nx()*g.Nx())) % (g.ny()*g.Ny());
546 int gIdx2 = globalIdx/(g.nx()*g.ny()*g.Nx()*g.Ny());
547 coords[0] = gIdx0/(l.nx()*l.Nx());
548 coords[1] = gIdx1/(l.ny()*l.Ny());
549 coords[2] = gIdx2/(l.nz()*l.Nz());
550 int lIdx0 = gIdx0%(l.nx()*l.Nx());
551 int lIdx1 = gIdx1%(l.ny()*l.Ny());
552 int lIdx2 = gIdx2%(l.nz()*l.Nz());
553 localIdx = (lIdx2*l.ny()*l.Ny() + lIdx1)*l.nx()*l.Nx() + lIdx0;
554 if( MPI_Cart_rank( comm, coords, &PID) == MPI_SUCCESS )
555 return true;
556 else
557 return false;
558 }
560 const RealGrid3d<real_type>& local() const {return l;}
562 const RealGrid3d<real_type>& global() const {return g;}
563 protected:
566
569 aRealMPITopology3d( RealGrid1d<real_type> gx, RealGrid1d<real_type> gy, RealGrid1d<real_type> gz, MPI_Comm comm): g( gx, gy, gz), l(gx, gy, gz), comm(comm){
570 check_division( gx.N(), gy.N(), gz.N(), gx.bcx(), gy.bcx(), gz.bcx());
571 update_local();
572 int remain_dims[] = {true,true,false}; //true true false
573 MPI_Cart_sub( comm, remain_dims, &planeComm);
574 }
581 virtual void do_set( unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny, unsigned new_nz, unsigned new_Nz)=0;
582 private:
583 void check_division( unsigned Nx, unsigned Ny, unsigned Nz, bc bcx, bc bcy, bc bcz)
584 {
585 int rank, dims[3], periods[3], coords[3];
586 MPI_Cart_get( comm, 3, dims, periods, coords);
587 MPI_Comm_rank( comm, &rank);
588 if( rank == 0)
589 {
590 if(!(Nx%dims[0]==0))
591 std::cerr << "Nx "<<Nx<<" npx "<<dims[0]<<std::endl;
592 assert( Nx%dims[0] == 0);
593 if( !(Ny%dims[1]==0))
594 std::cerr << "Ny "<<Ny<<" npy "<<dims[1]<<std::endl;
595 assert( Ny%dims[1] == 0);
596 if( !(Nz%dims[2]==0))
597 std::cerr << "Nz "<<Nz<<" npz "<<dims[2]<<std::endl;
598 assert( Nz%dims[2] == 0);
599 if( bcx == dg::PER) assert( periods[0] == true);
600 else assert( periods[0] == false);
601 if( bcy == dg::PER) assert( periods[1] == true);
602 else assert( periods[1] == false);
603 if( bcz == dg::PER) assert( periods[2] == true);
604 else assert( periods[2] == false);
605 }
606 }
607 void update_local(){
608 int dims[3], periods[3], coords[3];
609 MPI_Cart_get( comm, 3, dims, periods, coords);
610 real_type x0 = g.x0() + g.lx()/(real_type)dims[0]*(real_type)coords[0];
611 real_type x1 = g.x0() + g.lx()/(real_type)dims[0]*(real_type)(coords[0]+1);
612 if( coords[0] == dims[0]-1)
613 x1 = g.x1();
614
615 real_type y0 = g.y0() + g.ly()/(real_type)dims[1]*(real_type)coords[1];
616 real_type y1 = g.y0() + g.ly()/(real_type)dims[1]*(real_type)(coords[1]+1);
617 if( coords[1] == dims[1]-1)
618 y1 = g.y1();
619
620 real_type z0 = g.z0() + g.lz()/(real_type)dims[2]*(real_type)coords[2];
621 real_type z1 = g.z0() + g.lz()/(real_type)dims[2]*(real_type)(coords[2]+1);
622 if( coords[2] == dims[2]-1)
623 z1 = g.z1();
624 unsigned Nx = g.Nx()/dims[0];
625 unsigned Ny = g.Ny()/dims[1];
626 unsigned Nz = g.Nz()/dims[2];
627
629 { x0, x1, g.nx(), Nx, g.bcx()},
630 { y0, y1, g.ny(), Ny, g.bcy()},
631 { z0, z1, g.nz(), Nz, g.bcz()});
632 }
633 RealGrid3d<real_type> g, l; //global grid
634 MPI_Comm comm, planeComm; //just an integer...
635};
637template<class real_type>
638int aRealMPITopology2d<real_type>::pidOf( real_type x, real_type y) const
639{
640 int dims[2], periods[2], coords[2];
641 MPI_Cart_get( comm, 2, dims, periods, coords);
642 coords[0] = (unsigned)floor( (x-g.x0())/g.lx()*(real_type)dims[0] );
643 coords[1] = (unsigned)floor( (y-g.y0())/g.ly()*(real_type)dims[1] );
644 //if point lies on or over boundary of last cell shift into current cell (not so good for periodic boundaries)
645 coords[0]=(coords[0]==dims[0]) ? coords[0]-1 :coords[0];
646 coords[1]=(coords[1]==dims[1]) ? coords[1]-1 :coords[1];
647 int rank;
648 if( MPI_Cart_rank( comm, coords, &rank) == MPI_SUCCESS )
649 return rank;
650 else
651 return -1;
652}
653template<class real_type>
654int aRealMPITopology3d<real_type>::pidOf( real_type x, real_type y, real_type z) const
655{
656 int dims[3], periods[3], coords[3];
657 MPI_Cart_get( comm, 3, dims, periods, coords);
658 coords[0] = (unsigned)floor( (x-g.x0())/g.lx()*(real_type)dims[0] );
659 coords[1] = (unsigned)floor( (y-g.y0())/g.ly()*(real_type)dims[1] );
660 coords[2] = (unsigned)floor( (z-g.z0())/g.lz()*(real_type)dims[2] );
661 //if point lies on or over boundary of last cell shift into current cell (not so good for periodic boundaries)
662 coords[0]=(coords[0]==dims[0]) ? coords[0]-1 :coords[0];
663 coords[1]=(coords[1]==dims[1]) ? coords[1]-1 :coords[1];
664 coords[2]=(coords[2]==dims[2]) ? coords[2]-1 :coords[2];
665 int rank;
666 if( MPI_Cart_rank( comm, coords, &rank) == MPI_SUCCESS )
667 return rank;
668 else
669 return -1;
670}
671template<class real_type>
672void aRealMPITopology2d<real_type>::do_set( unsigned nx, unsigned Nx, unsigned ny, unsigned Ny) {
673 g.set(nx,Nx,ny,Ny);
674 update_local();
675}
676template<class real_type>
677void aRealMPITopology3d<real_type>::do_set( unsigned nx, unsigned Nx, unsigned ny, unsigned Ny, unsigned nz, unsigned Nz) {
678 g.set(nx,Nx,ny,Ny,nz,Nz);
679 update_local();
680}
681
683
689template<class real_type>
690struct RealMPIGrid2d: public aRealMPITopology2d<real_type>
691{
696 RealMPIGrid2d( real_type x0, real_type x1, real_type y0, real_type y1, unsigned n, unsigned Nx, unsigned Ny, MPI_Comm comm):
697 aRealMPITopology2d<real_type>( {x0,x1,n,Nx,dg::PER},
698 {y0,y1,n,Ny,dg::PER}, comm)
699 { }
700
706 RealMPIGrid2d( real_type x0, real_type x1, real_type y0, real_type y1, unsigned n, unsigned Nx, unsigned Ny, bc bcx, bc bcy, MPI_Comm comm):
707 aRealMPITopology2d<real_type>( {x0,x1,n,Nx,bcx}, {y0,y1,n,Ny,bcy},comm)
708 { }
711 RealMPIGrid2d( RealGrid1d<real_type> gx, RealGrid1d<real_type> gy, MPI_Comm comm): aRealMPITopology2d<real_type>(gx,gy,comm){ }
713 explicit RealMPIGrid2d( const aRealMPITopology2d<real_type>& src): aRealMPITopology2d<real_type>(src){}
714 private:
715 virtual void do_set( unsigned nx, unsigned Nx, unsigned ny, unsigned Ny) override final{
717 }
718};
719
725template<class real_type>
726struct RealMPIGrid3d : public aRealMPITopology3d<real_type>
727{
730 RealMPIGrid3d( 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):
731 aRealMPITopology3d<real_type>( {x0, x1, n, Nx, dg::PER}, {y0, y1, n, Ny, dg::PER}, {z0, z1, 1, Nz, dg::PER}, comm )
732 { }
733
737 RealMPIGrid3d( 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, bc bcx, bc bcy, bc bcz, MPI_Comm comm):
738 aRealMPITopology3d<real_type>( {x0, x1, n, Nx, bcx}, {y0, y1, n, Ny, bcy}, {z0, z1, 1, Nz, bcz}, comm )
739 { }
745 explicit RealMPIGrid3d( const aRealMPITopology3d<real_type>& src): aRealMPITopology3d<real_type>(src){ }
746 private:
747 virtual void do_set( unsigned nx, unsigned Nx, unsigned ny, unsigned Ny, unsigned nz, unsigned Nz) override final{
749 }
750};
751
758namespace x{
763}//namespace x
765
766}//namespace dg
Struct holding coefficients for Discrete Legendre Transformation (DLT) related operations.
Definition: dlt.h:23
enums
base topology classes
bc
Switch between boundary conditions.
Definition: enums.h:15
@ PER
periodic boundaries
Definition: enums.h:16
@ x
x direction
dg::aRealMPITopology2d< double > aMPITopology2d
Definition: mpi_grid.h:756
dg::RealMPIGrid3d< double > MPIGrid3d
Definition: mpi_grid.h:755
dg::RealMPIGrid2d< double > MPIGrid2d
Definition: mpi_grid.h:754
dg::aRealMPITopology3d< double > aMPITopology3d
Definition: mpi_grid.h:757
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
mpi Vector class
Definition: mpi_vector.h:32
1D grid
Definition: grid.h:80
bc bcx() const
boundary conditions
Definition: grid.h:147
unsigned N() const
number of cells
Definition: grid.h:135
The simplest implementation of aRealTopology2d.
Definition: grid.h:818
The simplest implementation of aRealTopology3d.
Definition: grid.h:844
The simplest implementation of aRealMPITopology2d.
Definition: mpi_grid.h:691
RealMPIGrid2d(real_type x0, real_type x1, real_type y0, real_type y1, unsigned n, unsigned Nx, unsigned Ny, MPI_Comm comm)
Equal polynomial coefficients.
Definition: mpi_grid.h:696
RealMPIGrid2d(const aRealMPITopology2d< real_type > &src)
allow explicit type conversion from any other topology
Definition: mpi_grid.h:713
RealMPIGrid2d(RealGrid1d< real_type > gx, RealGrid1d< real_type > gy, MPI_Comm comm)
Construct a 2d grid as the product of two 1d grids.
Definition: mpi_grid.h:711
RealMPIGrid2d(real_type x0, real_type x1, real_type y0, real_type y1, unsigned n, unsigned Nx, unsigned Ny, bc bcx, bc bcy, MPI_Comm comm)
Equal polynomial coefficients.
Definition: mpi_grid.h:706
The simplest implementation of aRealMPITopology3d.
Definition: mpi_grid.h:727
RealMPIGrid3d(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, bc bcx, bc bcy, bc bcz, MPI_Comm comm)
Equal polynomial coefficients.
Definition: mpi_grid.h:737
RealMPIGrid3d(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)
Equal polynomial coefficients.
Definition: mpi_grid.h:730
RealMPIGrid3d(RealGrid1d< real_type > gx, RealGrid1d< real_type > gy, RealGrid1d< real_type > gz, MPI_Comm comm)
Construct a 3d topology as the product of three 1d grids.
Definition: mpi_grid.h:742
RealMPIGrid3d(const aRealMPITopology3d< real_type > &src)
Definition: mpi_grid.h:745
2D MPI abstract grid class
Definition: mpi_grid.h:45
real_type lx() const
Return global lx.
Definition: mpi_grid.h:80
void set(unsigned new_n, unsigned new_Nx, unsigned new_Ny)
Set the number of polynomials and cells.
Definition: mpi_grid.h:187
real_type x1() const
Return global x1.
Definition: mpi_grid.h:62
real_type ly() const
Return global ly.
Definition: mpi_grid.h:86
unsigned n() const
Return n.
Definition: mpi_grid.h:104
bool global2localIdx(int globalIdx, int &localIdx, int &PID) const
Map a global vector index to a local vector Index and the corresponding PID.
Definition: mpi_grid.h:226
real_type hy() const
Return global hy.
Definition: mpi_grid.h:98
const DLT< real_type > & dltx() const
discrete legendre transformation in x
Definition: mpi_grid.h:140
const RealGrid2d< real_type > & local() const
Return a non-MPI grid local for the calling process.
Definition: mpi_grid.h:252
bc bcy() const
global y boundary
Definition: mpi_grid.h:132
unsigned nx() const
number of polynomial coefficients in x
Definition: mpi_grid.h:106
unsigned ny() const
number of polynomial coefficients in y
Definition: mpi_grid.h:108
void multiplyCellNumbers(real_type fx, real_type fy)
Multiply the number of cells with a given factor.
Definition: mpi_grid.h:182
real_type hx() const
Return global hx.
Definition: mpi_grid.h:92
unsigned size() const
The total global number of points.
Definition: mpi_grid.h:147
real_type y0() const
Return global y0.
Definition: mpi_grid.h:68
unsigned Nx() const
Return the global number of cells.
Definition: mpi_grid.h:114
unsigned Ny() const
Return the global number of cells.
Definition: mpi_grid.h:120
real_type y1() const
Return global y1.
Definition: mpi_grid.h:74
real_type value_type
Definition: mpi_grid.h:46
aRealMPITopology2d & operator=(const aRealMPITopology2d &src)=default
virtual void do_set(unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny)=0
This function has an implementation.
const DLT< real_type > & dlty() const
discrete legendre transformation in y
Definition: mpi_grid.h:142
int pidOf(real_type x, real_type y) const
Returns the pid of the process that holds the local grid surrounding the given point.
MPI_Comm communicator() const
Return mpi cartesian communicator that is used in this grid.
Definition: mpi_grid.h:138
aRealMPITopology2d(RealGrid1d< real_type > gx, RealGrid1d< real_type > gy, MPI_Comm comm)
Construct a 2d grid as the product of two 1d grids.
Definition: mpi_grid.h:269
~aRealMPITopology2d()=default
disallow deletion through base class pointer
aRealMPITopology2d(const aRealMPITopology2d &src)=default
const RealGrid2d< real_type > & global() const
Return the global non-MPI grid.
Definition: mpi_grid.h:262
bool local2globalIdx(int localIdx, int PID, int &globalIdx) const
Map a local index plus the PID to a global vector index.
Definition: mpi_grid.h:205
void display(std::ostream &os=std::cout) const
Display global and local grid.
Definition: mpi_grid.h:158
void set(unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny)
Set the number of polynomials and cells.
Definition: mpi_grid.h:191
real_type x0() const
Return global x0.
Definition: mpi_grid.h:56
unsigned local_size() const
The total local number of points.
Definition: mpi_grid.h:152
bc bcx() const
global x boundary
Definition: mpi_grid.h:126
3D MPI Grid class
Definition: mpi_grid.h:329
real_type lz() const
Return global lz.
Definition: mpi_grid.h:388
bc bcz() const
global z boundary
Definition: mpi_grid.h:454
MPI_Comm get_perp_comm() const
MPI Cartesian communicator in the first two dimensions (x and y)
Definition: mpi_grid.h:464
real_type hz() const
Return global hz.
Definition: mpi_grid.h:406
real_type lx() const
Return global lx.
Definition: mpi_grid.h:376
unsigned local_size() const
The total local number of points.
Definition: mpi_grid.h:483
unsigned nz() const
number of polynomial coefficients in z
Definition: mpi_grid.h:418
unsigned Nz() const
Return the global number of cells.
Definition: mpi_grid.h:436
real_type x1() const
Return global x1.
Definition: mpi_grid.h:346
unsigned Ny() const
Return the global number of cells.
Definition: mpi_grid.h:430
aRealMPITopology3d(RealGrid1d< real_type > gx, RealGrid1d< real_type > gy, RealGrid1d< real_type > gz, MPI_Comm comm)
Construct a 3d topology as the product of three 1d grids.
Definition: mpi_grid.h:569
void display(std::ostream &os=std::cout) const
Display global and local grid paramters.
Definition: mpi_grid.h:489
void set(unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny, unsigned new_nz, unsigned new_Nz)
Set the number of polynomials and cells.
Definition: mpi_grid.h:517
MPI_Comm communicator() const
Return mpi cartesian communicator that is used in this grid.
Definition: mpi_grid.h:459
bool local2globalIdx(int localIdx, int PID, int &globalIdx) const
Map a local index plus the PID to a global vector index.
Definition: mpi_grid.h:524
const DLT< real_type > & dltz() const
Definition: mpi_grid.h:473
bool global2localIdx(int globalIdx, int &localIdx, int &PID) const
Map a global vector index to a local vector Index and the corresponding PID.
Definition: mpi_grid.h:540
real_type y1() const
Return global y1.
Definition: mpi_grid.h:358
int pidOf(real_type x, real_type y, real_type z) const
Returns the pid of the process that holds the local grid surrounding the given point.
const DLT< real_type > & dlt() const
The Discrete Legendre Transformation.
Definition: mpi_grid.h:470
bc bcy() const
global y boundary
Definition: mpi_grid.h:448
const RealGrid3d< real_type > & global() const
Return the global non-MPI grid.
Definition: mpi_grid.h:562
real_type ly() const
Return global ly.
Definition: mpi_grid.h:382
real_type z1() const
Return global z1.
Definition: mpi_grid.h:370
void multiplyCellNumbers(real_type fx, real_type fy)
Multiply the number of cells with a given factor.
Definition: mpi_grid.h:507
const DLT< real_type > & dlty() const
Definition: mpi_grid.h:472
real_type hy() const
Return global hy.
Definition: mpi_grid.h:400
unsigned n() const
Return n.
Definition: mpi_grid.h:412
bc bcx() const
global x boundary
Definition: mpi_grid.h:442
virtual void do_set(unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny, unsigned new_nz, unsigned new_Nz)=0
aRealMPITopology3d(const aRealMPITopology3d &src)=default
unsigned ny() const
number of polynomial coefficients in y
Definition: mpi_grid.h:416
~aRealMPITopology3d()=default
disallow deletion through base class pointer
real_type z0() const
Return global z0.
Definition: mpi_grid.h:364
const RealGrid3d< real_type > & local() const
Return a non-MPI grid local for the calling process.
Definition: mpi_grid.h:560
real_type hx() const
Return global hx.
Definition: mpi_grid.h:394
unsigned Nx() const
Return the global number of cells.
Definition: mpi_grid.h:424
unsigned nx() const
number of polynomial coefficients in x
Definition: mpi_grid.h:414
real_type y0() const
Return global y0.
Definition: mpi_grid.h:352
real_type x0() const
Return global x0.
Definition: mpi_grid.h:340
real_type value_type
Definition: mpi_grid.h:330
aRealMPITopology3d & operator=(const aRealMPITopology3d &src)=default
unsigned size() const
The total global number of points.
Definition: mpi_grid.h:478
void set(unsigned new_n, unsigned new_Nx, unsigned new_Ny, unsigned new_Nz)
Set the number of polynomials and cells.
Definition: mpi_grid.h:513
const DLT< real_type > & dltx() const
Definition: mpi_grid.h:471