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

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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <boundaryconditions.h>
#include <physicalmodels/navierstokes2d.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

double NavierStokes2DComputeCFL (void *, void *, double, double)
 
int NavierStokes2DFlux (double *, double *, int, void *, double)
 
int NavierStokes2DStiffFlux (double *, double *, int, void *, double)
 
int NavierStokes2DNonStiffFlux (double *, double *, int, void *, double)
 
int NavierStokes2DRoeAverage (double *, double *, double *, void *)
 
int NavierStokes2DParabolicFunction (double *, double *, void *, void *, double)
 
int NavierStokes2DSource (double *, double *, void *, void *, double)
 
int NavierStokes2DJacobian (double *, double *, void *, int, int, int)
 
int NavierStokes2DStiffJacobian (double *, double *, void *, int, int, int)
 
int NavierStokes2DLeftEigenvectors (double *, double *, void *, int)
 
int NavierStokes2DRightEigenvectors (double *, double *, void *, int)
 
int NavierStokes2DUpwindRoe (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwindRF (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwindLLF (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwindSWFS (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwindRusanov (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwinddFRoe (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwinddFRF (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwinddFLLF (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwinddFRusanov (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwindFdFRoe (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwindFdFRF (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwindFdFLLF (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwindFdFRusanov (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwindRusanovModified (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwinddFRusanovModified (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DUpwindFdFRusanovModified (double *, double *, double *, double *, double *, double *, int, void *, double)
 
int NavierStokes2DGravityField (void *, void *)
 
int NavierStokes2DModifiedSolution (double *, double *, int, void *, void *, double)
 
int NavierStokes2DPreStep (double *, void *, void *, double)
 
int NavierStokes2DInitialize (void *s, void *m)
 

Detailed Description

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

Author
Debojyoti Ghosh

Definition in file NavierStokes2DInitialize.c.

Function Documentation

◆ NavierStokes2DComputeCFL()

double NavierStokes2DComputeCFL ( void *  s,
void *  m,
double  dt,
double  t 
)

Computes the maximum CFL number over the domain. Note that the CFL is computed over the local domain on this processor only.

Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables
dtTime step size for which to compute the CFL
tTime

Definition at line 16 of file NavierStokes2DComputeCFL.c.

22 {
23  HyPar *solver = (HyPar*) s;
24  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
26 
27  int *dim = solver->dim_local;
28  int ghosts = solver->ghosts;
29  int ndims = solver->ndims;
30  int index[ndims];
31  double *u = solver->u;
32 
33  double max_cfl = 0;
34  int done = 0; _ArraySetValue_(index,ndims,0);
35  while (!done) {
36  int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p);
37  double rho,vx,vy,e,P,c,dxinv,dyinv,local_cfl[2];
38  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma);
39 
40  c = sqrt(param->gamma*P/rho); /* speed of sound */
41  _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */
42  _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */
43 
44  local_cfl[_XDIR_] = (absolute(vx)+c)*dt*dxinv; /* local cfl for this grid point (x) */
45  local_cfl[_YDIR_] = (absolute(vy)+c)*dt*dyinv; /* local cfl for this grid point (y) */
46  if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_];
47  if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_];
48 
49  _ArrayIncrementIndex_(ndims,dim,index,done);
50  }
51 
52  return(max_cfl);
53 }
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
double * u
Definition: hypar.h:116
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _YDIR_
Definition: euler2d.h:41
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
int ghosts
Definition: hypar.h:52
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _DECLARE_IERR_
Definition: basic.h:17
double * dxinv
Definition: hypar.h:110

◆ NavierStokes2DFlux()

int NavierStokes2DFlux ( double *  f,
double *  u,
int  dir,
void *  s,
double  t 
)

Compute the hyperbolic flux function for the 2D Navier-Stokes equations:

\begin{eqnarray} dir = x, & {\bf f}\left({\bf u}\right) = \left[\begin{array}{c} \rho u \\ \rho u^2 + p \\ \rho u v \\ (e+p)u \end{array}\right], \\ dir = y, & {\bf f}\left({\bf u}\right) = \left[\begin{array}{c} \rho v \\ \rho u v \\ \rho v^2 + p \\ (e+p)v \end{array}\right] \end{eqnarray}

Note: the flux function needs to be computed at the ghost points as well.

Parameters
fArray to hold the computed flux vector (same layout as u)
uArray with the solution vector
dirSpatial dimension (x or y) for which to compute the flux
sSolver object of type HyPar
tCurrent simulation time

Definition at line 21 of file NavierStokes2DFlux.c.

28 {
29  HyPar *solver = (HyPar*) s;
30  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
31  int *dim = solver->dim_local;
32  int ghosts = solver->ghosts;
33  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
34 
35  /* set bounds for array index to include ghost points */
36  _ArrayAddCopy1D_(dim,(2*ghosts),bounds,_MODEL_NDIMS_);
37  /* set offset such that index is compatible with ghost point arrangement */
38  _ArraySetValue_(offset,_MODEL_NDIMS_,-ghosts);
39 
40  int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0);
41  while (!done) {
42  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
43  double rho, vx, vy, e, P;
44  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma);
45  _NavierStokes2DSetFlux_((f+_MODEL_NVARS_*p),rho,vx,vy,e,P,dir);
46  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
47  }
48 
49  return(0);
50 }
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
#define _ArrayAddCopy1D_(x, a, y, size)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
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.
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
#define _NavierStokes2DSetFlux_(f, rho, vx, vy, e, P, dir)
#define _MODEL_NVARS_
Definition: euler1d.h:58

◆ NavierStokes2DStiffFlux()

int NavierStokes2DStiffFlux ( double *  f,
double *  u,
int  dir,
void *  s,
double  t 
)

Compute the stiff flux, given the solution vector. The stiff flux is the component of the total flux that represents the acoustic modes (see _NavierStokes2DSetStiffFlux_). Here, the linearized approximation to the stiff flux is computed as:

\begin{equation} {\bf f}\left({\bf u}\right) = A_f{\bf u} \end{equation}

where \(A_f = A_f\left({\bf u}_{ref}\right)\) is the fast Jacobian (NavierStokes2D::fast_jac) evaluated for the solution at the beginning of each time step ( \({\bf u}_{ref}\) is NavierStokes2D::solution). This is done in NavierStokes2DPreStep().

Note: the flux function needs to be computed at the ghost points as well.

Parameters
fArray to hold the computed flux vector (same layout as u)
uArray with the solution vector
dirSpatial dimension (x or y) for which to compute the flux
sSolver object of type HyPar
tCurrent simulation time

Definition at line 63 of file NavierStokes2DFlux.c.

70 {
71  HyPar *solver = (HyPar*) s;
72  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
73  int *dim = solver->dim_local;
74  int ghosts = solver->ghosts;
75  static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_;
76  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
77 
78  /* set bounds for array index to include ghost points */
79  _ArrayAddCopy1D_(dim,(2*ghosts),bounds,_MODEL_NDIMS_);
80  /* set offset such that index is compatible with ghost point arrangement */
81  _ArraySetValue_(offset,_MODEL_NDIMS_,-ghosts);
82 
83  int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0);
84  while (!done) {
85  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
86  double *Af = param->fast_jac+(2*p+dir)*JacSize;
88  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
89  }
90 
91  return(0);
92 }
#define _ArrayAddCopy1D_(x, a, y, size)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
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.
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
#define _MODEL_NVARS_
Definition: euler1d.h:58

◆ NavierStokes2DNonStiffFlux()

int NavierStokes2DNonStiffFlux ( double *  f,
double *  u,
int  dir,
void *  s,
double  t 
)

Compute the non-stiff flux, given the solution vector. The non-stiff flux is the component of the total flux that represents the entropy modes (see _NavierStokes2DSetNonStiffFlux_). Here, the linearized approximation to the non-stiff flux is computed as:

\begin{equation} {\bf f}\left({\bf u}\right) - A_f{\bf u} \end{equation}

where \({\bf f}\left({\bf u}\right)\) is the total flux computed in NavierStokes2DFlux(), and \(A_f{\bf u}\) is the linearized stiff flux computed in NavierStokes2DStiffFlux().

Note: the flux function needs to be computed at the ghost points as well.

Parameters
fArray to hold the computed flux vector (same layout as u)
uArray with the solution vector
dirSpatial dimension (x or y) for which to compute the flux
sSolver object of type HyPar
tCurrent simulation time

Definition at line 104 of file NavierStokes2DFlux.c.

111 {
112  HyPar *solver = (HyPar*) s;
113  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
114  int *dim = solver->dim_local;
115  int ghosts = solver->ghosts;
116  static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_;
117  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
118  static double ftot[_MODEL_NVARS_], fstiff[_MODEL_NVARS_];
119 
120  /* set bounds for array index to include ghost points */
121  _ArrayAddCopy1D_(dim,(2*ghosts),bounds,_MODEL_NDIMS_);
122  /* set offset such that index is compatible with ghost point arrangement */
123  _ArraySetValue_(offset,_MODEL_NDIMS_,-ghosts);
124 
125  int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0);
126  while (!done) {
127  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
128  /* compute total flux */
129  double rho, vx, vy, e, P;
130  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma);
131  _NavierStokes2DSetFlux_(ftot,rho,vx,vy,e,P,dir);
132  /* compute stiff stuff */
133  double *Af = param->fast_jac+(2*p+dir)*JacSize;
134  MatVecMult4(_MODEL_NVARS_,fstiff,Af,(u+_MODEL_NVARS_*p));
135  /* subtract stiff flux from total flux */
136  _ArraySubtract1D_((f+_MODEL_NVARS_*p),ftot,fstiff,_MODEL_NVARS_);
137  /* Done */
138  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
139  }
140 
141  return(0);
142 }
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
#define _ArraySubtract1D_(x, a, b, size)
#define _ArrayAddCopy1D_(x, a, y, size)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
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.
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
#define _NavierStokes2DSetFlux_(f, rho, vx, vy, e, P, dir)
#define _MODEL_NVARS_
Definition: euler1d.h:58

◆ NavierStokes2DRoeAverage()

int NavierStokes2DRoeAverage ( double *  uavg,
double *  uL,
double *  uR,
void *  p 
)

Compute the Roe-averaged state for the 2D Navier Stokes equations. This function just calls the macro _NavierStokes2DRoeAverage_ and is not used by any functions within the 2D Navier Stokes module. However, it's necessary to define it and provide it to the the solver object (HyPar) so that it can then send it to interpolation functions for a characteristic-based reconstruction.

Parameters
uavgThe computed Roe-averaged state
uLLeft state (conserved variables)
uRRight state (conserved variables)
pObject of type NavierStokes2D with physics-related variables

Definition at line 15 of file NavierStokes2DFunctions.c.

21 {
22  NavierStokes2D *param = (NavierStokes2D*) p;
23  _NavierStokes2DRoeAverage_(uavg,uL,uR,param->gamma);
24  return(0);
25 }
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
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.

◆ NavierStokes2DParabolicFunction()

int NavierStokes2DParabolicFunction ( double *  par,
double *  u,
void *  s,
void *  m,
double  t 
)

Compute the viscous terms in the 2D Navier Stokes equations: this function computes the following:

\begin{equation} \frac {\partial} {\partial x} \left[\begin{array}{c} 0 \\ \tau_{xx} \\ \tau_{yx} \\ u \tau_{xx} + v \tau_{yx} - q_x \end{array}\right] + \frac {\partial} {\partial y} \left[\begin{array}{c} 0 \\ \tau_{xy} \\ \tau_{yy} \\ u \tau_{xy} + v \tau_{yy} - q_y \end{array}\right] \end{equation}

where

\begin{align} \tau_{xx} &= \frac{2}{3}\left(\frac{\mu}{Re}\right)\left(2\frac{\partial u}{\partial x} - \frac{\partial v}{\partial y}\right),\\ \tau_{xy} &= \left(\frac{\mu}{Re}\right)\left(\frac{\partial u}{\partial y} + \frac{\partial v}{\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}\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} \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. NavierStokes2DInitialize() assigns this function to HyPar::ParabolicFunction.

Reference:

  • Tannehill, Anderson and Pletcher, Computational Fluid Mechanics and Heat Transfer, Chapter 5, Section 5.1.7 (However, the non-dimensional velocity and the Reynolds number is based on speed of sound, instead of the freestream velocity).
Parameters
parArray to hold the computed viscous terms
uSolution vector array
sSolver object of type HyPar
mMPI object of type MPIVariables
tCurrent simulation time

Definition at line 38 of file NavierStokes2DParabolicFunction.c.

45 {
46  HyPar *solver = (HyPar*) s;
47  MPIVariables *mpi = (MPIVariables*) m;
48  NavierStokes2D *physics = (NavierStokes2D*) solver->physics;
49  int i,j,v;
51 
52  int ghosts = solver->ghosts;
53  int imax = solver->dim_local[0];
54  int jmax = solver->dim_local[1];
55  int *dim = solver->dim_local;
56  int nvars = solver->nvars;
57  int ndims = solver->ndims;
58  int size = (imax+2*ghosts)*(jmax+2*ghosts)*nvars;
59 
60  _ArraySetValue_(par,size,0.0);
61  if (physics->Re <= 0) return(0); /* inviscid flow */
62  solver->count_par++;
63 
64  static double two_third = 2.0/3.0;
65  double inv_gamma_m1 = 1.0 / (physics->gamma-1.0);
66  double inv_Re = 1.0 / physics->Re;
67  double inv_Pr = 1.0 / physics->Pr;
68 
69  double *Q; /* primitive variables */
70  Q = (double*) calloc (size,sizeof(double));
71  for (i=-ghosts; i<(imax+ghosts); i++) {
72  for (j=-ghosts; j<(jmax+ghosts); j++) {
73  int p,index[2]; index[0]=i; index[1]=j;
74  double energy,pressure;
75  _ArrayIndex1D_(ndims,dim,index,ghosts,p); p *= nvars;
76  _NavierStokes2DGetFlowVar_( (u+p),Q[p+0],Q[p+1],Q[p+2],energy,
77  pressure,physics->gamma);
78  Q[p+3] = physics->gamma*pressure/Q[p+0]; /* temperature */
79  }
80  }
81 
82  double *QDerivX = (double*) calloc (size,sizeof(double));
83  double *QDerivY = (double*) calloc (size,sizeof(double));
84 
85  IERR solver->FirstDerivativePar(QDerivX,Q,_XDIR_,1,solver,mpi); CHECKERR(ierr);
86  IERR solver->FirstDerivativePar(QDerivY,Q,_YDIR_,1,solver,mpi); CHECKERR(ierr);
87 
88  IERR MPIExchangeBoundariesnD(solver->ndims,solver->nvars,dim,
89  solver->ghosts,mpi,QDerivX); CHECKERR(ierr);
90  IERR MPIExchangeBoundariesnD(solver->ndims,solver->nvars,dim,
91  solver->ghosts,mpi,QDerivY); CHECKERR(ierr);
92 
93  for (i=-ghosts; i<(imax+ghosts); i++) {
94  for (j=-ghosts; j<(jmax+ghosts); j++) {
95  int p,index[2]; index[0]=i; index[1]=j;
96  double dxinv, dyinv;
97  _ArrayIndex1D_(ndims,dim,index,ghosts,p); p *= nvars;
98  _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv);
99  _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv);
100  _ArrayScale1D_((QDerivX+p),dxinv,nvars);
101  _ArrayScale1D_((QDerivY+p),dyinv,nvars);
102  }
103  }
104 
105  double *FViscous = (double*) calloc (size,sizeof(double));
106  double *FDeriv = (double*) calloc (size,sizeof(double));
107 
108  /* Along X */
109  for (i=-ghosts; i<(imax+ghosts); i++) {
110  for (j=-ghosts; j<(jmax+ghosts); j++) {
111  int p,index[2]; index[0]=i; index[1]=j;;
112  _ArrayIndex1D_(ndims,dim,index,ghosts,p); p *= nvars;
113 
114  double uvel, vvel, T, Tx, ux, uy, vx, vy;
115  uvel = (Q+p)[1];
116  vvel = (Q+p)[2];
117  T = (Q+p)[3];
118  Tx = (QDerivX+p)[3];
119  ux = (QDerivX+p)[1];
120  vx = (QDerivX+p)[2];
121  uy = (QDerivY+p)[1];
122  vy = (QDerivY+p)[2];
123 
124  /* calculate viscosity coeff based on Sutherland's law */
125  double mu = raiseto(T, 0.76);
126 
127  double tau_xx, tau_xy, qx;
128  tau_xx = two_third * (mu*inv_Re) * (2*ux - vy);
129  tau_xy = (mu*inv_Re) * (uy + vx);
130  qx = ( (mu*inv_Re) * inv_gamma_m1 * inv_Pr ) * Tx;
131 
132  (FViscous+p)[0] = 0.0;
133  (FViscous+p)[1] = tau_xx;
134  (FViscous+p)[2] = tau_xy;
135  (FViscous+p)[3] = uvel*tau_xx + vvel*tau_xy + qx;
136  }
137  }
138  IERR solver->FirstDerivativePar(FDeriv,FViscous,_XDIR_,-1,solver,mpi); CHECKERR(ierr);
139  for (i=0; i<imax; i++) {
140  for (j=0; j<jmax; j++) {
141  int p,index[2]; index[0]=i; index[1]=j;
142  double dxinv;
143  _ArrayIndex1D_(ndims,dim,index,ghosts,p); p *= nvars;
144  _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv);
145  for (v=0; v<nvars; v++) (par+p)[v] += (dxinv * (FDeriv+p)[v] );
146  }
147  }
148 
149  /* Along Y */
150  for (i=-ghosts; i<(imax+ghosts); i++) {
151  for (j=-ghosts; j<(jmax+ghosts); j++) {
152  int p,index[2]; index[0]=i; index[1]=j;
153  _ArrayIndex1D_(ndims,dim,index,ghosts,p); p *= nvars;
154 
155  double uvel, vvel, T, Ty, ux, uy, vx, vy;
156  uvel = (Q+p)[1];
157  vvel = (Q+p)[2];
158  T = (Q+p)[3];
159  Ty = (QDerivY+p)[3];
160  ux = (QDerivX+p)[1];
161  vx = (QDerivX+p)[2];
162  uy = (QDerivY+p)[1];
163  vy = (QDerivY+p)[2];
164 
165  /* calculate viscosity coeff based on Sutherland's law */
166  double mu = raiseto(T, 0.76);
167 
168  double tau_yx, tau_yy, qy;
169  tau_yx = (mu*inv_Re) * (uy + vx);
170  tau_yy = two_third * (mu*inv_Re) * (-ux + 2*vy);
171  qy = ( (mu*inv_Re) * inv_gamma_m1 * inv_Pr ) * Ty;
172 
173  (FViscous+p)[0] = 0.0;
174  (FViscous+p)[1] = tau_yx;
175  (FViscous+p)[2] = tau_yy;
176  (FViscous+p)[3] = uvel*tau_yx + vvel*tau_yy + qy;
177  }
178  }
179  IERR solver->FirstDerivativePar(FDeriv,FViscous,_YDIR_,-1,solver,mpi); CHECKERR(ierr);
180  for (i=0; i<imax; i++) {
181  for (j=0; j<jmax; j++) {
182  int p,index[2]; index[0]=i; index[1]=j;
183  double dyinv;
184  _ArrayIndex1D_(ndims,dim,index,ghosts,p); p *= nvars;
185  _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv);
186  for (v=0; v<nvars; v++) (par+p)[v] += (dyinv * (FDeriv+p)[v] );
187  }
188  }
189 
190  free(Q);
191  free(QDerivX);
192  free(QDerivY);
193  free(FViscous);
194  free(FDeriv);
195 
196  return(0);
197 }
int nvars
Definition: hypar.h:29
#define IERR
Definition: basic.h:16
#define CHECKERR(ierr)
Definition: basic.h:18
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
int MPIExchangeBoundariesnD(int, int, int *, int, void *, double *)
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _YDIR_
Definition: euler2d.h:41
int count_par
Definition: hypar.h:418
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
int(* FirstDerivativePar)(double *, double *, int, int, void *, void *)
Definition: hypar.h:243
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
int ghosts
Definition: hypar.h:52
Structure of MPI-related variables.
#define _ArrayScale1D_(x, a, size)
#define raiseto(x, a)
Definition: math_ops.h:37
#define _DECLARE_IERR_
Definition: basic.h:17
double * dxinv
Definition: hypar.h:110

◆ NavierStokes2DSource()

int NavierStokes2DSource ( double *  source,
double *  u,
void *  s,
void *  m,
double  t 
)

Computes the gravitational source term using a well-balanced formulation: the source term is rewritten as follows:

\begin{equation} \left[\begin{array}{c} 0 \\ -\rho {\bf g}\cdot{\bf \hat{i}} \\ -\rho {\bf g}\cdot{\bf \hat{j}} \\ -\rho u {\bf g}\cdot{\bf \hat{i}} - \rho v {\bf g}\cdot{\bf \hat{j}} \end{array}\right] = \left[\begin{array}{cccc} 0 & p_0 \varrho^{-1} & 0 & p_0 u \varrho^{-1} \end{array}\right] \cdot \frac{\partial}{\partial x}\left[\begin{array}{c} 0 \\ \varphi \\ 0 \\ \varphi \end{array}\right] + \left[\begin{array}{cccc} 0 & 0 & p_0 \varrho^{-1} & p_0 v \varrho^{-1} \end{array}\right] \cdot \frac{\partial}{\partial y}\left[\begin{array}{c} 0 \\ 0 \\ \varphi \\ \varphi \end{array}\right] \end{equation}

where \(\varphi = \varphi\left(x,y\right)\) and \(\varrho = \varrho\left(x,y\right)\) are computed in NavierStokes2DGravityField(). The derivatives are computed in an exactly identical manner as the hyperbolic flux (i.e., using a conservative finite-difference formulation) (see HyperbolicFunction()).

References:

  • Ghosh, D., Constantinescu, E.M., Well-Balanced Formulation of Gravitational Source Terms for Conservative Finite-Difference Atmospheric Flow Solvers, AIAA Paper 2015-2889, 7th AIAA Atmospheric and Space Environments Conference, June 22-26, 2015, Dallas, TX, http://dx.doi.org/10.2514/6.2015-2889
  • Ghosh, D., Constantinescu, E.M., A Well-Balanced, Conservative Finite-Difference Algorithm for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580.
Parameters
sourceArray to hold the computed source
uSolution vector array
sSolver object of type HyPar
mMPI object of type MPIVariables
tCurrent simulation time

Definition at line 37 of file NavierStokes2DSource.c.

44 {
45  HyPar *solver = (HyPar* ) s;
46  MPIVariables *mpi = (MPIVariables*) m;
47  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
48 
49  if ((param->grav_x == 0.0) && (param->grav_y == 0.0))
50  return(0); /* no gravitational forces */
51 
52  int v, done, p, p1, p2;
53  double *SourceI = solver->fluxI; /* interace source term */
54  double *SourceC = solver->fluxC; /* cell-centered source term */
55  double *SourceL = solver->fL;
56  double *SourceR = solver->fR;
57 
58  int ndims = solver->ndims;
59  int ghosts = solver->ghosts;
60  int *dim = solver->dim_local;
61  double *x = solver->x;
62  double *dxinv = solver->dxinv;
63  double RT = param->p0 / param->rho0;
64  int index[ndims],index1[ndims],index2[ndims],dim_interface[ndims];
65 
66  /* Along X-direction */
67  if (param->grav_x != 0.0) {
68  /* set interface dimensions */
69  _ArrayCopy1D_(dim,dim_interface,ndims); dim_interface[_XDIR_]++;
70  /* calculate the split source function exp(-phi/RT) */
71  IERR NavierStokes2DSourceFunction(SourceC,u,x,solver,mpi,t,_XDIR_); CHECKERR(ierr);
72  /* calculate the left and right interface source terms */
73  IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr);
74  IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr);
75  /* calculate the final interface source term */
76  IERR NavierStokes2DSourceUpwind(SourceI,SourceL,SourceR,u,_XDIR_,solver,t);
77  /* calculate the final cell-centered source term */
78  done = 0; _ArraySetValue_(index,ndims,0);
79  while (!done) {
80  _ArrayCopy1D_(index,index1,ndims);
81  _ArrayCopy1D_(index,index2,ndims); index2[_XDIR_]++;
82  _ArrayIndex1D_(ndims,dim ,index ,ghosts,p );
83  _ArrayIndex1D_(ndims,dim_interface,index1,0 ,p1);
84  _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2);
85 
86  double dx_inverse; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,dxinv,dx_inverse);
87  double rho, uvel, vvel, e, P;
88  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,uvel,vvel,e,P,param->gamma);
89  double term[_MODEL_NVARS_] = {0.0, rho*RT, 0.0, rho*RT*uvel};
90  for (v=0; v<_MODEL_NVARS_; v++) {
91  source[_MODEL_NVARS_*p+v] += ( (term[v]*param->grav_field_f[p])
92  * (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse );
93  }
94  uvel = P; /* useless statement to avoid compiler warnings */
95  _ArrayIncrementIndex_(ndims,dim,index,done);
96  }
97  }
98 
99  /* Along Y-direction */
100  if (param->grav_y != 0.0) {
101  /* set interface dimensions */
102  _ArrayCopy1D_(dim,dim_interface,ndims); dim_interface[_YDIR_]++;
103  /* calculate the split source function exp(-phi/RT) */
104  IERR NavierStokes2DSourceFunction(SourceC,u,x,solver,mpi,t,_YDIR_); CHECKERR(ierr);
105  /* calculate the left and right interface source terms */
106  IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_YDIR_,solver,mpi,0); CHECKERR(ierr);
107  IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_YDIR_,solver,mpi,0); CHECKERR(ierr);
108  /* calculate the final interface source term */
109  IERR NavierStokes2DSourceUpwind(SourceI,SourceL,SourceR,u,_YDIR_,solver,t);
110 
111  /* calculate the final cell-centered source term */
112  done = 0; _ArraySetValue_(index,ndims,0);
113  while (!done) {
114  _ArrayCopy1D_(index,index1,ndims);
115  _ArrayCopy1D_(index,index2,ndims); index2[_YDIR_]++;
116  _ArrayIndex1D_(ndims,dim ,index ,ghosts,p );
117  _ArrayIndex1D_(ndims,dim_interface,index1,0 ,p1);
118  _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2);
119 
120  double dy_inverse; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,dxinv,dy_inverse);
121  double rho, uvel, vvel, e, P;
122  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,uvel,vvel,e,P,param->gamma);
123  double term[_MODEL_NVARS_] = {0.0, 0.0, rho*RT, rho*RT*vvel};
124  for (v=0; v<_MODEL_NVARS_; v++) {
125  source[_MODEL_NVARS_*p+v] += ( (term[v]*param->grav_field_f[p])
126  * (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dy_inverse );
127  }
128  uvel = P; /* useless statement to avoid compiler warnings */
129  _ArrayIncrementIndex_(ndims,dim,index,done);
130  }
131  }
132 
133  return(0);
134 }
#define IERR
Definition: basic.h:16
#define CHECKERR(ierr)
Definition: basic.h:18
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
static int NavierStokes2DSourceFunction(double *, double *, double *, void *, void *, double, int)
double * x
Definition: hypar.h:107
double * fluxI
Definition: hypar.h:136
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _YDIR_
Definition: euler2d.h:41
int(* InterpolateInterfacesHyp)(double *, double *, double *, double *, int, int, void *, void *, int)
Definition: hypar.h:224
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
void * physics
Definition: hypar.h:266
static int NavierStokes2DSourceUpwind(double *, double *, double *, double *, int, void *, double)
double * fR
Definition: hypar.h:139
double * fL
Definition: hypar.h:139
#define _XDIR_
Definition: euler1d.h:75
int ghosts
Definition: hypar.h:52
Structure of MPI-related variables.
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
double * fluxC
Definition: hypar.h:128
double * dxinv
Definition: hypar.h:110

