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