1 #include <gpulab/grid.h>
\r
2 #include <gpulab/FD/stencil.h>
\r
4 int main(int argc, char *argv[])
\r
6 // Initialize grid dimensions
\r
7 unsigned int Nx = 10, Ny = 10;
\r
8 gpulab::grid_dim<unsigned int> dim(Nx,Ny);
\r
9 gpulab::grid<double> u(dim);
\r
10 gpulab::grid<double> ux(u);
\r
11 gpulab::grid<double> uxy(u);
\r
13 // Put meaningful values into u here ...
\r
15 // Stencil size, alpha=beta=2, 9pt 2D stencil
\r
17 // 1st order derivative
\r
18 gpulab::FD::stencil_2d<double> stencil(1, alpha);
\r
19 // Calculate uxy = du/dx + du/dy
\r
20 stencil.mult(u,uxy);
\r
21 // Calculate ux = du/dx
\r
22 stencil.diff_x(u,ux);
\r
23 // Host and device pointers to stencil coeffs
\r
24 double const* hc = stencil.coeffs_host();
\r
25 double const* dc = stencil.coeffs_device();
\r