◆ NavierStokes2DJacobian()

int NavierStokes2DJacobian ( double *  Jac,
double *  u,
void *  p,
int  dir,
int  nvars,
int  upw 
)

Function to compute the flux Jacobian of the 2D Navier-Stokes equations, given the solution at a grid point. The Jacobian is square matrix of size nvar=4, and is returned as a 1D array (double) of 16 elements in row-major format.

Parameters
JacJacobian matrix: 1D array of size nvar^2 = 16
usolution at a grid point (array of size nvar = 4)
pobject containing the physics-related parameters
dirdimension (0 -> x, 1 -> y)
nvarsnumber of vector components
upw0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux

Definition at line 14 of file NavierStokes2DJacobian.c.

24 {
25  NavierStokes2D *param = (NavierStokes2D*) p;
28 
29  /* get the eigenvalues and left,right eigenvectors */
30  _NavierStokes2DEigenvalues_ (u,D,param->gamma,dir);
31  _NavierStokes2DLeftEigenvectors_ (u,L,param->gamma,dir);
33 
34  int aupw = absolute(upw), k;
35  k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) );
36  k = 5; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) );
37  k = 10; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) );
38  k = 15; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) );
39 
40  MatMult4(_MODEL_NVARS_,DL,D,L);
41  MatMult4(_MODEL_NVARS_,Jac,R,DL);
42 
43  return(0);
44 }
#define absolute(a)
Definition: math_ops.h:32
#define min(a, b)
Definition: math_ops.h:14
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
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.
#define MatMult4(N, A, X, Y)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DStiffJacobian()

