ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_TerrainMetrics.H
Go to the documentation of this file.
1 #ifndef ERF_TERRAIN_METRIC_H_
2 #define ERF_TERRAIN_METRIC_H_
3 
4 #include <AMReX.H>
5 #include <AMReX_Geometry.H>
6 #include <AMReX_MultiFab.H>
7 #include <ERF_IndexDefines.H>
8 #include <cmath>
10 
11 /**
12  * Routine to define default z_phys_nd and z_phys_cc
13  */
14 void
15 init_default_zphys (int lev, const amrex::Geometry& geom,
16  amrex::MultiFab& z_phys_nd, amrex::MultiFab& z_phys_cc,
17  amrex::Real z_offset = zero);
18 
19 /**
20  * The cells of a (cell-centered) BoxArray as boxes that are never stacked on each other:
21  * wherever a box sits on the top face of another, the run of cells in z that the two belong
22  * to becomes a single box. Returns ba itself when no two boxes of ba are stacked.
23  *
24  * @param[in] ba cell-centered BoxArray
25  */
26 amrex::BoxArray
27 join_boxes_stacked_in_z (const amrex::BoxArray& ba);
28 
29 /**
30  * Utility routines for constructing terrain metric terms
31  */
32 
33 // Declare functions for ERF.cpp
34 /**
35  * Initialize staggered z-levels and stretched vertical spacing.
36  *
37  * @param[out] zlevels_stag Staggered z-levels.
38  * @param[out] stretched_dz_h Host stretched vertical spacing.
39  * @param[out] stretched_dz_d Device stretched vertical spacing.
40  * @param[in] geom Geometry information.
41  * @param[in] ref_ratio Refinement ratios.
42  * @param[in] grid_stretching_ratio Ratio for grid stretching; zero with a positive dz0
43  * solves for the ratio that closes on the domain top.
44  * @param[in] dz0 Initial vertical spacing.
45  */
46 void
47 init_zlevels (amrex::Vector<amrex::Vector<amrex::Real>>& zlevels_stag,
48  amrex::Vector<amrex::Vector<amrex::Real>>& stretched_dz_h,
49  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>>& stretched_dz_d,
50  amrex::Vector<amrex::Geometry> const& geom,
51  amrex::Vector<amrex::IntVect> const& ref_ratio,
52  const amrex::Real grid_stretching_ratio,
53  const amrex::Real dz0);
54 
55 /**
56  * How the terrain-fitted mesh on a fine level is built when erf.terrain_smoothing != 0.
57  *
58  * The STF and Sullivan TF transformations are not defined on a level that does not
59  * reach the top of the domain, so on a fine level we instead start from the mesh
60  * interpolated from the coarse level. A caller that has done that interpolation --
61  * and, for Transform, has also written the fine-resolution terrain into the k=0 slab
62  * and saved the pre-overwrite field -- says so by passing anything other than None.
63  * Every other caller keeps the historical behavior of aborting, because it has not
64  * prepared z_phys_nd in a way this path can use.
65  */
66 enum struct FineTerrain {
67  None, //!< caller has not prepared a fine mesh from the coarse level
68  Interpolate, //!< use the coordinates interpolated from the coarse level as-is
69  Transform //!< add the fine terrain as a correction that decays with height
70 };
71 
72 /**
73  * Read erf.amr_terrain_refinement and translate it into a FineTerrain.
74  *
75  * Aborts on any value other than "interpolate" or "transform" so that a typo cannot
76  * silently select a path that leaves the fine mesh untransformed.
77  */
80 
81 /**
82  * Construct terrain-fitted coordinates.
83  *
84  * @param[in] lev Level index.
85  * @param[in] geom Geometry information.
86  * @param[out] z_phys_nd Nodal physical height field.
87  * @param[in] z_levels_h Host z-levels.
88  * @param[in] phys_bc_type Physical boundary condition types.
89  * @param[in] fine_terrain How a fine level with terrain_smoothing != 0 is to be built.
90  * @param[in] z_phys_interp Mesh interpolated from the coarse level before the fine
91  * terrain was written into the k=0 slab; required by, and
92  * only used for, FineTerrain::Transform.
93  */
94 void
95 make_terrain_fitted_coords (int lev, const amrex::Geometry& geom,
96  amrex::MultiFab& z_phys_nd,
97  amrex::Vector<amrex::Real> const& z_levels_h,
98  amrex::GpuArray<ERF_BC, AMREX_SPACEDIM*2>& phys_bc_type,
99  FineTerrain fine_terrain = FineTerrain::None,
100  amrex::MultiFab const* z_phys_interp = nullptr,
101  bool moving_mesh = false);
102 
103 /** Verify that a fitted mesh is horizontally flat and follows z_levels_h. */
104 void
106  const amrex::MultiFab& z_phys_nd,
107  const amrex::Vector<amrex::Real>& z_levels_h);
108 
109 /** Abort unless z_phys_nd is the same at every node of the top of the domain. */
110 void
112  const amrex::Geometry& geom,
113  const amrex::MultiFab& z_phys_nd);
114 
115 /**
116  * Initialize the terrain grid mapping.
117  *
118  * @param[in] lev Level index.
119  * @param[in] geom Geometry information.
120  * @param[out] z_phys_nd Nodal physical height field.
121  * @param[in] z_levels_h Host z-levels.
122  * @param[in] fine_terrain How a fine level with terrain_smoothing != 0 is to be built.
123  * @param[in] z_phys_interp Mesh interpolated from the coarse level; see above.
124  */
125 void
126 init_which_terrain_grid (int lev, const amrex::Geometry& geom,
127  amrex::MultiFab& z_phys_nd,
128  amrex::Vector<amrex::Real> const& z_levels_h,
129  FineTerrain fine_terrain = FineTerrain::None,
130  amrex::MultiFab const* z_phys_interp = nullptr);
131 
132 /**
133  * Finish the terrain-fitted mesh on a fine level whose interior was set by
134  * interpolation from the coarse level (erf.terrain_smoothing != 0).
135  *
136  * For FineTerrain::Transform this adds the fine-resolution terrain as a correction
137  * that decays linearly to zero at the top of the fine grids. For both modes it then
138  * fills the nodes outside the lateral domain boundary and the layer below the
139  * surface, which init_which_terrain_grid()'s BTF branch would otherwise have filled.
140  *
141  * @param[in] lev Level index.
142  * @param[in] geom Geometry information.
143  * @param[in,out] z_phys_nd Nodal physical height field.
144  * @param[in] z_levels_h Host z-levels.
145  * @param[in] fine_terrain Interpolate or Transform.
146  * @param[in] z_phys_interp Mesh interpolated from the coarse level; see above.
147  */
148 void
149 init_fine_terrain_grid (int lev, const amrex::Geometry& geom,
150  amrex::MultiFab& z_phys_nd,
151  amrex::Vector<amrex::Real> const& z_levels_h,
152  FineTerrain fine_terrain,
153  amrex::MultiFab const* z_phys_interp);
154 
155 // Compute the min dz at cell center with terrain
156 /**
157  * Compute the minimum vertical spacing with terrain.
158  *
159  * @param[in] z_phys_nd Nodal physical height field.
160  * @return Minimum vertical grid spacing.
161  */
162 amrex::Real
163 get_dzmin_terrain (amrex::MultiFab& z_phys_nd);
164 
165 /**
166  * Re-derive the stretched vertical spacing at one level from the nominal z-levels.
167  *
168  * init_zlevels() fills both zlevels_stag and stretched_dz_* together, but
169  * zlevels_stag can be replaced after construction (init_from_wrfinput() does this
170  * when erf.avg_grid_faces_to_nodes = false, and restart reads it back from the
171  * checkpoint). Call this whenever zlevels_stag[lev] changes so that the cell
172  * heights never drift out of sync with the levels they are supposed to describe.
173  *
174  * @param[in] lev Level index.
175  * @param[in] zlevels_stag Staggered z-levels (the source of truth).
176  * @param[out] stretched_dz_h Host stretched vertical spacing.
177  * @param[out] stretched_dz_d Device stretched vertical spacing.
178  */
179 void
181  amrex::Vector<amrex::Vector<amrex::Real>> const& zlevels_stag,
182  amrex::Vector<amrex::Vector<amrex::Real>>& stretched_dz_h,
183  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>>& stretched_dz_d);
184 
185 //*****************************************************************************************
186 // Compute terrain metric terms at cell-center
187 //*****************************************************************************************
188 // Metric is at cell center
189 /**
190  * Compute the zeta metric term at the cell center.
191  *
192  * @param[in] i x-index
193  * @param[in] j y-index
194  * @param[in] k z-index
195  * @param[in] cellSizeInv Inverse cell spacing.
196  * @param[in] z_nd Nodal physical height field.
197  * @return Zeta metric term.
198  */
199 AMREX_GPU_HOST_DEVICE
200 AMREX_FORCE_INLINE
201 amrex::Real
202 Compute_h_zeta_AtCellCenter (const int &i, const int &j, const int &k,
203  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
204  const amrex::Array4<const amrex::Real>& z_nd)
205 {
206  amrex::Real dzInv = cellSizeInv[2];
207  amrex::Real met_h_zeta = fourth * dzInv *
208  ( z_nd(i+1,j,k+1) + z_nd(i+1,j+1,k+1) + z_nd(i,j,k+1) + z_nd(i,j+1,k+1)
209  - z_nd(i+1,j,k ) - z_nd(i+1,j+1,k ) - z_nd(i,j,k ) - z_nd(i,j+1,k ) );
210  return met_h_zeta;
211 }
212 
213 // Metric is at cell center
214 /**
215  * Compute the xi metric term at the cell center.
216  *
217  * @param[in] i x-index
218  * @param[in] j y-index
219  * @param[in] k z-index
220  * @param[in] cellSizeInv Inverse cell spacing.
221  * @param[in] z_nd Nodal physical height field.
222  * @return Xi metric term.
223  */
224 AMREX_GPU_HOST_DEVICE
225 AMREX_FORCE_INLINE
226 amrex::Real
227 Compute_h_xi_AtCellCenter (const int &i, const int &j, const int &k,
228  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
229  const amrex::Array4<const amrex::Real>& z_nd)
230 {
231  amrex::Real dxInv = cellSizeInv[0];
232  amrex::Real met_h_xi = fourth * dxInv *
233  ( z_nd(i+1,j,k) + z_nd(i+1,j+1,k) + z_nd(i+1,j,k+1) + z_nd(i+1,j+1,k+1)
234  - z_nd(i ,j,k) - z_nd(i ,j+1,k) - z_nd(i ,j,k+1) - z_nd(i ,j+1,k+1) );
235  return met_h_xi;
236 }
237 
238 // Metric is at cell center
239 /**
240  * Compute the eta metric term at the cell center.
241  *
242  * @param[in] i x-index
243  * @param[in] j y-index
244  * @param[in] k z-index
245  * @param[in] cellSizeInv Inverse cell spacing.
246  * @param[in] z_nd Nodal physical height field.
247  * @return Eta metric term.
248  */
249 AMREX_GPU_HOST_DEVICE
250 AMREX_FORCE_INLINE
251 amrex::Real
252 Compute_h_eta_AtCellCenter (const int &i, const int &j, const int &k,
253  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
254  const amrex::Array4<const amrex::Real>& z_nd)
255 {
256  amrex::Real dyInv = cellSizeInv[1];
257  amrex::Real met_h_eta = fourth * dyInv *
258  ( z_nd(i,j+1,k) + z_nd(i+1,j+1,k) + z_nd(i,j+1,k+1) + z_nd(i+1,j+1,k+1)
259  - z_nd(i,j ,k) - z_nd(i+1,j ,k) - z_nd(i,j ,k+1) - z_nd(i+1,j ,k+1) );
260  return met_h_eta;
261 }
262 
263 
264 //*****************************************************************************************
265 // Compute terrain metric terms at face-centers
266 //*****************************************************************************************
267 // Metric coincides with U location
268 /**
269  * Compute the zeta metric term at the i-face.
270  *
271  * @param[in] i x-index
272  * @param[in] j y-index
273  * @param[in] k z-index
274  * @param[in] cellSizeInv Inverse cell spacing.
275  * @param[in] z_nd Nodal physical height field.
276  * @return Zeta metric term.
277  */
278 AMREX_GPU_DEVICE
279 AMREX_FORCE_INLINE
280 amrex::Real
281 Compute_h_zeta_AtIface (const int &i, const int &j, const int &k,
282  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
283  const amrex::Array4<const amrex::Real>& z_nd)
284 {
285  amrex::Real met_h_zeta = myhalf * cellSizeInv[2] * ( (z_nd(i,j ,k+1) - z_nd(i,j ,k))
286  + (z_nd(i,j+1,k+1) - z_nd(i,j+1,k)) );
287  return met_h_zeta;
288 }
289 
290 // Metric coincides with U location
291 /**
292  * Compute the xi metric term at the i-face.
293  *
294  * @param[in] i x-index
295  * @param[in] j y-index
296  * @param[in] k z-index
297  * @param[in] cellSizeInv Inverse cell spacing.
298  * @param[in] z_nd Nodal physical height field.
299  * @return Xi metric term.
300  */
301 AMREX_GPU_HOST_DEVICE
302 AMREX_FORCE_INLINE
303 amrex::Real
304 Compute_h_xi_AtIface (const int &i, const int &j, const int &k,
305  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
306  const amrex::Array4<const amrex::Real>& z_nd)
307 {
308  amrex::Real met_h_xi = amrex::Real(0.125) * cellSizeInv[0] * (
309  (z_nd(i+1,j ,k ) - z_nd(i-1,j ,k )) + (z_nd(i+1,j ,k+1) - z_nd(i-1,j ,k+1)) +
310  (z_nd(i+1,j+1,k ) - z_nd(i-1,j+1,k )) + (z_nd(i+1,j+1,k+1) - z_nd(i-1,j+1,k+1)) );
311  return met_h_xi;
312 }
313 
314 // Metric coincides with U location
315 /**
316  * Compute the eta metric term at the i-face.
317  *
318  * @param[in] i x-index
319  * @param[in] j y-index
320  * @param[in] k z-index
321  * @param[in] cellSizeInv Inverse cell spacing.
322  * @param[in] z_nd Nodal physical height field.
323  * @return Eta metric term.
324  */
325 AMREX_GPU_DEVICE
326 AMREX_FORCE_INLINE
327 amrex::Real
328 Compute_h_eta_AtIface (const int &i, const int &j, const int &k,
329  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
330  const amrex::Array4<const amrex::Real>& z_nd)
331 {
332  amrex::Real met_h_eta = myhalf * cellSizeInv[1] * ( (z_nd(i,j+1,k ) - z_nd(i,j,k ))
333  + (z_nd(i,j+1,k+1) - z_nd(i,j,k+1)) );
334  return met_h_eta;
335 }
336 
337 // Metric coincides with V location
338 /**
339  * Compute the zeta metric term at the j-face.
340  *
341  * @param[in] i x-index
342  * @param[in] j y-index
343  * @param[in] k z-index
344  * @param[in] cellSizeInv Inverse cell spacing.
345  * @param[in] z_nd Nodal physical height field.
346  * @return Zeta metric term.
347  */
348 AMREX_GPU_DEVICE
349 AMREX_FORCE_INLINE
350 amrex::Real
351 Compute_h_zeta_AtJface (const int &i, const int &j, const int &k,
352  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
353  const amrex::Array4<const amrex::Real>& z_nd)
354 {
355  amrex::Real met_h_zeta = myhalf * cellSizeInv[2] * ( (z_nd(i ,j,k+1) - z_nd(i ,j,k ))
356  + (z_nd(i+1,j,k+1) - z_nd(i+1,j,k )) );
357  return met_h_zeta;
358 }
359 
360 // Metric coincides with V location
361 /**
362  * Compute the xi metric term at the j-face.
363  *
364  * @param[in] i x-index
365  * @param[in] j y-index
366  * @param[in] k z-index
367  * @param[in] cellSizeInv Inverse cell spacing.
368  * @param[in] z_nd Nodal physical height field.
369  * @return Xi metric term.
370  */
371 AMREX_GPU_DEVICE
372 AMREX_FORCE_INLINE
373 amrex::Real
374 Compute_h_xi_AtJface (const int &i, const int &j, const int &k,
375  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
376  const amrex::Array4<const amrex::Real>& z_nd)
377 {
378  amrex::Real met_h_xi = myhalf * cellSizeInv[0] * ( (z_nd(i+1,j,k ) - z_nd(i,j,k ))
379  + (z_nd(i+1,j,k+1) - z_nd(i,j,k+1)) );
380  return met_h_xi;
381 }
382 
383 // Metric coincides with V location
384 /**
385  * Compute the eta metric term at the j-face.
386  *
387  * @param[in] i x-index
388  * @param[in] j y-index
389  * @param[in] k z-index
390  * @param[in] cellSizeInv Inverse cell spacing.
391  * @param[in] z_nd Nodal physical height field.
392  * @return Eta metric term.
393  */
394 AMREX_GPU_HOST_DEVICE
395 AMREX_FORCE_INLINE
396 amrex::Real
397 Compute_h_eta_AtJface (const int &i, const int &j, const int &k,
398  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
399  const amrex::Array4<const amrex::Real>& z_nd)
400 {
401  amrex::Real met_h_eta = amrex::Real(0.125) * cellSizeInv[1] *
402  ( (z_nd(i ,j+1,k ) - z_nd(i ,j-1,k )) + (z_nd(i ,j+1,k+1) - z_nd(i ,j-1,k+1)) +
403  (z_nd(i+1,j+1,k ) - z_nd(i+1,j-1,k )) + (z_nd(i+1,j+1,k+1) - z_nd(i+1,j-1,k+1)) );
404  return met_h_eta;
405 }
406 
407 // Metric coincides with K location
408 /**
409  * Compute the zeta metric term at the k-face.
410  *
411  * @param[in] i x-index
412  * @param[in] j y-index
413  * @param[in] k z-index
414  * @param[in] cellSizeInv Inverse cell spacing.
415  * @param[in] z_nd Nodal physical height field.
416  * @return Zeta metric term.
417  */
418 AMREX_GPU_HOST_DEVICE
419 AMREX_FORCE_INLINE
420 amrex::Real
421 Compute_h_zeta_AtKface (const int &i, const int &j, const int &k,
422  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
423  const amrex::Array4<const amrex::Real>& z_nd)
424 {
425  amrex::Real met_h_zeta = amrex::Real(0.125) * cellSizeInv[2] *
426  ( (z_nd(i ,j ,k+1) - z_nd(i ,j ,k-1)) + (z_nd(i+1,j ,k+1) - z_nd(i+1,j ,k-1)) +
427  (z_nd(i ,j+1,k+1) - z_nd(i ,j+1,k-1)) + (z_nd(i+1,j+1,k+1) - z_nd(i+1,j+1,k-1)) );
428  return met_h_zeta;
429 }
430 
431 // Metric coincides with K location
432 /**
433  * Compute the xi metric term at the k-face.
434  *
435  * @param[in] i x-index
436  * @param[in] j y-index
437  * @param[in] k z-index
438  * @param[in] cellSizeInv Inverse cell spacing.
439  * @param[in] z_nd Nodal physical height field.
440  * @return Xi metric term.
441  */
442 AMREX_GPU_HOST_DEVICE
443 AMREX_FORCE_INLINE
444 amrex::Real
445 Compute_h_xi_AtKface (const int &i, const int &j, const int &k,
446  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
447  const amrex::Array4<const amrex::Real>& z_nd)
448 {
449  amrex::Real met_h_xi = myhalf * cellSizeInv[0] * ( (z_nd(i+1,j ,k) - z_nd(i,j ,k))
450  + (z_nd(i+1,j+1,k) - z_nd(i,j+1,k)) );
451  return met_h_xi;
452 }
453 
454 // Metric coincides with K location
455 /**
456  * Compute the eta metric term at the k-face.
457  *
458  * @param[in] i x-index
459  * @param[in] j y-index
460  * @param[in] k z-index
461  * @param[in] cellSizeInv Inverse cell spacing.
462  * @param[in] z_nd Nodal physical height field.
463  * @return Eta metric term.
464  */
465 AMREX_GPU_HOST_DEVICE
466 AMREX_FORCE_INLINE
467 amrex::Real
468 Compute_h_eta_AtKface (const int &i, const int &j, const int &k,
469  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
470  const amrex::Array4<const amrex::Real>& z_nd)
471 {
472  amrex::Real met_h_eta = myhalf * cellSizeInv[1] * ( (z_nd(i ,j+1,k) - z_nd(i ,j,k))
473  + (z_nd(i+1,j+1,k) - z_nd(i+1,j,k)) );
474  return met_h_eta;
475 }
476 
477 
478 //*****************************************************************************************
479 // Compute terrain metric terms at edge-centers
480 //*****************************************************************************************
481 // -- EdgeCenterK --
482 
483 // Metric is at edge and center Z (red pentagon)
484 /**
485  * Compute the zeta metric term at the k-edge center.
486  *
487  * @param[in] i x-index
488  * @param[in] j y-index
489  * @param[in] k z-index
490  * @param[in] cellSizeInv Inverse cell spacing.
491  * @param[in] z_nd Nodal physical height field.
492  * @return Zeta metric term.
493  */
494 AMREX_GPU_DEVICE
495 AMREX_FORCE_INLINE
496 amrex::Real
497 Compute_h_zeta_AtEdgeCenterK (const int &i, const int &j, const int &k,
498  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
499  const amrex::Array4<const amrex::Real>& z_nd)
500 {
501  amrex::Real dzInv = cellSizeInv[2];
502  amrex::Real met_h_zeta = dzInv * (z_nd(i,j,k+1) - z_nd(i,j,k));
503  return met_h_zeta;
504 }
505 
506 // Metric is at edge and center Z (red pentagon)
507 /**
508  * Compute the xi metric term at the k-edge center.
509  *
510  * @param[in] i x-index
511  * @param[in] j y-index
512  * @param[in] k z-index
513  * @param[in] cellSizeInv Inverse cell spacing.
514  * @param[in] z_nd Nodal physical height field.
515  * @return Xi metric term.
516  */
517 AMREX_GPU_DEVICE
518 AMREX_FORCE_INLINE
519 amrex::Real
520 Compute_h_xi_AtEdgeCenterK (const int &i, const int &j, const int &k,
521  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
522  const amrex::Array4<const amrex::Real>& z_nd)
523 {
524  amrex::Real dxInv = cellSizeInv[0];
525  amrex::Real met_h_xi = fourth * dxInv *
526  ( z_nd(i+1,j,k) + z_nd(i+1,j,k+1)
527  - z_nd(i-1,j,k) - z_nd(i-1,j,k+1) );
528  return met_h_xi;
529 }
530 
531 // Metric is at edge and center Z (red pentagon)
532 /**
533  * Compute the eta metric term at the k-edge center.
534  *
535  * @param[in] i x-index
536  * @param[in] j y-index
537  * @param[in] k z-index
538  * @param[in] cellSizeInv Inverse cell spacing.
539  * @param[in] z_nd Nodal physical height field.
540  * @return Eta metric term.
541  */
542 AMREX_GPU_DEVICE
543 AMREX_FORCE_INLINE
544 amrex::Real
545 Compute_h_eta_AtEdgeCenterK (const int &i, const int &j, const int &k,
546  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
547  const amrex::Array4<const amrex::Real>& z_nd)
548 {
549  amrex::Real dyInv = cellSizeInv[1];
550  amrex::Real met_h_eta = fourth * dyInv *
551  ( z_nd(i,j+1,k) + z_nd(i,j+1,k+1)
552  - z_nd(i,j-1,k) - z_nd(i,j-1,k+1) );
553  return met_h_eta;
554 }
555 
556 // -- EdgeCenterJ --
557 
558 // Metric is at edge and center Y (magenta cross)
559 /**
560  * Compute the zeta metric term at the j-edge center.
561  *
562  * @param[in] i x-index
563  * @param[in] j y-index
564  * @param[in] k z-index
565  * @param[in] cellSizeInv Inverse cell spacing.
566  * @param[in] z_nd Nodal physical height field.
567  * @return Zeta metric term.
568  */
569 AMREX_GPU_DEVICE
570 AMREX_FORCE_INLINE
571 amrex::Real
572 Compute_h_zeta_AtEdgeCenterJ (const int &i, const int &j, const int &k,
573  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
574  const amrex::Array4<const amrex::Real>& z_nd)
575 {
576  amrex::Real dzInv = cellSizeInv[2];
577  amrex::Real met_h_zeta = fourth * dzInv * ( z_nd(i,j,k+1) + z_nd(i,j+1,k+1)
578  - z_nd(i,j,k-1) - z_nd(i,j+1,k-1) );
579  return met_h_zeta;
580 }
581 
582 // Metric is at edge and center Y (magenta cross)
583 /**
584  * Compute the xi metric term at the j-edge center.
585  *
586  * @param[in] i x-index
587  * @param[in] j y-index
588  * @param[in] k z-index
589  * @param[in] cellSizeInv Inverse cell spacing.
590  * @param[in] z_nd Nodal physical height field.
591  * @return Xi metric term.
592  */
593 AMREX_GPU_DEVICE
594 AMREX_FORCE_INLINE
595 amrex::Real
596 Compute_h_xi_AtEdgeCenterJ (const int &i, const int &j, const int &k,
597  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
598  const amrex::Array4<const amrex::Real>& z_nd)
599 {
600  amrex::Real dxInv = cellSizeInv[0];
601  amrex::Real met_h_xi = fourth * dxInv *
602  ( z_nd(i+1,j+1,k) + z_nd(i+1,j ,k)
603  - z_nd(i-1,j+1,k) - z_nd(i-1,j ,k) );
604  return met_h_xi;
605 }
606 
607 // Metric is at edge and center Y (magenta cross)
608 /**
609  * Compute the eta metric term at the j-edge center.
610  *
611  * @param[in] i x-index
612  * @param[in] j y-index
613  * @param[in] k z-index
614  * @param[in] cellSizeInv Inverse cell spacing.
615  * @param[in] z_nd Nodal physical height field.
616  * @return Eta metric term.
617  */
618 AMREX_GPU_DEVICE
619 AMREX_FORCE_INLINE
620 amrex::Real
621 Compute_h_eta_AtEdgeCenterJ (const int &i, const int &j, const int &k,
622  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
623  const amrex::Array4<const amrex::Real>& z_nd)
624 {
625  amrex::Real dyInv = cellSizeInv[1];
626  amrex::Real met_h_eta = dyInv * ( z_nd(i,j+1,k) - z_nd(i,j,k) );
627  return met_h_eta;
628 }
629 
630 // -- EdgeCenterI --
631 
632 // Metric is at edge and center X (purple hexagon)
633 /**
634  * Compute the zeta metric term at the i-edge center.
635  *
636  * @param[in] i x-index
637  * @param[in] j y-index
638  * @param[in] k z-index
639  * @param[in] cellSizeInv Inverse cell spacing.
640  * @param[in] z_nd Nodal physical height field.
641  * @return Zeta metric term.
642  */
643 AMREX_GPU_DEVICE
644 AMREX_FORCE_INLINE
645 amrex::Real
646 Compute_h_zeta_AtEdgeCenterI (const int &i, const int &j, const int &k,
647  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
648  const amrex::Array4<const amrex::Real>& z_nd)
649 {
650  amrex::Real dzInv = cellSizeInv[2];
651  amrex::Real met_h_zeta = fourth * dzInv * ( z_nd(i,j,k+1) + z_nd(i+1,j,k+1)
652  - z_nd(i,j,k-1) - z_nd(i+1,j,k-1) );
653  return met_h_zeta;
654 }
655 
656 // Metric is at edge and center X (purple hexagon)
657 /**
658  * Compute the xi metric term at the i-edge center.
659  *
660  * @param[in] i x-index
661  * @param[in] j y-index
662  * @param[in] k z-index
663  * @param[in] cellSizeInv Inverse cell spacing.
664  * @param[in] z_nd Nodal physical height field.
665  * @return Xi metric term.
666  */
667 AMREX_GPU_DEVICE
668 AMREX_FORCE_INLINE
669 amrex::Real
670 Compute_h_xi_AtEdgeCenterI (const int &i, const int &j, const int &k,
671  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
672  const amrex::Array4<const amrex::Real>& z_nd)
673 {
674  amrex::Real dxInv = cellSizeInv[0];
675  amrex::Real met_h_xi = dxInv * ( z_nd(i+1,j,k) - z_nd(i,j,k) );
676  return met_h_xi;
677 }
678 
679 // Metric is at edge and center X (purple hexagon)
680 /**
681  * Compute the eta metric term at the i-edge center.
682  *
683  * @param[in] i x-index
684  * @param[in] j y-index
685  * @param[in] k z-index
686  * @param[in] cellSizeInv Inverse cell spacing.
687  * @param[in] z_nd Nodal physical height field.
688  * @return Eta metric term.
689  */
690 AMREX_GPU_DEVICE
691 AMREX_FORCE_INLINE
692 amrex::Real
693 Compute_h_eta_AtEdgeCenterI (const int &i, const int &j, const int &k,
694  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
695  const amrex::Array4<const amrex::Real>& z_nd)
696 {
697  amrex::Real dyInv = cellSizeInv[1];
698  amrex::Real met_h_eta = fourth * dyInv *
699  ( z_nd(i+1,j+1,k) + z_nd(i,j+1,k)
700  - z_nd(i+1,j-1,k) - z_nd(i,j-1,k) );
701  return met_h_eta;
702 }
703 
704 // Relative height above terrain surface at cell center from z_nd (nodal absolute height)
705 /**
706  * Compute the physical height at the cell center.
707  *
708  * @param[in] i x-index
709  * @param[in] j y-index
710  * @param[in] k z-index
711  * @param[in] z_nd Nodal physical height field.
712  * @return Physical height at cell center.
713  */
714 AMREX_GPU_DEVICE
715 AMREX_FORCE_INLINE
716 amrex::Real
717 Compute_Z_AtCellCenter (const int &i, const int &j, const int &k,
718  const amrex::Array4<const amrex::Real>& z_nd)
719 {
720  const amrex::Real z_cc = amrex::Real(0.125)*( z_nd(i ,j ,k) + z_nd(i ,j ,k+1)
721  + z_nd(i+1,j ,k) + z_nd(i+1,j ,k+1)
722  + z_nd(i ,j+1,k) + z_nd(i ,j+1,k+1)
723  + z_nd(i+1,j+1,k) + z_nd(i+1,j+1,k+1));
724 
725  return z_cc;
726 }
727 
728 // Relative height above terrain surface at cell center from z_nd (nodal absolute height)
729 /**
730  * Compute the physical height at the W-face.
731  *
732  * @param[in] i x-index
733  * @param[in] j y-index
734  * @param[in] k z-index
735  * @param[in] z_nd Nodal physical height field.
736  * @return Physical height at W-face.
737  */
738 AMREX_GPU_HOST_DEVICE
739 AMREX_FORCE_INLINE
740 amrex::Real
741 Compute_Z_AtWFace (const int &i, const int &j, const int &k,
742  const amrex::Array4<const amrex::Real>& z_nd)
743 {
744  const amrex::Real z_wf = fourth*( z_nd(i ,j ,k) + z_nd(i+1,j ,k)
745  + z_nd(i ,j+1,k) + z_nd(i+1,j+1,k) );
746 
747  return z_wf;
748 }
749 
750 // Relative height above terrain surface at cell center from z_nd (nodal absolute height)
751 /**
752  * Compute the relative height above the terrain surface at the cell center.
753  *
754  * @param[in] i x-index
755  * @param[in] j y-index
756  * @param[in] k z-index
757  * @param[in] z_sfc_nd Nodal physical height field of the surface.
758  * @param[in] z_nd Nodal physical height field.
759  * @return Relative height at cell center.
760  */
761 AMREX_GPU_HOST_DEVICE
762 AMREX_FORCE_INLINE
763 amrex::Real
764 Compute_Zrel_AtCellCenter (const int &i, const int &j, const int &k,
765  const amrex::Array4<const amrex::Real>& z_sfc_nd,
766  const amrex::Array4<const amrex::Real>& z_nd)
767 {
768  const amrex::Real z_cc = amrex::Real(0.125)*( z_nd(i ,j ,k) + z_nd(i ,j ,k+1) +
769  + z_nd(i+1,j ,k) + z_nd(i+1,j ,k+1)
770  + z_nd(i ,j+1,k) + z_nd(i ,j+1,k+1)
771  + z_nd(i+1,j+1,k) + z_nd(i+1,j+1,k+1));
772  const amrex::Real z0_wf = fourth*( z_sfc_nd(i ,j ,0) + z_sfc_nd(i ,j+1,0)
773  + z_sfc_nd(i+1,j ,0) + z_sfc_nd(i+1,j+1,0));
774 
775  return (z_cc - z0_wf);
776 }
777 
778 
779 //*****************************************************************************************
780 // Contravariant velocity computation
781 //*****************************************************************************************
782 
783 // Define omega given u,v and w (4th order)
784 /**
785  * Compute the contravariant vertical velocity omega from w.
786  *
787  * @param[in] i x-index
788  * @param[in] j y-index
789  * @param[in] k z-index
790  * @param[in] w Vertical velocity.
791  * @param[in] u_arr X-velocity array.
792  * @param[in] v_arr Y-velocity array.
793  * @param[in] mf_ux Map factor m_x at x-faces (u points).
794  * @param[in] mf_vy Map factor m_y at y-faces (v points).
795  * @param[in] z_nd Nodal physical height field.
796  * @param[in] dxInv Inverse cell spacing.
797  * @return Contravariant vertical velocity.
798  */
799 AMREX_GPU_DEVICE
800 AMREX_FORCE_INLINE
801 amrex::Real
802 OmegaFromW (int& i, int& j, int& k, amrex::Real w,
803  const amrex::Array4<const amrex::Real>& u_arr,
804  const amrex::Array4<const amrex::Real>& v_arr,
805  const amrex::Array4<const amrex::Real>& mf_ux,
806  const amrex::Array4<const amrex::Real>& mf_vy,
807  const amrex::Array4<const amrex::Real>& z_nd,
808  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv)
809 {
810  // This is dh/dxi at hi and lo edges
811  amrex::Real z_x_p2 = Compute_Z_AtWFace(i+2,j,k,z_nd);
812  amrex::Real z_x_p1 = Compute_Z_AtWFace(i+1,j,k,z_nd);
813  amrex::Real z_x_m1 = Compute_Z_AtWFace(i-1,j,k,z_nd);
814  amrex::Real z_x_m2 = Compute_Z_AtWFace(i-2,j,k,z_nd);
815  amrex::Real met_xi = (amrex::Real(1.0/amrex::Real(12.0))*(z_x_m2 - z_x_p2)
816  + amrex::Real(8.0/amrex::Real(12.0))*(z_x_p1 - z_x_m1)) * dxInv[0];
817 
818  // This is dh/deta at hi and lo edges
819  amrex::Real z_y_p2 = Compute_Z_AtWFace(i,j+2,k,z_nd);
820  amrex::Real z_y_p1 = Compute_Z_AtWFace(i,j+1,k,z_nd);
821  amrex::Real z_y_m1 = Compute_Z_AtWFace(i,j-1,k,z_nd);
822  amrex::Real z_y_m2 = Compute_Z_AtWFace(i,j-2,k,z_nd);
823  amrex::Real met_eta = (amrex::Real(1.0/amrex::Real(12.0))*(z_y_m2 - z_y_p2)
824  + amrex::Real(8.0/amrex::Real(12.0))*(z_y_p1 - z_y_m1)) * dxInv[1];
825 
826  // Use extrapolation instead of interpolation if at the bottom boundary
827  amrex::Real u_hi = (k == 0) ? amrex::Real(1.5) * u_arr(i+1,j ,k ) - myhalf * u_arr(i+1,j ,k+1) :
828  myhalf * ( u_arr(i+1,j ,k-1) + u_arr(i+1,j ,k ) );
829  amrex::Real u_lo = (k == 0) ? amrex::Real(1.5) * u_arr(i ,j ,k ) - myhalf * u_arr(i ,j ,k+1) :
830  myhalf * ( u_arr(i ,j ,k-1) + u_arr(i ,j ,k ) );
831  amrex::Real mf_ux_hi = mf_ux(i+1,j,0);
832  amrex::Real mf_ux_lo = mf_ux(i ,j,0);
833 
834  amrex::Real v_hi = (k == 0) ? amrex::Real(1.5) * v_arr(i ,j+1,k ) - myhalf * v_arr(i ,j+1,k+1) :
835  myhalf * ( v_arr(i ,j+1,k-1) + v_arr(i ,j+1,k ) );
836  amrex::Real v_lo = (k == 0) ? amrex::Real(1.5) * v_arr(i ,j ,k ) - myhalf * v_arr(i ,j ,k+1) :
837  myhalf * ( v_arr(i ,j ,k-1) + v_arr(i ,j ,k ) );
838  amrex::Real mf_vy_hi = mf_vy(i,j+1,0);
839  amrex::Real mf_vy_lo = mf_vy(i,j ,0);
840 
841  amrex::Real u_met = met_xi * myhalf * ( u_hi*mf_ux_hi + u_lo*mf_ux_lo );
842  amrex::Real v_met = met_eta * myhalf * ( v_hi*mf_vy_hi + v_lo*mf_vy_lo );
843 
844  amrex::Real omega = w - u_met - v_met;
845  return omega;
846 }
847 
848 // Define w given u and v arrays and scalar omega (4th order)
849 /**
850  * Compute the vertical velocity w from the contravariant omega.
851  *
852  * @param[in] i x-index
853  * @param[in] j y-index
854  * @param[in] k z-index
855  * @param[in] omega Contravariant vertical velocity.
856  * @param[in] u_arr X-velocity array.
857  * @param[in] v_arr Y-velocity array.
858  * @param[in] mf_ux Map factor m_x at x-faces (u points).
859  * @param[in] mf_vy Map factor m_y at y-faces (v points).
860  * @param[in] z_nd Nodal physical height field.
861  * @param[in] dxInv Inverse cell spacing.
862  * @return Vertical velocity w.
863  */
864 AMREX_GPU_DEVICE
865 AMREX_FORCE_INLINE
866 amrex::Real
867 WFromOmega (int& i, int& j, int& k, amrex::Real omega,
868  const amrex::Array4<const amrex::Real>& u_arr,
869  const amrex::Array4<const amrex::Real>& v_arr,
870  const amrex::Array4<const amrex::Real>& mf_ux,
871  const amrex::Array4<const amrex::Real>& mf_vy,
872  const amrex::Array4<const amrex::Real>& z_nd,
873  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv)
874 {
875  // This is dh/dxi at hi and lo edges
876  amrex::Real z_x_p2 = Compute_Z_AtWFace(i+2,j,k,z_nd);
877  amrex::Real z_x_p1 = Compute_Z_AtWFace(i+1,j,k,z_nd);
878  amrex::Real z_x_m1 = Compute_Z_AtWFace(i-1,j,k,z_nd);
879  amrex::Real z_x_m2 = Compute_Z_AtWFace(i-2,j,k,z_nd);
880  amrex::Real met_xi = (amrex::Real(1.0/amrex::Real(12.0))*(z_x_m2 - z_x_p2)
881  + amrex::Real(8.0/amrex::Real(12.0))*(z_x_p1 - z_x_m1)) * dxInv[0];
882 
883  // This is dh/deta at hi and lo edges
884  amrex::Real z_y_p2 = Compute_Z_AtWFace(i,j+2,k,z_nd);
885  amrex::Real z_y_p1 = Compute_Z_AtWFace(i,j+1,k,z_nd);
886  amrex::Real z_y_m1 = Compute_Z_AtWFace(i,j-1,k,z_nd);
887  amrex::Real z_y_m2 = Compute_Z_AtWFace(i,j-2,k,z_nd);
888  amrex::Real met_eta = (amrex::Real(1.0/amrex::Real(12.0))*(z_y_m2 - z_y_p2)
889  + amrex::Real(8.0/amrex::Real(12.0))*(z_y_p1 - z_y_m1)) * dxInv[1];
890 
891  // Use extrapolation instead of interpolation if at the bottom boundary
892  amrex::Real u_hi = (k == 0) ? amrex::Real(1.5) * u_arr(i+1,j ,k ) - myhalf * u_arr(i+1,j ,k+1) :
893  myhalf * ( u_arr(i+1,j ,k-1) + u_arr(i+1,j ,k ) );
894  amrex::Real u_lo = (k == 0) ? amrex::Real(1.5) * u_arr(i ,j ,k ) - myhalf * u_arr(i ,j ,k+1) :
895  myhalf * ( u_arr(i ,j ,k-1) + u_arr(i ,j ,k ) );
896  amrex::Real mf_ux_hi = mf_ux(i+1,j,0);
897  amrex::Real mf_ux_lo = mf_ux(i ,j,0);
898 
899  amrex::Real v_hi = (k == 0) ? amrex::Real(1.5) * v_arr(i ,j+1,k ) - myhalf * v_arr(i ,j+1,k+1) :
900  myhalf * ( v_arr(i ,j+1,k-1) + v_arr(i ,j+1,k ) );
901  amrex::Real v_lo = (k == 0) ? amrex::Real(1.5) * v_arr(i ,j ,k ) - myhalf * v_arr(i ,j ,k+1) :
902  myhalf * ( v_arr(i ,j ,k-1) + v_arr(i ,j ,k ) );
903  amrex::Real mf_vy_hi = mf_vy(i,j+1,0);
904  amrex::Real mf_vy_lo = mf_vy(i,j ,0);
905 
906  amrex::Real u_met = met_xi * myhalf * ( u_hi*mf_ux_hi + u_lo*mf_ux_lo );
907  amrex::Real v_met = met_eta * myhalf * ( v_hi*mf_vy_hi + v_lo*mf_vy_lo );
908 
909  amrex::Real w = omega + u_met + v_met;
910  return w;
911 }
912 
913 //
914 // NOTE: 2nd order kept here for debugging purposes
915 //
916 
917 # if 0
918 // Define omega given u,v and w (2nd order)
919 /**
920  * Compute the contravariant vertical velocity omega from w (2nd order).
921  *
922  * @param[in] i x-index
923  * @param[in] j y-index
924  * @param[in] k z-index
925  * @param[in] w Vertical velocity.
926  * @param[in] u_arr X-velocity array.
927  * @param[in] v_arr Y-velocity array.
928  * @param[in] mf_ux Map factor m_x at x-faces (u points).
929  * @param[in] mf_vy Map factor m_y at y-faces (v points).
930  * @param[in] z_nd Nodal physical height field.
931  * @param[in] dxInv Inverse cell spacing.
932  * @return Contravariant vertical velocity.
933  */
934 AMREX_GPU_DEVICE
935 AMREX_FORCE_INLINE
936 amrex::Real
937 OmegaFromW (int& i, int& j, int& k, amrex::Real w,
938  const amrex::Array4<const amrex::Real>& u_arr,
939  const amrex::Array4<const amrex::Real>& v_arr,
940  const amrex::Array4<const amrex::Real>& mf_ux,
941  const amrex::Array4<const amrex::Real>& mf_vy,
942  const amrex::Array4<const amrex::Real>& z_nd,
943  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv)
944 {
945  // This is dh/dxi at hi and lo edges
946  amrex::Real z_x_h = Compute_Z_AtWFace(i+1,j,k,z_nd);
947  amrex::Real z_x_l = Compute_Z_AtWFace(i-1,j,k,z_nd);
948  amrex::Real met_xi = myhalf * (z_x_h - z_x_l) * dxInv[0];
949 
950  // This is dh/deta at hi and lo edges
951  amrex::Real z_y_h = Compute_Z_AtWFace(i,j+1,k,z_nd);
952  amrex::Real z_y_l = Compute_Z_AtWFace(i,j-1,k,z_nd);
953  amrex::Real met_eta = myhalf * (z_y_h - z_y_l) * dxInv[1];
954 
955  // Use extrapolation instead of interpolation if at the bottom boundary
956  amrex::Real u_hi = (k == 0) ? amrex::Real(1.5) * u_arr(i+1,j ,k ) - myhalf * u_arr(i+1,j ,k+1) :
957  myhalf * ( u_arr(i+1,j ,k-1) + u_arr(i+1,j ,k ) );
958  amrex::Real u_lo = (k == 0) ? amrex::Real(1.5) * u_arr(i ,j ,k ) - myhalf * u_arr(i ,j ,k+1) :
959  myhalf * ( u_arr(i ,j ,k-1) + u_arr(i ,j ,k ) );
960  amrex::Real mf_ux_hi = mf_ux(i+1,j,0);
961  amrex::Real mf_ux_lo = mf_ux(i ,j,0);
962 
963  amrex::Real v_hi = (k == 0) ? amrex::Real(1.5) * v_arr(i ,j+1,k ) - myhalf * v_arr(i ,j+1,k+1) :
964  myhalf * ( v_arr(i ,j+1,k-1) + v_arr(i ,j+1,k ) );
965  amrex::Real v_lo = (k == 0) ? amrex::Real(1.5) * v_arr(i ,j ,k ) - myhalf * v_arr(i ,j ,k+1) :
966  myhalf * ( v_arr(i ,j ,k-1) + v_arr(i ,j ,k ) );
967  amrex::Real mf_vy_hi = mf_vy(i,j+1,0);
968  amrex::Real mf_vy_lo = mf_vy(i,j ,0);
969 
970  amrex::Real u_met = met_xi * myhalf * ( u_hi*mf_ux_hi + u_lo*mf_ux_lo );
971  amrex::Real v_met = met_eta * myhalf * ( v_hi*mf_vy_hi + v_lo*mf_vy_lo );
972 
973  amrex::Real omega = w - u_met - v_met;
974  return omega;
975 }
976 
977 // Define w given u and v arrays and scalar omega (2nd order)
978 /**
979  * Compute the vertical velocity w from the contravariant omega (2nd order).
980  *
981  * @param[in] i x-index
982  * @param[in] j y-index
983  * @param[in] k z-index
984  * @param[in] omega Contravariant vertical velocity.
985  * @param[in] u_arr X-velocity array.
986  * @param[in] v_arr Y-velocity array.
987  * @param[in] mf_ux Map factor m_x at x-faces (u points).
988  * @param[in] mf_vy Map factor m_y at y-faces (v points).
989  * @param[in] z_nd Nodal physical height field.
990  * @param[in] dxInv Inverse cell spacing.
991  * @return Vertical velocity w.
992  */
993 AMREX_GPU_DEVICE
994 AMREX_FORCE_INLINE
995 amrex::Real
996 WFromOmega (int& i, int& j, int& k, amrex::Real omega,
997  const amrex::Array4<const amrex::Real>& u_arr,
998  const amrex::Array4<const amrex::Real>& v_arr,
999  const amrex::Array4<const amrex::Real>& mf_ux,
1000  const amrex::Array4<const amrex::Real>& mf_vy,
1001  const amrex::Array4<const amrex::Real>& z_nd,
1002  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv)
1003 {
1004  // This is dh/dxi at hi and lo edges
1005  amrex::Real z_x_h = Compute_Z_AtWFace(i+1,j,k,z_nd);
1006  amrex::Real z_x_l = Compute_Z_AtWFace(i-1,j,k,z_nd);
1007  amrex::Real met_xi = myhalf * (z_x_h - z_x_l) * dxInv[0];
1008 
1009  // This is dh/deta at hi and lo edges
1010  amrex::Real z_y_h = Compute_Z_AtWFace(i,j+1,k,z_nd);
1011  amrex::Real z_y_l = Compute_Z_AtWFace(i,j-1,k,z_nd);
1012  amrex::Real met_eta = myhalf * (z_y_h - z_y_l) * dxInv[1];
1013 
1014  // Use extrapolation instead of interpolation if at the bottom boundary
1015  amrex::Real u_hi = (k == 0) ? amrex::Real(1.5) * u_arr(i+1,j ,k ) - myhalf * u_arr(i+1,j ,k+1) :
1016  myhalf * ( u_arr(i+1,j ,k-1) + u_arr(i+1,j ,k ) );
1017  amrex::Real u_lo = (k == 0) ? amrex::Real(1.5) * u_arr(i ,j ,k ) - myhalf * u_arr(i ,j ,k+1) :
1018  myhalf * ( u_arr(i ,j ,k-1) + u_arr(i ,j ,k ) );
1019  amrex::Real mf_ux_hi = mf_ux(i+1,j,0);
1020  amrex::Real mf_ux_lo = mf_ux(i ,j,0);
1021 
1022  amrex::Real v_hi = (k == 0) ? amrex::Real(1.5) * v_arr(i ,j+1,k ) - myhalf * v_arr(i ,j+1,k+1) :
1023  myhalf * ( v_arr(i ,j+1,k-1) + v_arr(i ,j+1,k ) );
1024  amrex::Real v_lo = (k == 0) ? amrex::Real(1.5) * v_arr(i ,j ,k ) - myhalf * v_arr(i ,j ,k+1) :
1025  myhalf * ( v_arr(i ,j ,k-1) + v_arr(i ,j ,k ) );
1026  amrex::Real mf_vy_hi = mf_vy(i,j+1,0);
1027  amrex::Real mf_vy_lo = mf_vy(i,j ,0);
1028 
1029  amrex::Real u_met = met_xi * myhalf * ( u_hi*mf_ux_hi + u_lo*mf_ux_lo );
1030  amrex::Real v_met = met_eta * myhalf * ( v_hi*mf_vy_hi + v_lo*mf_vy_lo );
1031 
1032  amrex::Real w = omega + u_met + v_met;
1033  return w;
1034 }
1035 #endif
1036 
1037 
1038 //*****************************************************************************************
1039 // Rotate scalar flux vector and stress tensor for MOST
1040 //*****************************************************************************************
1041 /**
1042  * Rotate a scalar flux vector into terrain-following coordinates.
1043  *
1044  * @param[in] i x-index
1045  * @param[in] j y-index
1046  * @param[in] klo z-index
1047  * @param[in] flux Scalar flux value.
1048  * @param[in] dxInv Inverse cell spacing.
1049  * @param[in] zphys_arr Physical height field.
1050  * @param[out] phi1_arr Rotated flux component 1.
1051  * @param[out] phi2_arr Rotated flux component 2.
1052  * @param[out] phi3_arr Rotated flux component 3.
1053  */
1054 AMREX_GPU_DEVICE
1055 AMREX_FORCE_INLINE
1056 void
1057 rotate_scalar_flux (const int& i,
1058  const int& j,
1059  const int& klo,
1060  const int& /*dir*/,
1061  const amrex::Real& flux,
1062  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv,
1063  const amrex::Array4<const amrex::Real>& zphys_arr,
1064  const amrex::Array4<amrex::Real>& phi1_arr,
1065  const amrex::Array4<amrex::Real>& phi2_arr,
1066  const amrex::Array4<amrex::Real>& phi3_arr)
1067 {
1068  amrex::Real h_xi = Compute_h_xi_AtCellCenter(i, j, klo, dxInv, zphys_arr);
1069  amrex::Real h_eta = Compute_h_eta_AtCellCenter(i, j, klo, dxInv, zphys_arr);
1070  amrex::Real InvNorm = one / std::sqrt(one + h_xi*h_xi + h_eta*h_eta);
1071  phi1_arr(i,j,klo) = -h_xi * flux * InvNorm;
1072  phi2_arr(i,j,klo) = -h_eta * flux * InvNorm;
1073  phi3_arr(i,j,klo) = flux * InvNorm;
1074 }
1075 
1076 /**
1077  * Rotate the stress tensor for the MOST model.
1078  *
1079  * @param[in] i x-index
1080  * @param[in] j y-index
1081  * @param[in] klo z-index
1082  * @param[in] flux Flux value used for rotation.
1083  * @param[in] dxInv Inverse cell spacing.
1084  * @param[in] zphys_arr Physical height field.
1085  * @param[in] u_arr X-velocity array.
1086  * @param[in] v_arr Y-velocity array.
1087  * @param[in] w_arr Z-velocity array.
1088  * @param[out] tau11_arr Stress component tau11.
1089  * @param[out] tau22_arr Stress component tau22.
1090  * @param[out] tau33_arr Stress component tau33.
1091  * @param[out] tau12_arr Stress component tau12.
1092  * @param[out] tau21_arr Stress component tau21.
1093  * @param[out] tau13_arr Stress component tau13.
1094  * @param[out] tau31_arr Stress component tau31.
1095  * @param[out] tau23_arr Stress component tau23.
1096  * @param[out] tau32_arr Stress component tau32.
1097  */
1098 AMREX_GPU_DEVICE
1099 AMREX_FORCE_INLINE
1100 void
1101 rotate_stress_tensor (const int& i,
1102  const int& j,
1103  const int& klo,
1104  const int& /*dir*/,
1105  const amrex::Real& flux,
1106  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv,
1107  const amrex::Array4<const amrex::Real>& zphys_arr,
1108  const amrex::Array4<const amrex::Real>& u_arr,
1109  const amrex::Array4<const amrex::Real>& v_arr,
1110  const amrex::Array4<const amrex::Real>& w_arr,
1111  const amrex::Array4<amrex::Real>& /*tau11_arr*/,
1112  const amrex::Array4<amrex::Real>& /*tau22_arr*/,
1113  const amrex::Array4<amrex::Real>& /*tau33_arr*/,
1114  const amrex::Array4<amrex::Real>& /*tau12_arr*/,
1115  const amrex::Array4<amrex::Real>& /*tau21_arr*/,
1116  const amrex::Array4<amrex::Real>& tau13_arr,
1117  const amrex::Array4<amrex::Real>& tau31_arr,
1118  const amrex::Array4<amrex::Real>& tau23_arr,
1119  const amrex::Array4<amrex::Real>& tau32_arr)
1120 {
1121  // Unit-normal vector
1122  amrex::Array1D<amrex::Real,0,2> n_hat;
1123 
1124  // Unit-tangent vectors
1125  amrex::Array1D<amrex::Real,0,2> u_t_hat;
1126 
1127  // Final basis vector for right-hand coord sys
1128  amrex::Array1D<amrex::Real,0,2> a_hat;
1129 
1130  // Rotation matrix
1131  amrex::Array2D<amrex::Real,0,2,0,2> R_mat;
1132 
1133  // Metric data
1134  amrex::Real h_xi = Compute_h_xi_AtIface(i, j, klo, dxInv, zphys_arr);
1135  amrex::Real h_eta = Compute_h_eta_AtIface(i, j, klo, dxInv, zphys_arr);
1136  amrex::Real h_zeta = Compute_h_zeta_AtIface(i, j, klo, dxInv, zphys_arr);
1137 
1138  // Populate the inward normal vector
1139  amrex::Real Inormn = one/std::sqrt(one + h_xi*h_xi + h_eta*h_eta);
1140  n_hat(0) = -Inormn*h_xi; n_hat(1) = -Inormn*h_eta; n_hat(2) = Inormn;
1141 
1142  // Populate the u_t vector (u_t = u - (u \cdot n)n)
1143  amrex::Real u = u_arr(i,j,klo);
1144  amrex::Real v = fourth * ( v_arr(i ,j,klo) + v_arr(i ,j+1,klo)
1145  + v_arr(i-1,j,klo) + v_arr(i-1,j+1,klo) );
1146  amrex::Real w = myhalf * ( w_arr(i ,j,klo) + w_arr(i-1,j ,klo) );
1147  amrex::Real u_dot_n = n_hat(0)*u + n_hat(1)*v + n_hat(2)*w;
1148  u_t_hat(0) = u - u_dot_n*n_hat(0);
1149  u_t_hat(1) = v - u_dot_n*n_hat(1);
1150  u_t_hat(2) = w - u_dot_n*n_hat(2);
1151  amrex::Real Norm_u_t = u_t_hat(0)*u_t_hat(0)
1152  + u_t_hat(1)*u_t_hat(1)
1153  + u_t_hat(2)*u_t_hat(2);
1154 
1155  // NOTE: the direction of the tangential velocity is undefined when that
1156  // velocity vanishes (a quiescent surface cell, or flow normal to the
1157  // terrain), so we cannot normalize. Leaving u_t_hat as the zero vector
1158  // is the only rotation-invariant choice, and it is the right limit for
1159  // a quiescent cell since the flux vanishes with the surface wind too.
1160  amrex::Real Inorm_u_t = (Norm_u_t > zero) ? one/std::sqrt(Norm_u_t) : zero;
1161  for (int icol(0); icol<3; ++icol) {
1162  u_t_hat(icol) *= Inorm_u_t;
1163  }
1164 
1165  // Populate the a_hat = n_hat X u_t_hat vector
1166  a_hat(0) = n_hat(1)*u_t_hat(2) - n_hat(2)*u_t_hat(1);
1167  a_hat(1) = -(n_hat(0)*u_t_hat(2) - n_hat(2)*u_t_hat(0));
1168  a_hat(2) = n_hat(0)*u_t_hat(1) - n_hat(1)*u_t_hat(0);
1169 
1170  // Copy column vectors into R_mat
1171  // NOTE: basis vectors form rows of R_mat
1172  int icol = 0;
1173  for (int jrow(0); jrow<3; ++jrow) {
1174  R_mat(icol,jrow) = u_t_hat(jrow);
1175  }
1176  icol = 1;
1177  for (int jrow(0); jrow<3; ++jrow) {
1178  R_mat(icol,jrow) = a_hat(jrow);
1179  }
1180  icol = 2;
1181  for (int jrow(0); jrow<3; ++jrow) {
1182  R_mat(icol,jrow) = n_hat(jrow);
1183  }
1184 
1185  // Body-fixed stresses
1186  amrex::Real T11 = two*R_mat(0,0)*R_mat(2,0)*flux;
1187  amrex::Real T22 = two*R_mat(0,1)*R_mat(2,1)*flux;
1188  //amrex::Real T33 = two*R_mat(0,2)*R_mat(2,2)*flux;
1189  amrex::Real T12 = (R_mat(0,0)*R_mat(2,1) + R_mat(2,0)*R_mat(0,1))*flux;
1190  amrex::Real T13 = (R_mat(0,0)*R_mat(2,2) + R_mat(0,2)*R_mat(2,0))*flux;
1191  amrex::Real T23 = (R_mat(0,2)*R_mat(2,1) + R_mat(0,1)*R_mat(2,2))*flux;
1192 
1193  // Populate the stress tensor (apply JT)
1194  // NOTE: We cannot set the stresses that do not live at the
1195  // bottom face --- e.g., tau11/22/33/12/21.
1196  tau13_arr(i,j,klo) = -h_xi*T11 - h_eta*T12 + T13;
1197  tau31_arr(i,j,klo) = h_zeta*T13;
1198 
1199  tau23_arr(i,j,klo) = -h_xi*T12 - h_eta*T22 + T23;
1200  tau32_arr(i,j,klo) = h_zeta*T23;
1201 }
1202 #endif
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:16
const int klo
Definition: ERF_InitCustomPert_KE.H:9
Dimensionless numeric literals and pure mathematical constants.
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:38
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:42
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtEdgeCenterJ(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:621
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtEdgeCenterK(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:520
void init_zlevels(amrex::Vector< amrex::Vector< amrex::Real >> &zlevels_stag, amrex::Vector< amrex::Vector< amrex::Real >> &stretched_dz_h, amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real >> &stretched_dz_d, amrex::Vector< amrex::Geometry > const &geom, amrex::Vector< amrex::IntVect > const &ref_ratio, const amrex::Real grid_stretching_ratio, const amrex::Real dz0)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtKface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:445
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtEdgeCenterJ(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:596
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtJface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:397
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtEdgeCenterJ(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:572
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void rotate_scalar_flux(const int &i, const int &j, const int &klo, const int &, const amrex::Real &flux, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &zphys_arr, const amrex::Array4< amrex::Real > &phi1_arr, const amrex::Array4< amrex::Real > &phi2_arr, const amrex::Array4< amrex::Real > &phi3_arr)
Definition: ERF_TerrainMetrics.H:1057
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtEdgeCenterK(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:497
void make_terrain_fitted_coords(int lev, const amrex::Geometry &geom, amrex::MultiFab &z_phys_nd, amrex::Vector< amrex::Real > const &z_levels_h, amrex::GpuArray< ERF_BC, AMREX_SPACEDIM *2 > &phys_bc_type, FineTerrain fine_terrain=FineTerrain::None, amrex::MultiFab const *z_phys_interp=nullptr, bool moving_mesh=false)
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtEdgeCenterI(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:646
void validate_flat_terrain(int lev, const amrex::MultiFab &z_phys_nd, const amrex::Vector< amrex::Real > &z_levels_h)
FineTerrain
Definition: ERF_TerrainMetrics.H:66
@ Transform
add the fine terrain as a correction that decays with height
@ None
caller has not prepared a fine mesh from the coarse level
@ Interpolate
use the coordinates interpolated from the coarse level as-is
void validate_flat_top(int lev, const amrex::Geometry &geom, const amrex::MultiFab &z_phys_nd)
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_Z_AtCellCenter(const int &i, const int &j, const int &k, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:717
FineTerrain which_fine_terrain()
Definition: ERF_TerrainMetrics.cpp:546
void init_which_terrain_grid(int lev, const amrex::Geometry &geom, amrex::MultiFab &z_phys_nd, amrex::Vector< amrex::Real > const &z_levels_h, FineTerrain fine_terrain=FineTerrain::None, amrex::MultiFab const *z_phys_interp=nullptr)
amrex::BoxArray join_boxes_stacked_in_z(const amrex::BoxArray &ba)
void init_fine_terrain_grid(int lev, const amrex::Geometry &geom, amrex::MultiFab &z_phys_nd, amrex::Vector< amrex::Real > const &z_levels_h, FineTerrain fine_terrain, amrex::MultiFab const *z_phys_interp)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtCellCenter(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:227
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_Zrel_AtCellCenter(const int &i, const int &j, const int &k, const amrex::Array4< const amrex::Real > &z_sfc_nd, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:764
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real WFromOmega(int &i, int &j, int &k, amrex::Real omega, const amrex::Array4< const amrex::Real > &u_arr, const amrex::Array4< const amrex::Real > &v_arr, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vy, const amrex::Array4< const amrex::Real > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv)
Definition: ERF_TerrainMetrics.H:867
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:281
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtKface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:468
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtKface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:421
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtJface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:374
void update_stretched_dz(int lev, amrex::Vector< amrex::Vector< amrex::Real >> const &zlevels_stag, amrex::Vector< amrex::Vector< amrex::Real >> &stretched_dz_h, amrex::Vector< amrex::Gpu::DeviceVector< amrex::Real >> &stretched_dz_d)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_Z_AtWFace(const int &i, const int &j, const int &k, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:741
amrex::Real get_dzmin_terrain(amrex::MultiFab &z_phys_nd)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtCellCenter(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:252
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtEdgeCenterK(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:545
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real OmegaFromW(int &i, int &j, int &k, amrex::Real w, const amrex::Array4< const amrex::Real > &u_arr, const amrex::Array4< const amrex::Real > &v_arr, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vy, const amrex::Array4< const amrex::Real > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv)
Definition: ERF_TerrainMetrics.H:802
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtCellCenter(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:202
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:328
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtEdgeCenterI(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:670
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtJface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:351
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:304
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void rotate_stress_tensor(const int &i, const int &j, const int &klo, const int &, const amrex::Real &flux, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &zphys_arr, const amrex::Array4< const amrex::Real > &u_arr, const amrex::Array4< const amrex::Real > &v_arr, const amrex::Array4< const amrex::Real > &w_arr, const amrex::Array4< amrex::Real > &, const amrex::Array4< amrex::Real > &, const amrex::Array4< amrex::Real > &, const amrex::Array4< amrex::Real > &, const amrex::Array4< amrex::Real > &, const amrex::Array4< amrex::Real > &tau13_arr, const amrex::Array4< amrex::Real > &tau31_arr, const amrex::Array4< amrex::Real > &tau23_arr, const amrex::Array4< amrex::Real > &tau32_arr)
Definition: ERF_TerrainMetrics.H:1101
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtEdgeCenterI(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:693
void init_default_zphys(int lev, const amrex::Geometry &geom, amrex::MultiFab &z_phys_nd, amrex::MultiFab &z_phys_cc, amrex::Real z_offset=zero)
@ omega
Definition: ERF_Morrison.H:57