ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_Advection.H
Go to the documentation of this file.
1 #ifndef ERF_ADVECTION_H_
2 #define ERF_ADVECTION_H_
3 
4 #include "AMReX.H"
5 #include "AMReX_MultiFab.H"
6 #include "AMReX_iMultiFab.H"
7 #include "AMReX_BCRec.H"
8 #include "AMReX_YAFluxRegister.H"
9 
10 #include "ERF_DataStruct.H"
11 #include "ERF_IndexDefines.H"
12 #include "ERF_SurfaceLayer.H"
13 #include "ERF_EB.H"
14 
15 /** Compute advection tendency for density and averaged momentum fluxes */
16 void AdvectionSrcForRho (const amrex::Box& bx,
17  const amrex::Array4<amrex::Real>& src,
18  const amrex::Array4<const amrex::Real>& rho_u, // These are being used
19  const amrex::Array4<const amrex::Real>& rho_v, // to define the fluxes
20  const amrex::Array4<const amrex::Real>& omega,
21  const amrex::Array4< amrex::Real>& avg_xmom, // These are being defined
22  const amrex::Array4< amrex::Real>& avg_ymom, // from the rho fluxes
23  const amrex::Array4< amrex::Real>& avg_zmom,
24  const amrex::Array4<const amrex::Real>& ax_arr,
25  const amrex::Array4<const amrex::Real>& ay_arr,
26  const amrex::Array4<const amrex::Real>& az_arr,
27  const amrex::Array4<const amrex::Real>& detJ,
28  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
29  const amrex::Array4<const amrex::Real>& mf_mx,
30  const amrex::Array4<const amrex::Real>& mf_my,
31  const amrex::Array4<const amrex::Real>& mf_uy,
32  const amrex::Array4<const amrex::Real>& mf_vx,
33  const amrex::GpuArray<const amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_arr,
34  const bool fixed_rho);
35 
36 /** Compute advection tendencies for cell-centered scalar components */
37 void AdvectionSrcForScalars (const amrex::Box& bx,
38  const int icomp, const int ncomp,
39  const amrex::Array4<const amrex::Real>& avg_xmom,
40  const amrex::Array4<const amrex::Real>& avg_ymom,
41  const amrex::Array4<const amrex::Real>& avg_zmom,
42  const amrex::Array4<const amrex::Real>& cell_prim,
43  const amrex::Array4<amrex::Real>& src,
44  const amrex::Array4<const amrex::Real>& vf_arr,
45  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
46  const amrex::Array4<const amrex::Real>& mf_mx,
47  const amrex::Array4<const amrex::Real>& mf_my,
48  const AdvType horiz_adv_type, const AdvType vert_adv_type,
49  const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac,
50  const amrex::GpuArray<const amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_arr,
51  const amrex::Box& domain,
52  const amrex::BCRec* bc_ptr_h);
53 
54 /** Compute advection tendencies for all components of momentum */
55 void AdvectionSrcForMom (const amrex::MFIter& mfi,
56  const amrex::Box& bxx, const amrex::Box& bxy, const amrex::Box& bxz,
57  const amrex::Vector<amrex::Box>& bxx_grown,
58  const amrex::Vector<amrex::Box>& bxy_grown,
59  const amrex::Vector<amrex::Box>& bxz_grown,
60  const amrex::Array4< amrex::Real>& rho_u_rhs, const amrex::Array4< amrex::Real>& rho_v_rhs,
61  const amrex::Array4< amrex::Real>& rho_w_rhs,
62  const amrex::Array4<const amrex::Real>& rho,
63  const amrex::Array4<const amrex::Real>& u , const amrex::Array4<const amrex::Real>& v,
64  const amrex::Array4<const amrex::Real>& w ,
65  const amrex::Array4<const amrex::Real>& rho_u , const amrex::Array4<const amrex::Real>& rho_v,
66  const amrex::Array4<const amrex::Real>& Omega ,
67  const amrex::Array4<const amrex::Real>& z_nd,
68  const amrex::Array4<const amrex::Real>& ax,
69  const amrex::Array4<const amrex::Real>& ay,
70  const amrex::Array4<const amrex::Real>& az,
71  const amrex::Array4<const amrex::Real>& detJ,
72  amrex::Gpu::DeviceVector<amrex::Real>& stretched_dz_d,
73  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
74  const amrex::Array4<const amrex::Real>& mf_mx,
75  const amrex::Array4<const amrex::Real>& mf_ux,
76  const amrex::Array4<const amrex::Real>& mf_vx,
77  const amrex::Array4<const amrex::Real>& mf_my,
78  const amrex::Array4<const amrex::Real>& mf_uy,
79  const amrex::Array4<const amrex::Real>& mf_vy,
80  const AdvType horiz_adv_type, const AdvType vert_adv_type,
81  const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac,
82  MeshType& mesh_type, TerrainType& terrain_type,
83  const eb_& ebfact,
84  amrex::GpuArray<amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_u_arr,
85  amrex::GpuArray<amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_v_arr,
86  amrex::GpuArray<amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_w_arr,
87  const amrex::Vector<amrex::iMultiFab>& physbnd_mask,
88  const bool already_on_centroids,
89  const int lo_z_face, const int hi_z_face,
90  const amrex::Box& domain,
91  const amrex::BCRec* bc_ptr_h);
92 
93 /** Compute advection tendencies for all components of momentum when dz is constant */
95  const amrex::Box& bxx, const amrex::Box& bxy, const amrex::Box& bxz,
96  const amrex::Array4< amrex::Real>& rho_u_rhs, const amrex::Array4< amrex::Real>& rho_v_rhs,
97  const amrex::Array4< amrex::Real>& rho_w_rhs,
98  const amrex::Array4<const amrex::Real>& u , const amrex::Array4<const amrex::Real>& v,
99  const amrex::Array4<const amrex::Real>& w ,
100  const amrex::Array4<const amrex::Real>& rho_u , const amrex::Array4<const amrex::Real>& rho_v,
101  const amrex::Array4<const amrex::Real>& Omega ,
102  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
103  const amrex::Gpu::DeviceVector<amrex::Real>& stretched_dz_d,
104  const amrex::Array4<const amrex::Real>& mf_mx,
105  const amrex::Array4<const amrex::Real>& mf_ux,
106  const amrex::Array4<const amrex::Real>& mf_vx,
107  const amrex::Array4<const amrex::Real>& mf_my,
108  const amrex::Array4<const amrex::Real>& mf_uy,
109  const amrex::Array4<const amrex::Real>& mf_vy,
110  const AdvType horiz_adv_type, const AdvType vert_adv_type,
111  const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac,
112  TerrainType& terrain_type,
113  const int lo_z_face, const int hi_z_face);
114 
115 /** Compute advection tendencies for all components of momentum when dz is stretched */
117  const amrex::Box& bxx, const amrex::Box& bxy, const amrex::Box& bxz,
118  const amrex::Array4< amrex::Real>& rho_u_rhs, const amrex::Array4< amrex::Real>& rho_v_rhs,
119  const amrex::Array4< amrex::Real>& rho_w_rhs,
120  const amrex::Array4<const amrex::Real>& u , const amrex::Array4<const amrex::Real>& v,
121  const amrex::Array4<const amrex::Real>& w ,
122  const amrex::Array4<const amrex::Real>& rho_u , const amrex::Array4<const amrex::Real>& rho_v,
123  const amrex::Array4<const amrex::Real>& Omega ,
124  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
125  const amrex::Gpu::DeviceVector<amrex::Real>& stretched_dz_d,
126  const amrex::Array4<const amrex::Real>& mf_mx,
127  const amrex::Array4<const amrex::Real>& mf_ux,
128  const amrex::Array4<const amrex::Real>& mf_vx,
129  const amrex::Array4<const amrex::Real>& mf_my,
130  const amrex::Array4<const amrex::Real>& mf_uy,
131  const amrex::Array4<const amrex::Real>& mf_vy,
132  const AdvType horiz_adv_type, const AdvType vert_adv_type,
133  const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac,
134  const int lo_z_face, const int hi_z_face);
135 
136 /** Compute advection tendencies for all components of momentum for TERRAIN-FITTED COORDS only */
138  const amrex::Box& bxx, const amrex::Box& bxy, const amrex::Box& bxz,
139  const amrex::Array4< amrex::Real>& rho_u_rhs, const amrex::Array4< amrex::Real>& rho_v_rhs,
140  const amrex::Array4< amrex::Real>& rho_w_rhs,
141  const amrex::Array4<const amrex::Real>& u , const amrex::Array4<const amrex::Real>& v,
142  const amrex::Array4<const amrex::Real>& w ,
143  const amrex::Array4<const amrex::Real>& rho_u , const amrex::Array4<const amrex::Real>& rho_v,
144  const amrex::Array4<const amrex::Real>& Omega ,
145  const amrex::Array4<const amrex::Real>& z_nd,
146  const amrex::Array4<const amrex::Real>& ax,
147  const amrex::Array4<const amrex::Real>& ay,
148  const amrex::Array4<const amrex::Real>& az,
149  const amrex::Array4<const amrex::Real>& detJ,
150  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
151  const amrex::Array4<const amrex::Real>& mf_mx,
152  const amrex::Array4<const amrex::Real>& mf_ux,
153  const amrex::Array4<const amrex::Real>& mf_vx,
154  const amrex::Array4<const amrex::Real>& mf_my,
155  const amrex::Array4<const amrex::Real>& mf_uy,
156  const amrex::Array4<const amrex::Real>& mf_vy,
157  const AdvType horiz_adv_type, const AdvType vert_adv_type,
158  const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac,
159  const int lo_z_face, const int hi_z_face);
160 
161 /** Compute advection tendencies for all components of momentum when using EB for terrain */
162 void AdvectionSrcForMom_EB (const amrex::MFIter& mfi,
163  const amrex::Box& bxx, const amrex::Box& bxy, const amrex::Box& bxz,
164  const amrex::Vector<amrex::Box>& bxx_grown,
165  const amrex::Vector<amrex::Box>& bxy_grown,
166  const amrex::Vector<amrex::Box>& bxz_grown,
167  const amrex::Array4< amrex::Real>& rho_u_rhs, const amrex::Array4< amrex::Real>& rho_v_rhs,
168  const amrex::Array4< amrex::Real>& rho_w_rhs,
169  const amrex::Array4<const amrex::Real>& u , const amrex::Array4<const amrex::Real>& v,
170  const amrex::Array4<const amrex::Real>& w ,
171  const amrex::Array4<const amrex::Real>& rho_u , const amrex::Array4<const amrex::Real>& rho_v,
172  const amrex::Array4<const amrex::Real>& Omega ,
173  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
174  const amrex::Array4<const amrex::Real>& mf_mx,
175  const amrex::Array4<const amrex::Real>& mf_ux,
176  const amrex::Array4<const amrex::Real>& mf_vx,
177  const amrex::Array4<const amrex::Real>& mf_my,
178  const amrex::Array4<const amrex::Real>& mf_uy,
179  const amrex::Array4<const amrex::Real>& mf_vy,
180  const AdvType horiz_adv_type, const AdvType vert_adv_type,
181  const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac,
182  const eb_& ebfact,
183  amrex::GpuArray<amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_u_arr,
184  amrex::GpuArray<amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_v_arr,
185  amrex::GpuArray<amrex::Array4<amrex::Real>, AMREX_SPACEDIM>& flx_w_arr,
186  const amrex::Vector<amrex::iMultiFab>& physbnd_mask,
187  const bool already_on_centroids,
188  const int lo_z_face, const int hi_z_face,
189  const amrex::Box& domain);
190 
191 /**
192  * Shrink a z-momentum box away from the bottom and top of the domain, where no
193  * z-momentum source term is computed.
194  *
195  * The shrink must be applied only at an end that actually coincides with the domain,
196  * which is why this takes `domain` rather than shrinking unconditionally: on a grid
197  * decomposed in z, an unconditional shrink also removes the w-face at every internal
198  * split, and any operator run on the result silently skips those faces.
199  *
200  * `b` is z-nodal; `domain` is cell-centered.
201  */
202 inline amrex::Box
203 ShrinkZmomBoxAtDomainEnds (amrex::Box b, const amrex::Box& domain)
204 {
205  if (b.smallEnd(2) == domain.smallEnd(2)) { b.growLo(2,-1); }
206  if (b.bigEnd(2) == domain.bigEnd(2) + 1) { b.growHi(2,-1); }
207  return b;
208 }
209 
210 /**
211  * Which side of the domain is open in one coordinate direction, as seen by the
212  * cells an open-boundary kernel is about to update.
213  */
214 enum struct OpenSide : int { lo = -1, none = 0, hi = 1 };
215 
216 /** One box on an open lateral boundary, tagged with the side(s) that are open there. */
217 struct OpenBCPatch {
218  amrex::Box box;
221 };
222 
223 /**
224  * Remove from an open-boundary box the cells that also sit on a perpendicular
225  * open boundary, so that no cell is updated by two different open-boundary kernels.
226  *
227  * `b` is trimmed in dimension `dim` only at an end that actually coincides with the
228  * corresponding end of `domain`. The domain-level open flags by themselves are not a
229  * sufficient test: `b` is a per-box (or per-tile) slab whose ends generally lie in
230  * the interior, and trimming those would silently drop interior cells from the
231  * open-boundary treatment and make the answer depend on the grid decomposition.
232  *
233  * `domain` is cell-centered; the index of the boundary is taken in the index space
234  * of `b`, which may be node-centered in `dim`.
235  */
236 inline amrex::Box
237 TrimOpenBCCorner (amrex::Box b,
238  const int dim,
239  const amrex::Box& domain,
240  const bool lo_open,
241  const bool hi_open)
242 {
243  if (!b.ok()) { return b; }
244 
245  const int dom_lo = domain.smallEnd(dim);
246  const int dom_hi = domain.bigEnd(dim) + (b.ixType().nodeCentered(dim) ? 1 : 0);
247 
248  if (lo_open && b.smallEnd(dim) == dom_lo) { b.growLo(dim,-1); }
249  if (hi_open && b.bigEnd(dim) == dom_hi) { b.growHi(dim,-1); }
250 
251  return b;
252 }
253 
254 /**
255  * Build the one-cell-wide box where the `x_side` and `y_side` open boundaries meet,
256  * or an empty box if `b` does not reach both of them.
257  */
258 inline amrex::Box
259 OpenBCCornerBox (amrex::Box b,
260  const amrex::Box& domain,
261  const OpenSide x_side,
262  const OpenSide y_side)
263 {
264  AMREX_ALWAYS_ASSERT(x_side != OpenSide::none && y_side != OpenSide::none);
265 
266  if (!b.ok()) { return amrex::Box(); }
267 
268  const OpenSide side[2] = {x_side, y_side};
269  for (int dim(0); dim < 2; ++dim) {
270  const int idx = (side[dim] == OpenSide::lo) ?
271  domain.smallEnd(dim) :
272  domain.bigEnd(dim) + (b.ixType().nodeCentered(dim) ? 1 : 0);
273  if (idx < b.smallEnd(dim) || idx > b.bigEnd(dim)) { return amrex::Box(); }
274  b = amrex::makeSlab(b, dim, idx);
275  }
276 
277  return b;
278 }
279 
280 /**
281  * Enumerate the boxes on which the open-boundary tangential operator must be applied
282  * for a quantity that has no boundary-normal owner at a lateral corner -- that is,
283  * w and the cell-centered state, both of which are tangent to every lateral boundary.
284  *
285  * The returned boxes are disjoint and together cover every cell of `b` that lies on an
286  * open lateral boundary: the four edges, trimmed so they do not reach into a corner,
287  * plus the corners themselves, which carry both sides so the kernel differences across
288  * neither open boundary there.
289  */
290 inline amrex::Vector<OpenBCPatch>
291 OpenBCTangentPatches (const amrex::Box& b,
292  const amrex::Box& domain,
293  const bool xlo_open,
294  const bool xhi_open,
295  const bool ylo_open,
296  const bool yhi_open)
297 {
298  amrex::Vector<OpenBCPatch> patches;
299  if (!b.ok()) { return patches; }
300  patches.reserve(8);
301 
302  const int dom_xhi = domain.bigEnd(0) + (b.ixType().nodeCentered(0) ? 1 : 0);
303  const int dom_yhi = domain.bigEnd(1) + (b.ixType().nodeCentered(1) ? 1 : 0);
304 
305  // Edges: each is trimmed by the open boundaries perpendicular to it, which own
306  // the corner cells by way of the corner patches added below.
307  if (xlo_open && b.smallEnd(0) == domain.smallEnd(0)) {
308  amrex::Box e = TrimOpenBCCorner(amrex::makeSlab(b,0,domain.smallEnd(0)), 1, domain, ylo_open, yhi_open);
309  if (e.ok()) { patches.push_back({e, OpenSide::lo, OpenSide::none}); }
310  }
311  if (xhi_open && b.bigEnd(0) == dom_xhi) {
312  amrex::Box e = TrimOpenBCCorner(amrex::makeSlab(b,0,dom_xhi), 1, domain, ylo_open, yhi_open);
313  if (e.ok()) { patches.push_back({e, OpenSide::hi, OpenSide::none}); }
314  }
315  if (ylo_open && b.smallEnd(1) == domain.smallEnd(1)) {
316  amrex::Box e = TrimOpenBCCorner(amrex::makeSlab(b,1,domain.smallEnd(1)), 0, domain, xlo_open, xhi_open);
317  if (e.ok()) { patches.push_back({e, OpenSide::none, OpenSide::lo}); }
318  }
319  if (yhi_open && b.bigEnd(1) == dom_yhi) {
320  amrex::Box e = TrimOpenBCCorner(amrex::makeSlab(b,1,dom_yhi), 0, domain, xlo_open, xhi_open);
321  if (e.ok()) { patches.push_back({e, OpenSide::none, OpenSide::hi}); }
322  }
323 
324  // Corners
325  for (OpenSide x_side : {OpenSide::lo, OpenSide::hi}) {
326  if (!((x_side == OpenSide::lo) ? xlo_open : xhi_open)) { continue; }
327  for (OpenSide y_side : {OpenSide::lo, OpenSide::hi}) {
328  if (!((y_side == OpenSide::lo) ? ylo_open : yhi_open)) { continue; }
329  amrex::Box c = OpenBCCornerBox(b, domain, x_side, y_side);
330  if (c.ok()) { patches.push_back({c, x_side, y_side}); }
331  }
332  }
333 
334  return patches;
335 }
336 
337 /** Compute advection tendencies for all normal components of momentum */
338 void
339 AdvectionSrcForOpenBC_Normal (const amrex::Box& bx,
340  const int& dir,
341  const amrex::Array4< amrex::Real>& rhs_arr,
342  const amrex::Array4<const amrex::Real>& vel_norm_arr,
343  const amrex::Array4<const amrex::Real>& cell_data_arr,
344  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dxInv,
345  const bool do_lo=false);
346 
347 /** Compute advection tendencies for u momentum tangent to open BC */
348 void
349 AdvectionSrcForOpenBC_Tangent_Xmom (const amrex::Box& bxx,
350  const int& dir,
351  const amrex::Array4< amrex::Real>& rho_u_rhs,
352  const amrex::Array4<const amrex::Real>& u,
353  const amrex::Array4<const amrex::Real>& rho_u,
354  const amrex::Array4<const amrex::Real>& rho_v,
355  const amrex::Array4<const amrex::Real>& Omega,
356  const amrex::Array4<const amrex::Real>& ax,
357  const amrex::Array4<const amrex::Real>& az,
358  const amrex::Array4<const amrex::Real>& detJ,
359  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
360  const bool do_lo=false);
361 
362 /** Compute advection tendencies for v momentum tangent to open BC */
363 void
364 AdvectionSrcForOpenBC_Tangent_Ymom (const amrex::Box& bxy,
365  const int& dir,
366  const amrex::Array4< amrex::Real>& rho_v_rhs,
367  const amrex::Array4<const amrex::Real>& v,
368  const amrex::Array4<const amrex::Real>& rho_u,
369  const amrex::Array4<const amrex::Real>& rho_v,
370  const amrex::Array4<const amrex::Real>& Omega,
371  const amrex::Array4<const amrex::Real>& ay,
372  const amrex::Array4<const amrex::Real>& az,
373  const amrex::Array4<const amrex::Real>& detJ,
374  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
375  const bool do_lo=false);
376 
377 /** Compute advection tendencies for w momentum tangent to open BC
378  * `x_side` and `y_side` say which lateral boundaries the cells being updated lie on;
379  * both are set at a corner, where neither direction may be differenced across. */
380 void
381 AdvectionSrcForOpenBC_Tangent_Zmom (const amrex::Box& bxz,
382  const OpenSide x_side,
383  const OpenSide y_side,
384  const amrex::Array4< amrex::Real>& rho_w_rhs,
385  const amrex::Array4<const amrex::Real>& w,
386  const amrex::Array4<const amrex::Real>& rho_u,
387  const amrex::Array4<const amrex::Real>& rho_v,
388  const amrex::Array4<const amrex::Real>& Omega,
389  const amrex::Array4<const amrex::Real>& ax,
390  const amrex::Array4<const amrex::Real>& ay,
391  const amrex::Array4<const amrex::Real>& az,
392  const amrex::Array4<const amrex::Real>& detJ,
393  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
394  const int domhi_z);
395 
396 /** Compute advection tendencies for scalar fields tangential to open BC.
397  *
398  * @param[in] bx box over which scalar tendencies are updated
399  * @param[in] x_side lateral x boundary, if any
400  * @param[in] y_side lateral y boundary, if any
401  * @param[in] scalar_icomp first component of the supplied scalar view to read
402  * @param[in] rhs_icomp first component of the supplied tendency view to write
403  * @param[in] ncomp number of components to update
404  * @param[out] rhs tendency view
405  * @param[in] scalar supplied scalar view
406  * @param[in] avg_xmom x-component of time-averaged mass flux
407  * @param[in] avg_ymom y-component of time-averaged mass flux
408  * @param[in] avg_zmom z-component of time-averaged mass flux
409  * @param[in] detJ metric Jacobian
410  * @param[in] cellSizeInv inverse grid spacing
411  *
412  * At a corner both sides are set, so neither direction is differenced across
413  * its open boundary.
414  */
415 void
417  const OpenSide x_side,
418  const OpenSide y_side,
419  const int scalar_icomp,
420  const int rhs_icomp,
421  const int ncomp,
422  const amrex::Array4< amrex::Real>& rhs,
423  const amrex::Array4<const amrex::Real>& scalar,
424  const amrex::Array4<const amrex::Real>& avg_xmom,
425  const amrex::Array4<const amrex::Real>& avg_ymom,
426  const amrex::Array4<const amrex::Real>& avg_zmom,
427  const amrex::Array4<const amrex::Real>& detJ,
428  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv);
429 
430 /** Compute advection tendencies for conserved variables tangential to open BC
431  * `x_side` and `y_side` say which lateral boundaries the cells being updated lie on;
432  * both are set at a corner, where neither direction may be differenced across.
433  * This native adapter maps conserved component `icomp + n` to primitive component
434  * `icomp + n - 1` before calling the component-explicit scalar operation. */
435 void
437  const OpenSide x_side,
438  const OpenSide y_side,
439  const int& icomp,
440  const int& ncomp,
441  const amrex::Array4< amrex::Real>& cell_rhs,
442  const amrex::Array4<const amrex::Real>& cell_prim,
443  const amrex::Array4<const amrex::Real>& avg_xmom,
444  const amrex::Array4<const amrex::Real>& avg_ymom,
445  const amrex::Array4<const amrex::Real>& avg_zmom,
446  const amrex::Array4<const amrex::Real>& detJ,
447  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv);
448 
449 /** Compute advection tendencies in the normal direction for variables tangent to open BC */
450 AMREX_GPU_HOST_DEVICE
451 AMREX_FORCE_INLINE
454  const int& j,
455  const int& k,
456  const int& nprim,
457  const int& dir,
458  const amrex::Array4<const amrex::Real>& prim_tang_arr,
459  const amrex::Array4<const amrex::Real>& mom_norm_arr,
460  const amrex::Real& dxInv,
461  const bool do_lo=false);
462 
463 /** Return the effective advection type used for the requested Runge-Kutta stage. */
464 AMREX_GPU_HOST_DEVICE
465 AMREX_FORCE_INLINE
466 AdvType
467 EfficientAdvType (int nrk, AdvType adv_type)
468 {
469  AdvType eff_adv_type;
470 
471  if (nrk == 0) {
472 
473  eff_adv_type = AdvType::Centered_2nd;
474 
475  } else if (nrk == 1) {
476 
477  if ( (adv_type == AdvType::Centered_2nd) ||
478  (adv_type == AdvType::Upwind_3rd) ||
479  (adv_type == AdvType::Centered_4th) ||
480  (adv_type == AdvType::Weno_3) ||
481  (adv_type == AdvType::Weno_3Z) ||
482  (adv_type == AdvType::Weno_3MZQ) )
483  {
484  eff_adv_type = AdvType::Centered_2nd;
485 
486  } else if ( (adv_type == AdvType::Upwind_5th) ||
487  (adv_type == AdvType::Weno_5) ||
488  (adv_type == AdvType::Weno_5Z) )
489  {
490  eff_adv_type = AdvType::Upwind_3rd;
491 
492  } else { // (adv_type == AdvType::Centered_6th)
493 
494  eff_adv_type = AdvType::Centered_4th;
495  }
496 
497  } else {
498 
499  eff_adv_type = adv_type;
500  }
501 
502  return(eff_adv_type);
503 }
504 #endif
void AdvectionSrcForMom(const amrex::MFIter &mfi, const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Vector< amrex::Box > &bxx_grown, const amrex::Vector< amrex::Box > &bxy_grown, const amrex::Vector< amrex::Box > &bxz_grown, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &rho, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, MeshType &mesh_type, TerrainType &terrain_type, const eb_ &ebfact, amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_u_arr, amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_v_arr, amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_w_arr, const amrex::Vector< amrex::iMultiFab > &physbnd_mask, const bool already_on_centroids, const int lo_z_face, const int hi_z_face, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h)
void AdvectionSrcForRho(const amrex::Box &bx, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &omega, const amrex::Array4< amrex::Real > &avg_xmom, const amrex::Array4< amrex::Real > &avg_ymom, const amrex::Array4< amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &ax_arr, const amrex::Array4< const amrex::Real > &ay_arr, const amrex::Array4< const amrex::Real > &az_arr, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const bool fixed_rho)
amrex::Box TrimOpenBCCorner(amrex::Box b, const int dim, const amrex::Box &domain, const bool lo_open, const bool hi_open)
Definition: ERF_Advection.H:237
amrex::Vector< OpenBCPatch > OpenBCTangentPatches(const amrex::Box &b, const amrex::Box &domain, const bool xlo_open, const bool xhi_open, const bool ylo_open, const bool yhi_open)
Definition: ERF_Advection.H:291
OpenSide
Definition: ERF_Advection.H:214
void AdvectionSrcForMom_EB(const amrex::MFIter &mfi, const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Vector< amrex::Box > &bxx_grown, const amrex::Vector< amrex::Box > &bxy_grown, const amrex::Vector< amrex::Box > &bxz_grown, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const eb_ &ebfact, amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_u_arr, amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_v_arr, amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_w_arr, const amrex::Vector< amrex::iMultiFab > &physbnd_mask, const bool already_on_centroids, const int lo_z_face, const int hi_z_face, const amrex::Box &domain)
void AdvectionSrcForMom_StretchedDz(const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const int lo_z_face, const int hi_z_face)
void AdvectionSrcForOpenBC_Tangent_Ymom(const amrex::Box &bxy, const int &dir, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const bool do_lo=false)
void AdvectionSrcForScalars(const amrex::Box &bx, const int icomp, const int ncomp, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const amrex::Real > &vf_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h)
void AdvectionSrcForOpenBC_Tangent_Xmom(const amrex::Box &bxx, const int &dir, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const bool do_lo=false)
void AdvectionSrcForMom_TF(const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const int lo_z_face, const int hi_z_face)
void AdvectionSrcForOpenBC_Tangent_Cons(const amrex::Box &bx, const OpenSide x_side, const OpenSide y_side, const int &icomp, const int &ncomp, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv)
void AdvectionSrcForOpenBC_Normal(const amrex::Box &bx, const int &dir, const amrex::Array4< amrex::Real > &rhs_arr, const amrex::Array4< const amrex::Real > &vel_norm_arr, const amrex::Array4< const amrex::Real > &cell_data_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const bool do_lo=false)
void AdvectionSrcForOpenBC_Tangent_Scalars(const amrex::Box &bx, const OpenSide x_side, const OpenSide y_side, const int scalar_icomp, const int rhs_icomp, const int ncomp, const amrex::Array4< amrex::Real > &rhs, const amrex::Array4< const amrex::Real > &scalar, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForOpenBC_Tangent(const int &i, const int &j, const int &k, const int &nprim, const int &dir, const amrex::Array4< const amrex::Real > &prim_tang_arr, const amrex::Array4< const amrex::Real > &mom_norm_arr, const amrex::Real &dxInv, const bool do_lo=false)
void AdvectionSrcForMom_ConstantDz(const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, TerrainType &terrain_type, const int lo_z_face, const int hi_z_face)
amrex::Box OpenBCCornerBox(amrex::Box b, const amrex::Box &domain, const OpenSide x_side, const OpenSide y_side)
Definition: ERF_Advection.H:259
void AdvectionSrcForOpenBC_Tangent_Zmom(const amrex::Box &bxz, const OpenSide x_side, const OpenSide y_side, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const int domhi_z)
amrex::Box ShrinkZmomBoxAtDomainEnds(amrex::Box b, const amrex::Box &domain)
Definition: ERF_Advection.H:203
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE AdvType EfficientAdvType(int nrk, AdvType adv_type)
Definition: ERF_Advection.H:467
Declares the embedded-boundary factory manager used by ERF levels.
AdvType
Definition: ERF_IndexDefines.H:309
@ Centered_4th
@ Centered_2nd
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:17
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int idx(int i, int j, int k, int nx, int ny)
Definition: ERF_InitForEnsemble.cpp:396
Real w
Definition: ERF_Plotfile2DInterpolator.cpp:22
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Owns and exposes cell-centered and face-centered EB factories.
Definition: ERF_EB.H:24
@ rho
Definition: ERF_Kessler.H:25
@ omega
Definition: ERF_Morrison.H:55
Definition: ERF_Advection.H:217
amrex::Box box
Definition: ERF_Advection.H:218
OpenSide y_side
Definition: ERF_Advection.H:220
OpenSide x_side
Definition: ERF_Advection.H:219