15template<
class real_type>
16struct RealCurvilinearProductMPIGrid3d;
24template<
class real_type>
37 dg::
aRealMPIGeometry2d<real_type>( {0,
generator.width(), tx.
n, tx.
N, tx.
b}, {0.,
generator.height(), ty.n, ty.N, ty.b}, comm), m_handle(
generator)
40 RealCurvilinearGrid2d<real_type> g(
generator, tx, ty);
41 divide_and_conquer(g);
58 virtual void do_set(
unsigned nx,
unsigned Nx,
unsigned ny,
unsigned Ny)
override final
62 divide_and_conquer(g);
64 void divide_and_conquer(
const RealCurvilinearGrid2d<real_type>& g_)
68 std::vector<thrust::host_vector<real_type> >
map = g_.map();
69 for(
unsigned i=0; i<3; i++)
70 for(
unsigned j=0; j<3; j++)
72 m_metric.idx(i,j) =
metric.idx(i,j);
76 m_jac.values().resize(
jacobian.values().size());
79 m_metric.values().resize(
metric.values().size());
80 for(
unsigned i=0; i<
metric.values().
size(); i++)
82 m_map.resize(
map.size());
83 for(
unsigned i=0; i<
map.size(); i++)
87 virtual SparseTensor<MPI_Vector<thrust::host_vector<real_type>>> do_compute_jacobian( ) const override final{
90 virtual SparseTensor<MPI_Vector<thrust::host_vector<real_type>>> do_compute_metric( ) const override final{
93 virtual std::vector<MPI_Vector<thrust::host_vector<real_type>>> do_compute_map()const override final{
return m_map;}
95 std::vector<MPI_Vector<thrust::host_vector<real_type>>> m_map;
104template<
class real_type>
112 RealCurvilinearProductMPIGrid3d(
generator, {
n,
Nx,
bcx}, {
n,
Ny,
bcy}, {0.,2.*
M_PI,1,
Nz,
bcz}, comm){}
119 dg::
aRealProductMPIGeometry3d<real_type>( {0,
generator.width(), tx.
n, tx.
N, tx.
b}, {0.,
generator.height(), ty.n, ty.N, ty.b}, gz, comm),
125 constructParallel(this->
nz(), this->
local().
Nz());
143 virtual void do_set(
unsigned nx,
unsigned Nx,
unsigned ny,
unsigned Ny,
unsigned nz,
unsigned Nz)
override final
151 constructParallel(this->
nz(), this->
local().
Nz());
153 void constructPerp( RealCurvilinearMPIGrid2d<real_type>& g2d)
155 m_jac=g2d.jacobian();
158 void constructParallel(
unsigned nz,
unsigned localNz )
163 unsigned size2d = this->
nx()*this->
ny()*this->
local().Nx()*this->
local().Ny();
165 MPI_Comm comm = this->
communicator(), comm_mod, comm_mod_reduce;
166 exblas::mpi_reduce_communicator( comm, &comm_mod, &comm_mod_reduce);
167 for(
unsigned r=0; r<6;r++)
169 m_jac.values()[r].data().resize(
size);
170 m_jac.values()[r].set_communicator( comm, comm_mod, comm_mod_reduce);
172 m_map[0].data().resize(
size);
173 m_map[0].set_communicator( comm, comm_mod, comm_mod_reduce);
174 m_map[1].data().resize(
size);
175 m_map[1].set_communicator( comm, comm_mod, comm_mod_reduce);
177 for(
unsigned k=1; k<
nz*localNz; k++)
178 for(
unsigned i=0; i<size2d; i++)
180 for(
unsigned r=0; r<6; r++)
181 m_jac.values()[r].data()[k*size2d+i] = m_jac.values()[r].data()[(k-1)*size2d+i];
182 m_map[0].data()[k*size2d+i] = m_map[0].data()[(k-1)*size2d+i];
183 m_map[1].data()[k*size2d+i] = m_map[1].data()[(k-1)*size2d+i];
186 virtual SparseTensor<MPI_Vector<thrust::host_vector<real_type>>> do_compute_jacobian( ) const override final{
189 virtual SparseTensor<MPI_Vector<thrust::host_vector<real_type>>> do_compute_metric( ) const override final{
190 return detail::square( m_jac, m_map[0], m_handle->isOrthogonal());
192 virtual std::vector<MPI_Vector<thrust::host_vector<real_type>>> do_compute_map()const override final{
return m_map;}
194 std::vector<MPI_Vector<thrust::host_vector<real_type>>> m_map;
195 ClonePtr<dg::geo::aRealGenerator2d<real_type>> m_handle;
198template<
class real_type>
200 dg::aRealMPIGeometry2d<real_type>( g.global().gx(), g.global().gy(), g.get_perp_comm() ),
201 m_handle(g.generator())
208 unsigned s = this->
local().size();
209 MPI_Comm comm = g.get_perp_comm(), comm_mod, comm_mod_reduce;
210 exblas::mpi_reduce_communicator( comm, &comm_mod, &comm_mod_reduce);
211 for(
unsigned i=0; i<m_jac.values().
size(); i++)
213 m_jac.values()[i].data().resize(s);
214 m_jac.values()[i].set_communicator( comm, comm_mod, comm_mod_reduce);
216 for(
unsigned i=0; i<m_metric.values().
size(); i++)
218 m_metric.values()[i].data().resize(s);
219 m_metric.values()[i].set_communicator( comm, comm_mod, comm_mod_reduce);
225 for(
unsigned i=0; i<m_map.size(); i++)
227 m_map[i].data().resize(s);
228 m_map[i].set_communicator( comm, comm_mod, comm_mod_reduce);
static DG_DEVICE double cooZ3d(double x, double y, double z)
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
dg::geo::RealCurvilinearMPIGrid2d< double > CurvilinearMPIGrid2d
Definition: mpi_curvilinear.h:233
dg::geo::RealCurvilinearProductMPIGrid3d< double > CurvilinearProductMPIGrid3d
Definition: mpi_curvilinear.h:234
MPI_Vector< thrust::host_vector< real_type > > global2local(const thrust::host_vector< real_type > &global, const aRealMPITopology3d< real_type > &g)
SparseTensor< MPI_Vector< thrust::host_vector< real_type > > > jacobian() const
SparseTensor< MPI_Vector< thrust::host_vector< real_type > > > metric() const
std::vector< MPI_Vector< thrust::host_vector< real_type > > > map() const
virtual void do_set(unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny)=0
const RealGrid2d< real_type > & global() const
MPI_Comm get_perp_comm() const
MPI_Comm communicator() const
const RealGrid3d< real_type > & global() const
virtual void do_set(unsigned new_nx, unsigned new_Nx, unsigned new_ny, unsigned new_Ny, unsigned new_nz, unsigned new_Nz)=0
const RealGrid3d< real_type > & local() const
A two-dimensional grid based on curvilinear coordinates.
Definition: curvilinear.h:113
A two-dimensional MPI grid based on curvilinear coordinates.
Definition: mpi_curvilinear.h:26
RealCurvilinearMPIGrid2d(const RealCurvilinearProductMPIGrid3d< real_type > &g)
explicit conversion of 3d product grid to the perpendicular grid
RealCurvilinearMPIGrid2d(const aRealGenerator2d< real_type > &generator, Topology1d tx, Topology1d ty, MPI_Comm comm)
Construct the computational space as the product of two 1d grids.
Definition: mpi_curvilinear.h:36
virtual RealCurvilinearMPIGrid2d * clone() const override final
Definition: mpi_curvilinear.h:48
virtual RealCurvilinearGrid2d< real_type > * global_geometry() const override final
Definition: mpi_curvilinear.h:49
RealCurvilinearMPIGrid2d(const aRealGenerator2d< real_type > &generator, unsigned n, unsigned Nx, unsigned Ny, dg::bc bcx, dg::bc bcy, MPI_Comm comm)
Construct a 2D grid.
Definition: mpi_curvilinear.h:30
const aRealGenerator2d< real_type > & generator() const
read access to the generator
Definition: mpi_curvilinear.h:47
A 2x1 curvilinear product space grid.
Definition: curvilinear.h:160
A 2x1 curvilinear product space MPI grid.
Definition: mpi_curvilinear.h:106
RealCurvilinearProductMPIGrid3d(const aRealGenerator2d< real_type > &generator, Topology1d tx, Topology1d ty, RealGrid1d< real_type > gz, MPI_Comm comm)
Construct the computational space as the product of three 1d grids.
Definition: mpi_curvilinear.h:118
const aRealGenerator2d< real_type > & generator() const
read access to the generator
Definition: mpi_curvilinear.h:130
virtual RealCurvilinearProductGrid3d< real_type > * global_geometry() const
Definition: mpi_curvilinear.h:132
dg::geo::RealCurvilinearMPIGrid2d< real_type > perpendicular_grid
Definition: mpi_curvilinear.h:107
virtual RealCurvilinearProductMPIGrid3d * clone() const override final
Definition: mpi_curvilinear.h:131
RealCurvilinearProductMPIGrid3d(const aRealGenerator2d< real_type > &generator, unsigned n, unsigned Nx, unsigned Ny, unsigned Nz, bc bcx, bc bcy, bc bcz, MPI_Comm comm)
Construct a 3D grid.
Definition: mpi_curvilinear.h:111
Helper class for construction.
Definition: curvilinear.h:65
unsigned n
Definition: curvilinear.h:66
bc b
Definition: curvilinear.h:68
unsigned N
Definition: curvilinear.h:67
The abstract generator base class.
Definition: generator.h:20