HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
NavierStokes2DJacobian.c File Reference

Contains the functions compute flux Jacobians for the 2D Navier-Stokes system. More...

Go to the source code of this file.

Functions

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

Detailed Description

Contains the functions compute flux Jacobians for the 2D Navier-Stokes system.

Author
Debojyoti Ghosh

Definition in file NavierStokes2DJacobian.c.

Function Documentation

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 _NavierStokes2DEigenvalues_(u, D, gamma, dir)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define MatMult4(N, A, X, Y)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#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.
#define absolute(a)
Definition: math_ops.h:32
#define max(a, b)
Definition: math_ops.h:18
#define min(a, b)
Definition: math_ops.h:14
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 _YDIR_
Definition: euler2d.h:41
#define _NavierStokes2DEigenvalues_(u, D, gamma, dir)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define MatMult4(N, A, X, Y)
#define _NavierStokes2DRightEigenvectors_(u, R, ga, dir)
#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.
#define absolute(a)
Definition: math_ops.h:32
#define max(a, b)
Definition: math_ops.h:18
#define min(a, b)
Definition: math_ops.h:14
#define _XDIR_
Definition: euler1d.h:75