HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
NavierStokes2DInitialize_GPU.c File Reference

Initialization of the physics-related variables and function pointers for the 2D Navier-Stokes system. More...

#include <stdio.h>
#include <arrayfunctions_gpu.h>
#include <physicalmodels/navierstokes2d.h>
#include <hypar.h>

Go to the source code of this file.

Functions

int gpuNavierStokes2DInitialize (void *s, void *m)
 

Detailed Description

Initialization of the physics-related variables and function pointers for the 2D Navier-Stokes system.

Author
Youngdae Kim

Definition in file NavierStokes2DInitialize_GPU.c.

Function Documentation

◆ gpuNavierStokes2DInitialize()

int gpuNavierStokes2DInitialize ( void *  s,
void *  m 
)

Initialize GPU-related arrays.

Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables

Definition at line 11 of file NavierStokes2DInitialize_GPU.c.

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)
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
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
double * gpu_fast_jac