int NavierStokes2DStiffJacobian ( double *  Jac,
double *  u,
void *  p,
int  dir,
int  nvars,
int  upw 
)

Function to compute the Jacobian of the fast flux (representing the acoustic waves) of the 2D Navier-Stokes equations, given the solution at a grid point. The Jacobian is square matrix of size nvar=4, and is returned as a 1D array (double) of 16 elements in row-major format.

Parameters
JacJacobian matrix: 1D array of size nvar^2 = 16
usolution at a grid point (array of size nvar = 4)
pobject containing the physics-related parameters
dirdimension (0 -> x, 1 -> y)
nvarsnumber of vector components
upw0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux

Definition at line 51 of file NavierStokes2DJacobian.c.

61 {
62  NavierStokes2D *param = (NavierStokes2D*) p;
65 
66  /* get the eigenvalues and left,right eigenvectors */
67  _NavierStokes2DEigenvalues_ (u,D,param->gamma,dir);
68  _NavierStokes2DLeftEigenvectors_ (u,L,param->gamma,dir);
70 
71  int aupw = absolute(upw), k;
72  k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) );
73  k = 5; D[k] = ( dir == _YDIR_ ? 0.0 : absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ) );
74  k = 10; D[k] = ( dir == _XDIR_ ? 0.0 : absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ) );
75  k = 15; D[k] = 0.0;
76 
77  MatMult4(_MODEL_NVARS_,DL,D,L);
78  MatMult4(_MODEL_NVARS_,Jac,R,DL);
79 
80  return(0);
81 }
#define absolute(a)
Definition: math_ops.h:32
#define min(a, b)
Definition: math_ops.h:14
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
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.
#define MatMult4(N, A, X, Y)
#define _XDIR_
Definition: euler1d.h:75
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DLeftEigenvectors()

int NavierStokes2DLeftEigenvectors ( double *  u,
double *  L,
void *  p,
int  dir 
)

Compute the left eigenvections for the 2D Navier Stokes equations. This function just calls the macro _NavierStokes2DLeftEigenvectors_ and is not used by any functions within the 2D Navier Stokes module. However, it's necessary to define it and provide it to the the solver object (HyPar) so that it can then send it to interpolation functions for a characteristic-based reconstruction.

Parameters
uConserved solution at a grid point
LArray of size nvar^2 = 4^2 to save the matrix of left eigenvectors in (row-major format).
pObject of type NavierStokes2D with physics-related variables
dirSpatial dimension (x or y)

Definition at line 19 of file NavierStokes2DEigen.c.

26 {
27  NavierStokes2D *param = (NavierStokes2D*) p;
29  return(0);
30 }
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
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.

◆ NavierStokes2DRightEigenvectors()

int NavierStokes2DRightEigenvectors ( double *  u,
double *  R,
void *  p,
int  dir 
)

Compute the right eigenvections for the 2D Navier Stokes equations. This function just calls the macro _NavierStokes2DRightEigenvectors_ and is not used by any functions within the 2D Navier Stokes module. However, it's necessary to define it and provide it to the the solver object (HyPar) so that it can then send it to interpolation functions for a characteristic-based reconstruction.

Parameters
uConserved solution at a grid point
RArray of size nvar^2 = 4^2 to save the matrix of right eigenvectors in (row-major format).
pObject of type NavierStokes2D with physics-related variables
dirSpatial dimension (x or y)

Definition at line 38 of file NavierStokes2DEigen.c.

45 {
46  NavierStokes2D *param = (NavierStokes2D*) p;
48  return(0);
49 }
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
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.

◆ NavierStokes2DUpwindRoe()

int NavierStokes2DUpwindRoe ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

Roe's upwinding scheme.

\begin{equation} {\bf f}_{j+1/2} = \frac{1}{2}\left[ {\bf f}_{j+1/2}^L + {\bf f}_{j+1/2}^R - \left| A\left({\bf u}_{j+1/2}^L,{\bf u}_{j+1/2}^R\right) \right| \left( {\bf u}_{j+1/2}^R - {\bf u}_{j+1/2}^L \right)\right] \end{equation}

This upwinding scheme is modified for the balanced discretization of the 2D Navier Stokes equations when there is a non-zero gravitational force. See the reference below. For flows without any gravitational forces, it reduces to its original form.

  • Ghosh, D., Constantinescu, E.M., Well-Balanced Formulation of Gravitational Source Terms for Conservative Finite-Difference Atmospheric Flow Solvers, AIAA Paper 2015-2889, 7th AIAA Atmospheric and Space Environments Conference, June 22-26, 2015, Dallas, TX, http://dx.doi.org/10.2514/6.2015-2889
  • Ghosh, D., Constantinescu, E.M., A Well-Balanced, Conservative Finite-Difference Algorithm for Atmospheric Flows, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 34 of file NavierStokes2DUpwind.c.

45 {
46  HyPar *solver = (HyPar*) s;
47  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
48  int done;
49 
50  int *dim = solver->dim_local;
51 
52  int bounds_outer[2], bounds_inter[2];
53  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
54  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
58 
59  done = 0; int index_outer[2] = {0,0}; int index_inter[2];
60  while (!done) {
61  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
62  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
63  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
64  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
65  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
66  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
67  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
68  double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_];
69 
70  /* Roe's upwinding scheme */
71 
72  udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]);
73  udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]);
74  udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]);
75  udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]);
76 
77  _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma);
78  _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir);
79  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
80  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
81 
82  /* Harten's Entropy Fix - Page 362 of Leveque */
83  int k;
84  double delta = 0.000001, delta2 = delta*delta;
85  double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
86  k=0; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) );
87  k=5; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) );
88  k=10; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) );
89  k=15; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) );
90 
91  MatMult4(_MODEL_NVARS_,DL,D,L);
92  MatMult4(_MODEL_NVARS_,modA,R,DL);
93  MatVecMult4(_MODEL_NVARS_,udiss,modA,udiff);
94 
95  fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0];
96  fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1];
97  fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2];
98  fI[_MODEL_NVARS_*p+3] = 0.5 * (fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3];
99  }
100  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
101  }
102 
103  return(0);
104 }
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
#define MatMult4(N, A, X, Y)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DUpwindRF()

int NavierStokes2DUpwindRF ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

Characteristic-based Roe-fixed upwinding scheme.

\begin{align} \alpha_{j+1/2}^{k,L} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf f}_{j+1/2}^{k,L}, \\ \alpha_{j+1/2}^{k,R} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf f}_{j+1/2}^{k,R}, \\ v_{j+1/2}^{k,L} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf u}_{j+1/2}^{k,L}, \\ v_{j+1/2}^{k,R} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf u}_{j+1/2}^{k,R}, \\ \alpha_{j+1/2}^k &= \left\{ \begin{array}{cc} \alpha_{j+1/2}^{k,L} & {\rm if}\ \lambda_{j,j+1/2,j+1} > 0 \\ \alpha_{j+1/2}^{k,R} & {\rm if}\ \lambda_{j,j+1/2,j+1} < 0 \\ \frac{1}{2}\left[ \alpha_{j+1/2}^{k,L} + \alpha_{j+1/2}^{k,R} - \left(\max_{\left[j,j+1\right]} \lambda\right) \left( v_{j+1/2}^{k,R} - v_{j+1/2}^{k,L} \right) \right] & {\rm otherwise} \end{array}\right., \\ {\bf f}_{j+1/2} &= \sum_{k=1}^3 \alpha_{j+1/2}^k {\bf r}_{j+1/2}^k \end{align}

where \({\bf l}\), \({\bf r}\), and \(\lambda\) are the left-eigenvectors, right-eigenvectors and eigenvalues. The subscripts denote the grid locations.

Note that this upwinding scheme cannot be used for solving flows with non-zero gravitational forces.

Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 120 of file NavierStokes2DUpwind.c.

131 {
132  HyPar *solver = (HyPar*) s;
133  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
134  int done,k;
135 
136  int *dim = solver->dim_local;
137 
138  int bounds_outer[2], bounds_inter[2];
139  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
140  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
143 
144  done = 0; int index_outer[2] = {0,0}, index_inter[2];
145  while (!done) {
146  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
147  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
148  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
149  double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_],
150  ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_];
151 
152  /* Roe-Fixed upwinding scheme */
153 
154  _NavierStokes2DRoeAverage_(uavg,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param->gamma);
155 
156  _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir);
157  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
158  _NavierStokes2DRightEigenvectors_(uavg,R,param->gamma,dir);
159 
160  /* calculate characteristic fluxes and variables */
165 
166  double eigL[4],eigC[4],eigR[4];
167  _NavierStokes2DEigenvalues_((uL+_MODEL_NVARS_*p),D,param->gamma,dir);
168  eigL[0] = D[0];
169  eigL[1] = D[5];
170  eigL[2] = D[10];
171  eigL[3] = D[15];
172  _NavierStokes2DEigenvalues_((uR+_MODEL_NVARS_*p),D,param->gamma,dir);
173  eigR[0] = D[0];
174  eigR[1] = D[5];
175  eigR[2] = D[10];
176  eigR[3] = D[15];
177  _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir);
178  eigC[0] = D[0];
179  eigC[1] = D[5];
180  eigC[2] = D[10];
181  eigC[3] = D[15];
182 
183  for (k = 0; k < _MODEL_NVARS_; k++) {
184  if ((eigL[k] > 0) && (eigC[k] > 0) && (eigR[k] > 0)) fc[k] = fcL[k];
185  else if ((eigL[k] < 0) && (eigC[k] < 0) && (eigR[k] < 0)) fc[k] = fcR[k];
186  else {
187  double alpha = max3(absolute(eigL[k]),absolute(eigC[k]),absolute(eigR[k]));
188  fc[k] = 0.5 * (fcL[k] + fcR[k] + alpha * (ucL[k]-ucR[k]));
189  }
190  }
191 
192  /* calculate the interface flux from the characteristic flux */
194  }
195  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
196  }
197 
198  return(0);
199 }
#define max3(a, b, c)
Definition: math_ops.h:27
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
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.
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58

◆ NavierStokes2DUpwindLLF()

int NavierStokes2DUpwindLLF ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

Characteristic-based local Lax-Friedrich upwinding scheme.

\begin{align} \alpha_{j+1/2}^{k,L} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf f}_{j+1/2}^{k,L}, \\ \alpha_{j+1/2}^{k,R} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf f}_{j+1/2}^{k,R}, \\ v_{j+1/2}^{k,L} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf u}_{j+1/2}^{k,L}, \\ v_{j+1/2}^{k,R} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf u}_{j+1/2}^{k,R}, \\ \alpha_{j+1/2}^k &= \frac{1}{2}\left[ \alpha_{j+1/2}^{k,L} + \alpha_{j+1/2}^{k,R} - \left(\max_{\left[j,j+1\right]} \lambda\right) \left( v_{j+1/2}^{k,R} - v_{j+1/2}^{k,L} \right) \right], \\ {\bf f}_{j+1/2} &= \sum_{k=1}^3 \alpha_{j+1/2}^k {\bf r}_{j+1/2}^k \end{align}

where \({\bf l}\), \({\bf r}\), and \(\lambda\) are the left-eigenvectors, right-eigenvectors and eigenvalues. The subscripts denote the grid locations.

This upwinding scheme is modified for the balanced discretization of the 2D Navier Stokes equations when there is a non-zero gravitational force. See the reference below. For flows without any gravitational forces, it reduces to its original form.

  • Ghosh, D., Constantinescu, E.M., Well-Balanced Formulation of Gravitational Source Terms for Conservative Finite-Difference Atmospheric Flow Solvers, AIAA Paper 2015-2889, 7th AIAA Atmospheric and Space Environments Conference, June 22-26, 2015, Dallas, TX, http://dx.doi.org/10.2514/6.2015-2889
  • Ghosh, D., Constantinescu, E.M., A Well-Balanced, Conservative Finite-Difference Algorithm for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580.
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 223 of file NavierStokes2DUpwind.c.

