HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
ShallowWater2DFlux.c
Go to the documentation of this file.
1 
6 #include <stdlib.h>
7 #include <arrayfunctions.h>
9 #include <hypar.h>
10 
21  double *f,
22  double *u,
23  int dir,
24  void *s,
25  double t
26  )
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 }
int ShallowWater2DFlux(double *f, double *u, int dir, void *s, double t)
2D Shallow Water Equations
#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
Contains structure definition for hypar.
#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
Contains macros and function definitions for common array operations.
#define _ShallowWater2DGetFlowVar_(u, h, uvel, vvel)