HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
shallowwater1d.h
Go to the documentation of this file.
1 
22 #include <basic.h>
23 #include <math.h>
24 #include <matops.h>
25 
29 #define _SHALLOW_WATER_1D_ "shallow-water-1d"
30 
31 /* define ndims and nvars for this model */
32 #undef _MODEL_NDIMS_
33 #undef _MODEL_NVARS_
34 
35 #define _MODEL_NDIMS_ 1
36 
37 #define _MODEL_NVARS_ 2
38 
39 /* choices for upwinding schemes */
41 #define _ROE_ "roe"
42 
43 #define _LLF_ "llf-char"
44 
45 /* grid direction */
46 #undef _XDIR_
47 
48 #define _XDIR_ 0
49 
54 #define _ShallowWater1DGetFlowVar_(u,h,v) \
55  { \
56  h = u[0]; \
57  v = u[1] / h; \
58  }
59 
64 #define _ShallowWater1DSetFlux_(f,h,v,g) \
65  { \
66  f[0] = (h) * (v); \
67  f[1] = (h) * (v) * (v) + 0.5 * (g) * (h) * (h); \
68  }
69 
74 #define _ShallowWater1DRoeAverage_(uavg,uL,uR,p) \
75  { \
76  double h ,v; \
77  double hL,vL; \
78  double hR,vR; \
79  _ShallowWater1DGetFlowVar_(uL,hL,vL); \
80  _ShallowWater1DGetFlowVar_(uR,hR,vR); \
81  h = 0.5 * (hL + hR); \
82  v = (sqrt(hL)*vL + sqrt(hR)*vR) / (sqrt(hL) + sqrt(hR)); \
83  uavg[0] = h; \
84  uavg[1] = h*v; \
85  }
86 
93 #define _ShallowWater1DEigenvalues_(u,D,p,dir) \
94  { \
95  double h,v,c; \
96  _ShallowWater1DGetFlowVar_(u,h,v); \
97  c = sqrt(p->g*h); \
98  D[0*_MODEL_NVARS_+0] = (v+c); D[0*_MODEL_NVARS_+1] = 0; \
99  D[1*_MODEL_NVARS_+0] = 0; D[1*_MODEL_NVARS_+1] = (v-c); \
100  }
101 
106 #define _ShallowWater1DLeftEigenvectors_(u,L,p,dir) \
107  { \
108  double R[_MODEL_NVARS_*_MODEL_NVARS_]; \
109  _ShallowWater1DRightEigenvectors_(u,R,p,dir); \
110  _MatrixInvert_(R,L,_MODEL_NVARS_); \
111  }
112 
117 #define _ShallowWater1DRightEigenvectors_(u,R,p,dir) \
118  { \
119  double h,v,c; \
120  _ShallowWater1DGetFlowVar_(u,h,v); \
121  c = sqrt(p->g*h); \
122  R[0*_MODEL_NVARS_+0] = 1.0; \
123  R[1*_MODEL_NVARS_+0] = v+c; \
124  R[0*_MODEL_NVARS_+1] = 1.0; \
125  R[1*_MODEL_NVARS_+1] = v-c; \
126  }
127 
137 typedef struct shallowwater1d_parameters {
138  double g;
139  int bt_type,
140  topo_flag;
141  double *b;
142  char upw_choice[_MAX_STRING_SIZE_];
150  int (*SourceUpwind)(double*,double*,double*,double*,int,void*,double);
152 
154 int ShallowWater1DInitialize (void*,void*);
156 int ShallowWater1DCleanup (void*);
157 
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 _MAX_STRING_SIZE_
Definition: basic.h:14
int ShallowWater1DInitialize(void *, void *)
Contains macros and function definitions for common matrix operations.
Some basic definitions and macros.
int ShallowWater1DCleanup(void *)