HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
numa3d.h
Go to the documentation of this file.
1 /*
2  *
3  * 3D 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  * J.F. Kelly and F.X. Giraldo, "Continuous and Discontinuous
13  * Galerkin Methods for a Scalable 3D Nonhydrostatic Atmospheric
14  * Model: limited-area mode", J. Comp. Phys., Vol. 231, 7988-8008
15  * (2012)
16  *
17  * N. Ahmad and J. Lindeman, "Euler solutions using flux-based wave
18  * decomposition", Intl. J. Num. Method. Fluid., Vol. 54 (1),
19  * 47-72 (2007)
20  *
21 */
22 
23 #include <basic.h>
24 #include <mathfunctions.h>
25 
26 #define _NUMA3D_ "numa3d"
27 
28 /* define ndims and nvars for this model */
29 #undef _MODEL_NDIMS_
30 #undef _MODEL_NVARS_
31 #define _MODEL_NDIMS_ 3
32 #define _MODEL_NVARS_ 5
33 
34 /* grid directions */
35 #define _XDIR_ 0
36 #define _YDIR_ 1
37 #define _ZDIR_ 2
38 
39 #define _Numa3DGetFlowVars_(u,drho,uvel,vvel,wvel,dT,rho0) \
40  { \
41  drho = u[0]; \
42  uvel = u[1]/(rho0+drho); \
43  vvel = u[2]/(rho0+drho); \
44  wvel = u[3]/(rho0+drho); \
45  dT = u[4]; \
46  }
47 
48 #define _Numa3DSetFlux_(f,dir,drho,uvel,vvel,wvel,dT,dP,rho0,T0) \
49  { \
50  if (dir == _XDIR_) { \
51  f[0] = (rho0+drho) * uvel; \
52  f[1] = (rho0+drho)*uvel*uvel + dP; \
53  f[2] = (rho0+drho)*uvel*vvel; \
54  f[3] = (rho0+drho)*uvel*wvel; \
55  f[4] = uvel*(dT+T0); \
56  } else if (dir == _YDIR_) { \
57  f[0] = (rho0+drho) * vvel; \
58  f[1] = (rho0+drho)*uvel*vvel; \
59  f[2] = (rho0+drho)*vvel*vvel + dP; \
60  f[3] = (rho0+drho)*wvel*vvel; \
61  f[4] = vvel*(dT+T0); \
62  } else if (dir == _ZDIR_) { \
63  f[0] = (rho0+drho) * wvel; \
64  f[1] = (rho0+drho)*uvel*wvel; \
65  f[2] = (rho0+drho)*vvel*wvel; \
66  f[3] = (rho0+drho)*wvel*wvel + dP; \
67  f[4] = wvel*(dT+T0); \
68  } \
69  }
70 
71 #define _Numa3DSetLinearFlux_(f,dir,drho,uvel,vvel,wvel,dT,dP,rho0,T0) \
72  { \
73  if (dir == _XDIR_) { \
74  f[0] = (rho0+drho) * uvel; \
75  f[1] = dP; \
76  f[2] = 0.0; \
77  f[3] = 0.0; \
78  f[4] = (rho0+drho)*uvel*T0/rho0; \
79  } else if (dir == _YDIR_) { \
80  f[0] = (rho0+drho) * vvel; \
81  f[1] = 0.0; \
82  f[2] = dP; \
83  f[3] = 0.0; \
84  f[4] = (rho0+drho)*vvel*T0/rho0; \
85  } else if (dir == _ZDIR_) { \
86  f[0] = (rho0+drho) * wvel; \
87  f[1] = 0.0; \
88  f[2] = 0.0; \
89  f[3] = dP; \
90  f[4] = (rho0+drho)*wvel*T0/rho0; \
91  } \
92  }
93 
94 #define _Numa3DSetSource_(s,param,uvel,vvel,drho,rho0) \
95  { \
96  s[0] = 0.0; \
97  s[1] = 2.0*param->Omega*vvel*(rho0+drho); \
98  s[2] = -2.0*param->Omega*uvel*(rho0+drho); \
99  s[3] = -param->g*drho; \
100  s[4] = 0.0; \
101  }
102 
103 #define _Numa3DComputePressure_(params,T0,dT,P0,dP) \
104  { \
105  double gamma = params->gamma; \
106  double Pref = params->Pref; \
107  double R = params->R; \
108  double P_total = Pref * raiseto((R*(T0+dT)/Pref),gamma); \
109  dP = P_total - P0; \
110  }
111 
112 #define _Numa3DComputeLinearizedPressure_(params,T0,dT,P0,dP) \
113  { \
114  double gamma = params->gamma; \
115  dP = (gamma*P0/T0) * dT; \
116  }
117 
118 #define _Numa3DComputeSpeedofSound_(gamma,R,T0,dT,rho0,drho,EP,c) \
119  { \
120  c = sqrt(gamma*R*(T0+dT)*EP/(rho0+drho)); \
121  }
122 
123 #define _Numa3DComputeLinearizedSpeedofSound_(gamma,R,T0,rho0,EP,c) \
124  { \
125  c = sqrt(gamma*R*T0*EP/rho0); \
126  }
127 
128 typedef struct numa3d_parameters {
129  double gamma; /* Ratio of heat capacities */
130  double R; /* Universal gas constant */
131  double Omega; /* Angular speed of Earth */
132  double g; /* acceleration due to gravity */
133  int init_atmos; /* choice of initial atmosphere */
134 
135  /* pressure & temperature at zero altitude */
136  double Pref, Tref;
137 
138  /* function to calculate hydrostatically balanced flow variables */
139  void (*StandardAtmosphere)(void*,double,double*,double*,double*,double*);
140 
141  /* choice of upwinding scheme */
142  char upwind[_MAX_STRING_SIZE_];
143 } Numa3D;
144 
145 int Numa3DInitialize (void*,void*);
146 int Numa3DCleanup (void*);
147 
148 /* Available upwinding schemes */
149 #define _RUSANOV_UPWINDING_ "rusanov"
150 #define _RF_CHAR_UPWINDING_ "rf-char" /* does not work! */
double Tref
Definition: numa3d.h:136
double R
Definition: numa3d.h:130
#define _MAX_STRING_SIZE_
Definition: basic.h:14
Definition: numa3d.h:128
Contains function definitions for common mathematical functions.
double Omega
Definition: numa3d.h:131
double gamma
Definition: numa3d.h:129
int Numa3DInitialize(void *, void *)
double g
Definition: numa3d.h:132
int Numa3DCleanup(void *)
Definition: Numa3DCleanup.c:5
Some basic definitions and macros.
int init_atmos
Definition: numa3d.h:133