HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
NavierStokes2DParabolicFunction_GPU.cu
Go to the documentation of this file.
1 /*! @file NavierStokes2DParabolicFunction_GPU.cu
2  @author Youngdae Kim
3  @brief Compute the viscous terms for the 2D Navier Stokes equations
4 */
5 #include <basic_gpu.h>
6 #include <arrayfunctions_gpu.h>
7 #include <mathfunctions.h>
8 #include <physicalmodels/navierstokes2d.h>
9 #include <mpivars.h>
10 #include <hypar.h>
11 
12 #ifdef CUDA_VAR_ORDERDING_AOS
13 
14 /*! Kernel for gpuNavierStokes2DParabolicFunction() */
15 __global__
16 void NavierStokes2DParabolicFunction_Q_kernel(
17  int ngrid_points,
18  int nvars,
19  double gamma,
20  const double *u,
21  double *Q
22 )
23 {
24  int p = threadIdx.x + (blockDim.x * blockIdx.x);
25  if (p < ngrid_points) {
26  double energy, pressure;
27  p *= nvars;
28  _NavierStokes2DGetFlowVar_( (u+p),Q[p+0],Q[p+1],Q[p+2],energy,
29  pressure,gamma);
30  Q[p+3] = gamma*pressure/Q[p+0];
31  }
32 
33  return;
34 }
35 
36 /*!
37  Compute the viscous terms in the 2D Navier Stokes equations: this function computes
38  the following:
39  \f{equation}{
40  \frac {\partial} {\partial x} \left[\begin{array}{c} 0 \\ \tau_{xx} \\ \tau_{yx} \\ u \tau_{xx} + v \tau_{yx} - q_x \end{array}\right]
41  + \frac {\partial} {\partial y} \left[\begin{array}{c} 0 \\ \tau_{xy} \\ \tau_{yy} \\ u \tau_{xy} + v \tau_{yy} - q_y \end{array}\right]
42  \f}
43  where
44  \f{align}{
45  \tau_{xx} &= \frac{2}{3}\left(\frac{\mu}{Re}\right)\left(2\frac{\partial u}{\partial x} - \frac{\partial v}{\partial y}\right),\\
46  \tau_{xy} &= \left(\frac{\mu}{Re}\right)\left(\frac{\partial u}{\partial y} + \frac{\partial v}{\partial x}\right),\\
47  \tau_{yx} &= \left(\frac{\mu}{Re}\right)\left(\frac{\partial u}{\partial y} + \frac{\partial v}{\partial x}\right),\\
48  \tau_{yy} &= \frac{2}{3}\left(\frac{\mu}{Re}\right)\left(-\frac{\partial u}{\partial x} +2\frac{\partial v}{\partial y}\right),\\
49  q_x &= -\frac{mu}{\left(\gamma-1\right)Re Pr}\frac{\partial T}{\partial x}, \\
50  q_y &= -\frac{mu}{\left(\gamma-1\right)Re Pr}\frac{\partial T}{\partial y}
51  \f}
52  and the temperature is \f$T = \gamma p/\rho\f$. \f$Re\f$ and \f$Pr\f$ are the Reynolds and Prandtl numbers, respectively. Note that this function
53  computes the entire parabolic term, and thus bypasses HyPar's parabolic function calculation interfaces. NavierStokes2DInitialize() assigns this
54  function to #HyPar::ParabolicFunction.
55  \n\n
56  Reference:
57  + Tannehill, Anderson and Pletcher, Computational Fluid Mechanics and Heat Transfer,
58  Chapter 5, Section 5.1.7 (However, the non-dimensional velocity and the Reynolds
59  number is based on speed of sound, instead of the freestream velocity).
60 */
61 extern "C" int gpuNavierStokes2DParabolicFunction(
62  double *par, /*!< Array to hold the computed viscous terms */
63  double *u, /*!< Solution vector array */
64  void *s, /*!< Solver object of type #HyPar */
65  void *m, /*!< MPI object of type #MPIVariables */
66  double t /*!< Current simulation time */
67 )
68 {
69  HyPar *solver = (HyPar*) s;
70  NavierStokes2D *physics = (NavierStokes2D*) solver->physics;
71  _DECLARE_IERR_;
72 
73  int ghosts = solver->ghosts;
74  int imax = solver->dim_local[0];
75  int jmax = solver->dim_local[1];
76  int nvars = solver->nvars;
77  int size = (imax+2*ghosts)*(jmax+2*ghosts)*nvars;
78 
79  gpuArraySetValue(par, size, 0.0);
80  if (physics->Re <= 0) return(0); /* inviscid flow */
81 
82  printf("gpuNavierStokes2DParabolicFunction() hasn't been fully implemented yet.\n");
83  return 1;
84 }
85 
86 #endif