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