HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
numa2d.h
Go to the documentation of this file.
1 /*
2  *
3  * 2D Nonhydrostatic Unified Model of the Atmosphere (NUMA)
4  *
5  * References:
6  *
7  * F.X. Giraldo, M. Restelli, and M. Laeuter, "Semi-Implicit
8  * Formulations of the Euler Equations: Applications to
9  * Nonhydrostatic Atmospheric Modeling", SIAM J. Sci. Comp.,
10  * Vol. 32, 3394-3425 (2010)
11  *
12  * N. Ahmad and J. Lindeman, "Euler solutions using flux-based wave
13  * decomposition", Intl. J. Num. Method. Fluid., Vol. 54 (1),
14  * 47-72 (2007)
15  *
16 */
17 
18 #include <basic.h>
19 #include <mathfunctions.h>
20 
21 #define _NUMA2D_ "numa2d"
22 
23 /* define ndims and nvars for this model */
24 #undef _MODEL_NDIMS_
25 #undef _MODEL_NVARS_
26 #define _MODEL_NDIMS_ 2
27 #define _MODEL_NVARS_ 4
28 
29 /* grid directions */
30 #define _XDIR_ 0
31 #define _YDIR_ 1
32 
33 #define _Numa2DGetFlowVars_(u,drho,uvel,vvel,dT,rho0) \
34  { \
35  drho = u[0]; \
36  uvel = u[1]/(rho0+drho); \
37  vvel = u[2]/(rho0+drho); \
38  dT = u[3]; \
39  }
40 
41 #define _Numa2DSetFlux_(f,dir,drho,uvel,vvel,dT,dP,rho0,T0) \
42  { \
43  if (dir == _XDIR_) { \
44  f[0] = (rho0+drho) * uvel; \
45  f[1] = (rho0+drho)*uvel*uvel + dP; \
46  f[2] = (rho0+drho)*uvel*vvel; \
47  f[3] = uvel*(dT+T0); \
48  } else if (dir == _YDIR_) { \
49  f[0] = (rho0+drho) * vvel; \
50  f[1] = (rho0+drho)*uvel*vvel; \
51  f[2] = (rho0+drho)*vvel*vvel + dP; \
52  f[3] = vvel*(dT+T0); \
53  } \
54  }
55 
56 #define _Numa2DSetLinearFlux_(f,dir,drho,uvel,vvel,dT,dP,rho0,T0) \
57  { \
58  if (dir == _XDIR_) { \
59  f[0] = (rho0+drho) * uvel; \
60  f[1] = dP; \
61  f[2] = 0.0; \
62  f[3] = (rho0+drho)*uvel*T0/rho0; \
63  } else if (dir == _YDIR_) { \
64  f[0] = (rho0+drho) * vvel; \
65  f[1] = 0.0; \
66  f[2] = dP; \
67  f[3] = (rho0+drho)*vvel*T0/rho0; \
68  } \
69  }
70 
71 #define _Numa2DSetSource_(s,param,drho) \
72  { \
73  s[0] = 0.0; \
74  s[1] = 0.0; \
75  s[2] = -param->g*drho; \
76  s[3] = 0.0; \
77  }
78 
79 #define _Numa2DComputePressure_(params,T0,dT,P0,dP) \
80  { \
81  double gamma = params->gamma; \
82  double Pref = params->Pref; \
83  double R = params->R; \
84  double P_total = Pref * raiseto((R*(T0+dT)/Pref),gamma); \
85  dP = P_total - P0; \
86  }
87 
88 #define _Numa2DComputeLinearizedPressure_(params,T0,dT,P0,dP) \
89  { \
90  double gamma = params->gamma; \
91  dP = (gamma*P0/T0) * dT; \
92  }
93 
94 #define _Numa2DComputeTemperature_(rho0,drho,T0,dT,temperature) \
95  { \
96  temperature = (T0+dT)*EP/(rho0+drho); \
97  }
98 
99 #define _Numa2DComputeSpeedofSound_(gamma,R,T0,dT,rho0,drho,EP,c) \
100  { \
101  c = sqrt(gamma*R*(T0+dT)*EP/(rho0+drho)); \
102  }
103 
104 #define _Numa2DComputeLinearizedSpeedofSound_(gamma,R,T0,rho0,EP,c) \
105  { \
106  c = sqrt(gamma*R*T0*EP/rho0); \
107  }
108 
109 typedef struct numa2d_parameters {
110  double gamma; /* Ratio of heat capacities */
111  double R; /* Universal gas constant */
112  double g; /* acceleration due to gravity */
113  int init_atmos; /* choice of initial atmosphere */
114  double mu; /* coefficient of dynamic viscosity */
115 
116  /* pressure & temperature at zero altitude */
117  double Pref, Tref;
118 
119  /* function to calculate hydrostatically balanced flow variables */
120  void (*StandardAtmosphere)(void*,double,double*,double*,double*,double*);
121 
122  /* choice of upwinding scheme */
123  char upwind[_MAX_STRING_SIZE_];
124 } Numa2D;
125 
126 int Numa2DInitialize (void*,void*);
127 int Numa2DCleanup (void*);
128 
129 /* Available upwinding schemes */
130 #define _RUSANOV_UPWINDING_ "rusanov"
int init_atmos
Definition: numa2d.h:113
double Tref
Definition: numa2d.h:117
Contains function definitions for common mathematical functions.
double mu
Definition: numa2d.h:114
Some basic definitions and macros.
double R
Definition: numa2d.h:111
double g
Definition: numa2d.h:112
#define _MAX_STRING_SIZE_
Definition: basic.h:14
Definition: numa2d.h:109
int Numa2DCleanup(void *)
Definition: Numa2DCleanup.c:5
double gamma
Definition: numa2d.h:110
int Numa2DInitialize(void *, void *)