43 #define _SHALLOW_WATER_2D_ "shallow-water-2d" 49 #define _MODEL_NDIMS_ 2 51 #define _MODEL_NVARS_ 3 57 #define _LLF_ "llf-char" 73 #define _ShallowWater2DGetFlowVar_(u,h,uvel,vvel) \ 91 #define _ShallowWater2DSetFlux_(f,h,uvel,vvel,g,dir) \ 93 if (dir == _XDIR_) { \ 94 f[0] = (h) * (uvel); \ 95 f[1] = (h) * (uvel) * (uvel) + 0.5 * (g) * (h) * (h); \ 96 f[2] = (h) * (uvel) * (vvel); \ 97 } else if (dir == _YDIR_) { \ 98 f[0] = (h) * (vvel); \ 99 f[1] = (h) * (uvel) * (vvel); \ 100 f[2] = (h) * (vvel) * (vvel) + 0.5 * (g) * (h) * (h); \ 108 #define _ShallowWater2DRoeAverage_(uavg,uL,uR,p) \ 110 double h , uvel , vvel ; \ 111 double hL, uvelL, vvelL; \ 112 double hR, uvelR, vvelR; \ 113 _ShallowWater2DGetFlowVar_(uL,hL,uvelL,vvelL); \ 114 _ShallowWater2DGetFlowVar_(uR,hR,uvelR,vvelR); \ 115 h = 0.5 * (hL + hR ); \ 116 uvel = (sqrt(hL)*uvelL + sqrt(hR)*uvelR) / (sqrt(hL) + sqrt(hR)); \ 117 vvel = (sqrt(hL)*vvelL + sqrt(hR)*vvelR) / (sqrt(hL) + sqrt(hR)); \ 129 #define _ShallowWater2DEigenvalues_(u,D,p,dir) \ 131 double h,uvel,vvel,c; \ 132 _ShallowWater2DGetFlowVar_(u,h,uvel,vvel); \ 134 if (dir == _XDIR_) { \ 135 D[0*_MODEL_NVARS_+0] = uvel-c; D[0*_MODEL_NVARS_+1] = 0; D[0*_MODEL_NVARS_+2] = 0; \ 136 D[1*_MODEL_NVARS_+0] = 0; D[1*_MODEL_NVARS_+1] = uvel; D[1*_MODEL_NVARS_+2] = 0; \ 137 D[2*_MODEL_NVARS_+0] = 0; D[2*_MODEL_NVARS_+1] = 0; D[2*_MODEL_NVARS_+2] = uvel+c; \ 138 } else if (dir == _YDIR_) { \ 139 D[0*_MODEL_NVARS_+0] = vvel-c; D[0*_MODEL_NVARS_+1] = 0; D[0*_MODEL_NVARS_+2] = 0; \ 140 D[1*_MODEL_NVARS_+0] = 0; D[1*_MODEL_NVARS_+1] = vvel; D[1*_MODEL_NVARS_+2] = 0; \ 141 D[2*_MODEL_NVARS_+0] = 0; D[2*_MODEL_NVARS_+1] = 0; D[2*_MODEL_NVARS_+2] = vvel+c; \ 154 #define _ShallowWater2DLeftEigenvectors_(u,L,p,dir) \ 156 double h,uvel,vvel,c; \ 157 _ShallowWater2DGetFlowVar_(u,h,uvel,vvel); \ 160 if (dir == _XDIR_) { \ 161 L[0*_MODEL_NVARS_+0] = 0.5 + uvel/(2*c); \ 162 L[0*_MODEL_NVARS_+1] = -1.0/(2*c); \ 163 L[0*_MODEL_NVARS_+2] = 0.0; \ 165 L[1*_MODEL_NVARS_+0] = vvel; \ 166 L[1*_MODEL_NVARS_+1] = 0.0; \ 167 L[1*_MODEL_NVARS_+2] = -1.0; \ 169 L[2*_MODEL_NVARS_+0] = 0.5 - uvel/(2*c); \ 170 L[2*_MODEL_NVARS_+1] = 1.0/(2*c); \ 171 L[2*_MODEL_NVARS_+2] = 0.0; \ 173 } else if (dir == _YDIR_) { \ 174 L[0*_MODEL_NVARS_+0] = 0.5 + vvel/(2*c); \ 175 L[0*_MODEL_NVARS_+1] = 0.0; \ 176 L[0*_MODEL_NVARS_+2] = -1.0/(2*c); \ 178 L[1*_MODEL_NVARS_+0] = -uvel; \ 179 L[1*_MODEL_NVARS_+1] = 1.0; \ 180 L[1*_MODEL_NVARS_+2] = 0.0; \ 182 L[2*_MODEL_NVARS_+0] = 0.5 - vvel/(2*c); \ 183 L[2*_MODEL_NVARS_+1] = 0.0; \ 184 L[2*_MODEL_NVARS_+2] = 1.0/(2*c); \ 197 #define _ShallowWater2DRightEigenvectors_(u,R,p,dir) \ 199 double h,uvel,vvel,c; \ 200 _ShallowWater2DGetFlowVar_(u,h,uvel,vvel); \ 203 if (dir == _XDIR_) { \ 204 R[0*_MODEL_NVARS_+0] = 1.0; \ 205 R[1*_MODEL_NVARS_+0] = uvel-c; \ 206 R[2*_MODEL_NVARS_+0] = vvel; \ 208 R[0*_MODEL_NVARS_+1] = 0.0; \ 209 R[1*_MODEL_NVARS_+1] = 0.0; \ 210 R[2*_MODEL_NVARS_+1] = -1.0;\ 212 R[0*_MODEL_NVARS_+2] = 1.0; \ 213 R[1*_MODEL_NVARS_+2] = uvel+c; \ 214 R[2*_MODEL_NVARS_+2] = vvel; \ 216 } else if (dir == _YDIR_) { \ 217 R[0*_MODEL_NVARS_+0] = 1.0; \ 218 R[1*_MODEL_NVARS_+0] = uvel; \ 219 R[2*_MODEL_NVARS_+0] = vvel-c; \ 221 R[0*_MODEL_NVARS_+1] = 0.0; \ 222 R[1*_MODEL_NVARS_+1] = 1.0; \ 223 R[2*_MODEL_NVARS_+1] = 0.0;\ 225 R[0*_MODEL_NVARS_+2] = 1.0; \ 226 R[1*_MODEL_NVARS_+2] = uvel; \ 227 R[2*_MODEL_NVARS_+2] = vvel+c; \ 240 typedef struct shallowwater2d_parameters {
256 int (*SourceUpwind)(
double*,
double*,
double*,
double*,int,
void*,double);
Contains macros and function definitions for common matrix operations.
int ShallowWater2DInitialize(void *, void *)
Some basic definitions and macros.
int ShallowWater2DCleanup(void *)
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.
#define _MAX_STRING_SIZE_