234 {
235  HyPar *solver = (HyPar*) s;
236  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
237  int done;
238 
239  int *dim = solver->dim_local;
240 
241  int bounds_outer[2], bounds_inter[2];
242  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
243  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
246 
247  done = 0; int index_outer[2] = {0,0}, index_inter[2];
248  while (!done) {
249  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
250  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
251  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
252  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
253  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
254  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
255  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
256  double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_],
257  ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_];
258  double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
259 
260  /* Local Lax-Friedrich upwinding scheme */
261 
262  _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma);
263  _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir);
264  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
265  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
266 
267  /* calculate characteristic fluxes and variables */
272 
273  double eigL[4],eigC[4],eigR[4];
274  _NavierStokes2DEigenvalues_((u+_MODEL_NVARS_*pL),D,param->gamma,dir);
275  eigL[0] = D[0];
276  eigL[1] = D[5];
277  eigL[2] = D[10];
278  eigL[3] = D[15];
279  _NavierStokes2DEigenvalues_((u+_MODEL_NVARS_*pR),D,param->gamma,dir);
280  eigR[0] = D[0];
281  eigR[1] = D[5];
282  eigR[2] = D[10];
283  eigR[3] = D[15];
284  _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir);
285  eigC[0] = D[0];
286  eigC[1] = D[5];
287  eigC[2] = D[10];
288  eigC[3] = D[15];
289 
290  double alpha;
291  alpha = kappa * max3(absolute(eigL[0]),absolute(eigC[0]),absolute(eigR[0]));
292  fc[0] = 0.5 * (fcL[0] + fcR[0] + alpha * (ucL[0]-ucR[0]));
293  alpha = max3(absolute(eigL[1]),absolute(eigC[1]),absolute(eigR[1]));
294  fc[1] = 0.5 * (fcL[1] + fcR[1] + alpha * (ucL[1]-ucR[1]));
295  alpha = max3(absolute(eigL[2]),absolute(eigC[2]),absolute(eigR[2]));
296  fc[2] = 0.5 * (fcL[2] + fcR[2] + alpha * (ucL[2]-ucR[2]));
297  alpha = max3(absolute(eigL[3]),absolute(eigC[3]),absolute(eigR[3]));
298  fc[3] = 0.5 * (fcL[3] + fcR[3] + alpha * (ucL[3]-ucR[3]));
299 
300  /* calculate the interface flux from the characteristic flux */
302  }
303  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
304  }
305 
306  return(0);
307 }
#define max3(a, b, c)
Definition: math_ops.h:27
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DUpwindSWFS()

int NavierStokes2DUpwindSWFS ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

Steger-Warming Flux-Splitting scheme

  • Steger, J.L., Warming, R.F., "Flux vector splitting of the inviscid gasdynamic equations with application to finite-difference methods", J. Comput. Phys., 40(2), 1981, pp. 263-293, http://dx.doi.org/10.1016/0021-9991(81)90210-2.

Note that this method cannot be used for flows with non-zero gravitational forces.

Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 316 of file NavierStokes2DUpwind.c.

327 {
328  HyPar *solver = (HyPar*) s;
329  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
330  int done,k;
332 
333  int ndims = solver->ndims;
334  int *dim = solver->dim_local;
335 
336  int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims];
337  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
338  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
339  static double fp[_MODEL_NVARS_], fm[_MODEL_NVARS_],uavg[_MODEL_NVARS_];
340 
341  done = 0; _ArraySetValue_(index_outer,ndims,0);
342  while (!done) {
343  _ArrayCopy1D_(index_outer,index_inter,ndims);
344  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
345  int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p);
346  double rho,vx,vy,e,P,c,gamma=param->gamma,term,Mach,lp[_MODEL_NVARS_],lm[_MODEL_NVARS_];
347 
348  /* Steger Warming flux splitting */
349  _NavierStokes2DRoeAverage_(uavg,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param->gamma);
350  _NavierStokes2DGetFlowVar_(uavg,rho,vx,vy,e,P,param->gamma);
351  Mach = (dir==_XDIR_ ? vx : vy) / sqrt(gamma*P/rho);
352 
353  if (Mach < -1.0) {
354 
356 
357  } else if (Mach < 1.0) {
358 
359  double kx = 0, ky = 0;
360  kx = (dir==_XDIR_ ? 1.0 : 0.0);
361  ky = (dir==_YDIR_ ? 1.0 : 0.0);
362 
363  _NavierStokes2DGetFlowVar_((uL+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma);
364  c = sqrt(gamma*P/rho);
365  term = rho/(2.0*gamma);
366  lp[0] = lp[1] = kx*vx + ky*vy;
367  lp[2] = lp[0] + c;
368  lp[3] = lp[0] - c;
369  for (k=0; k<_MODEL_NVARS_; k++) if (lp[k] < 0.0) lp[k] = 0.0;
370 
371  fp[0] = term * (2.0*(gamma-1.0)*lp[0] + lp[2] + lp[3]);
372  fp[1] = term * (2.0*(gamma-1.0)*lp[0]*vx + lp[2]*(vx+c*kx) + lp[3]*(vx-c*kx));
373  fp[2] = term * (2.0*(gamma-1.0)*lp[0]*vy + lp[2]*(vy+c*ky) + lp[3]*(vy-c*ky));
374  fp[3] = term * ((gamma-1.0)*lp[0]*(vx*vx+vy*vy) + 0.5*lp[2]*((vx+c*kx)*(vx+c*kx) + (vy+c*ky)*(vy+c*ky))
375  + 0.5*lp[3]*((vx-c*kx)*(vx-c*kx) + (vy-c*ky)*(vy-c*ky))
376  + ((3.0-gamma)*(lp[2]+lp[3])*c*c)/(2.0*(gamma-1.0)) );
377 
378  _NavierStokes2DGetFlowVar_((uR+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma);
379  c = sqrt(gamma*P/rho);
380  term = rho/(2.0*gamma);
381  lm[0] = lm[1] = kx*vx + ky*vy;
382  lm[2] = lm[0] + c;
383  lm[3] = lm[0] - c;
384  for (k=0; k<_MODEL_NVARS_; k++) if (lm[k] > 0.0) lm[k] = 0.0;
385 
386  fm[0] = term * (2.0*(gamma-1.0)*lm[0] + lm[2] + lm[3]);
387  fm[1] = term * (2.0*(gamma-1.0)*lm[0]*vx + lm[2]*(vx+c*kx) + lm[3]*(vx-c*kx));
388  fm[2] = term * (2.0*(gamma-1.0)*lm[0]*vy + lm[2]*(vy+c*ky) + lm[3]*(vy-c*ky));
389  fm[3] = term * ((gamma-1.0)*lm[0]*(vx*vx+vy*vy) + 0.5*lm[2]*((vx+c*kx)*(vx+c*kx) + (vy+c*ky)*(vy+c*ky))
390  + 0.5*lm[3]*((vx-c*kx)*(vx-c*kx) + (vy-c*ky)*(vy-c*ky))
391  + ((3.0-gamma)*(lm[2]+lm[3])*c*c)/(2.0*(gamma-1.0)) );
392 
394 
395  } else {
396 
398 
399  }
400 
401  }
402  _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done);
403  }
404 
405  return(0);
406 }
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _ArrayAdd1D_(x, a, b, size)
#define _YDIR_
Definition: euler2d.h:41
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _DECLARE_IERR_
Definition: basic.h:17
#define _ArrayCopy1D_(x, y, size)

◆ NavierStokes2DUpwindRusanov()

int NavierStokes2DUpwindRusanov ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

Rusanov's upwinding scheme.

\begin{equation} {\bf f}_{j+1/2} = \frac{1}{2}\left[ {\bf f}_{j+1/2}^L + {\bf f}_{j+1/2}^R - \max_{j,j+1} \nu_j \left( {\bf u}_{j+1/2}^R - {\bf u}_{j+1/2}^L \right)\right] \end{equation}

where \(\nu = c + \left|u\right|\).

  • Rusanov, V. V., "The calculation of the interaction of non-stationary shock waves and obstacles," USSR Computational Mathematics and Mathematical Physics, Vol. 1, No. 2, 1962, pp. 304–320

This upwinding scheme is modified for the balanced discretization of the 2D Navier Stokes equations when there is a non-zero gravitational force. See the reference below. For flows without any gravitational forces, it reduces to its original form.

  • Ghosh, D., Constantinescu, E.M., Well-Balanced Formulation of Gravitational Source Terms for Conservative Finite-Difference Atmospheric Flow Solvers, AIAA Paper 2015-2889, 7th AIAA Atmospheric and Space Environments Conference, June 22-26, 2015, Dallas, TX, http://dx.doi.org/10.2514/6.2015-2889
  • Ghosh, D., Constantinescu, E.M., A Well-Balanced, Conservative Finite-Difference Algorithm for Atmospheric Flows, AIAA Journal, http://dx.doi.org/10.2514/1.J054580.
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 428 of file NavierStokes2DUpwind.c.

439 {
440  HyPar *solver = (HyPar*) s;
441  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
442  int *dim = solver->dim_local, done;
443 
444  int bounds_outer[2], bounds_inter[2];
445  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
446  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
447 
448  done = 0; int index_outer[2] = {0,0}; int index_inter[2];
449  while (!done) {
450  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
451  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
452  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
453  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
454  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
455  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
456  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
457  double udiff[_MODEL_NVARS_],uavg[_MODEL_NVARS_];
458 
459  /* Modified Rusanov's upwinding scheme */
460 
461  udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]);
462  udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]);
463  udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]);
464  udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]);
465 
466  _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma);
467 
468  double c, vel[_MODEL_NDIMS_], rho,E,P;
469  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->gamma);
470  c = sqrt(param->gamma*P/rho);
471  double alphaL = c + absolute(vel[dir]), betaL = absolute(vel[dir]);
472  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->gamma);
473  c = sqrt(param->gamma*P/rho);
474  double alphaR = c + absolute(vel[dir]), betaR = absolute(vel[dir]);
475  _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->gamma);
476  c = sqrt(param->gamma*P/rho);
477  double alphaavg = c + absolute(vel[dir]), betaavg = absolute(vel[dir]);
478 
479  double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
480  double alpha = kappa*max3(alphaL,alphaR,alphaavg);
481 
482  fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0])-alpha*udiff[0];
483  fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1])-alpha*udiff[1];
484  fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2])-alpha*udiff[2];
485  fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3])-alpha*udiff[3];
486  }
487  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
488  }
489 
490  return(0);
491 }
#define max3(a, b, c)
Definition: math_ops.h:27
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DUpwinddFRoe()

int NavierStokes2DUpwinddFRoe ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

The Roe upwinding scheme (NavierStokes2DUpwindRoe) for the partitioned hyperbolic flux that comprises of the acoustic waves only (see NavierStokes2DStiffFlux, _NavierStokes2DSetStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \( u\pm a\) are used. Reference:

  • Ghosh, D., Constantinescu, E. M., Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning, SIAM Journal on Scientific Computing, 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369.
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 589 of file NavierStokes2DUpwind.c.

600 {
601  HyPar *solver = (HyPar*) s;
602  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
603  int done;
604 
605  int *dim = solver->dim_local;
606  double *uref = param->solution;
607 
608  int bounds_outer[2], bounds_inter[2];
609  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
610  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
614 
615  done = 0; int index_outer[2] = {0,0}; int index_inter[2];
616  while (!done) {
617  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
618  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
619  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
620  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
621  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
622  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
623  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
624  double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_];
625 
626  /* Roe's upwinding scheme */
627 
628  udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]);
629  udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]);
630  udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]);
631  udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]);
632 
633  _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma);
634  _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir);
635  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
636  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
637 
638  /* Harten's Entropy Fix - Page 362 of Leveque */
639  int k;
640  double delta = 0.000001, delta2 = delta*delta;
641  double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
642  k=0; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) );
643  k=5; D[k] = (dir == _YDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) );
644  k=10; D[k] = (dir == _XDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) );
645  k=15; D[k] = 0.0;
646 
647  MatMult4(_MODEL_NVARS_,DL,D,L);
648  MatMult4(_MODEL_NVARS_,modA,R,DL);
649  MatVecMult4(_MODEL_NVARS_,udiss,modA,udiff);
650 
651  fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0];
652  fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1];
653  fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2];
654  fI[_MODEL_NVARS_*p+3] = 0.5 * (fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3];
655  }
656  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
657  }
658 
659  return(0);
660 }
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
#define MatMult4(N, A, X, Y)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DUpwinddFRF()

int NavierStokes2DUpwinddFRF ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

The characteristic-based Roe-fixed upwinding scheme (NavierStokes2DUpwindRF) for the partitioned hyperbolic flux that comprises of the acoustic waves only (see NavierStokes2DStiffFlux, _NavierStokes2DSetStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \( u\pm a\) are used. Reference:

  • Ghosh, D., Constantinescu, E. M., Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning, SIAM Journal on Scientific Computing, 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369.
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 670 of file NavierStokes2DUpwind.c.

681 {
682  HyPar *solver = (HyPar*) s;
683  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
684  int done,k;
685 
686  int *dim = solver->dim_local;
687  double *uref = param->solution;
688 
689  int bounds_outer[2], bounds_inter[2];
690  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
691  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
694 
695  done = 0; int index_outer[2] = {0,0}, index_inter[2];
696  while (!done) {
697  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
698  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
699  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
700  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
701  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
702  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
703  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
704  double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_],
705  ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_];
706 
707  /* Roe-Fixed upwinding scheme */
708 
709  _NavierStokes2DRoeAverage_(uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma);
710 
711  _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir);
712  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
713  _NavierStokes2DRightEigenvectors_(uavg,R,param->gamma,dir);
714 
715  /* calculate characteristic fluxes and variables */
720 
721  double eigL[4],eigC[4],eigR[4];
722  _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->gamma,dir);
723  eigL[0] = D[0];
724  eigL[1] = (dir == _YDIR_ ? 0.0 : D[5]);
725  eigL[2] = (dir == _XDIR_ ? 0.0 : D[10]);
726  eigL[3] = 0.0;
727  _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->gamma,dir);
728  eigR[0] = D[0];
729  eigR[1] = (dir == _YDIR_ ? 0.0 : D[5]);
730  eigR[2] = (dir == _XDIR_ ? 0.0 : D[10]);
731  eigR[3] = 0.0;
732  _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir);
733  eigC[0] = D[0];
734  eigC[1] = (dir == _YDIR_ ? 0.0 : D[5]);
735  eigC[2] = (dir == _XDIR_ ? 0.0 : D[10]);
736  eigC[3] = 0.0;
737 
738  for (k = 0; k < _MODEL_NVARS_; k++) {
739  if ((eigL[k] > 0) && (eigC[k] > 0) && (eigR[k] > 0)) fc[k] = fcL[k];
740  else if ((eigL[k] < 0) && (eigC[k] < 0) && (eigR[k] < 0)) fc[k] = fcR[k];
741  else {
742  double alpha = max3(absolute(eigL[k]),absolute(eigC[k]),absolute(eigR[k]));
743  fc[k] = 0.5 * (fcL[k] + fcR[k] + alpha * (ucL[k]-ucR[k]));
744  }
745  }
746 
747  /* calculate the interface flux from the characteristic flux */
749  }
750  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
751  }
752 
753  return(0);
754 }
#define max3(a, b, c)
Definition: math_ops.h:27
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)

