HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 }
#define _MODEL_NVARS_
Definition: euler1d.h:58
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
void gpuMemcpy(void *, const void *, size_t, enum gpuMemcpyKind)
#define _MODEL_NDIMS_
Definition: euler1d.h:56
int ghosts
Definition: hypar.h:52
2D Navier Stokes equations (compressible flows)
double * grav_field_f
int gpuNavierStokes2DInitialize(void *s, void *m)
double * gpu_grav_field_g
double * grav_field_g
Contains function definitions for common array operations on GPU.
void gpuMemset(void *, int, size_t)
void gpuMalloc(void **, size_t)
Contains structure definition for hypar.
double * gpu_solution
double * gpu_fast_jac
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 * gpu_grav_field_f
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23