Compute the viscous terms in the 3D Navier Stokes equations: this function computes the following:
\begin{equation} \frac {\partial} {\partial x} \left[\begin{array}{c} 0 \\ \tau_{xx} \\ \tau_{yx} \\ \tau_{zx} \\ u \tau_{xx} + v \tau_{yx} + w \tau_{zx} - q_x \end{array}\right] + \frac {\partial} {\partial y} \left[\begin{array}{c} 0 \\ \tau_{xy} \\ \tau_{yy} \\ \tau_{zy} \\ u \tau_{xy} + v \tau_{yy} + w \tau_{zy} - q_y \end{array}\right] + \frac {\partial} {\partial z} \left[\begin{array}{c} 0 \\ \tau_{xz} \\ \tau_{yz} \\ \tau_{zz} \\ u \tau_{xz} + v \tau_{yz} + w \tau_{zz} - q_z \end{array}\right] \end{equation}
\begin{align} \tau_{xx} &= \frac{2}{3}\left(\frac{\mu}{Re}\right)\left(2\frac{\partial u}{\partial x} - \frac{\partial v}{\partial y} - \frac{\partial w}{\partial z}\right),\\ \tau_{xy} &= \left(\frac{\mu}{Re}\right)\left(\frac{\partial u}{\partial y} + \frac{\partial v}{\partial x}\right),\\ \tau_{xz} &= \left(\frac{\mu}{Re}\right)\left(\frac{\partial u}{\partial z} + \frac{\partial w}{\partial x}\right),\\ \tau_{yx} &= \left(\frac{\mu}{Re}\right)\left(\frac{\partial u}{\partial y} + \frac{\partial v}{\partial x}\right),\\ \tau_{yy} &= \frac{2}{3}\left(\frac{\mu}{Re}\right)\left(-\frac{\partial u}{\partial x} +2\frac{\partial v}{\partial y} - \frac{\partial w}{\partial z}\right),\\ \tau_{yz} &= \left(\frac{\mu}{Re}\right)\left(\frac{\partial w}{\partial y} + \frac{\partial v}{\partial z}\right),\\ \tau_{zx} &= \left(\frac{\mu}{Re}\right)\left(\frac{\partial u}{\partial z} + \frac{\partial w}{\partial x}\right),\\ \tau_{zy} &= \left(\frac{\mu}{Re}\right)\left(\frac{\partial v}{\partial z} + \frac{\partial w}{\partial y}\right),\\ \tau_{zz} &= \frac{2}{3}\left(\frac{\mu}{Re}\right)\left(-\frac{\partial u}{\partial x} - \frac{\partial v}{\partial y} + 2\frac{\partial v}{\partial y}\right),\\ q_x &= -\frac{mu}{\left(\gamma-1\right)Re Pr}\frac{\partial T}{\partial x}, \\ q_y &= -\frac{mu}{\left(\gamma-1\right)Re Pr}\frac{\partial T}{\partial y}, \\ q_z &= -\frac{mu}{\left(\gamma-1\right)Re Pr}\frac{\partial T}{\partial z} \end{align}
and the temperature is \(T = \gamma p/\rho\). \(Re\) and \(Pr\) are the Reynolds and Prandtl numbers, respectively. Note that this function computes the entire parabolic term, and thus bypasses HyPar's parabolic function calculation interfaces. NavierStokes3DInitialize() assigns this function to HyPar::ParabolicFunction.
Reference:
64 int ghosts = solver->
ghosts;
72 if (physics->
Re <= 0)
return(0);
75 static double two_third = 2.0/3.0;
76 double inv_gamma_m1 = 1.0 / (physics->
gamma-1.0);
77 double inv_Re = 1.0 / physics->
Re;
78 double inv_Pr = 1.0 / physics->
Pr;
81 clock_t startEvent, stopEvent;
85 Q = (
double*) calloc (size*_MODEL_NVARS_,
sizeof(
double));
91 for (i=-ghosts; i<(imax+ghosts); i++) {
92 for (j=-ghosts; j<(jmax+ghosts); j++) {
93 for (k=-ghosts; k<(kmax+ghosts); k++) {
94 int p,index[3]; index[0]=i; index[1]=j; index[2]=k;
95 double energy,pressure;
106 Q[p+4] = physics->
gamma*pressure/Q[p+0];
111 #if defined(CPU_STAT)
113 printf(
"%-50s CPU time (secs) = %.6f\n",
114 "NaverStokes3DParabolicFunction_Q",(
double)(stopEvent-startEvent)/CLOCKS_PER_SEC);
117 double *QDerivX = (
double*) calloc (size*_MODEL_NVARS_,
sizeof(
double));
118 double *QDerivY = (
double*) calloc (size*_MODEL_NVARS_,
sizeof(
double));
119 double *QDerivZ = (
double*) calloc (size*_MODEL_NVARS_,
sizeof(
double));
132 for (i=-ghosts; i<(imax+ghosts); i++) {
133 for (j=-ghosts; j<(jmax+ghosts); j++) {
134 for (k=-ghosts; k<(kmax+ghosts); k++) {
135 int p,index[3]; index[0]=i; index[1]=j; index[2]=k;
136 double dxinv, dyinv, dzinv;
148 double *FViscous = (
double*) calloc (size*_MODEL_NVARS_,
sizeof(
double));
149 double *FDeriv = (
double*) calloc (size*_MODEL_NVARS_,
sizeof(
double));
152 for (i=-ghosts; i<(imax+ghosts); i++) {
153 for (j=-ghosts; j<(jmax+ghosts); j++) {
154 for (k=-ghosts; k<(kmax+ghosts); k++) {
155 int p,index[3]; index[0]=i; index[1]=j; index[2]=k;
158 double uvel, vvel, wvel, T, Tx,
159 ux, uy, uz, vx, vy, wx, wz;
182 double tau_xx, tau_xy, tau_xz, qx;
183 tau_xx = two_third * (mu*inv_Re) * (2*ux - vy - wz);
184 tau_xy = (mu*inv_Re) * (uy + vx);
185 tau_xz = (mu*inv_Re) * (uz + wx);
186 qx = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Tx;
188 (FViscous+p)[0] = 0.0;
189 (FViscous+p)[1] = tau_xx;
190 (FViscous+p)[2] = tau_xy;
191 (FViscous+p)[3] = tau_xz;
192 (FViscous+p)[4] = uvel*tau_xx + vvel*tau_xy + wvel*tau_xz + qx;
198 for (i=0; i<imax; i++) {
199 for (j=0; j<jmax; j++) {
200 for (k=0; k<kmax; k++) {
201 int p,index[3]; index[0]=i; index[1]=j; index[2]=k;
205 for (v=0; v<
_MODEL_NVARS_; v++) (par+p)[v] += (dxinv * (FDeriv+p)[v] );
211 for (i=-ghosts; i<(imax+ghosts); i++) {
212 for (j=-ghosts; j<(jmax+ghosts); j++) {
213 for (k=-ghosts; k<(kmax+ghosts); k++) {
214 int p,index[3]; index[0]=i; index[1]=j; index[2]=k;
217 double uvel, vvel, wvel, T, Ty,
218 ux, uy, vx, vy, vz, wy, wz;
235 double tau_yx, tau_yy, tau_yz, qy;
236 tau_yx = (mu*inv_Re) * (uy + vx);
237 tau_yy = two_third * (mu*inv_Re) * (-ux + 2*vy - wz);
238 tau_yz = (mu*inv_Re) * (vz + wy);
239 qy = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Ty;
241 (FViscous+p)[0] = 0.0;
242 (FViscous+p)[1] = tau_yx;
243 (FViscous+p)[2] = tau_yy;
244 (FViscous+p)[3] = tau_yz;
245 (FViscous+p)[4] = uvel*tau_yx + vvel*tau_yy + wvel*tau_yz + qy;
251 for (i=0; i<imax; i++) {
252 for (j=0; j<jmax; j++) {
253 for (k=0; k<kmax; k++) {
254 int p,index[3]; index[0]=i; index[1]=j; index[2]=k;
258 for (v=0; v<
_MODEL_NVARS_; v++) (par+p)[v] += (dyinv * (FDeriv+p)[v] );
264 for (i=-ghosts; i<(imax+ghosts); i++) {
265 for (j=-ghosts; j<(jmax+ghosts); j++) {
266 for (k=-ghosts; k<(kmax+ghosts); k++) {
267 int p,index[3]; index[0]=i; index[1]=j; index[2]=k;
270 double uvel, vvel, wvel, T, Tz,
271 ux, uz, vy, vz, wx, wy, wz;
288 double tau_zx, tau_zy, tau_zz, qz;
289 tau_zx = (mu*inv_Re) * (uz + wx);
290 tau_zy = (mu*inv_Re) * (vz + wy);
291 tau_zz = two_third * (mu*inv_Re) * (-ux - vy + 2*wz);
292 qz = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Tz;
294 (FViscous+p)[0] = 0.0;
295 (FViscous+p)[1] = tau_zx;
296 (FViscous+p)[2] = tau_zy;
297 (FViscous+p)[3] = tau_zz;
298 (FViscous+p)[4] = uvel*tau_zx + vvel*tau_zy + wvel*tau_zz + qz;
304 for (i=0; i<imax; i++) {
305 for (j=0; j<jmax; j++) {
306 for (k=0; k<kmax; k++) {
307 int p,index[3]; index[0]=i; index[1]=j; index[2]=k;
311 for (v=0; v<
_MODEL_NVARS_; v++) (par+p)[v] += (dzinv * (FDeriv+p)[v] );
#define _NavierStokes3DGetFlowVar_(u, stride, rho, vx, vy, vz, e, P, gamma)
int npoints_local_wghosts
#define _ArraySetValue_(x, size, value)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
#define _ArrayScale1D_(x, a, size)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArrayBlockMultiply_(x, a, n, bs)
int(* FirstDerivativePar)(double *, double *, int, int, void *, void *)
Structure containing variables and parameters specific to the 3D Navier Stokes equations. This structure contains the physical parameters, variables, and function pointers specific to the 3D Navier-Stokes equations.
int MPIExchangeBoundariesnD(int, int, int *, int, void *, double *)
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
static const int _NavierStokes3D_stride_