ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_IndexDefines.H
Go to the documentation of this file.
1 #ifndef ERF_INDEX_DEFINES_H_
2 #define ERF_INDEX_DEFINES_H_
3 
4 #include <AMReX_REAL.H>
5 #include <AMReX_Arena.H>
6 
7 /**
8  * Definition of indexing parameters
9 */
10 
11 // This defines the ACTUAL number of non-moisture vars =
12 // rho, rhotheta, rhoKE
13 #define NDRY 3
14 
15 // This defines the ACTUAL number of non-moisture scalar vars
16 #define NSCALARS 1
17 
18 // This defines the MAXIMUM number of moisture vars (six q's plus five n's)
19 #define NMOIST_max 11
20 
21 // This is the number of components if using moisture
22 // We use this to allocate the 1d arrays of boundary condition types,
23 // but not to allocate actual solution data
24 // Full moist state with no additional non-moist species
25 #define NVAR_MOIST_max (NDRY + NSCALARS + NMOIST_max)
26 
27 #define NVAR_max ((NDRY + NSCALARS + NMOIST_max) + 2*5) // allow up to 5 non-moist species
28 
29 // This is the number of components if we assume there is only one passive scalar
30 // We can use this when we assume all passive scalars have the same bc's
31 // We also assume (the final "+1" that the base state components have the same bcs)
32 #define NBCVAR_max ((NDRY + 1 + NMOIST_max + 1) + 2*5) // allow up to 5 non-moist species
33 
34 // This is the number of components if we assume there is only one passive scalar
35 // We can use this when we assume all passive scalars have the same diffusion coefficients
36 // The trailing 2*5 mirrors NVAR_max: a microphysics model may append up to 5 non-moist
37 // species (two components each) after the water species, and the diffusion coefficient
38 // tables below are indexed by primitive component over that full range as well
39 #define NPRIMVAR_max ((NDRY + 1 + NMOIST_max) + 2*5) // allow up to 5 non-moist species
40 
41 // Cell-centered state variables
42 #define Rho_comp 0
43 #define RhoTheta_comp (Rho_comp+1)
44 #define RhoKE_comp (Rho_comp+2) // for Deardorff LES Model, k-equation RANS, or MYNN PBL Model
45 
46 #define RhoScalar_comp (RhoKE_comp+1)
47 
48 #define RhoQ1_comp (RhoScalar_comp+NSCALARS)
49 #define RhoQ2_comp (RhoQ1_comp+1)
50 #define RhoQ3_comp (RhoQ1_comp+2)
51 #define RhoQ4_comp (RhoQ1_comp+3)
52 #define RhoQ5_comp (RhoQ1_comp+4)
53 #define RhoQ6_comp (RhoQ1_comp+5)
54 #define RhoQ7_comp (RhoQ1_comp+6)
55 #define RhoQ8_comp (RhoQ1_comp+7)
56 #define RhoQ9_comp (RhoQ1_comp+8)
57 #define RhoQ10_comp (RhoQ1_comp+9)
58 #define RhoQ11_comp (RhoQ1_comp+10)
59 
60 // Cell-centered primitive variables
61 #define PrimTheta_comp (RhoTheta_comp -1)
62 #define PrimKE_comp (RhoKE_comp -1)
63 #define PrimScalar_comp (RhoScalar_comp-1)
64 #define PrimQ1_comp (RhoQ1_comp-1)
65 #define PrimQ2_comp (RhoQ2_comp-1)
66 #define PrimQ3_comp (RhoQ3_comp-1)
67 #define PrimQ4_comp (RhoQ4_comp-1)
68 #define PrimQ5_comp (RhoQ5_comp-1)
69 #define PrimQ6_comp (RhoQ6_comp-1)
70 #define PrimQ7_comp (RhoQ7_comp-1)
71 #define PrimQ8_comp (RhoQ8_comp-1)
72 #define PrimQ9_comp (RhoQ9_comp-1)
73 #define PrimQ10_comp (RhoQ10_comp-1)
74 #define PrimQ11_comp (RhoQ11_comp-1)
75 
76 // Base state variables
77 namespace BaseState {
78  enum {
79  r0_comp = 0,
84  num_comps
85  };
86 }
87 
88 // NOTE: we still use this indexing even if no moisture
89 // NOTE: We assume a single boundary condition for all passive scalars
90 namespace BCVars {
91  enum {
92  cons_bc = 0,
111  NumTypes
112  };
113 }
114 
115 // Note that we don't use these, but we need this vector to be long enough
116 // not to segfault when we do the FillPatch operation.
117 namespace BaseBCVars {
118  enum {
124  };
125 }
126 
127 namespace RealBdyVars {
128  enum {
129  U = 0,
130  V = 1,
131  T = 2,
132  QV = 3,
133  R = 4,
134  QC = 5,
135  QI = 6,
136  NumTypes
137  };
138 }
139 
140 // Additional runtime boundary slots used when all precipitating
141 // hydrometeors are represented as separate ERF state components. Keep the
142 // compact QC/QI indices above unchanged for aggregate-boundary compatibility.
144  enum {
146  QS,
147  QG,
148  NumTypes
149  };
150 }
151 
152 namespace WRFBdyVars {
153  enum {
154  U = 0,
155  V = 1,
156  T = 2,
157  QV = 3, // water vapor
158  R = 4, // density
159  PH , // Perturbational geopotential
160  MU , // bdy perturbation dry air mass in column (we will get mub from the initial data)
161  PC , // p_s - p_top = dry hydrostatic pressure difference between the surface and the model top
162  QC , // cloud water
163  QI , // cloud ice
164  NumTypes
165  };
166 
167  constexpr int LegacyNumTypes = PC + 1;
168 }
169 
170 // Additional serialized/cache slots used when all precipitating hydrometeors
171 // are retained separately. The legacy and aggregate layouts remain unchanged.
173  enum {
175  QS,
176  QG,
177  NumTypes
178  };
179 }
180 
181 static_assert(WRFBdyVars::U == 0 && WRFBdyVars::V == 1 &&
182  WRFBdyVars::T == 2 && WRFBdyVars::QV == 3 &&
183  WRFBdyVars::R == 4 && WRFBdyVars::PH == 5 &&
184  WRFBdyVars::MU == 6 && WRFBdyVars::PC == 7,
185  "The serialized legacy WRF boundary layout must not change");
186 
187 namespace MetGridBdyVars {
188  enum {
189  U = 0,
190  V = 1,
191  T = 2,
192  QV = 3,
193  NumTypes
194  };
195 }
196 
197 namespace MetGridTmpSrcVars {
198  enum {
199  Theta = 0,
200  QV = 1,
201  NumTypes
202  };
203 }
204 
205 namespace MetGridTmpDstVars {
206  enum {
207  P = 0,
208  T = 1,
209  Theta = 2,
210  QV = 3,
211  NumTypes
212  };
213 }
214 
215 namespace Vars {
216  enum {
217  cons = 0,
221  NumTypes
222  };
223 }
224 
225 namespace GpVars {
226  enum {
227  gpx = 0,
230  };
231 }
232 
233 namespace IntVars {
234  enum {
235  cons = 0,
239  NumTypes
240  };
241 }
242 
243 // We separate out horizontal and vertical turbulent diffusivities
244 // These are the same for LES, but different for PBL models
245 namespace EddyDiff {
246  enum {
247  Mom_h = 0,
258  // Nonlocal (countergradient) terms. All four are stored *normalized by the
259  // PBL height*, i.e. as a gradient of the transported quantity, so that the
260  // implicit vertical diffusion solvers form the countergradient flux as
261  // F_cg = +rho*alpha*gamma
262  // with no further metric or grid-spacing factors.
263  HGAMT_v, // MRF/YSU countergradient for heat (HGAMT/h, units K/m), zero outside PBL
264  HGAMQ_v, // MRF/YSU countergradient for moisture (HGAMQ/h, units kg/kg/m), zero outside PBL
265  HGAMU_v, // YSU countergradient for x-momentum (HGAMU/h, units 1/s), zero outside PBL
266  HGAMV_v, // YSU countergradient for y-momentum (HGAMV/h, units 1/s), zero outside PBL
267  // k-eqn RANS diagnostics: smoothed turbulent Richardson number and the
268  // two stability functions (Axell & Liungman 2001, Eqs. 29-32)
272  NumDiffs
273  };
274 }
275 
276 enum struct ERF_BC {
277  symmetry,
278  inflow,
279  outflow,
281  ho_outflow,
282  open,
283  no_slip_wall,
284  slip_wall,
285  periodic,
287  undefined
288 };
289 
290 // NOTE: the first of these must match up with the BCType enum
291 // in amrex/Src/Base/AMReX_BC_TYPES.H. We had extras at
292 // the end to use locally
293 namespace ERFBCType {
295  bogus = -666,
297  int_dir = 0,
299  foextrap = 2,
300  ext_dir = 3,
301  hoextrap = 4,
305  neumann = 104,
306  neumann_int = 105,
307  open = 106,
308  ext_dir_upwind = 107
309 };
310 }
311 
312 enum struct AdvType : int {
313  Centered_2nd = 101,
314  Upwind_3rd = 102,
315  Upwind_3rd_SL = 103,
316  Centered_4th = 104,
317  Upwind_5th = 105,
318  Centered_6th = 106,
319  Weno_3 = 107,
320  Weno_3Z = 108,
321  Weno_5 = 109,
322  Weno_5Z = 110,
323  Weno_3MZQ = 111,
324  Weno_7 = 112,
325  Weno_7Z = 113,
326  Unknown = 114
327 };
328 #endif
#define NBCVAR_max
Definition: ERF_IndexDefines.H:32
AdvType
Definition: ERF_IndexDefines.H:312
@ Upwind_3rd_SL
@ Centered_4th
@ Centered_6th
@ Centered_2nd
ERF_BC
Definition: ERF_IndexDefines.H:276
@ ho_outflow
@ inflow_outflow
@ no_slip_wall
@ surface_layer
Definition: ERF_IndexDefines.H:90
@ RhoQ6_bc_comp
Definition: ERF_IndexDefines.H:102
@ RhoScalar_bc_comp
Definition: ERF_IndexDefines.H:96
@ zvel_bc
Definition: ERF_IndexDefines.H:110
@ RhoQ1_bc_comp
Definition: ERF_IndexDefines.H:97
@ NumTypes
Definition: ERF_IndexDefines.H:111
@ RhoQ4_bc_comp
Definition: ERF_IndexDefines.H:100
@ RhoKE_bc_comp
Definition: ERF_IndexDefines.H:95
@ RhoQ7_bc_comp
Definition: ERF_IndexDefines.H:103
@ RhoQ10_bc_comp
Definition: ERF_IndexDefines.H:106
@ RhoQ3_bc_comp
Definition: ERF_IndexDefines.H:99
@ RhoTheta_bc_comp
Definition: ERF_IndexDefines.H:94
@ RhoQ2_bc_comp
Definition: ERF_IndexDefines.H:98
@ Rho_bc_comp
Definition: ERF_IndexDefines.H:93
@ RhoQ11_bc_comp
Definition: ERF_IndexDefines.H:107
@ yvel_bc
Definition: ERF_IndexDefines.H:109
@ cons_bc
Definition: ERF_IndexDefines.H:92
@ xvel_bc
Definition: ERF_IndexDefines.H:108
@ RhoQ9_bc_comp
Definition: ERF_IndexDefines.H:105
@ RhoQ8_bc_comp
Definition: ERF_IndexDefines.H:104
@ RhoQ5_bc_comp
Definition: ERF_IndexDefines.H:101
Definition: ERF_IndexDefines.H:117
@ rho0_bc_comp
Definition: ERF_IndexDefines.H:119
@ th0_bc_comp
Definition: ERF_IndexDefines.H:122
@ qv0_bc_comp
Definition: ERF_IndexDefines.H:123
@ pi0_bc_comp
Definition: ERF_IndexDefines.H:121
@ p0_bc_comp
Definition: ERF_IndexDefines.H:120
Definition: ERF_IndexDefines.H:77
@ num_comps
Definition: ERF_IndexDefines.H:84
@ qv0_comp
Definition: ERF_IndexDefines.H:83
@ pi0_comp
Definition: ERF_IndexDefines.H:81
@ p0_comp
Definition: ERF_IndexDefines.H:80
@ th0_comp
Definition: ERF_IndexDefines.H:82
@ r0_comp
Definition: ERF_IndexDefines.H:79
Definition: ERF_IndexDefines.H:293
mathematicalBndryTypes
Definition: ERF_IndexDefines.H:294
@ neumann
Definition: ERF_IndexDefines.H:305
@ ext_dir_ingested
Definition: ERF_IndexDefines.H:304
@ open
Definition: ERF_IndexDefines.H:307
@ reflect_odd
Definition: ERF_IndexDefines.H:296
@ hoextrap
Definition: ERF_IndexDefines.H:301
@ foextrap
Definition: ERF_IndexDefines.H:299
@ ext_dir
Definition: ERF_IndexDefines.H:300
@ ext_dir_prim
Definition: ERF_IndexDefines.H:303
@ bogus
Definition: ERF_IndexDefines.H:295
@ surface_layer
Definition: ERF_IndexDefines.H:302
@ ext_dir_upwind
Definition: ERF_IndexDefines.H:308
@ int_dir
Definition: ERF_IndexDefines.H:297
@ neumann_int
Definition: ERF_IndexDefines.H:306
@ reflect_even
Definition: ERF_IndexDefines.H:298
Definition: ERF_IndexDefines.H:245
@ Theta_v
Definition: ERF_IndexDefines.H:253
@ Turb_lengthscale
Definition: ERF_IndexDefines.H:257
@ Scalar_v
Definition: ERF_IndexDefines.H:255
@ Mom_h
Definition: ERF_IndexDefines.H:247
@ HGAMU_v
Definition: ERF_IndexDefines.H:265
@ Q_v
Definition: ERF_IndexDefines.H:256
@ Q_h
Definition: ERF_IndexDefines.H:251
@ Mom_v
Definition: ERF_IndexDefines.H:252
@ RANS_Rt
Definition: ERF_IndexDefines.H:269
@ HGAMQ_v
Definition: ERF_IndexDefines.H:264
@ HGAMT_v
Definition: ERF_IndexDefines.H:263
@ Scalar_h
Definition: ERF_IndexDefines.H:250
@ KE_v
Definition: ERF_IndexDefines.H:254
@ NumDiffs
Definition: ERF_IndexDefines.H:272
@ RANS_cmu
Definition: ERF_IndexDefines.H:270
@ Theta_h
Definition: ERF_IndexDefines.H:248
@ HGAMV_v
Definition: ERF_IndexDefines.H:266
@ KE_h
Definition: ERF_IndexDefines.H:249
@ RANS_cmu_prime
Definition: ERF_IndexDefines.H:271
Definition: ERF_IndexDefines.H:225
@ gpz
Definition: ERF_IndexDefines.H:229
@ gpy
Definition: ERF_IndexDefines.H:228
@ gpx
Definition: ERF_IndexDefines.H:227
Definition: ERF_IndexDefines.H:233
@ NumTypes
Definition: ERF_IndexDefines.H:239
@ ymom
Definition: ERF_IndexDefines.H:237
@ cons
Definition: ERF_IndexDefines.H:235
@ zmom
Definition: ERF_IndexDefines.H:238
@ xmom
Definition: ERF_IndexDefines.H:236
Definition: ERF_IndexDefines.H:187
@ U
Definition: ERF_IndexDefines.H:189
@ NumTypes
Definition: ERF_IndexDefines.H:193
@ V
Definition: ERF_IndexDefines.H:190
@ QV
Definition: ERF_IndexDefines.H:192
@ T
Definition: ERF_IndexDefines.H:191
Definition: ERF_IndexDefines.H:205
@ P
Definition: ERF_IndexDefines.H:207
@ Theta
Definition: ERF_IndexDefines.H:209
@ QV
Definition: ERF_IndexDefines.H:210
@ T
Definition: ERF_IndexDefines.H:208
@ NumTypes
Definition: ERF_IndexDefines.H:211
Definition: ERF_IndexDefines.H:197
@ Theta
Definition: ERF_IndexDefines.H:199
@ QV
Definition: ERF_IndexDefines.H:200
@ NumTypes
Definition: ERF_IndexDefines.H:201
Definition: ERF_IndexDefines.H:143
@ QG
Definition: ERF_IndexDefines.H:147
@ NumTypes
Definition: ERF_IndexDefines.H:148
@ QR
Definition: ERF_IndexDefines.H:145
@ QS
Definition: ERF_IndexDefines.H:146
Definition: ERF_IndexDefines.H:127
@ R
Definition: ERF_IndexDefines.H:133
@ U
Definition: ERF_IndexDefines.H:129
@ NumTypes
Definition: ERF_IndexDefines.H:136
@ QV
Definition: ERF_IndexDefines.H:132
@ T
Definition: ERF_IndexDefines.H:131
@ QC
Definition: ERF_IndexDefines.H:134
@ QI
Definition: ERF_IndexDefines.H:135
@ V
Definition: ERF_IndexDefines.H:130
Definition: ERF_IndexDefines.H:215
@ xvel
Definition: ERF_IndexDefines.H:218
@ cons
Definition: ERF_IndexDefines.H:217
@ zvel
Definition: ERF_IndexDefines.H:220
@ NumTypes
Definition: ERF_IndexDefines.H:221
@ yvel
Definition: ERF_IndexDefines.H:219
Definition: ERF_IndexDefines.H:172
@ NumTypes
Definition: ERF_IndexDefines.H:177
@ QS
Definition: ERF_IndexDefines.H:175
@ QG
Definition: ERF_IndexDefines.H:176
@ QR
Definition: ERF_IndexDefines.H:174
Definition: ERF_IndexDefines.H:152
constexpr int LegacyNumTypes
Definition: ERF_IndexDefines.H:167
@ QI
Definition: ERF_IndexDefines.H:163
@ QC
Definition: ERF_IndexDefines.H:162
@ T
Definition: ERF_IndexDefines.H:156
@ R
Definition: ERF_IndexDefines.H:158
@ QV
Definition: ERF_IndexDefines.H:157
@ V
Definition: ERF_IndexDefines.H:155
@ PC
Definition: ERF_IndexDefines.H:161
@ NumTypes
Definition: ERF_IndexDefines.H:164
@ MU
Definition: ERF_IndexDefines.H:160
@ U
Definition: ERF_IndexDefines.H:154
@ PH
Definition: ERF_IndexDefines.H:159