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

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

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

Go to the source code of this file.

Functions

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

Detailed Description

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

Author
Debojyoti Ghosh

Definition in file ShallowWater1DFlux.c.

Function Documentation

◆ ShallowWater1DFlux()

int ShallowWater1DFlux ( 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}{c} hu \\ hu^2 + \frac{1}{2} gh^2 \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 (unused since this is a 1D system)
sSolver object of type HyPar
tCurrent time

Definition at line 16 of file ShallowWater1DFlux.c.

23 {
24  HyPar *solver = (HyPar*) s;
25  ShallowWater1D *param = (ShallowWater1D*) solver->physics;
26  int *dim = solver->dim_local;
27  int ghosts = solver->ghosts;
28  static const int ndims = _MODEL_NDIMS_;
29  static const int nvars = _MODEL_NVARS_;
30  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
31 
32  /* set bounds for array index to include ghost points */
33  _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims);
34  /* set offset such that index is compatible with ghost point arrangement */
35  _ArraySetValue_(offset,ndims,-ghosts);
36 
37  int done = 0; _ArraySetValue_(index,ndims,0);
38  while (!done) {
39  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
40  double h, v;
41  _ShallowWater1DGetFlowVar_((u+nvars*p),h,v);
42  _ShallowWater1DSetFlux_((f+nvars*p),h,v,param->g);
43  _ArrayIncrementIndex_(ndims,bounds,index,done);
44  }
45 
46  return(0);
47 }
Structure containing variables and parameters specific to the 1D Shallow Water equations. This structure contains the physical parameters, variables, and function pointers specific to the 1D ShallowWater equations.
#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)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ShallowWater1DSetFlux_(f, h, v, g)
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
#define _ShallowWater1DGetFlowVar_(u, h, v)
int ghosts
Definition: hypar.h:52
#define _MODEL_NVARS_
Definition: euler1d.h:58