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

Contains the functions to compute the hyperbolic flux for the 2D shallow water equations over the domain. More...

#include <stdlib.h>
#include <arrayfunctions.h>
#include <physicalmodels/shallowwater2d.h>
#include <hypar.h>

Go to the source code of this file.

Functions

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

Detailed Description

Contains the functions to compute the hyperbolic flux for the 2D shallow water equations over the domain.

Author
Debojyoti Ghosh

Definition in file ShallowWater2DFlux.c.

Function Documentation

◆ ShallowWater2DFlux()

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

Compute the hyperbolic flux over the local domain.

\begin{equation} {\bf F}\left({\bf u}\right) = \left\{\begin{array}{cc} \left[\begin{array}{c} hu \\ hu^2 + \frac{1}{2} gh^2 \\ huv \end{array}\right] & {\rm dir} = x \\ \left[\begin{array}{c} hv \\ huv \\ hv^2 + \frac{1}{2} gh^2 \end{array}\right] & {\rm dir} = y \\ \end{array}\right. \end{equation}

Parameters
fArray to hold the computed flux (same size and layout as u)
uArray containing the conserved solution
dirSpatial dimension
sSolver object of type HyPar
tCurrent time

Definition at line 20 of file ShallowWater2DFlux.c.

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