HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
NavierStokes2DInitialize_GPU.c
Go to the documentation of this file.
1 
5 #include <stdio.h>
6 #include <arrayfunctions_gpu.h>
8 #include <hypar.h>
9 
12  void *s,
13  void *m
14 )
15 {
16  HyPar *solver = (HyPar*) s;
17  NavierStokes2D *physics = (NavierStokes2D*) solver->physics;
18 
19  int *dim = solver->dim_local;
20  int ghosts = solver->ghosts;
21  int d, size = 1; for (d = 0; d <_MODEL_NDIMS_; d++) size *= (dim[d] + 2*ghosts);
22 
23  gpuMalloc((void**)&physics->gpu_grav_field_f, size*sizeof(double));
24  gpuMalloc((void**)&physics->gpu_grav_field_g, size*sizeof(double));
25  gpuMalloc((void**)&physics->gpu_fast_jac, 2*size*_MODEL_NVARS_*_MODEL_NVARS_*sizeof(double));
26  gpuMalloc((void**)&physics->gpu_solution, size*_MODEL_NVARS_*sizeof(double));
27  gpuMemcpy(physics->gpu_grav_field_f, physics->grav_field_f, size*sizeof(double), gpuMemcpyHostToDevice);
28  gpuMemcpy(physics->gpu_grav_field_g, physics->grav_field_g, size*sizeof(double), gpuMemcpyHostToDevice);
29  gpuMemset(physics->gpu_fast_jac, 0, 2*size*_MODEL_NVARS_*_MODEL_NVARS_*sizeof(double));
30  gpuMemset(physics->gpu_solution, 0, size*_MODEL_NVARS_*sizeof(double));
31 
32  return (0);
33 }
void gpuMemset(void *, int, size_t)
Contains function definitions for common array operations on GPU.
double * grav_field_g
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
void gpuMalloc(void **, size_t)
double * gpu_grav_field_f
double * gpu_solution
#define _MODEL_NDIMS_
Definition: euler1d.h:56
Contains structure definition for hypar.
2D Navier Stokes equations (compressible flows)
Structure containing variables and parameters specific to the 2D Navier Stokes equations. This structure contains the physical parameters, variables, and function pointers specific to the 2D Navier-Stokes equations.
double * grav_field_f
double * gpu_grav_field_g
int * dim_local
Definition: hypar.h:37
void gpuMemcpy(void *, const void *, size_t, enum gpuMemcpyKind)
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
#define _MODEL_NVARS_
Definition: euler1d.h:58
int gpuNavierStokes2DInitialize(void *s, void *m)
double * gpu_fast_jac