◆ NavierStokes2DUpwinddFLLF()

int NavierStokes2DUpwinddFLLF ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

The characteristic-based local Lax-Friedrich upwinding scheme (NavierStokes2DUpwindLLF) for the partitioned hyperbolic flux that comprises of the acoustic waves only (see NavierStokes2DStiffFlux, _NavierStokes2DSetStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \( u\pm a\) are used. Reference:

  • Ghosh, D., Constantinescu, E. M., Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning, SIAM Journal on Scientific Computing, 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369.
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 764 of file NavierStokes2DUpwind.c.

775 {
776  HyPar *solver = (HyPar*) s;
777  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
778  int done;
779 
780  int *dim = solver->dim_local;
781  double *uref = param->solution;
782 
783  int bounds_outer[2], bounds_inter[2];
784  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
785  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
788 
789  done = 0; int index_outer[2] = {0,0}, index_inter[2];
790  while (!done) {
791  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
792  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
793  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
794  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
795  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
796  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
797  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
798  double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_],
799  ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_];
800  double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
801 
802  /* Local Lax-Friedrich upwinding scheme */
803 
804  _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma);
805  _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir);
806  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
807  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
808 
809  /* calculate characteristic fluxes and variables */
814 
815  double eigL[4],eigC[4],eigR[4];
816  _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->gamma,dir);
817  eigL[0] = D[0];
818  eigL[1] = (dir == _YDIR_ ? 0.0 : D[5]);
819  eigL[2] = (dir == _XDIR_ ? 0.0 : D[10]);
820  eigL[3] = 0.0;
821  _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->gamma,dir);
822  eigR[0] = D[0];
823  eigR[1] = (dir == _YDIR_ ? 0.0 : D[5]);
824  eigR[2] = (dir == _XDIR_ ? 0.0 : D[10]);
825  eigR[3] = 0.0;
826  _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir);
827  eigC[0] = D[0];
828  eigC[1] = (dir == _YDIR_ ? 0.0 : D[5]);
829  eigC[2] = (dir == _XDIR_ ? 0.0 : D[10]);
830  eigC[3] = 0.0;
831 
832  double alpha;
833  alpha = kappa * max3(absolute(eigL[0]),absolute(eigC[0]),absolute(eigR[0]));
834  fc[0] = 0.5 * (fcL[0] + fcR[0] + alpha * (ucL[0]-ucR[0]));
835  alpha = max3(absolute(eigL[1]),absolute(eigC[1]),absolute(eigR[1]));
836  fc[1] = 0.5 * (fcL[1] + fcR[1] + alpha * (ucL[1]-ucR[1]));
837  alpha = max3(absolute(eigL[2]),absolute(eigC[2]),absolute(eigR[2]));
838  fc[2] = 0.5 * (fcL[2] + fcR[2] + alpha * (ucL[2]-ucR[2]));
839  alpha = max3(absolute(eigL[3]),absolute(eigC[3]),absolute(eigR[3]));
840  fc[3] = 0.5 * (fcL[3] + fcR[3] + alpha * (ucL[3]-ucR[3]));
841 
842  /* calculate the interface flux from the characteristic flux */
844  }
845  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
846  }
847 
848  return(0);
849 }
#define max3(a, b, c)
Definition: math_ops.h:27
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DUpwinddFRusanov()

int NavierStokes2DUpwinddFRusanov ( double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
int  ,
void *  ,
double   
)

◆ NavierStokes2DUpwindFdFRoe()

int NavierStokes2DUpwindFdFRoe ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

The Roe upwinding scheme (NavierStokes2DUpwindRoe) for the partitioned hyperbolic flux that comprises of the entropy waves only (see NavierStokes2DNonStiffFlux, _NavierStokes2DSetStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \(u\) are used. Reference:

  • Ghosh, D., Constantinescu, E. M., Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning, SIAM Journal on Scientific Computing, 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369.
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 950 of file NavierStokes2DUpwind.c.

961 {
962  HyPar *solver = (HyPar*) s;
963  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
964  int done;
965 
966  int *dim = solver->dim_local;
967  double *uref = param->solution;
968 
969  int bounds_outer[2], bounds_inter[2];
970  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
971  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
975 
976  done = 0; int index_outer[2] = {0,0}; int index_inter[2];
977  while (!done) {
978  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
979  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
980  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
981  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
982  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
983  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
984  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
985  int k;
986  double udiff[_MODEL_NVARS_],uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_],
987  udiss_total[_MODEL_NVARS_],udiss_stiff[_MODEL_NVARS_];
988  double delta = 0.000001, delta2 = delta*delta;
989  double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
990 
991  /* Roe's upwinding scheme */
992 
993  udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]);
994  udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]);
995  udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]);
996  udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]);
997 
998  /* Compute total dissipation */
999  _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma);
1000  _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir);
1001  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
1002  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
1003  k=0; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) );
1004  k=5; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) );
1005  k=10; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) );
1006  k=15; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) );
1007  MatMult4(_MODEL_NVARS_,DL,D,L);
1008  MatMult4(_MODEL_NVARS_,modA,R,DL);
1009  MatVecMult4(_MODEL_NVARS_,udiss_total,modA,udiff);
1010 
1011  /* Compute dissipation corresponding to acoustic modes */
1012  _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma);
1013  _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir);
1014  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
1015  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
1016  k=0; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) );
1017  k=5; D[k] = (dir == _YDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) );
1018  k=10; D[k] = (dir == _XDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) );
1019  k=15; D[k] = 0.0;
1020  MatMult4(_MODEL_NVARS_,DL,D,L);
1021  MatMult4(_MODEL_NVARS_,modA,R,DL);
1022  MatVecMult4(_MODEL_NVARS_,udiss_stiff,modA,udiff);
1023 
1024  /* Compute the dissipation term for the entropy modes */
1025  _ArraySubtract1D_(udiss,udiss_total,udiss_stiff,_MODEL_NVARS_);
1026 
1027  fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0];
1028  fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1];
1029  fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2];
1030  fI[_MODEL_NVARS_*p+3] = 0.5 * (fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3];
1031  }
1032  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
1033  }
1034 
1035  return(0);
1036 }
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _ArraySubtract1D_(x, a, b, size)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
#define MatMult4(N, A, X, Y)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DUpwindFdFRF()

int NavierStokes2DUpwindFdFRF ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

The characteristic-based Roe-fixed upwinding scheme (NavierStokes2DUpwindRF) for the partitioned hyperbolic flux that comprises of the entropy waves only (see NavierStokes2DNonStiffFlux, _NavierStokes2DSetNonStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \(u\) are used. Reference:

  • Ghosh, D., Constantinescu, E. M., Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning, SIAM Journal on Scientific Computing, 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369.
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 1046 of file NavierStokes2DUpwind.c.

1057 {
1058  HyPar *solver = (HyPar*) s;
1059  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
1060  int done,k;
1061 
1062  int *dim = solver->dim_local;
1063  double *uref = param->solution;
1064 
1065  int bounds_outer[2], bounds_inter[2];
1066  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
1067  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
1070 
1071  done = 0; int index_outer[2] = {0,0}, index_inter[2];
1072  while (!done) {
1073  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
1074  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
1075  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
1076  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
1077  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
1078  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
1079  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
1080  double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_],
1081  ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_];
1082 
1083  /* Roe-Fixed upwinding scheme */
1084 
1085  _NavierStokes2DRoeAverage_(uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma);
1086 
1087  _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir);
1088  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
1089  _NavierStokes2DRightEigenvectors_(uavg,R,param->gamma,dir);
1090 
1091  /* calculate characteristic fluxes and variables */
1092  MatVecMult4(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p));
1093  MatVecMult4(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p));
1094  MatVecMult4(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p));
1095  MatVecMult4(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p));
1096 
1097  double eigL[4],eigC[4],eigR[4];
1098  _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->gamma,dir);
1099  eigL[0] = 0.0;
1100  eigL[1] = (dir == _XDIR_ ? 0.0 : D[5]);
1101  eigL[2] = (dir == _YDIR_ ? 0.0 : D[10]);
1102  eigL[3] = D[15];
1103  _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->gamma,dir);
1104  eigR[0] = 0.0;
1105  eigR[1] = (dir == _XDIR_ ? 0.0 : D[5]);
1106  eigR[2] = (dir == _YDIR_ ? 0.0 : D[10]);
1107  eigR[3] = D[15];
1108  _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir);
1109  eigC[0] = 0.0;
1110  eigC[1] = (dir == _XDIR_ ? 0.0 : D[5]);
1111  eigC[2] = (dir == _YDIR_ ? 0.0 : D[10]);
1112  eigC[3] = D[15];
1113 
1114  for (k = 0; k < _MODEL_NVARS_; k++) {
1115  if ((eigL[k] > 0) && (eigC[k] > 0) && (eigR[k] > 0)) fc[k] = fcL[k];
1116  else if ((eigL[k] < 0) && (eigC[k] < 0) && (eigR[k] < 0)) fc[k] = fcR[k];
1117  else {
1118  double alpha = max3(absolute(eigL[k]),absolute(eigC[k]),absolute(eigR[k]));
1119  fc[k] = 0.5 * (fcL[k] + fcR[k] + alpha * (ucL[k]-ucR[k]));
1120  }
1121  }
1122 
1123  /* calculate the interface flux from the characteristic flux */
1125  }
1126  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
1127  }
1128 
1129  return(0);
1130 }
#define max3(a, b, c)
Definition: math_ops.h:27
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)

◆ NavierStokes2DUpwindFdFLLF()

int NavierStokes2DUpwindFdFLLF ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

The characteristic-based local Lax-Friedrich upwinding scheme (NavierStokes2DUpwindLLF) for the partitioned hyperbolic flux that comprises of the entropy waves only (see NavierStokes2DNonStiffFlux, _NavierStokes2DSetNonStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \(u\) are used. Reference:

  • Ghosh, D., Constantinescu, E. M., Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning, SIAM Journal on Scientific Computing, 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369.
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 1140 of file NavierStokes2DUpwind.c.

1151 {
1152  HyPar *solver = (HyPar*) s;
1153  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
1154  int done;
1155 
1156  int *dim = solver->dim_local;
1157  double *uref = param->solution;
1158 
1159  int bounds_outer[2], bounds_inter[2];
1160  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
1161  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
1164 
1165  done = 0; int index_outer[2] = {0,0}, index_inter[2];
1166  while (!done) {
1167  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
1168  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
1169  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
1170  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
1171  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
1172  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
1173  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
1174  double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_],
1175  ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_];
1176  double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
1177 
1178  /* Local Lax-Friedrich upwinding scheme */
1179 
1180  _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma);
1181  _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir);
1182  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
1183  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
1184 
1185  /* calculate characteristic fluxes and variables */
1186  MatVecMult4(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p));
1187  MatVecMult4(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p));
1188  MatVecMult4(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p));
1189  MatVecMult4(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p));
1190 
1191  double eigL[4],eigC[4],eigR[4];
1192  _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->gamma,dir);
1193  eigL[0] = 0.0;
1194  eigL[1] = (dir == _XDIR_ ? 0.0 : D[5]);
1195  eigL[2] = (dir == _YDIR_ ? 0.0 : D[10]);
1196  eigL[3] = D[15];
1197  _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->gamma,dir);
1198  eigR[0] = 0.0;
1199  eigR[1] = (dir == _XDIR_ ? 0.0 : D[5]);
1200  eigR[2] = (dir == _YDIR_ ? 0.0 : D[10]);
1201  eigR[3] = D[15];
1202  _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir);
1203  eigC[0] = 0.0;
1204  eigC[1] = (dir == _XDIR_ ? 0.0 : D[5]);
1205  eigC[2] = (dir == _YDIR_ ? 0.0 : D[10]);
1206  eigC[3] = D[15];
1207 
1208  double alpha;
1209  alpha = kappa * max3(absolute(eigL[0]),absolute(eigC[0]),absolute(eigR[0]));
1210  fc[0] = 0.5 * (fcL[0] + fcR[0] + alpha * (ucL[0]-ucR[0]));
1211  alpha = max3(absolute(eigL[1]),absolute(eigC[1]),absolute(eigR[1]));
1212  fc[1] = 0.5 * (fcL[1] + fcR[1] + alpha * (ucL[1]-ucR[1]));
1213  alpha = max3(absolute(eigL[2]),absolute(eigC[2]),absolute(eigR[2]));
1214  fc[2] = 0.5 * (fcL[2] + fcR[2] + alpha * (ucL[2]-ucR[2]));
1215  alpha = max3(absolute(eigL[3]),absolute(eigC[3]),absolute(eigR[3]));
1216  fc[3] = 0.5 * (fcL[3] + fcR[3] + alpha * (ucL[3]-ucR[3]));
1217 
1218  /* calculate the interface flux from the characteristic flux */
1220  }
1221  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
1222  }
1223 
1224  return(0);
1225 }
#define max3(a, b, c)
Definition: math_ops.h:27
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DUpwindFdFRusanov()

