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

Contains the functions compute flux Jacobians for the 2D shallow water system. More...

Go to the source code of this file.

Functions

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

Detailed Description

Contains the functions compute flux Jacobians for the 2D shallow water system.

Author
Debojyoti Ghosh

Definition in file ShallowWater2DJacobian.c.

Function Documentation

◆ ShallowWater2DJacobian()

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

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

Parameters
JacJacobian matrix: 1D array of size nvar^2 = 9
usolution at a grid point (array of size nvar = 3)
pobject containing the physics-related parameters
dirspatial dimension (x/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 ShallowWater2DJacobian.c.

24 {
25  ShallowWater2D *param = (ShallowWater2D*) p;
28 
29  /* get the eigenvalues and left,right eigenvectors */
30  _ShallowWater2DEigenvalues_ (u,D,param,dir);
31  _ShallowWater2DLeftEigenvectors_ (u,L,param,dir);
32  _ShallowWater2DRightEigenvectors_(u,R,param,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 = 4; 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 = 8; 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 
39  MatMult3(_MODEL_NVARS_,DL,D,L);
40  MatMult3(_MODEL_NVARS_,Jac,R,DL);
41 
42  return(0);
43 }
#define absolute(a)
Definition: math_ops.h:32
#define min(a, b)
Definition: math_ops.h:14
Structure containing variables and parameters specific to the 2D Shallow Water equations. This structure contains the physical parameters, variables, and function pointers specific to the 2D ShallowWater equations.
#define _ShallowWater2DLeftEigenvectors_(u, L, p, dir)
#define _ShallowWater2DEigenvalues_(u, D, p, dir)
#define MatMult3(N, A, X, Y)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _ShallowWater2DRightEigenvectors_(u, R, p, dir)
#define max(a, b)
Definition: math_ops.h:18