35template<
class BinaryOp,
class real_type>
40 int dims[2], periods[2], coords[2];
41 MPI_Cart_get( g.
communicator(), 2, dims, periods, coords);
42 thrust::host_vector<real_type> absx( l.
nx()*l.
Nx());
43 thrust::host_vector<real_type> absy( l.
ny()*l.
Ny());
44 for(
unsigned i=0; i<l.
Nx(); i++)
45 for(
unsigned j=0; j<l.
nx(); j++)
47 unsigned coord = i+l.
Nx()*coords[0];
48 real_type xmiddle = DG_FMA( g.
hx(), (real_type)(coord), g.
x0());
49 real_type h2 = g.
hx()/2.;
50 real_type absj = 1.+g.
dltx().abscissas()[j];
51 absx[i*l.
nx()+j] = DG_FMA( h2, absj, xmiddle);
53 for(
unsigned i=0; i<l.
Ny(); i++)
54 for(
unsigned j=0; j<l.
ny(); j++)
56 unsigned coord = i+l.
Ny()*coords[1];
57 real_type ymiddle = DG_FMA( g.
hy(), (real_type)(coord), g.
y0());
58 real_type h2 = g.
hy()/2.;
59 real_type absj = 1.+g.
dlty().abscissas()[j];
60 absy[i*l.
ny()+j] = DG_FMA( h2, absj, ymiddle );
63 thrust::host_vector<real_type> w( l.
size());
64 for(
unsigned i=0; i<l.
Ny(); i++)
65 for(
unsigned k=0; k<l.
ny(); k++)
66 for(
unsigned j=0; j<l.
Nx(); j++)
67 for(
unsigned r=0; r<l.
nx(); r++)
68 w[ ((i*l.
ny()+k)*l.
Nx() + j)*l.
nx() + r] = f( absx[j*l.
nx()+r], absy[i*l.
ny()+k]);
73template<
class real_type>
74MPI_Vector<thrust::host_vector<real_type> >
evaluate( real_type(f)(real_type, real_type),
const aRealMPITopology2d<real_type>& g)
76 return evaluate<real_type(real_type, real_type)>( *f, g);
98template<
class TernaryOp,
class real_type>
104 int dims[3], periods[3], coords[3];
105 MPI_Cart_get( g.
communicator(), 3, dims, periods, coords);
106 thrust::host_vector<real_type> absx( l.
nx()*l.
Nx());
107 thrust::host_vector<real_type> absy( l.
ny()*l.
Ny());
108 thrust::host_vector<real_type> absz( l.
nz()*l.
Nz());
109 for(
unsigned i=0; i<l.
Nx(); i++)
110 for(
unsigned j=0; j<l.
nx(); j++)
112 unsigned coord = i+l.
Nx()*coords[0];
113 real_type xmiddle = DG_FMA( g.
hx(), (real_type)(coord), g.
x0());
114 real_type h2 = g.
hx()/2.;
115 real_type absj = 1.+g.
dltx().abscissas()[j];
116 absx[i*l.
nx()+j] = DG_FMA( h2, absj, xmiddle);
118 for(
unsigned i=0; i<l.
Ny(); i++)
119 for(
unsigned j=0; j<l.
ny(); j++)
121 unsigned coord = i+l.
Ny()*coords[1];
122 real_type ymiddle = DG_FMA( g.
hy(), (real_type)(coord), g.
y0());
123 real_type h2 = g.
hy()/2.;
124 real_type absj = 1.+g.
dlty().abscissas()[j];
125 absy[i*l.
ny()+j] = DG_FMA( h2, absj, ymiddle );
127 for(
unsigned i=0; i<l.
Nz(); i++)
128 for(
unsigned j=0; j<l.
nz(); j++)
130 unsigned coord = i+l.
Nz()*coords[2];
131 real_type zmiddle = DG_FMA( g.
hz(), (real_type)(coord), g.
z0());
132 real_type h2 = g.
hz()/2.;
133 real_type absj = 1.+g.
dltz().abscissas()[j];
134 absz[i*l.
nz()+j] = DG_FMA( h2, absj, zmiddle );
137 thrust::host_vector<real_type> w( l.
size());
138 for(
unsigned s=0; s<l.
Nz(); s++)
139 for(
unsigned m=0; m<l.
nz(); m++)
140 for(
unsigned i=0; i<l.
Ny(); i++)
141 for(
unsigned k=0; k<l.
ny(); k++)
142 for(
unsigned j=0; j<l.
Nx(); j++)
143 for(
unsigned r=0; r<l.
nx(); r++)
144 w[ ((((s*l.
nz()+m)*l.
Ny()+i)*l.
ny()+k)*l.
Nx() + j)*l.
nx() + r] =
145 f( absx[j*l.
nx()+r], absy[i*l.
ny()+k], absz[s*l.
nz()+m]);
150template<
class real_type>
151MPI_Vector<thrust::host_vector<real_type> >
evaluate( real_type(f)(real_type, real_type, real_type),
const aRealMPITopology3d<real_type>& g)
153 return evaluate<real_type(real_type, real_type, real_type)>( *f, g);
167template<
class real_type>
170 assert( global.size() == g.
global().size());
172 thrust::host_vector<real_type> temp(l.
size());
173 int dims[3], periods[3], coords[3];
174 MPI_Cart_get( g.
communicator(), 3, dims, periods, coords);
176 for(
unsigned s=0; s<l.
nz()*l.
Nz(); s++)
178 for(
unsigned i=0; i<l.
ny()*l.
Ny(); i++)
180 for(
unsigned j=0; j<l.
nx()*l.
Nx(); j++)
182 unsigned idx1 = (s*l.
ny()*l.
Ny()+i)*l.
nx()*l.
Nx() + j;
183 unsigned idx2 = ((((coords[2]*l.
nz()*l.
Nz()+s)*dims[1]
184 +coords[1])*l.
ny()*l.
Ny()+i)*dims[0]
185 +coords[0])*l.
nx()*l.
Nx() + j;
186 temp[idx1] = global[idx2];
194template<
class real_type>
197 assert( global.size() == g.
global().size());
199 thrust::host_vector<real_type> temp(l.
size());
200 int dims[2], periods[2], coords[2];
201 MPI_Cart_get( g.
communicator(), 2, dims, periods, coords);
203 for(
unsigned i=0; i<l.
ny()*l.
Ny(); i++)
205 for(
unsigned j=0; j<l.
nx()*l.
Nx(); j++)
207 unsigned idx1 = i*l.
nx()*l.
Nx() + j;
208 unsigned idx2 = ((coords[1]*l.
ny()*l.
Ny()+i)*dims[0]
209 + coords[0])*l.
nx()*l.
Nx() + j;
210 temp[idx1] = global[idx2];
Function discretization routines.
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
MPI_Vector< thrust::host_vector< real_type > > global2local(const thrust::host_vector< real_type > &global, const aRealMPITopology3d< real_type > &g)
Take the relevant local part of a global vector.
Definition: mpi_evaluation.h:168
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 aRealTopology2d.
Definition: grid.h:818
The simplest implementation of aRealTopology3d.
Definition: grid.h:844
2D MPI abstract grid class
Definition: mpi_grid.h:45
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
real_type hx() const
Return global hx.
Definition: mpi_grid.h:92
real_type y0() const
Return global y0.
Definition: mpi_grid.h:68
const DLT< real_type > & dlty() const
discrete legendre transformation in y
Definition: mpi_grid.h:142
MPI_Comm communicator() const
Return mpi cartesian communicator that is used in this grid.
Definition: mpi_grid.h:138
const RealGrid2d< real_type > & global() const
Return the global non-MPI grid.
Definition: mpi_grid.h:262
real_type x0() const
Return global x0.
Definition: mpi_grid.h:56
3D MPI Grid class
Definition: mpi_grid.h:329
real_type hz() const
Return global hz.
Definition: mpi_grid.h:406
MPI_Comm communicator() const
Return mpi cartesian communicator that is used in this grid.
Definition: mpi_grid.h:459
const DLT< real_type > & dltz() const
Definition: mpi_grid.h:473
const RealGrid3d< real_type > & global() const
Return the global non-MPI grid.
Definition: mpi_grid.h:562
const DLT< real_type > & dlty() const
Definition: mpi_grid.h:472
real_type hy() const
Return global hy.
Definition: mpi_grid.h:400
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
real_type y0() const
Return global y0.
Definition: mpi_grid.h:352
real_type x0() const
Return global x0.
Definition: mpi_grid.h:340
const DLT< real_type > & dltx() const
Definition: mpi_grid.h:471
unsigned ny() const
number of polynomial coefficients in y
Definition: grid.h:340
unsigned size() const
The total number of points.
Definition: grid.h:424
unsigned Nx() const
number of cells in x
Definition: grid.h:346
unsigned nx() const
number of polynomial coefficients in x
Definition: grid.h:338
unsigned Ny() const
number of cells in y
Definition: grid.h:352
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