14template<
class container>
15void simple_mpi_average(
unsigned nx,
unsigned ny,
const container& in0,
const container& in1, container& out, MPI_Comm comm)
17 const double* in0_ptr = thrust::raw_pointer_cast( in0.data());
18 const double* in1_ptr = thrust::raw_pointer_cast( in1.data());
19 double* out_ptr = thrust::raw_pointer_cast( out.data());
23 for(
unsigned i=1; i<ny; i++)
25 in0_view.construct( in0_ptr+i*nx, nx);
26 in1_view.construct( in1_ptr+i*nx, nx);
29 static thrust::host_vector<double> send_buf;
32 MPI_Allreduce(MPI_IN_PLACE, send_buf.data(), nx, MPI_DOUBLE, MPI_SUM, comm);
43template<
class container>
63 int remain_dims[] = {
false,
false};
71 remain_dims[0] =
true;
78 remain_dims[1] =
true;
90 for(
unsigned i=0; i<2; i++)
91 remain_dims[i] = !remain_dims[i];
95 thrust::host_vector<double> t1d( size1d);
97 if( !(
"exact"==mode ||
"simple" == mode))
108 int remain_dims[] = {
false,
false,
false};
113 m_nx = nx, m_ny = ny*nz;
114 remain_dims[0] =
true;
115 if(
"simple" == mode)
120 remain_dims[2] =
true;
121 m_nx = nx*ny, m_ny = nz;
130 m_nx = nx*ny, m_ny = nz;
131 remain_dims[0] = remain_dims[1] =
true;
132 if(
"simple" == mode)
137 m_nx = nx, m_ny = ny*nz;
138 remain_dims[1] = remain_dims[2] =
true;
145 std::cerr <<
"Warning: this direction is not implemented\n";
150 for(
unsigned i=0; i<3; i++)
151 remain_dims[i] = !remain_dims[i];
155 thrust::host_vector<double> t1d;
157 t1d = thrust::host_vector<double>( m_ny,0.);
159 t1d = thrust::host_vector<double>( m_nx,0.);
161 if( !(
"exact"==mode ||
"simple" == mode))
182 if(
"exact" == m_mode)
183 dg::mpi_average( m_nx, m_ny, src.
data(), m_w.data(),
184 m_temp1d.data(), m_comm, m_comm_mod, m_comm_mod_reduce);
188 dg::simple_mpi_average( m_ny, m_nx, m_temp.data(), m_w.data(),
189 m_temp1d.data(), m_comm);
200 if(
"exact" == m_mode)
203 dg::mpi_average( m_ny, m_nx, m_temp.data(), m_w.data(),
204 m_temp1d.data(), m_comm, m_comm_mod, m_comm_mod_reduce);
207 dg::simple_mpi_average( m_nx, m_ny, src.
data(), m_w.data(),
208 m_temp1d.data(), m_comm);
220 MPI_Comm m_comm, m_comm_mod, m_comm_mod_reduce;
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
void assign(const from_ContainerType &from, ContainerType &to, Params &&... ps)
Generic way to assign the contents of a from_ContainerType object to a ContainerType object optionall...
Definition: blas1.h:665
void scal(ContainerType &x, get_value_type< ContainerType > alpha)
Definition: blas1.h:185
void pointwiseDot(get_value_type< ContainerType > alpha, const ContainerType1 &x1, const ContainerType2 &x2, get_value_type< ContainerType > beta, ContainerType &y)
Definition: blas1.h:336
coo3d
3d contra- and covariant coordinates
Definition: enums.h:177
direction
Direction of a discrete derivative.
Definition: enums.h:97
coo2d
2d coordinates
Definition: enums.h:171
MPI_Vector< thrust::host_vector< real_type > > weights(const aRealMPITopology2d< real_type > &g)
Nodal weight coefficients.
Definition: mpi_weights.h:22
void extend_column(unsigned nx, unsigned ny, const ContainerType &in, ContainerType &out)
Copy a line into columns of output vector.
Definition: average_dispatch.h:67
void extend_line(unsigned nx, unsigned ny, const ContainerType &in, ContainerType &out)
Copy a line into rows of output vector.
Definition: average_dispatch.h:47
void transpose(unsigned nx, unsigned ny, const ContainerType &in, ContainerType &out)
Transpose vector.
Definition: average_dispatch.h:26
static void mpi_reduce_communicator(MPI_Comm comm, MPI_Comm *comm_mod, MPI_Comm *comm_mod_reduce)
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
Average(const aMPITopology2d &g, enum coo2d direction, std::string mode="exact")
Prepare internal workspace.
Definition: average_mpi.h:58
Average(const aMPITopology3d &g, enum coo3d direction, std::string mode="exact")
Prepare internal workspace.
Definition: average_mpi.h:102
Topological average computations in a Cartesian topology.
Definition: average.h:53
void operator()(const ContainerType &src, ContainerType &res, bool extend=true)
Compute the average as configured in the constructor.
Definition: average.h:156
mpi Vector class
Definition: mpi_vector.h:32
const container & data() const
Get underlying data.
Definition: mpi_vector.h:66
A vector view class, usable in dg functions.
Definition: view.h:43
2D MPI abstract grid class
Definition: mpi_grid.h:45
real_type lx() const
Return global lx.
Definition: mpi_grid.h:80
real_type ly() const
Return global ly.
Definition: mpi_grid.h:86
const RealGrid2d< real_type > & local() const
Return a non-MPI grid local for the calling process.
Definition: mpi_grid.h:252
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
MPI_Comm communicator() const
Return mpi cartesian communicator that is used in this grid.
Definition: mpi_grid.h:138
3D MPI Grid class
Definition: mpi_grid.h:329
real_type lz() const
Return global lz.
Definition: mpi_grid.h:388
real_type lx() const
Return global lx.
Definition: mpi_grid.h:376
unsigned nz() const
number of polynomial coefficients in z
Definition: mpi_grid.h:418
MPI_Comm communicator() const
Return mpi cartesian communicator that is used in this grid.
Definition: mpi_grid.h:459
real_type ly() const
Return global ly.
Definition: mpi_grid.h:382
unsigned ny() const
number of polynomial coefficients in y
Definition: mpi_grid.h:416
const RealGrid3d< real_type > & local() const
Return a non-MPI grid local for the calling process.
Definition: mpi_grid.h:560
unsigned nx() const
number of polynomial coefficients in x
Definition: mpi_grid.h:414