2#include <thrust/host_vector.h>
3#include <thrust/device_vector.h>
4#include "dg/backend/blas1_dispatch_shared.h"
29template<
class SharedContainer,
class real_type>
32 assert( out.size() == grid.
nz()*grid.
Nz());
33 unsigned size2d=grid.
nx()*grid.
ny()*grid.
Nx()*grid.
Ny();
34 for(
unsigned i=0; i<grid.
nz()*grid.
Nz(); i++)
35 out[i].construct( thrust::raw_pointer_cast(in.data()) + i*size2d, size2d);
46template<
class SharedContainer,
class real_type>
49 std::vector<View<SharedContainer>> out;
51 unsigned size2d=l.
nx()*l.
ny()*l.
Nx()*l.
Ny();
52 out.resize( l.
nz()*l.
Nz());
53 for(
unsigned i=0; i<l.
nz()*l.
Nz(); i++)
54 out[i].construct( thrust::raw_pointer_cast(in.data()) + i*size2d, size2d);
67template<
class Container,
class real_type>
71 thrust::host_vector<real_type> vector( grid.
size());
72 std::vector<dg::View< thrust::host_vector<real_type>>> view =
74 for(
unsigned i=0; i<grid.
nz()*grid.
Nz(); i++)
82template<
class MPIContainer>
84 std::conditional_t< std::is_const<MPIContainer>::value,
100template<
class MPIContainer,
class real_type>
106 unsigned size2d=l.
nx()*l.
ny()*l.
Nx()*l.
Ny();
107 for(
unsigned i=0; i<l.
nz()*l.
Nz(); i++)
109 out[i].data().construct( thrust::raw_pointer_cast(in.data().data()) +
122template<
class MPIContainer,
class real_type>
123std::vector<get_mpi_view_type<MPIContainer> >
split(
126 std::vector<get_mpi_view_type<MPIContainer>> out;
128 MPI_Comm_compare( in.communicator(), grid.
communicator(), &result);
129 assert( result == MPI_CONGRUENT || result == MPI_IDENT);
130 MPI_Comm planeComm = grid.
get_perp_comm(), comm_mod, comm_mod_reduce;
134 unsigned size2d=l.
nx()*l.
ny()*l.
Nx()*l.
Ny();
135 out.resize( l.
nz()*l.
Nz());
136 for(
unsigned i=0; i<l.
nz()*l.
Nz(); i++)
138 out[i].data().construct( thrust::raw_pointer_cast(in.data().data())
140 out[i].set_communicator( planeComm, comm_mod, comm_mod_reduce);
154template<
class LocalContainer,
class real_type>
160 std::vector<MPI_Vector<dg::View<thrust::host_vector<real_type>>> > view =
162 for(
unsigned i=0; i<grid.
nz()*grid.
local().Nz(); i++)
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
static DG_DEVICE double zero(double x)
Definition: functions.h:29
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
Definition: blas1.h:164
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
void assign3dfrom2d(const thrust::host_vector< real_type > &in2d, Container &out, const aRealTopology3d< real_type > &grid)
Construct a 3d vector given a 2d host vector.
Definition: split_and_join.h:68
std::conditional_t< std::is_const< MPIContainer >::value, MPI_Vector< View< const typename MPIContainer::container_type > >, MPI_Vector< View< typename MPIContainer::container_type > > > get_mpi_view_type
Definition: split_and_join.h:86
void split(SharedContainer &in, std::vector< View< SharedContainer > > &out, const aRealTopology3d< real_type > &grid)
Split a vector into planes along the last dimension (fast version)
Definition: split_and_join.h:30
Function discretization routines for mpi vectors.
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...
mpi Vector class
Definition: mpi_vector.h:32
The simplest implementation of aRealTopology3d.
Definition: grid.h:844
A vector view class, usable in dg functions.
Definition: view.h:43
3D MPI Grid class
Definition: mpi_grid.h:329
MPI_Comm get_perp_comm() const
MPI Cartesian communicator in the first two dimensions (x and y)
Definition: mpi_grid.h:464
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
const RealGrid3d< real_type > & local() const
Return a non-MPI grid local for the calling process.
Definition: mpi_grid.h:560
An abstract base class for three-dimensional grids.
Definition: grid.h:523
unsigned size() const
The total number of points.
Definition: grid.h:670
unsigned nz() const
number of polynomial coefficients in z
Definition: grid.h:616
unsigned Nx() const
number of points in x
Definition: grid.h:622
unsigned ny() const
number of polynomial coefficients in y
Definition: grid.h:614
unsigned Ny() const
number of points in y
Definition: grid.h:628
unsigned Nz() const
number of points in z
Definition: grid.h:634
unsigned nx() const
number of polynomial coefficients in x
Definition: grid.h:612