int NavierStokes2DUpwindFdFRusanov ( double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
double *  ,
int  ,
void *  ,
double   
)

◆ NavierStokes2DUpwindRusanovModified()

int NavierStokes2DUpwindRusanovModified ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

Modified Rusanov's upwinding scheme: NavierStokes2DUpwindRusanov() modified as described in the following paper (for consistent characteristic-based splitting):

  • Ghosh, D., Constantinescu, E. M., "Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning", Submitted (http://arxiv.org/abs/1510.05751).
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 499 of file NavierStokes2DUpwind.c.

510 {
511  HyPar *solver = (HyPar*) s;
512  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
513  int done;
514 
515  int *dim = solver->dim_local;
516 
517  int bounds_outer[2], bounds_inter[2];
518  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
519  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
523 
524  done = 0; int index_outer[2] = {0,0}; int index_inter[2];
525  while (!done) {
526  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
527  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
528  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
529  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
530  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
531  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
532  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
533  double udiff[_MODEL_NVARS_],uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_];
534 
535  /* Modified Rusanov's upwinding scheme */
536 
537  udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]);
538  udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]);
539  udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]);
540  udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]);
541 
542  _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma);
543  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
544  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
545 
546  double c, vel[_MODEL_NDIMS_], rho,E,P;
547  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->gamma);
548  c = sqrt(param->gamma*P/rho);
549  double alphaL = c + absolute(vel[dir]), betaL = absolute(vel[dir]);
550  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->gamma);
551  c = sqrt(param->gamma*P/rho);
552  double alphaR = c + absolute(vel[dir]), betaR = absolute(vel[dir]);
553  _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->gamma);
554  c = sqrt(param->gamma*P/rho);
555  double alphaavg = c + absolute(vel[dir]), betaavg = absolute(vel[dir]);
556 
557  double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
558  double alpha = kappa*max3(alphaL,alphaR,alphaavg);
559  double beta = kappa*max3(betaL,betaR,betaavg);
560 
562  D[0] = alpha;
563  D[5] = (dir == _XDIR_ ? alpha : beta);
564  D[10] = (dir == _YDIR_ ? alpha : beta);
565  D[15] = beta;
566  MatMult4(_MODEL_NVARS_,DL,D,L);
567  MatMult4(_MODEL_NVARS_,modA,R,DL);
568  MatVecMult4(_MODEL_NVARS_,udiss,modA,udiff);
569 
570  fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0])-udiss[0];
571  fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1])-udiss[1];
572  fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2])-udiss[2];
573  fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3])-udiss[3];
574  }
575  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
576  }
577 
578  return(0);
579 }
#define max3(a, b, c)
Definition: math_ops.h:27
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
#define MatMult4(N, A, X, Y)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DUpwinddFRusanovModified()

int NavierStokes2DUpwinddFRusanovModified ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

The modified Rusanov upwinding scheme (NavierStokes2DUpwindRusanovModified()) for the partitioned hyperbolic flux that comprises of the acoustic waves only (see NavierStokes2DStiffFlux, _NavierStokes2DSetStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \( u\pm a\) are used. Reference:

  • Ghosh, D., Constantinescu, E. M., Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning, SIAM Journal on Scientific Computing, 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369.
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 859 of file NavierStokes2DUpwind.c.

870 {
871  HyPar *solver = (HyPar*) s;
872  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
873  int done;
874 
875  int *dim = solver->dim_local;
876  double *uref = param->solution;
877 
878  int bounds_outer[2], bounds_inter[2];
879  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
880  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
884 
885  done = 0; int index_outer[2] = {0,0}; int index_inter[2];
886  while (!done) {
887  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
888  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
889  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
890  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
891  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
892  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
893  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
894  double udiff[_MODEL_NVARS_], udiss[_MODEL_NVARS_], uavg[_MODEL_NVARS_];
895 
896  /* Rusanov's upwinding scheme */
897 
898  udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]);
899  udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]);
900  udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]);
901  udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]);
902 
903  _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma);
904  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
905  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
906 
907  double c, vel[_MODEL_NDIMS_], rho,E,P;
908  _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->gamma);
909  c = sqrt(param->gamma*P/rho);
910  double alphaL = c + absolute(vel[dir]);
911  _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->gamma);
912  c = sqrt(param->gamma*P/rho);
913  double alphaR = c + absolute(vel[dir]);
914  _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->gamma);
915  c = sqrt(param->gamma*P/rho);
916  double alphaavg = c + absolute(vel[dir]);
917 
918  double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
919  double alpha = kappa*max3(alphaL,alphaR,alphaavg);
920 
922  D[0] = alpha;
923  D[5] = (dir == _YDIR_ ? 0.0 : alpha);
924  D[10] = (dir == _XDIR_ ? 0.0 : alpha);
925  D[15] = 0.0;
926 
927  MatMult4(_MODEL_NVARS_,DL,D,L);
928  MatMult4(_MODEL_NVARS_,modA,R,DL);
929  MatVecMult4(_MODEL_NVARS_,udiss,modA,udiff);
930 
931  fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0];
932  fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1];
933  fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2];
934  fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3];
935  }
936  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
937  }
938 
939  return(0);
940 }
#define max3(a, b, c)
Definition: math_ops.h:27
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
#define MatMult4(N, A, X, Y)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DUpwindFdFRusanovModified()

int NavierStokes2DUpwindFdFRusanovModified ( double *  fI,
double *  fL,
double *  fR,
double *  uL,
double *  uR,
double *  u,
int  dir,
void *  s,
double  t 
)

The modified Rusanov upwinding scheme (NavierStokes2DUpwindRusanovModified()) for the partitioned hyperbolic flux that comprises of the entropy waves only (see NavierStokes2DNonStiffFlux, _NavierStokes2DSetNonStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \(u\) are used. Reference:

  • Ghosh, D., Constantinescu, E. M., Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning, SIAM Journal on Scientific Computing, 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369.
Parameters
fIComputed upwind interface flux
fLLeft-biased reconstructed interface flux
fRRight-biased reconstructed interface flux
uLLeft-biased reconstructed interface solution
uRRight-biased reconstructed interface solution
uCell-centered solution
dirSpatial dimension (x or y)
sSolver object of type HyPar
tCurrent solution time

Definition at line 1235 of file NavierStokes2DUpwind.c.

1246 {
1247  HyPar *solver = (HyPar*) s;
1248  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
1249  int done;
1250 
1251  int *dim = solver->dim_local;
1252  double *uref = param->solution;
1253 
1254  int bounds_outer[2], bounds_inter[2];
1255  bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1;
1256  bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++;
1260 
1261  done = 0; int index_outer[2] = {0,0}; int index_inter[2];
1262  while (!done) {
1263  index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1];
1264  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
1265  int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p);
1266  int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--;
1267  int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_);
1268  int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL);
1269  int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR);
1270  double udiff[_MODEL_NVARS_], udiss[_MODEL_NVARS_], uavg[_MODEL_NVARS_],
1271  udiss_total[_MODEL_NVARS_],udiss_acoustic[_MODEL_NVARS_];
1272 
1273  /* Modified Rusanov's upwinding scheme */
1274  double c, vel[_MODEL_NDIMS_], rho,E,P, alphaL, alphaR, alphaavg,
1275  betaL, betaR, betaavg, alpha, beta,
1276  kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
1277 
1278 
1279  udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]);
1280  udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]);
1281  udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]);
1282  udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]);
1283 
1284  /* Compute total dissipation */
1285  _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma);
1286  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
1287  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
1288  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->gamma);
1289  c = sqrt(param->gamma*P/rho);
1290  alphaL = c + absolute(vel[dir]);
1291  betaL = absolute(vel[dir]);
1292  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->gamma);
1293  c = sqrt(param->gamma*P/rho);
1294  alphaR = c + absolute(vel[dir]);
1295  betaR = absolute(vel[dir]);
1296  _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->gamma);
1297  c = sqrt(param->gamma*P/rho);
1298  alphaavg = c + absolute(vel[dir]);
1299  betaavg = absolute(vel[dir]);
1300  alpha = kappa*max3(alphaL,alphaR,alphaavg);
1301  beta = kappa*max3(betaL,betaR,betaavg);
1303  D[0] = alpha;
1304  D[5] = (dir == _XDIR_ ? alpha : beta);
1305  D[10] = (dir == _YDIR_ ? alpha : beta);
1306  D[15] = beta;
1307  MatMult4(_MODEL_NVARS_,DL,D,L);
1308  MatMult4(_MODEL_NVARS_,modA,R,DL);
1309  MatVecMult4(_MODEL_NVARS_,udiss_total,modA,udiff);
1310 
1311  /* Compute dissipation for the linearized acoustic modes */
1312  _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma);
1313  _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir);
1314  _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir);
1315  _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->gamma);
1316  c = sqrt(param->gamma*P/rho);
1317  alphaL = c + absolute(vel[dir]);
1318  _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->gamma);
1319  c = sqrt(param->gamma*P/rho);
1320  alphaR = c + absolute(vel[dir]);
1321  _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->gamma);
1322  c = sqrt(param->gamma*P/rho);
1323  alphaavg = c + absolute(vel[dir]);
1324  kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]);
1325  alpha = kappa*max3(alphaL,alphaR,alphaavg);
1327  D[0] = alpha;
1328  D[5] = (dir == _YDIR_ ? 0.0 : alpha);
1329  D[10] = (dir == _XDIR_ ? 0.0 : alpha);
1330  D[15] = 0.0;
1331  MatMult4(_MODEL_NVARS_,DL,D,L);
1332  MatMult4(_MODEL_NVARS_,modA,R,DL);
1333  MatVecMult4(_MODEL_NVARS_,udiss_acoustic,modA,udiff);
1334 
1335  /* Compute dissipation for the entropy modes */
1336  _ArraySubtract1D_(udiss,udiss_total,udiss_acoustic,_MODEL_NVARS_);
1337 
1338  fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0];
1339  fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1];
1340  fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2];
1341  fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3];
1342  }
1343  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done);
1344  }
1345 
1346  return(0);
1347 }
#define max3(a, b, c)
Definition: math_ops.h:27
#define absolute(a)
Definition: math_ops.h:32
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _ArraySubtract1D_(x, a, b, size)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRoeAverage_(uavg, uL, uR, gamma)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define MatVecMult4(N, y, A, x)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
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.
#define MatMult4(N, A, X, Y)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
#define _ArrayIndex1D2_(N, imax, i, ghost, index)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)
#define max(a, b)
Definition: math_ops.h:18

◆ NavierStokes2DGravityField()

int NavierStokes2DGravityField ( void *  s,
void *  m 
)

This function computes the pressure and density variation functions for the hydrostatic balance of the type specified by the user (NavierStokes2D:HB). The pressure and density in hydrostatic balance are given by

\begin{equation} \rho = \rho_0\varrho\left(x,y\right),\ p = p_0\varphi\left(x,y\right) \end{equation}

where \(\rho_0\) and \(p_0\) are the reference density (NavierStokes2D::rho0) and pressure (NavierStokes2D::p0). This function computes \(\varrho\) (NavierStokes2D::grav_field_f) and \(\varphi\) (NavierStokes2D::grav_field_g). For flows without gravity, \(\varrho = \varphi = 1\).

References:

  • Ghosh, D., Constantinescu, E.M., Well-Balanced Formulation of Gravitational Source Terms for Conservative Finite-Difference Atmospheric Flow Solvers, AIAA Paper 2015-2889, 7th AIAA Atmospheric and Space Environments Conference, June 22-26, 2015, Dallas, TX, http://dx.doi.org/10.2514/6.2015-2889
  • Ghosh, D., Constantinescu, E.M., A Well-Balanced, Conservative Finite-Difference Algorithm for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580.
Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables

Definition at line 33 of file NavierStokes2DGravityField.c.

