1 /*! @file NavierStokes2DParabolicFunction_GPU.cu
3 @brief Compute the viscous terms for the 2D Navier Stokes equations
6 #include <arrayfunctions_gpu.h>
7 #include <mathfunctions.h>
8 #include <physicalmodels/navierstokes2d.h>
12 #ifdef CUDA_VAR_ORDERDING_AOS
14 /*! Kernel for gpuNavierStokes2DParabolicFunction() */
16 void NavierStokes2DParabolicFunction_Q_kernel(
24 int p = threadIdx.x + (blockDim.x * blockIdx.x);
25 if (p < ngrid_points) {
26 double energy, pressure;
28 _NavierStokes2DGetFlowVar_( (u+p),Q[p+0],Q[p+1],Q[p+2],energy,
30 Q[p+3] = gamma*pressure/Q[p+0];
37 Compute the viscous terms in the 2D Navier Stokes equations: this function computes
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]
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}
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.
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).
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 */
69 HyPar *solver = (HyPar*) s;
70 NavierStokes2D *physics = (NavierStokes2D*) solver->physics;
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;
79 gpuArraySetValue(par, size, 0.0);
80 if (physics->Re <= 0) return(0); /* inviscid flow */
82 printf("gpuNavierStokes2DParabolicFunction() hasn't been fully implemented yet.\n");