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 
9 /**
10  * Routine to define default z_phys_nd and z_phys_cc
11  */
12 void
13 init_default_zphys (int lev, const amrex::Geometry& geom,
14  amrex::MultiFab& z_phys_nd, amrex::MultiFab& z_phys_cc);
15 
16 /**
17  * Utility routines for constructing terrain metric terms
18  */
19 
20 // Declare functions for ERF.cpp
21 void
22 init_zlevels (amrex::Vector<amrex::Vector<amrex::Real>>& zlevels_stag,
23  amrex::Vector<amrex::Vector<amrex::Real>>& stretched_dz_h,
24  amrex::Vector<amrex::Gpu::DeviceVector<amrex::Real>>& stretched_dz_d,
25  amrex::Vector<amrex::Geometry> const& geom,
26  amrex::Vector<amrex::IntVect> const& ref_ratio,
27  const amrex::Real grid_stretching_ratio,
28  const amrex::Real zsurf,
29  const amrex::Real dz0);
30 
31 void
32 make_terrain_fitted_coords (int lev, const amrex::Geometry& geom,
33  amrex::MultiFab& z_phys_nd,
34  amrex::Vector<amrex::Real> const& z_levels_h,
35  amrex::GpuArray<ERF_BC, AMREX_SPACEDIM*2>& phys_bc_type);
36 
37 void
38 init_which_terrain_grid (int lev, const amrex::Geometry& geom,
39  amrex::MultiFab& z_phys_nd,
40  amrex::Vector<amrex::Real> const& z_levels_h);
41 
42 // Compute the min dz at cell center with terrain
44 get_dzmin_terrain (amrex::MultiFab& z_phys_nd);
45 
46 //*****************************************************************************************
47 // Compute terrain metric terms at cell-center
48 //*****************************************************************************************
49 // Metric is at cell center
50 AMREX_FORCE_INLINE
51 AMREX_GPU_DEVICE
53 Compute_h_zeta_AtCellCenter (const int &i, const int &j, const int &k,
54  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
55  const amrex::Array4<const amrex::Real>& z_nd)
56 {
57  amrex::Real dzInv = cellSizeInv[2];
58  amrex::Real met_h_zeta = 0.25 * dzInv *
59  ( 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)
60  -z_nd(i+1,j,k ) - z_nd(i+1,j+1,k ) - z_nd(i,j,k ) - z_nd(i,j+1,k ) );
61  return met_h_zeta;
62 }
63 
64 // Metric is at cell center
65 AMREX_GPU_DEVICE
66 AMREX_FORCE_INLINE
68 Compute_h_xi_AtCellCenter (const int &i, const int &j, const int &k,
69  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
70  const amrex::Array4<const amrex::Real>& z_nd)
71 {
72  amrex::Real dxInv = cellSizeInv[0];
73  amrex::Real met_h_xi = 0.25 * dxInv *
74  ( 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)
75  -z_nd(i ,j,k) - z_nd(i ,j+1,k) - z_nd(i ,j,k+1) - z_nd(i ,j+1,k+1) );
76  return met_h_xi;
77 }
78 
79 // Metric is at cell center
80 AMREX_GPU_DEVICE
81 AMREX_FORCE_INLINE
83 Compute_h_eta_AtCellCenter (const int &i, const int &j, const int &k,
84  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
85  const amrex::Array4<const amrex::Real>& z_nd)
86 {
87  amrex::Real dyInv = cellSizeInv[1];
88  amrex::Real met_h_eta = 0.25 * dyInv *
89  ( 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)
90  -z_nd(i,j ,k) - z_nd(i+1,j ,k) - z_nd(i,j ,k+1) - z_nd(i+1,j ,k+1) );
91  return met_h_eta;
92 }
93 
94 
95 //*****************************************************************************************
96 // Compute terrain metric terms at face-centers
97 //*****************************************************************************************
98 // Metric coincides with U location
99 AMREX_GPU_DEVICE
100 AMREX_FORCE_INLINE
102 Compute_h_zeta_AtIface (const int &i, const int &j, const int &k,
103  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
104  const amrex::Array4<const amrex::Real>& z_nd)
105 {
106  amrex::Real met_h_zeta = 0.5 * cellSizeInv[2] * ( (z_nd(i,j ,k+1) - z_nd(i,j ,k))
107  + (z_nd(i,j+1,k+1) - z_nd(i,j+1,k)) );
108  return met_h_zeta;
109 }
110 
111 // Metric coincides with U location
112 AMREX_GPU_DEVICE
113 AMREX_FORCE_INLINE
115 Compute_h_xi_AtIface (const int &i, const int &j, const int &k,
116  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
117  const amrex::Array4<const amrex::Real>& z_nd)
118 {
119  amrex::Real met_h_xi = 0.125 * cellSizeInv[0] * (
120  (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)) +
121  (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)) );
122  return met_h_xi;
123 }
124 
125 // Metric coincides with U location
126 AMREX_GPU_DEVICE
127 AMREX_FORCE_INLINE
129 Compute_h_eta_AtIface (const int &i, const int &j, const int &k,
130  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
131  const amrex::Array4<const amrex::Real>& z_nd)
132 {
133  amrex::Real met_h_eta = 0.5 * cellSizeInv[1] * ( (z_nd(i,j+1,k ) - z_nd(i,j,k ))
134  + (z_nd(i,j+1,k+1) - z_nd(i,j,k+1)) );
135  return met_h_eta;
136 }
137 
138 // Metric coincides with V location
139 AMREX_GPU_DEVICE
140 AMREX_FORCE_INLINE
142 Compute_h_zeta_AtJface (const int &i, const int &j, const int &k,
143  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
144  const amrex::Array4<const amrex::Real>& z_nd)
145 {
146  amrex::Real met_h_zeta = 0.5 * cellSizeInv[2] * ( (z_nd(i ,j,k+1) - z_nd(i ,j,k ))
147  + (z_nd(i+1,j,k+1) - z_nd(i+1,j,k )) );
148  return met_h_zeta;
149 }
150 
151 // Metric coincides with V location
152 AMREX_GPU_DEVICE
153 AMREX_FORCE_INLINE
155 Compute_h_xi_AtJface (const int &i, const int &j, const int &k,
156  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
157  const amrex::Array4<const amrex::Real>& z_nd)
158 {
159  amrex::Real met_h_xi = 0.5 * cellSizeInv[0] * ( (z_nd(i+1,j,k ) - z_nd(i,j,k ))
160  + (z_nd(i+1,j,k+1) - z_nd(i,j,k+1)) );
161  return met_h_xi;
162 }
163 
164 // Metric coincides with V location
165 AMREX_GPU_DEVICE
166 AMREX_FORCE_INLINE
168 Compute_h_eta_AtJface (const int &i, const int &j, const int &k,
169  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
170  const amrex::Array4<const amrex::Real>& z_nd)
171 {
172  amrex::Real met_h_eta = 0.125 * cellSizeInv[1] *
173  ( (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)) +
174  (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)) );
175  return met_h_eta;
176 }
177 
178 // Metric coincides with K location
179 AMREX_GPU_DEVICE
180 AMREX_FORCE_INLINE
182 Compute_h_zeta_AtKface (const int &i, const int &j, const int &k,
183  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
184  const amrex::Array4<const amrex::Real>& z_nd)
185 {
186  amrex::Real met_h_zeta = 0.125 * cellSizeInv[2] *
187  ( (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)) +
188  (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)) );
189  return met_h_zeta;
190 }
191 
192 // Metric coincides with K location
193 AMREX_GPU_DEVICE
194 AMREX_FORCE_INLINE
196 Compute_h_xi_AtKface (const int &i, const int &j, const int &k,
197  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
198  const amrex::Array4<const amrex::Real>& z_nd)
199 {
200  amrex::Real met_h_xi = 0.5 * cellSizeInv[0] * ( (z_nd(i+1,j ,k) - z_nd(i,j ,k))
201  + (z_nd(i+1,j+1,k) - z_nd(i,j+1,k)) );
202  return met_h_xi;
203 }
204 
205 // Metric coincides with K location
206 AMREX_GPU_DEVICE
207 AMREX_FORCE_INLINE
209 Compute_h_eta_AtKface (const int &i, const int &j, const int &k,
210  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
211  const amrex::Array4<const amrex::Real>& z_nd)
212 {
213  amrex::Real met_h_eta = 0.5 * cellSizeInv[1] * ( (z_nd(i ,j+1,k) - z_nd(i ,j,k))
214  + (z_nd(i+1,j+1,k) - z_nd(i+1,j,k)) );
215  return met_h_eta;
216 }
217 
218 
219 //*****************************************************************************************
220 // Compute terrain metric terms at edge-centers
221 //*****************************************************************************************
222 // -- EdgeCenterK --
223 
224 // Metric is at edge and center Z (red pentagon)
225 AMREX_GPU_DEVICE
226 AMREX_FORCE_INLINE
228 Compute_h_zeta_AtEdgeCenterK (const int &i, const int &j, const int &k,
229  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
230  const amrex::Array4<const amrex::Real>& z_nd)
231 {
232  amrex::Real dzInv = cellSizeInv[2];
233  amrex::Real met_h_zeta = dzInv * (z_nd(i,j,k+1) - z_nd(i,j,k));
234  return met_h_zeta;
235 }
236 
237 // Metric is at edge and center Z (red pentagon)
238 AMREX_GPU_DEVICE
239 AMREX_FORCE_INLINE
241 Compute_h_xi_AtEdgeCenterK (const int &i, const int &j, const int &k,
242  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
243  const amrex::Array4<const amrex::Real>& z_nd)
244 {
245  amrex::Real dxInv = cellSizeInv[0];
246  amrex::Real met_h_xi = 0.25 * dxInv *
247  ( z_nd(i+1,j,k) + z_nd(i+1,j,k+1)
248  -z_nd(i-1,j,k) - z_nd(i-1,j,k+1) );
249  return met_h_xi;
250 }
251 
252 // Metric is at edge and center Z (red pentagon)
253 AMREX_GPU_DEVICE
254 AMREX_FORCE_INLINE
256 Compute_h_eta_AtEdgeCenterK (const int &i, const int &j, const int &k,
257  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
258  const amrex::Array4<const amrex::Real>& z_nd)
259 {
260  amrex::Real dyInv = cellSizeInv[1];
261  amrex::Real met_h_eta = 0.25 * dyInv *
262  ( z_nd(i,j+1,k) + z_nd(i,j+1,k+1)
263  -z_nd(i,j-1,k) - z_nd(i,j-1,k+1) );
264  return met_h_eta;
265 }
266 
267 // -- EdgeCenterJ --
268 
269 // Metric is at edge and center Y (magenta cross)
270 AMREX_GPU_DEVICE
271 AMREX_FORCE_INLINE
273 Compute_h_zeta_AtEdgeCenterJ (const int &i, const int &j, const int &k,
274  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
275  const amrex::Array4<const amrex::Real>& z_nd)
276 {
277  amrex::Real dzInv = cellSizeInv[2];
278  amrex::Real met_h_zeta = 0.25 * dzInv * ( z_nd(i,j,k+1) + z_nd(i,j+1,k+1)
279  -z_nd(i,j,k-1) - z_nd(i,j+1,k-1) );
280  return met_h_zeta;
281 }
282 
283 // Metric is at edge and center Y (magenta cross)
284 AMREX_GPU_DEVICE
285 AMREX_FORCE_INLINE
287 Compute_h_xi_AtEdgeCenterJ (const int &i, const int &j, const int &k,
288  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
289  const amrex::Array4<const amrex::Real>& z_nd)
290 {
291  amrex::Real dxInv = cellSizeInv[0];
292  amrex::Real met_h_xi = 0.25 * dxInv *
293  ( z_nd(i+1,j+1,k) + z_nd(i+1,j ,k)
294  -z_nd(i-1,j+1,k) - z_nd(i-1,j ,k) );
295  return met_h_xi;
296 }
297 
298 // Metric is at edge and center Y (magenta cross)
299 AMREX_GPU_DEVICE
300 AMREX_FORCE_INLINE
302 Compute_h_eta_AtEdgeCenterJ (const int &i, const int &j, const int &k,
303  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
304  const amrex::Array4<const amrex::Real>& z_nd)
305 {
306  amrex::Real dyInv = cellSizeInv[1];
307  amrex::Real met_h_eta = dyInv * ( z_nd(i,j+1,k) - z_nd(i,j,k) );
308  return met_h_eta;
309 }
310 
311 // -- EdgeCenterI --
312 
313 // Metric is at edge and center X (purple hexagon)
314 AMREX_GPU_DEVICE
315 AMREX_FORCE_INLINE
317 Compute_h_zeta_AtEdgeCenterI (const int &i, const int &j, const int &k,
318  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
319  const amrex::Array4<const amrex::Real>& z_nd)
320 {
321  amrex::Real dzInv = cellSizeInv[2];
322  amrex::Real met_h_zeta = 0.25 * dzInv * ( z_nd(i,j,k+1) + z_nd(i+1,j,k+1)
323  -z_nd(i,j,k-1) - z_nd(i+1,j,k-1) );
324  return met_h_zeta;
325 }
326 
327 // Metric is at edge and center X (purple hexagon)
328 AMREX_GPU_DEVICE
329 AMREX_FORCE_INLINE
331 Compute_h_xi_AtEdgeCenterI (const int &i, const int &j, const int &k,
332  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
333  const amrex::Array4<const amrex::Real>& z_nd)
334 {
335  amrex::Real dxInv = cellSizeInv[0];
336  amrex::Real met_h_xi = dxInv * ( z_nd(i+1,j,k) - z_nd(i,j,k) );
337  return met_h_xi;
338 }
339 
340 // Metric is at edge and center X (purple hexagon)
341 AMREX_GPU_DEVICE
342 AMREX_FORCE_INLINE
344 Compute_h_eta_AtEdgeCenterI (const int &i, const int &j, const int &k,
345  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
346  const amrex::Array4<const amrex::Real>& z_nd)
347 {
348  amrex::Real dyInv = cellSizeInv[1];
349  amrex::Real met_h_eta = 0.25 * dyInv *
350  ( z_nd(i+1,j+1,k) + z_nd(i,j+1,k)
351  -z_nd(i+1,j-1,k) - z_nd(i,j-1,k) );
352  return met_h_eta;
353 }
354 
355 // Relative height above terrain surface at cell center from z_nd (nodal absolute height)
356 AMREX_GPU_DEVICE
357 AMREX_FORCE_INLINE
359 Compute_Z_AtCellCenter (const int &i, const int &j, const int &k,
360  const amrex::Array4<const amrex::Real>& z_nd)
361 {
362  const amrex::Real z_cc = 0.125*( z_nd(i ,j ,k ) + z_nd(i ,j ,k+1) +
363  + z_nd(i+1,j ,k ) + z_nd(i ,j ,k+1)
364  + z_nd(i ,j+1,k ) + z_nd(i ,j+1,k+1)
365  + z_nd(i+1,j+1,k ) + z_nd(i ,j+1,k+1));
366 
367  return z_cc;
368 }
369 
370 // Relative height above terrain surface at cell center from z_nd (nodal absolute height)
371 AMREX_GPU_DEVICE
372 AMREX_FORCE_INLINE
374 Compute_Z_AtWFace (const int &i, const int &j, const int &k,
375  const amrex::Array4<const amrex::Real>& z_nd)
376 {
377  const amrex::Real z_wf = 0.25*( z_nd(i ,j ,k ) + z_nd(i+1,j ,k )
378  + z_nd(i ,j+1,k ) + z_nd(i+1,j+1,k ) );
379 
380  return z_wf;
381 }
382 
383 // Relative height above terrain surface at cell center from z_nd (nodal absolute height)
384 AMREX_GPU_DEVICE
385 AMREX_FORCE_INLINE
387 Compute_Zrel_AtCellCenter (const int &i, const int &j, const int &k,
388  const amrex::Array4<const amrex::Real>& z_nd)
389 {
390  const amrex::Real z_cc = 0.125*( z_nd(i ,j ,k ) + z_nd(i ,j ,k+1) +
391  + z_nd(i+1,j ,k ) + z_nd(i+1,j ,k+1)
392  + z_nd(i ,j+1,k ) + z_nd(i ,j+1,k+1)
393  + z_nd(i+1,j+1,k ) + z_nd(i+1,j+1,k+1));
394 
395  // Note: we assume the z_nd array spans from the bottom to top of the domain
396  // i.e. no domain decomposition across processors in vertical direction
397  const amrex::Real z0_cc = 0.25*( z_nd(i ,j ,0) + z_nd(i ,j+1,0)
398  + z_nd(i+1,j ,0) + z_nd(i+1,j+1,0));
399 
400  return (z_cc - z0_cc);
401 }
402 
403 
404 //*****************************************************************************************
405 // Contravariant velocity computation
406 //*****************************************************************************************
407 
408 // Define omega given u,v and w (4th order)
409 AMREX_GPU_DEVICE
410 AMREX_FORCE_INLINE
412 OmegaFromW (int& i, int& j, int& k, amrex::Real w,
413  const amrex::Array4<const amrex::Real>& u_arr,
414  const amrex::Array4<const amrex::Real>& v_arr,
415  const amrex::Array4<const amrex::Real>& mf_u,
416  const amrex::Array4<const amrex::Real>& mf_v,
417  const amrex::Array4<const amrex::Real>& z_nd,
418  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv)
419 {
420  // This is dh/dxi at hi and lo edges
421  amrex::Real z_x_p2 = Compute_Z_AtWFace(i+2,j,k,z_nd);
422  amrex::Real z_x_p1 = Compute_Z_AtWFace(i+1,j,k,z_nd);
423  amrex::Real z_x_m1 = Compute_Z_AtWFace(i-1,j,k,z_nd);
424  amrex::Real z_x_m2 = Compute_Z_AtWFace(i-2,j,k,z_nd);
425  amrex::Real met_xi = (amrex::Real(1.0/12.0)*(z_x_m2 - z_x_p2)
426  + amrex::Real(8.0/12.0)*(z_x_p1 - z_x_m1)) * dxInv[0];
427 
428  // This is dh/deta at hi and lo edges
429  amrex::Real z_y_p2 = Compute_Z_AtWFace(i,j+2,k,z_nd);
430  amrex::Real z_y_p1 = Compute_Z_AtWFace(i,j+1,k,z_nd);
431  amrex::Real z_y_m1 = Compute_Z_AtWFace(i,j-1,k,z_nd);
432  amrex::Real z_y_m2 = Compute_Z_AtWFace(i,j-2,k,z_nd);
433  amrex::Real met_eta = (amrex::Real(1.0/12.0)*(z_y_m2 - z_y_p2)
434  + amrex::Real(8.0/12.0)*(z_y_p1 - z_y_m1)) * dxInv[1];
435 
436  // Use extrapolation instead of interpolation if at the bottom boundary
437  amrex::Real u_hi = (k == 0) ? 1.5 * u_arr(i+1,j ,k ) - 0.5 * u_arr(i+1,j ,k+1) :
438  0.5 * ( u_arr(i+1,j ,k-1) + u_arr(i+1,j ,k ) );
439  amrex::Real u_lo = (k == 0) ? 1.5 * u_arr(i ,j ,k ) - 0.5 * u_arr(i ,j ,k+1) :
440  0.5 * ( u_arr(i ,j ,k-1) + u_arr(i ,j ,k ) );
441  amrex::Real mf_u_hi = mf_u(i+1,j,0);
442  amrex::Real mf_u_lo = mf_u(i ,j,0);
443 
444  amrex::Real v_hi = (k == 0) ? 1.5 * v_arr(i ,j+1,k ) - 0.5 * v_arr(i ,j+1,k+1) :
445  0.5 * ( v_arr(i ,j+1,k-1) + v_arr(i ,j+1,k ) );
446  amrex::Real v_lo = (k == 0) ? 1.5 * v_arr(i ,j ,k ) - 0.5 * v_arr(i ,j ,k+1) :
447  0.5 * ( v_arr(i ,j ,k-1) + v_arr(i ,j ,k ) );
448  amrex::Real mf_v_hi = mf_v(i,j+1,0);
449  amrex::Real mf_v_lo = mf_v(i,j ,0);
450 
451  amrex::Real u_met = met_xi * 0.5 * ( u_hi*mf_u_hi + u_lo*mf_u_lo );
452  amrex::Real v_met = met_eta * 0.5 * ( v_hi*mf_v_hi + v_lo*mf_v_lo );
453 
454  amrex::Real omega = w - u_met - v_met;
455  return omega;
456 }
457 
458 // Define w given u and v arrays and scalar omega (4th order)
459 AMREX_GPU_DEVICE
460 AMREX_FORCE_INLINE
462 WFromOmega (int& i, int& j, int& k, amrex::Real omega,
463  const amrex::Array4<const amrex::Real>& u_arr,
464  const amrex::Array4<const amrex::Real>& v_arr,
465  const amrex::Array4<const amrex::Real>& mf_u,
466  const amrex::Array4<const amrex::Real>& mf_v,
467  const amrex::Array4<const amrex::Real>& z_nd,
468  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv)
469 {
470  // This is dh/dxi at hi and lo edges
471  amrex::Real z_x_p2 = Compute_Z_AtWFace(i+2,j,k,z_nd);
472  amrex::Real z_x_p1 = Compute_Z_AtWFace(i+1,j,k,z_nd);
473  amrex::Real z_x_m1 = Compute_Z_AtWFace(i-1,j,k,z_nd);
474  amrex::Real z_x_m2 = Compute_Z_AtWFace(i-2,j,k,z_nd);
475  amrex::Real met_xi = (amrex::Real(1.0/12.0)*(z_x_m2 - z_x_p2)
476  + amrex::Real(8.0/12.0)*(z_x_p1 - z_x_m1)) * dxInv[0];
477 
478  // This is dh/deta at hi and lo edges
479  amrex::Real z_y_p2 = Compute_Z_AtWFace(i,j+2,k,z_nd);
480  amrex::Real z_y_p1 = Compute_Z_AtWFace(i,j+1,k,z_nd);
481  amrex::Real z_y_m1 = Compute_Z_AtWFace(i,j-1,k,z_nd);
482  amrex::Real z_y_m2 = Compute_Z_AtWFace(i,j-2,k,z_nd);
483  amrex::Real met_eta = (amrex::Real(1.0/12.0)*(z_y_m2 - z_y_p2)
484  + amrex::Real(8.0/12.0)*(z_y_p1 - z_y_m1)) * dxInv[1];
485 
486  // Use extrapolation instead of interpolation if at the bottom boundary
487  amrex::Real u_hi = (k == 0) ? 1.5 * u_arr(i+1,j ,k ) - 0.5 * u_arr(i+1,j ,k+1) :
488  0.5 * ( u_arr(i+1,j ,k-1) + u_arr(i+1,j ,k ) );
489  amrex::Real u_lo = (k == 0) ? 1.5 * u_arr(i ,j ,k ) - 0.5 * u_arr(i ,j ,k+1) :
490  0.5 * ( u_arr(i ,j ,k-1) + u_arr(i ,j ,k ) );
491  amrex::Real mf_u_hi = mf_u(i+1,j,0);
492  amrex::Real mf_u_lo = mf_u(i ,j,0);
493 
494  amrex::Real v_hi = (k == 0) ? 1.5 * v_arr(i ,j+1,k ) - 0.5 * v_arr(i ,j+1,k+1) :
495  0.5 * ( v_arr(i ,j+1,k-1) + v_arr(i ,j+1,k ) );
496  amrex::Real v_lo = (k == 0) ? 1.5 * v_arr(i ,j ,k ) - 0.5 * v_arr(i ,j ,k+1) :
497  0.5 * ( v_arr(i ,j ,k-1) + v_arr(i ,j ,k ) );
498  amrex::Real mf_v_hi = mf_v(i,j+1,0);
499  amrex::Real mf_v_lo = mf_v(i,j ,0);
500 
501  amrex::Real u_met = met_xi * 0.5 * ( u_hi*mf_u_hi + u_lo*mf_u_lo );
502  amrex::Real v_met = met_eta * 0.5 * ( v_hi*mf_v_hi + v_lo*mf_v_lo );
503 
504  amrex::Real w = omega + u_met + v_met;
505  return w;
506 }
507 
508 //
509 // NOTE: 2nd order kept here for debugging purposes
510 //
511 
512 # if 0
513 // Define omega given u,v and w (2nd order)
514 AMREX_GPU_DEVICE
515 AMREX_FORCE_INLINE
517 OmegaFromW (int& i, int& j, int& k, amrex::Real w,
518  const amrex::Array4<const amrex::Real>& u_arr,
519  const amrex::Array4<const amrex::Real>& v_arr,
520  const amrex::Array4<const amrex::Real>& mf_u,
521  const amrex::Array4<const amrex::Real>& mf_v,
522  const amrex::Array4<const amrex::Real>& z_nd,
523  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv)
524 {
525  // This is dh/dxi at hi and lo edges
526  amrex::Real z_x_h = Compute_Z_AtWFace(i+1,j,k,z_nd);
527  amrex::Real z_x_l = Compute_Z_AtWFace(i-1,j,k,z_nd);
528  amrex::Real met_xi = 0.5 * (z_x_h - z_x_l) * dxInv[0];
529 
530  // This is dh/deta at hi and lo edges
531  amrex::Real z_y_h = Compute_Z_AtWFace(i,j+1,k,z_nd);
532  amrex::Real z_y_l = Compute_Z_AtWFace(i,j-1,k,z_nd);
533  amrex::Real met_eta = 0.5 * (z_y_h - z_y_l) * dxInv[1];
534 
535  // Use extrapolation instead of interpolation if at the bottom boundary
536  amrex::Real u_hi = (k == 0) ? 1.5 * u_arr(i+1,j ,k ) - 0.5 * u_arr(i+1,j ,k+1) :
537  0.5 * ( u_arr(i+1,j ,k-1) + u_arr(i+1,j ,k ) );
538  amrex::Real u_lo = (k == 0) ? 1.5 * u_arr(i ,j ,k ) - 0.5 * u_arr(i ,j ,k+1) :
539  0.5 * ( u_arr(i ,j ,k-1) + u_arr(i ,j ,k ) );
540  amrex::Real mf_u_hi = mf_u(i+1,j,0);
541  amrex::Real mf_u_lo = mf_u(i ,j,0);
542 
543  amrex::Real v_hi = (k == 0) ? 1.5 * v_arr(i ,j+1,k ) - 0.5 * v_arr(i ,j+1,k+1) :
544  0.5 * ( v_arr(i ,j+1,k-1) + v_arr(i ,j+1,k ) );
545  amrex::Real v_lo = (k == 0) ? 1.5 * v_arr(i ,j ,k ) - 0.5 * v_arr(i ,j ,k+1) :
546  0.5 * ( v_arr(i ,j ,k-1) + v_arr(i ,j ,k ) );
547  amrex::Real mf_v_hi = mf_v(i,j+1,0);
548  amrex::Real mf_v_lo = mf_v(i,j ,0);
549 
550  amrex::Real u_met = met_xi * 0.5 * ( u_hi*mf_u_hi + u_lo*mf_u_lo );
551  amrex::Real v_met = met_eta * 0.5 * ( v_hi*mf_v_hi + v_lo*mf_v_lo );
552 
553  amrex::Real omega = w - u_met - v_met;
554  return omega;
555 }
556 
557 // Define w given u and v arrays and scalar omega (2nd order)
558 AMREX_GPU_DEVICE
559 AMREX_FORCE_INLINE
561 WFromOmega (int& i, int& j, int& k, amrex::Real omega,
562  const amrex::Array4<const amrex::Real>& u_arr,
563  const amrex::Array4<const amrex::Real>& v_arr,
564  const amrex::Array4<const amrex::Real>& mf_u,
565  const amrex::Array4<const amrex::Real>& mf_v,
566  const amrex::Array4<const amrex::Real>& z_nd,
567  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv)
568 {
569  // This is dh/dxi at hi and lo edges
570  amrex::Real z_x_h = Compute_Z_AtWFace(i+1,j,k,z_nd);
571  amrex::Real z_x_l = Compute_Z_AtWFace(i-1,j,k,z_nd);
572  amrex::Real met_xi = 0.5 * (z_x_h - z_x_l) * dxInv[0];
573 
574  // This is dh/deta at hi and lo edges
575  amrex::Real z_y_h = Compute_Z_AtWFace(i,j+1,k,z_nd);
576  amrex::Real z_y_l = Compute_Z_AtWFace(i,j-1,k,z_nd);
577  amrex::Real met_eta = 0.5 * (z_y_h - z_y_l) * dxInv[1];
578 
579  // Use extrapolation instead of interpolation if at the bottom boundary
580  amrex::Real u_hi = (k == 0) ? 1.5 * u_arr(i+1,j ,k ) - 0.5 * u_arr(i+1,j ,k+1) :
581  0.5 * ( u_arr(i+1,j ,k-1) + u_arr(i+1,j ,k ) );
582  amrex::Real u_lo = (k == 0) ? 1.5 * u_arr(i ,j ,k ) - 0.5 * u_arr(i ,j ,k+1) :
583  0.5 * ( u_arr(i ,j ,k-1) + u_arr(i ,j ,k ) );
584  amrex::Real mf_u_hi = mf_u(i+1,j,0);
585  amrex::Real mf_u_lo = mf_u(i ,j,0);
586 
587  amrex::Real v_hi = (k == 0) ? 1.5 * v_arr(i ,j+1,k ) - 0.5 * v_arr(i ,j+1,k+1) :
588  0.5 * ( v_arr(i ,j+1,k-1) + v_arr(i ,j+1,k ) );
589  amrex::Real v_lo = (k == 0) ? 1.5 * v_arr(i ,j ,k ) - 0.5 * v_arr(i ,j ,k+1) :
590  0.5 * ( v_arr(i ,j ,k-1) + v_arr(i ,j ,k ) );
591  amrex::Real mf_v_hi = mf_v(i,j+1,0);
592  amrex::Real mf_v_lo = mf_v(i,j ,0);
593 
594  amrex::Real u_met = met_xi * 0.5 * ( u_hi*mf_u_hi + u_lo*mf_u_lo );
595  amrex::Real v_met = met_eta * 0.5 * ( v_hi*mf_v_hi + v_lo*mf_v_lo );
596 
597  amrex::Real w = omega + u_met + v_met;
598  return w;
599 }
600 #endif
601 
602 
603 //*****************************************************************************************
604 // Rotate scalar flux vector and stress tensor for MOST
605 //*****************************************************************************************
606 AMREX_GPU_DEVICE
607 AMREX_FORCE_INLINE
608 void
609 rotate_scalar_flux (const int& i,
610  const int& j,
611  const int& klo,
612  const amrex::Real& flux,
613  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv,
614  const amrex::Array4<const amrex::Real>& zphys_arr,
615  const amrex::Array4<amrex::Real>& phi1_arr,
616  const amrex::Array4<amrex::Real>& phi2_arr,
617  const amrex::Array4<amrex::Real>& phi3_arr)
618 {
619  amrex::Real h_xi = Compute_h_xi_AtCellCenter(i, j, klo, dxInv, zphys_arr);
620  amrex::Real h_eta = Compute_h_eta_AtCellCenter(i, j, klo, dxInv, zphys_arr);
621  amrex::Real InvNorm = 1.0 / std::sqrt(1.0 + h_xi*h_xi + h_eta*h_eta);
622  phi1_arr(i,j,klo) = -h_xi * flux * InvNorm;
623  phi2_arr(i,j,klo) = -h_eta * flux * InvNorm;
624  phi3_arr(i,j,klo) = flux * InvNorm;
625 }
626 
627 AMREX_GPU_DEVICE
628 AMREX_FORCE_INLINE
629 void
630 rotate_stress_tensor (const int& i,
631  const int& j,
632  const int& klo,
633  const amrex::Real& flux,
634  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv,
635  const amrex::Array4<const amrex::Real>& zphys_arr,
636  const amrex::Array4<const amrex::Real>& u_arr,
637  const amrex::Array4<const amrex::Real>& v_arr,
638  const amrex::Array4<const amrex::Real>& w_arr,
639  const amrex::Array4<amrex::Real>& tau11_arr,
640  const amrex::Array4<amrex::Real>& tau22_arr,
641  const amrex::Array4<amrex::Real>& tau33_arr,
642  const amrex::Array4<amrex::Real>& tau12_arr,
643  const amrex::Array4<amrex::Real>& tau21_arr,
644  const amrex::Array4<amrex::Real>& tau13_arr,
645  const amrex::Array4<amrex::Real>& tau31_arr,
646  const amrex::Array4<amrex::Real>& tau23_arr,
647  const amrex::Array4<amrex::Real>& tau32_arr)
648 {
649  // Unit-normal vector
650  amrex::Array1D<amrex::Real,0,2> n_hat;
651 
652  // Unit-tangent vectors
653  amrex::Array1D<amrex::Real,0,2> t_hat_1;
654  amrex::Array1D<amrex::Real,0,2> t_hat_2;
655  amrex::Array1D<amrex::Real,0,2> u_t_hat;
656 
657  // Final basis vector for right-hand coord sys
658  amrex::Array1D<amrex::Real,0,2> a_hat;
659 
660  // Rotation matrix
661  amrex::Array2D<amrex::Real,0,2,0,2> R_mat;
662 
663  // Metric data
664  amrex::Real h_xi = Compute_h_xi_AtIface(i, j, klo, dxInv, zphys_arr);
665  amrex::Real h_eta = Compute_h_eta_AtIface(i, j, klo, dxInv, zphys_arr);
666  amrex::Real h_zeta = Compute_h_zeta_AtIface(i, j, klo, dxInv, zphys_arr);
667 
668  // Populate the normal vector
669  amrex::Real Inormn = 1./std::sqrt(1.0 + h_xi*h_xi + h_eta*h_eta);
670  n_hat(0) = Inormn*h_xi; n_hat(1) = Inormn*h_eta; n_hat(2) = -Inormn;
671 
672  // Populate the tangent vectors
673  amrex::Real Inorm1 = 1./std::sqrt(1.0 + h_xi*h_xi);
674  amrex::Real Inorm2 = 1./std::sqrt(1.0 + h_eta*h_eta);
675  t_hat_1(0) = -Inorm1; t_hat_2(1) = -Inorm2;
676  t_hat_1(2) = -Inorm1*h_xi; t_hat_2(2) = -Inorm2*h_eta;
677 
678  // Populate the u_t vector
679  amrex::Real Norm_u_t = 0.0;
680  amrex::Real mag1 = (u_arr(i,j,klo) + h_xi *w_arr(i,j,klo))*Inorm1;
681  amrex::Real mag2 = (v_arr(i,j,klo) + h_eta*w_arr(i,j,klo))*Inorm2;
682  for (int icol(0); icol<3; ++icol) {
683  u_t_hat(icol) = mag1*t_hat_1(icol) + mag2*t_hat_2(icol);
684  Norm_u_t += u_t_hat(icol)*u_t_hat(icol);
685  }
686  for (int icol(0); icol<3; ++icol) {
687  u_t_hat(icol) /= std::sqrt(Norm_u_t);
688  }
689 
690  // Populate the a_hat vector
691  a_hat(0) = n_hat(1)*u_t_hat(2) - n_hat(2)*u_t_hat(1);
692  a_hat(1) = -(n_hat(0)*u_t_hat(2) - n_hat(2)*u_t_hat(0));
693  a_hat(2) = n_hat(0)*u_t_hat(1) - n_hat(1)*u_t_hat(0);
694 
695  // Copy column vectors into R_mat
696  int jrow;
697  jrow = 0;
698  for (int icol(0); icol<3; ++icol) {
699  R_mat(icol,jrow) = u_t_hat(icol);
700  }
701  jrow = 1;
702  for (int icol(0); icol<3; ++icol) {
703  R_mat(icol,jrow) = a_hat(icol);
704  }
705  jrow = 2;
706  for (int icol(0); icol<3; ++icol) {
707  R_mat(icol,jrow) = n_hat(icol);
708  }
709 
710  // Body-fixed tau
711  amrex::Real T11 = 2.0*R_mat(0,0)*R_mat(2,0)*flux;
712  amrex::Real T22 = 2.0*R_mat(0,1)*R_mat(2,1)*flux;
713  amrex::Real T33 = 2.0*R_mat(0,2)*R_mat(2,2)*flux;
714  amrex::Real T12 = (R_mat(0,0)*R_mat(2,1) + R_mat(2,0)*R_mat(0,1))*flux;
715  amrex::Real T13 = (R_mat(0,0)*R_mat(2,2) + R_mat(0,2)*R_mat(2,0))*flux;
716  amrex::Real T23 = (R_mat(0,1)*R_mat(2,2) + R_mat(0,2)*R_mat(2,1))*flux;
717 
718  // Rotated stress fluxes
719  tau11_arr(i,j,klo) = h_zeta*T11;
720  tau22_arr(i,j,klo) = h_zeta*T22;
721  tau33_arr(i,j,klo) = -h_xi*T13 - h_eta*T23 + T33;
722 
723  tau12_arr(i,j,klo) = h_zeta*T12;
724  tau21_arr(i,j,klo) = tau21_arr(i,j,klo);
725 
726  tau13_arr(i,j,klo) = -h_xi*T11 - h_eta*T12 + T13;
727  tau31_arr(i,j,klo) = h_zeta*T13;
728 
729  tau23_arr(i,j,klo) = -h_xi*T12 - h_eta*T22 + T23;
730  tau32_arr(i,j,klo) = h_zeta*T23;
731 }
732 #endif
amrex::Real Real
Definition: ERF_ShocInterface.H:19
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_u, const amrex::Array4< const amrex::Real > &mf_v, const amrex::Array4< const amrex::Real > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv)
Definition: ERF_TerrainMetrics.H:412
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:302
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:241
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:287
AMREX_GPU_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:115
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:273
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:228
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 zsurf, const amrex::Real dz0)
AMREX_FORCE_INLINE AMREX_GPU_DEVICE 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:53
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:317
AMREX_GPU_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_nd)
Definition: ERF_TerrainMetrics.H:387
AMREX_GPU_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:83
AMREX_GPU_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:182
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:359
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void rotate_scalar_flux(const int &i, const int &j, const int &klo, 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:609
void init_default_zphys(int lev, const amrex::Geometry &geom, amrex::MultiFab &z_phys_nd, amrex::MultiFab &z_phys_cc)
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:102
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void rotate_stress_tensor(const int &i, const int &j, const int &klo, 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 > &tau11_arr, const amrex::Array4< amrex::Real > &tau22_arr, const amrex::Array4< amrex::Real > &tau33_arr, const amrex::Array4< amrex::Real > &tau12_arr, const amrex::Array4< amrex::Real > &tau21_arr, 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:630
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:155
amrex::Real get_dzmin_terrain(amrex::MultiFab &z_phys_nd)
AMREX_GPU_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:374
AMREX_GPU_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:196
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:256
void init_which_terrain_grid(int lev, const amrex::Geometry &geom, amrex::MultiFab &z_phys_nd, amrex::Vector< amrex::Real > const &z_levels_h)
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:129
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:331
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:142
AMREX_GPU_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:68
AMREX_GPU_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:168
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:344
AMREX_GPU_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:209
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)
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_u, const amrex::Array4< const amrex::Real > &mf_v, const amrex::Array4< const amrex::Real > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv)
Definition: ERF_TerrainMetrics.H:462
@ omega
Definition: ERF_Morrison.H:53