37 {
38  HyPar *solver = (HyPar*) s;
39  MPIVariables *mpi = (MPIVariables*) m;
40  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
41 
42  double *f = param->grav_field_f;
43  double *g = param->grav_field_g;
44  int *dim = solver->dim_local;
45  int ghosts = solver->ghosts;
46  int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_],
47  offset[_MODEL_NDIMS_], d, done;
48 
49  /* set bounds for array index to include ghost points */
50  _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_);
51  for (d=0; d<_MODEL_NDIMS_; d++) bounds[d] += 2*ghosts;
52  /* set offset such that index is compatible with ghost point arrangement */
53  _ArraySetValue_(offset,_MODEL_NDIMS_,-ghosts);
54 
55  double p0 = param->p0;
56  double rho0 = param->rho0;
57  double RT = p0 / rho0;
58  double gamma= param->gamma;
59  double R = param->R;
60  double Cp = gamma*R / (gamma-1.0);
61  double T0 = p0 / (rho0 * R);
62  double gx = param->grav_x;
63  double gy = param->grav_y;
64  double Nbv = param->N_bv;
65 
66  /* set the value of the gravity field */
67  done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0);
68  if (param->HB == 1) {
69  while (!done) {
70  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
71  double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->x,xcoord);
72  double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord);
73  f[p] = exp( (gx*xcoord+gy*ycoord)/RT);
74  g[p] = exp(-(gx*xcoord+gy*ycoord)/RT);
75  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
76  }
77  } else if (param->HB == 2) {
78  while (!done) {
79  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
80  double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->x,xcoord);
81  double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord);
82  f[p] = raiseto((1.0-(gx*xcoord+gy*ycoord)/(Cp*T0)), (-1.0 /(gamma-1.0)));
83  g[p] = raiseto((1.0-(gx*xcoord+gy*ycoord)/(Cp*T0)), (gamma/(gamma-1.0)));
84  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
85  }
86  } else if (param->HB == 3) {
87  while (!done) {
88  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
89  double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord);
90  if (gx != 0) {
91  if (!mpi->rank) {
92  fprintf(stderr,"Error in NavierStokes2DGravityField(): HB = 3 is implemented only for ");
93  fprintf(stderr,"gravity force along the y-coordinate.\n");
94  }
95  return(1);
96  }
97  double Pexner = 1 + ((gy*gy)/(Cp*T0*Nbv*Nbv)) * (exp(-(Nbv*Nbv/gy)*ycoord)-1.0);
98  f[p] = raiseto(Pexner, (-1.0 /(gamma-1.0))) * exp(Nbv*Nbv*ycoord/gy);
99  g[p] = raiseto(Pexner, (gamma/(gamma-1.0)));
100  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
101  }
102  } else {
103  while (!done) {
104  int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p);
105  f[p] = g[p] = 1.0;
106  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done);
107  }
108  }
109 
110  /* A sensible simulation will not specify peridic boundary conditions
111  * along a direction in which gravity acts.
112  * Gravity will be zero along the dimension periodic BCs are specified,
113  * so the value of the gravity potential will be the same along those
114  * grid lines.
115  * Thus, for both these cases, extrapolate the gravity field at the
116  * boundaries */
117  int indexb[_MODEL_NDIMS_], indexi[_MODEL_NDIMS_];
118  for (d = 0; d < _MODEL_NDIMS_; d++) {
119  /* left boundary */
120  if (!mpi->ip[d]) {
121  _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts;
122  _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = -ghosts;
123  done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0);
124  while (!done) {
125  _ArrayCopy1D_(indexb,indexi,_MODEL_NDIMS_); indexi[d] = ghosts-1-indexb[d];
126  int p1; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,indexb,offset,ghosts,p1);
127  int p2; _ArrayIndex1D_ (_MODEL_NDIMS_,dim,indexi,ghosts,p2);
128  f[p1] = f[p2];
129  g[p1] = g[p2];
130  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,indexb,done);
131  }
132  }
133  /* right boundary */
134  if (mpi->ip[d] == mpi->iproc[d]-1) {
135  _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts;
136  _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = dim[d];
137  done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0);
138  while (!done) {
139  _ArrayCopy1D_(indexb,indexi,_MODEL_NDIMS_); indexi[d] = dim[d]-1-indexb[d];
140  int p1; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,indexb,offset,ghosts,p1);
141  int p2; _ArrayIndex1D_ (_MODEL_NDIMS_,dim,indexi,ghosts,p2);
142  f[p1] = f[p2];
143  g[p1] = g[p2];
144  _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,indexb,done);
145  }
146  }
147  }
148 
149  return(0);
150 }
double * x
Definition: hypar.h:107
double * grav_field_g
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
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
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
int ghosts
Definition: hypar.h:52
Structure of MPI-related variables.
#define raiseto(x, a)
Definition: math_ops.h:37
#define _ArrayCopy1D_(x, y, size)

◆ NavierStokes2DModifiedSolution()

int NavierStokes2DModifiedSolution ( double *  uC,
double *  u,
int  d,
void *  s,
void *  m,
double  waqt 
)

This function computes the modified solution for the well-balanced treatment of the gravitational source terms. The modified solution vector is given by

\begin{equation} {\bf u}^* = \left[\begin{array}{c} \rho \varrho^{-1}\left(x,y\right) \\ \rho u \varrho^{-1}\left(x,y\right) \\ \rho v \varrho^{-1}\left(x,y\right) \\ e^* \end{array}\right] \end{equation}

where

\begin{equation} e^* = \frac{p \varphi^{-1}\left(x,y\right)}{\gamma-1} + \frac{1}{2}\rho \varrho^{-1}\left(x,y\right) \left(u^2+v^2\right) \end{equation}

\(\varrho\) and \(\varphi\) are computed in NavierStokes2DGravityField(). For flows without gravity, \({\bf u}^* = {\bf u}\).

References:

  • Ghosh, D., Constantinescu, E.M., Well-Balanced Formulation of Gravitational Source Terms for Conservative Finite-Difference Atmospheric Flow Solvers, AIAA Paper 2015-2889, 7th AIAA Atmospheric and Space Environments Conference, June 22-26, 2015, Dallas, TX, http://dx.doi.org/10.2514/6.2015-2889
  • Ghosh, D., Constantinescu, E.M., A Well-Balanced, Conservative Finite-Difference Algorithm for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580.
Parameters
uCArray to hold the computed modified solution
uSolution vector array
dspatial dimension (not used)
sSolver object of type HyPar
mMPI object of time MPIVariables
waqtCurrent simulation time

Definition at line 31 of file NavierStokes2DModifiedSolution.c.

39 {
40  HyPar *solver = (HyPar*) s;
41  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
42 
43  int ghosts = solver->ghosts;
44  int *dim = solver->dim_local;
45  int ndims = solver->ndims;
46  int index[ndims], bounds[ndims], offset[ndims];
47 
48  /* set bounds for array index to include ghost points */
49  _ArrayCopy1D_(dim,bounds,ndims);
50  int i; for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
51 
52  /* set offset such that index is compatible with ghost point arrangement */
53  _ArraySetValue_(offset,ndims,-ghosts);
54 
55  int done = 0; _ArraySetValue_(index,ndims,0);
56  double inv_gamma_m1 = 1.0 / (param->gamma-1.0);
57 
58  while (!done) {
59  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
60  double rho, uvel, vvel, E, P;
61  _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,uvel,vvel,E,P,param->gamma);
62  uC[_MODEL_NVARS_*p+0] = u[_MODEL_NVARS_*p+0] * param->grav_field_f[p];
63  uC[_MODEL_NVARS_*p+1] = u[_MODEL_NVARS_*p+1] * param->grav_field_f[p];
64  uC[_MODEL_NVARS_*p+2] = u[_MODEL_NVARS_*p+2] * param->grav_field_f[p];
65  uC[_MODEL_NVARS_*p+3] = (P*inv_gamma_m1)*(1.0/param->grav_field_g[p]) + (0.5*rho*(uvel*uvel+vvel*vvel))*param->grav_field_f[p];
66  _ArrayIncrementIndex_(ndims,bounds,index,done);
67  }
68 
69  return(0);
70 }
#define _NavierStokes2DGetFlowVar_(u, rho, vx, vy, e, P, gamma)
int ndims
Definition: hypar.h:26
double * grav_field_g
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
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
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ArrayCopy1D_(x, y, size)

◆ NavierStokes2DPreStep()

int NavierStokes2DPreStep ( double *  u,
void *  s,
void *  m,
double  waqt 
)

Pre-step function for the 2D Navier Stokes equations: This function is called at the beginning of each time step.

  • The solution at the beginning of the step is copied into NavierStokes2D::solution for the linearized flux partitioning.
  • The linearized "fast" Jacobian (representing the acoustic modes) NavierStokes2D::fast_jac is computed as:

    \begin{equation} A_f\left({\bf u}\right) = R\left({\bf u}\right)\Lambda_f\left({\bf u}\right)L\left({\bf u}\right) \end{equation}

    where \(R\) and \(L\) are the matrices of right and left eigenvectors, and,

    \begin{equation} \Lambda_f = diag\left[0,0,u+c,u-c \right] \end{equation}

    with \(c\) being the speed of sound.

    Reference:
  • Ghosh, D., Constantinescu, E. M., Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning, SIAM Journal on Scientific Computing, 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369.
Parameters
uSolution vector
sSolver object of type HyPar
mMPI object of type MPIVariables
waqtCurrent simulation time

Definition at line 33 of file NavierStokes2DPreStep.c.

39 {
40  HyPar *solver = (HyPar*) s;
41  NavierStokes2D *param = (NavierStokes2D*) solver->physics;
42  int *dim = solver->dim_local;
43  int ghosts = solver->ghosts, dir, p;
44  double *A;
45  static const int ndims = _MODEL_NDIMS_;
46  static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_;
47  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
50 
51  /* set bounds for array index to include ghost points */
52  _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims);
53  /* set offset such that index is compatible with ghost point arrangement */
54  _ArraySetValue_(offset,ndims,-ghosts);
55  /* copy the solution to act as a reference for linearization */
57 
58  int done = 0; _ArraySetValue_(index,ndims,0);
59  while (!done) {
60  _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
61 
62  dir = _XDIR_;
63  A = (param->fast_jac + 2*JacSize*p + dir*JacSize);
64  /* get the eigenvalues, and left & right eigenvectors */
65  _NavierStokes2DEigenvalues_ ((u+_MODEL_NVARS_*p),D,param->gamma,dir);
68  /* remove the entropy modes (corresponding to eigenvalues u) */
69  D[2*_MODEL_NVARS_+2] = D[3*_MODEL_NVARS_+3] = 0.0;
70  /* assemble the Jacobian */
71  MatMult4(_MODEL_NVARS_,DL,D,L );
72  MatMult4(_MODEL_NVARS_,A ,R,DL);
73 
74  dir = _YDIR_;
75  A = (param->fast_jac + 2*JacSize*p + dir*JacSize);
76  /* get the eigenvalues, and left & right eigenvectors */
80  /* remove the entropy modes (corresponding to eigenvalues v) */
81  D[1*_MODEL_NVARS_+1] = D[3*_MODEL_NVARS_+3] = 0.0;
82  /* assemble the Jacobian */
83  MatMult4(_MODEL_NVARS_,DL,D,L );
84  MatMult4(_MODEL_NVARS_,A ,R,DL);
85 
86  _ArrayIncrementIndex_(ndims,bounds,index,done);
87  }
88 
89  return(0);
90 }
#define _NavierStokes2DLeftEigenvectors_(u, L, ga, dir)
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
#define _ArrayAddCopy1D_(x, a, y, size)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#define _YDIR_
Definition: euler2d.h:41
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
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.
#define MatMult4(N, A, X, Y)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _XDIR_
Definition: euler1d.h:75
int ghosts
Definition: hypar.h:52
#define _MODEL_NVARS_
Definition: euler1d.h:58
int npoints_local_wghosts
Definition: hypar.h:42
#define _ArrayCopy1D_(x, y, size)

◆ NavierStokes2DInitialize()

int NavierStokes2DInitialize ( void *  s,
void *  m 
)

Initialize the 2D Navier-Stokes (NavierStokes2D) module: Sets the default parameters, read in and set physics-related parameters, and set the physics-related function pointers in HyPar.

This file reads the file "physics.inp" that must have the following format:

begin
    <keyword>   <value>
    <keyword>   <value>
    <keyword>   <value>
    ...
    <keyword>   <value>
end

where the list of keywords are:

Keyword name Type Variable Default value -------—
gamma double NavierStokes2D::gamma 1.4
Pr double NavierStokes2D::Pr 0.72
Re double NavierStokes2D::Re -1
Minf double NavierStokes2D::Minf 1.0
gravity double,double NavierStokes2D::grav_x,NavierStokes2D::grav_y 0.0,0.0
rho_ref double NavierStokes2D::rho0 1.0
p_ref double NavierStokes2D::p0 1.0
HB int NavierStokes2D::HB 1
R double NavierStokes2D::R 1.0
upwinding char[] NavierStokes2D::upw_choice "roe" (_ROE_)

Note: "physics.inp" is optional; if absent, default values will be used.

Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables

Definition at line 103 of file NavierStokes2DInitialize.c.

