5#include <thrust/host_vector.h>
6#include "dg/backend/config.h"
26template<
class real_type>
27thrust::host_vector<real_type> abscissas(
const RealGrid1d<real_type>& g)
29 thrust::host_vector<real_type> abs(g.size());
30 for(
unsigned i=0; i<g.N(); i++)
31 for(
unsigned j=0; j<g.n(); j++)
33 real_type xmiddle = DG_FMA( g.h(), (real_type)(i), g.x0());
34 real_type h2 = g.h()/2.;
35 real_type absj = 1.+g.dlt().abscissas()[j];
36 abs[i*g.n()+j] = DG_FMA( h2, absj, xmiddle);
66template<
class UnaryOp,
class real_type>
69 thrust::host_vector<real_type> abs = create::abscissas( g);
70 for(
unsigned i=0; i<g.
size(); i++)
75template<
class real_type>
76thrust::host_vector<real_type>
evaluate( real_type (f)(real_type),
const RealGrid1d<real_type>& g)
78 thrust::host_vector<real_type> v = evaluate<real_type (real_type)>( *f, g);
103template<
class BinaryOp,
class real_type>
106 thrust::host_vector<real_type> absx = create::abscissas( g.
gx());
107 thrust::host_vector<real_type> absy = create::abscissas( g.
gy());
109 thrust::host_vector<real_type> v( g.
size());
110 for(
unsigned i=0; i<g.
Ny(); i++)
111 for(
unsigned k=0; k<g.
ny(); k++)
112 for(
unsigned j=0; j<g.
Nx(); j++)
113 for(
unsigned r=0; r<g.
nx(); r++)
114 v[ ((i*g.
ny()+k)*g.
Nx() + j)*g.
nx() + r] =
115 f( absx[j*g.
nx()+r], absy[i*g.
ny()+k]);
119template<
class real_type>
120thrust::host_vector<real_type>
evaluate( real_type(f)(real_type, real_type),
const aRealTopology2d<real_type>& g)
122 return evaluate<real_type(real_type, real_type)>( *f, g);
145template<
class TernaryOp,
class real_type>
148 thrust::host_vector<real_type> absx = create::abscissas( g.
gx());
149 thrust::host_vector<real_type> absy = create::abscissas( g.
gy());
150 thrust::host_vector<real_type> absz = create::abscissas( g.
gz());
152 thrust::host_vector<real_type> v( g.
size());
153 for(
unsigned s=0; s<g.
Nz(); s++)
154 for(
unsigned ss=0; ss<g.
nz(); ss++)
155 for(
unsigned i=0; i<g.
Ny(); i++)
156 for(
unsigned ii=0; ii<g.
ny(); ii++)
157 for(
unsigned k=0; k<g.
Nx(); k++)
158 for(
unsigned kk=0; kk<g.
nx(); kk++)
159 v[ ((((s*g.
nz()+ss)*g.
Ny()+i)*g.
ny()+ii)*g.
Nx() + k)*g.
nx() + kk] =
160 f( absx[k*g.
nx()+kk], absy[i*g.
ny()+ii], absz[s*g.
nz()+ss]);
164template<
class real_type>
165thrust::host_vector<real_type>
evaluate( real_type(f)(real_type, real_type, real_type),
const aRealTopology3d<real_type>& g)
167 return evaluate<real_type(real_type, real_type, real_type)>( *f, g);
183template<
class real_type>
188 thrust::host_vector<real_type> to_out(g.
size(), 0.);
189 thrust::host_vector<real_type> to_in(in);
192 for(
unsigned i=0; i<in.size(); i++)
193 to_in[i] = in[ in.size()-1-i];
203 real_type constant = 0.;
205 for(
unsigned i=0; i<g.
N(); i++)
207 for(
unsigned k=0; k<n; k++)
209 for(
unsigned l=0; l<n; l++)
210 to_out[ i*n + k] +=
ninj(k,l)*to_in[ i*n + l];
211 to_out[ i*n + k] += constant;
213 for(
unsigned l=0; l<n; l++)
214 constant += h*
forward(0,l)*to_in[i*n+l];
216 thrust::host_vector<real_type> out(to_out);
219 for(
unsigned i=0; i<in.size(); i++)
220 out[i] = -to_out[ in.size()-1-i];
238template<
class UnaryOp,
class real_type>
241 thrust::host_vector<real_type> vector =
evaluate( f, g);
242 return integrate<real_type>(vector, g, dir);
245template<
class real_type>
248 thrust::host_vector<real_type> vector =
evaluate( f, g);
249 return integrate<real_type>(vector, g, dir);
direction
Direction of a discrete derivative.
Definition: enums.h:97
@ backward
backward derivative (cell to the left and current cell)
Definition: enums.h:99
@ forward
forward derivative (cell to the right and current cell)
Definition: enums.h:98
thrust::host_vector< real_type > integrate(const thrust::host_vector< real_type > &in, const RealGrid1d< real_type > &g, dg::direction dir=dg::forward)
Indefinite integral of a function on a grid.
Definition: evaluation.h:184
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
Operator< real_type > ninj(unsigned n)
Create the N-matrix.
Definition: operator.h:639
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
1D grid
Definition: grid.h:80
real_type h() const
cell size
Definition: grid.h:129
unsigned n() const
number of polynomial coefficients
Definition: grid.h:141
const DLT< real_type > & dlt() const
the discrete legendre transformation
Definition: grid.h:197
unsigned size() const
n()*N() (Total number of grid points)
Definition: grid.h:191
unsigned N() const
number of cells
Definition: grid.h:135
An abstract base class for two-dimensional grids.
Definition: grid.h:277
const RealGrid1d< real_type > & gy() const
The y-axis grid.
Definition: grid.h:379
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
const RealGrid1d< real_type > & gx() const
The x-axis grid.
Definition: grid.h:377
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
An abstract base class for three-dimensional grids.
Definition: grid.h:523
unsigned size() const
The total number of points.
Definition: grid.h:670
const RealGrid1d< real_type > & gz() const
The z-axis grid.
Definition: grid.h:664
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
const RealGrid1d< real_type > & gx() const
The x-axis grid.
Definition: grid.h:660
const RealGrid1d< real_type > & gy() const
The y-axis grid.
Definition: grid.h:662
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