HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
ShallowWater1DFlux.c
Go to the documentation of this file.
1 
6 #include <stdlib.h>
7 #include <arrayfunctions.h>
9 #include <hypar.h>
10 
17  double *f,
18  double *u,
19  int dir,
20  void *s,
21  double t
22  )
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.
1D Shallow Water Equations
int ShallowWater1DFlux(double *f, double *u, int dir, void *s, double t)
#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
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 _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
Contains macros and function definitions for common array operations.