107 {
108  HyPar *solver = (HyPar*) s;
109  MPIVariables *mpi = (MPIVariables*) m;
110  NavierStokes2D *physics = (NavierStokes2D*) solver->physics;
111  int ferr = 0;
112 
113  static int count = 0;
114 
115  if (solver->nvars != _MODEL_NVARS_) {
116  fprintf(stderr,"Error in NavierStokes2DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_);
117  return(1);
118  }
119  if (solver->ndims != _MODEL_NDIMS_) {
120  fprintf(stderr,"Error in NavierStokes2DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_);
121  return(1);
122  }
123 
124  /* default values */
125  physics->gamma = 1.4;
126  physics->Pr = 0.72;
127  physics->Re = -1;
128  physics->Minf = 1.0;
129  physics->C1 = 1.458e-6;
130  physics->C2 = 110.4;
131  physics->grav_x = 0.0;
132  physics->grav_y = 0.0;
133  physics->rho0 = 1.0;
134  physics->p0 = 1.0;
135  physics->HB = 1;
136  physics->R = 1.0;
137  physics->N_bv = 0.0;
138  strcpy(physics->upw_choice,"roe");
139 
140  /* reading physical model specific inputs - all processes */
141  if (!mpi->rank) {
142  FILE *in;
143  if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n");
144  in = fopen("physics.inp","r");
145  if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n");
146  else {
147  char word[_MAX_STRING_SIZE_];
148  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
149  if (!strcmp(word, "begin")){
150  while (strcmp(word, "end")){
151  ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
152  if (!strcmp(word, "gamma")) {
153  ferr = fscanf(in,"%lf",&physics->gamma); if (ferr != 1) return(1);
154  } else if (!strcmp(word,"upwinding")) {
155  ferr = fscanf(in,"%s",physics->upw_choice); if (ferr != 1) return(1);
156  } else if (!strcmp(word,"Pr")) {
157  ferr = fscanf(in,"%lf",&physics->Pr); if (ferr != 1) return(1);
158  } else if (!strcmp(word,"Re")) {
159  ferr = fscanf(in,"%lf",&physics->Re); if (ferr != 1) return(1);
160  } else if (!strcmp(word,"Minf")) {
161  ferr = fscanf(in,"%lf",&physics->Minf); if (ferr != 1) return(1);
162  } else if (!strcmp(word,"gravity")) {
163  ferr = fscanf(in,"%lf",&physics->grav_x); if (ferr != 1) return(1);
164  ferr = fscanf(in,"%lf",&physics->grav_y); if (ferr != 1) return(1);
165  } else if (!strcmp(word,"rho_ref")) {
166  ferr = fscanf(in,"%lf",&physics->rho0); if (ferr != 1) return(1);
167  } else if (!strcmp(word,"p_ref")) {
168  ferr = fscanf(in,"%lf",&physics->p0); if (ferr != 1) return(1);
169  } else if (!strcmp(word,"HB")) {
170  ferr = fscanf(in,"%d",&physics->HB); if (ferr != 1) return(1);
171  if (physics->HB==3) {
172  ferr = fscanf(in,"%lf",&physics->N_bv); if (ferr != 1) return(1);
173  }
174  } else if (!strcmp(word,"R")) {
175  ferr = fscanf(in,"%lf",&physics->R); if (ferr != 1) return(1);
176  } else if (strcmp(word,"end")) {
177  char useless[_MAX_STRING_SIZE_];
178  ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr);
179  printf("Warning: keyword %s in file \"physics.inp\" with value %s not ",word,useless);
180  printf("recognized or extraneous. Ignoring.\n");
181  }
182  }
183  } else {
184  fprintf(stderr,"Error: Illegal format in file \"physics.inp\".\n");
185  return(1);
186  }
187  }
188  fclose(in);
189  }
190 
192  IERR MPIBroadcast_double (&physics->gamma ,1 ,0,&mpi->world); CHECKERR(ierr);
193  IERR MPIBroadcast_double (&physics->Pr ,1 ,0,&mpi->world); CHECKERR(ierr);
194  IERR MPIBroadcast_double (&physics->Re ,1 ,0,&mpi->world); CHECKERR(ierr);
195  IERR MPIBroadcast_double (&physics->Minf ,1 ,0,&mpi->world); CHECKERR(ierr);
196  IERR MPIBroadcast_double (&physics->grav_x ,1 ,0,&mpi->world); CHECKERR(ierr);
197  IERR MPIBroadcast_double (&physics->grav_y ,1 ,0,&mpi->world); CHECKERR(ierr);
198  IERR MPIBroadcast_double (&physics->rho0 ,1 ,0,&mpi->world); CHECKERR(ierr);
199  IERR MPIBroadcast_double (&physics->p0 ,1 ,0,&mpi->world); CHECKERR(ierr);
200  IERR MPIBroadcast_double (&physics->R ,1 ,0,&mpi->world); CHECKERR(ierr);
201  IERR MPIBroadcast_double (&physics->N_bv ,1 ,0,&mpi->world); CHECKERR(ierr);
202  IERR MPIBroadcast_integer (&physics->HB ,1 ,0,&mpi->world); CHECKERR(ierr);
203 
204  /* Scaling the Reynolds number with the M_inf */
205  physics->Re /= physics->Minf;
206 
207  /* check that a well-balanced upwinding scheme is being used for cases with gravity */
208  if ( ((physics->grav_x != 0.0) || (physics->grav_y != 0.0))
209  && (strcmp(physics->upw_choice,_LLF_ ))
210  && (strcmp(physics->upw_choice,_RUSANOV_))
211  && (strcmp(physics->upw_choice,_ROE_ )) ) {
212  if (!mpi->rank) {
213  fprintf(stderr,"Error in NavierStokes2DInitialize: %s, %s or %s upwinding is needed for flows ",_LLF_,_ROE_,_RUSANOV_);
214  fprintf(stderr,"with gravitational forces.\n");
215  }
216  return(1);
217  }
218  /* check that solver has the correct choice of diffusion formulation */
219  if (strcmp(solver->spatial_type_par,_NC_2STAGE_) && (physics->Re > 0)) {
220  if (!mpi->rank)
221  fprintf(stderr,"Error in NavierStokes2DInitialize(): Parabolic term spatial discretization must be \"%s\"\n",_NC_2STAGE_);
222  return(1);
223  }
224 
225  /* initializing physical model-specific functions */
226 #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS)
227  if (solver->use_gpu) {
228  solver->FFunction = gpuNavierStokes2DFlux;
229  solver->SFunction = gpuNavierStokes2DSource;
230  solver->UFunction = gpuNavierStokes2DModifiedSolution;
231  } else {
232 #endif
233  solver->PreStep = NavierStokes2DPreStep;
235  solver->FFunction = NavierStokes2DFlux;
241 #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS)
242  }
243 #endif
244 
245 #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS)
246  if (solver->use_gpu) {
247  if (!strcmp(solver->SplitHyperbolicFlux,"yes")) {
248  if (!mpi->rank) {
249  fprintf(stderr,"Error in NavierStokes2DInitialize(): Not yet implemented on GPU!");
250  }
251  return 1;
252  } else {
254  if (!strcmp(physics->upw_choice,_RUSANOV_)) solver->Upwind = gpuNavierStokes2DUpwindRusanov;
255  else {
256  if (!mpi->rank) {
257  fprintf(stderr,"Error in NavierStokes2DInitialize(): %s is not implemented on GPU. ",
258  physics->upw_choice);
259  fprintf(stderr,"Only choice is %s.\n",_RUSANOV_);
260  }
261  return 1;
262  }
263  }
264  } else {
265 #endif
266  if (!strcmp(solver->SplitHyperbolicFlux,"yes")) {
270  if (!strcmp(physics->upw_choice,_ROE_)) {
274  } else if (!strcmp(physics->upw_choice,_RF_)) {
275  solver->Upwind = NavierStokes2DUpwindRF;
278  } else if (!strcmp(physics->upw_choice,_LLF_)) {
282  } else if (!strcmp(physics->upw_choice,_RUSANOV_)) {
286  } else {
287  if (!mpi->rank) {
288  fprintf(stderr,"Error in NavierStokes2DInitialize(): %s is not a valid upwinding scheme ",
289  physics->upw_choice);
290  fprintf(stderr,"for use with split hyperbolic flux form. Use %s, %s, %s, or %s.\n",
292  }
293  return(1);
294  }
295  } else {
297  if (!strcmp(physics->upw_choice,_ROE_ )) solver->Upwind = NavierStokes2DUpwindRoe;
298  else if (!strcmp(physics->upw_choice,_RF_ )) solver->Upwind = NavierStokes2DUpwindRF;
299  else if (!strcmp(physics->upw_choice,_LLF_ )) solver->Upwind = NavierStokes2DUpwindLLF;
300  else if (!strcmp(physics->upw_choice,_SWFS_ )) solver->Upwind = NavierStokes2DUpwindSWFS;
301  else if (!strcmp(physics->upw_choice,_RUSANOV_)) solver->Upwind = NavierStokes2DUpwindRusanov;
302  else {
303  if (!mpi->rank) {
304  fprintf(stderr,"Error in NavierStokes2DInitialize(): %s is not a valid upwinding scheme. ",
305  physics->upw_choice);
306  fprintf(stderr,"Choices are %s, %s, %s, %s, and %s.\n",_ROE_,_RF_,_LLF_,_SWFS_,_RUSANOV_);
307  }
308  return(1);
309  }
310  }
311 #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS)
312  }
313 #endif
314 
315  /* set the value of gamma in all the boundary objects */
316  int n;
317  DomainBoundary *boundary = (DomainBoundary*) solver->boundary;
318  for (n = 0; n < solver->nBoundaryZones; n++) boundary[n].gamma = physics->gamma;
319 
320  /* hijack the main solver's dissipation function pointer
321  * to this model's own function, since it's difficult to express
322  * the dissipation terms in the general form */
323 #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS)
324  if (solver->use_gpu) {
325  solver->ParabolicFunction = gpuNavierStokes2DParabolicFunction;
326  } else {
327 #endif
329 #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS)
330  }
331 #endif
332 
333  /* allocate array to hold the gravity field */
334  int *dim = solver->dim_local;
335  int ghosts = solver->ghosts;
336  int d, size = 1; for (d=0; d<_MODEL_NDIMS_; d++) size *= (dim[d] + 2*ghosts);
337  physics->grav_field_f = (double*) calloc (size, sizeof(double));
338  physics->grav_field_g = (double*) calloc (size, sizeof(double));
339  /* allocate arrays to hold the fast Jacobian for split form of the hyperbolic flux */
340  physics->fast_jac = (double*) calloc (2*size*_MODEL_NVARS_*_MODEL_NVARS_,sizeof(double));
341  physics->solution = (double*) calloc (size*_MODEL_NVARS_,sizeof(double));
342  /* initialize the gravity fields */
343  IERR NavierStokes2DGravityField(solver,mpi); CHECKERR(ierr);
344 
345 #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS)
346  if (solver->use_gpu) gpuNavierStokes2DInitialize(s,m);
347 #endif
348 
349  count++;
350  return(0);
351 }
int NavierStokes2DUpwinddFRoe(double *, double *, double *, double *, double *, double *, int, void *, double)
int nvars
Definition: hypar.h:29
#define IERR
Definition: basic.h:16
#define CHECKERR(ierr)
Definition: basic.h:18
int(* ParabolicFunction)(double *, double *, void *, void *, double)
Definition: hypar.h:256
char SplitHyperbolicFlux[_MAX_STRING_SIZE_]
Definition: hypar.h:92
void * boundary
Definition: hypar.h:159
int NavierStokes2DUpwinddFLLF(double *, double *, double *, double *, double *, double *, int, void *, double)
int MPIBroadcast_integer(int *, int, int, void *)
Definition: MPIBroadcast.c:23
int NavierStokes2DModifiedSolution(double *, double *, int, void *, void *, double)
int NavierStokes2DStiffJacobian(double *, double *, void *, int, int, int)
int(* AveragingFunction)(double *, double *, double *, void *)
Definition: hypar.h:354
int NavierStokes2DUpwinddFRF(double *, double *, double *, double *, double *, double *, int, void *, double)
int(* FdFFunction)(double *, double *, int, void *, double)
Definition: hypar.h:286
int(* SFunction)(double *, double *, void *, void *, double)
Definition: hypar.h:317
int NavierStokes2DRightEigenvectors(double *, double *, void *, int)
int(* Upwind)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:295
Structure containing the variables and function pointers defining a boundary.
int NavierStokes2DJacobian(double *, double *, void *, int, int, int)
int ndims
Definition: hypar.h:26
int MPIBroadcast_character(char *, int, int, void *)
Definition: MPIBroadcast.c:37
int(* FFunction)(double *, double *, int, void *, double)
Definition: hypar.h:276
double * grav_field_g
int NavierStokes2DStiffFlux(double *, double *, int, void *, double)
int MPIBroadcast_double(double *, int, int, void *)
Definition: MPIBroadcast.c:9
double(* ComputeCFL)(void *, void *, double, double)
Definition: hypar.h:269
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
int NavierStokes2DSource(double *, double *, void *, void *, double)
#define _MAX_STRING_SIZE_
Definition: basic.h:14
#define _ROE_
Definition: euler1d.h:62
int NavierStokes2DUpwindFdFRF(double *, double *, double *, double *, double *, double *, int, void *, double)
int NavierStokes2DUpwindRoe(double *, double *, double *, double *, double *, double *, int, void *, double)
int NavierStokes2DGravityField(void *, void *)
int NavierStokes2DUpwindFdFLLF(double *, double *, double *, double *, double *, double *, int, void *, double)
int NavierStokes2DUpwindRusanov(double *, double *, double *, double *, double *, double *, int, void *, double)
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#define _RUSANOV_
Definition: euler1d.h:70
MPI_Comm world
int NavierStokes2DPreStep(double *, void *, void *, double)
double NavierStokes2DComputeCFL(void *, void *, double, double)
int(* PreStep)(double *, void *, void *, double)
Definition: hypar.h:339
int NavierStokes2DLeftEigenvectors(double *, double *, void *, int)
char upw_choice[_MAX_STRING_SIZE_]
int(* UpwindFdF)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:307
char spatial_type_par[_MAX_STRING_SIZE_]
Definition: hypar.h:96
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.
int NavierStokes2DUpwindSWFS(double *, double *, double *, double *, double *, double *, int, void *, double)
double * grav_field_f
int NavierStokes2DUpwindLLF(double *, double *, double *, double *, double *, double *, int, void *, double)
int NavierStokes2DUpwindFdFRoe(double *, double *, double *, double *, double *, double *, int, void *, double)
int * dim_local
Definition: hypar.h:37
int NavierStokes2DNonStiffFlux(double *, double *, int, void *, double)
int NavierStokes2DUpwindRusanovModified(double *, double *, double *, double *, double *, double *, int, void *, double)
int(* dFFunction)(double *, double *, int, void *, double)
Definition: hypar.h:280
void * physics
Definition: hypar.h:266
int(* JFunction)(double *, double *, void *, int, int, int)
Definition: hypar.h:326
int NavierStokes2DUpwindRF(double *, double *, double *, double *, double *, double *, int, void *, double)
int NavierStokes2DParabolicFunction(double *, double *, void *, void *, double)
int(* UpwinddF)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:300
int ghosts
Definition: hypar.h:52
int NavierStokes2DFlux(double *, double *, int, void *, double)
#define _SWFS_
Definition: euler1d.h:68
Structure of MPI-related variables.
int use_gpu
Definition: hypar.h:449
#define _MODEL_NVARS_
Definition: euler1d.h:58
int gpuNavierStokes2DInitialize(void *s, void *m)
int nBoundaryZones
Definition: hypar.h:157
int NavierStokes2DUpwindFdFRusanovModified(double *, double *, double *, double *, double *, double *, int, void *, double)
int NavierStokes2DRoeAverage(double *, double *, double *, void *)
int NavierStokes2DUpwinddFRusanovModified(double *, double *, double *, double *, double *, double *, int, void *, double)
int(* GetRightEigenvectors)(double *, double *, void *, int)
Definition: hypar.h:359
#define _RF_
Definition: euler1d.h:64
int(* GetLeftEigenvectors)(double *, double *, void *, int)
Definition: hypar.h:357
int(* UFunction)(double *, double *, int, void *, void *, double)
Definition: hypar.h:321
#define _NC_2STAGE_
Definition: hypar.h:477
#define _LLF_
Definition: euler1d.h:66