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