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