ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_AdvectionSrcForOpenBC.cpp File Reference
#include <ERF_Advection.H>
Include dependency graph for ERF_AdvectionSrcForOpenBC.cpp:

Functions

void AdvectionSrcForOpenBC_Normal (const Box &bx, const int &dir, const Array4< Real > &rhs_arr, const Array4< const Real > &vel_norm_arr, const Array4< const Real > &cell_data_arr, const Array4< const Real > &mf_norm, const GpuArray< Real, AMREX_SPACEDIM > &dxInv, const bool do_lo)
 
void AdvectionSrcForOpenBC_Tangent_Xmom (const Box &bxx, const int &dir, const Array4< Real > &rho_u_rhs, const Array4< const Real > &u, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Array4< const Real > &Omega, const Array4< const Real > &ax, const Array4< const Real > &az, const Array4< const Real > &detJ, const Array4< const Real > &mf_ux, const Array4< const Real > &mf_uy, const Array4< const Real > &mf_vx, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const bool do_lo)
 
void AdvectionSrcForOpenBC_Tangent_Ymom (const Box &bxy, const int &dir, const Array4< Real > &rho_v_rhs, const Array4< const Real > &v, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Array4< const Real > &Omega, const Array4< const Real > &ay, const Array4< const Real > &az, const Array4< const Real > &detJ, const Array4< const Real > &mf_vx, const Array4< const Real > &mf_vy, const Array4< const Real > &mf_uy, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const bool do_lo)
 
void AdvectionSrcForOpenBC_Tangent_Zmom (const Box &bxz, const OpenSide x_side, const OpenSide y_side, const Array4< Real > &rho_w_rhs, const Array4< const Real > &w, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Array4< const Real > &Omega, const Array4< const Real > &ax, const Array4< const Real > &ay, const Array4< const Real > &az, const Array4< const Real > &detJ, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_my, const Array4< const Real > &mf_uy, const Array4< const Real > &mf_vx, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const int domhi_z)
 
void AdvectionSrcForOpenBC_Tangent_Scalars (const Box &bx, const OpenSide x_side, const OpenSide y_side, const int scalar_icomp, const int rhs_icomp, const int ncomp, const Array4< Real > &cell_rhs, const Array4< const Real > &cell_prim, const Array4< const Real > &avg_xmom, const Array4< const Real > &avg_ymom, const Array4< const Real > &avg_zmom, const Array4< const Real > &detJ, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_my, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv)
 
void AdvectionSrcForOpenBC_Tangent_Cons (const Box &bx, const OpenSide x_side, const OpenSide y_side, const int &icomp, const int &ncomp, const Array4< Real > &cell_rhs, const Array4< const Real > &cell_prim, const Array4< const Real > &avg_xmom, const Array4< const Real > &avg_ymom, const Array4< const Real > &avg_zmom, const Array4< const Real > &detJ, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_my, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv)
 
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Real AdvectionSrcForOpenBC_Tangent (const int &i, const int &j, const int &k, const int &nprim, const int &dir, const Array4< const Real > &prim_tang_arr, const Array4< const Real > &mom_norm_arr, const Array4< const Real > &mf_norm, const Real &dxInv, const bool do_lo, const bool avg_x, const bool avg_y, const bool avg_z)
 

Function Documentation

◆ AdvectionSrcForOpenBC_Normal()

void AdvectionSrcForOpenBC_Normal ( const Box &  bx,
const int &  dir,
const Array4< Real > &  rhs_arr,
const Array4< const Real > &  vel_norm_arr,
const Array4< const Real > &  cell_data_arr,
const Array4< const Real > &  mf_norm,
const GpuArray< Real, AMREX_SPACEDIM > &  dxInv,
const bool  do_lo 
)

Compute advection tendencies for momentum normal to an open boundary.

Parameters
[in]bxbox over which the boundary-normal momentum is updated
[in]dircoordinate direction normal to the open boundary
[out]rhs_arrtendency for the boundary-normal momentum equation
[in]vel_norm_arrvelocity component normal to the open boundary
[in]cell_data_arrcell-centered conservative state
[in]mf_normmap factor in direction dir at the cell center (mf_mx for dir 0, mf_my for dir 1)
[in]dxInvinverse grid spacing
[in]do_loflag for a low-side open boundary
27 {
28  // NOTE: Klemp, J. B., and R. Wilhelmson, 1978: The simulation of three-dimensional
29  // convective storm dynamics, J. Atmos. Sci., 35, 1070-Real(1096.)
30  // NOTE: Implementation is for the high bndry side. The low bndry side is obtained
31  // by flipping sgn = -one
32  // NOTE: Indices (i,j,k) correspond to data that is ON the open bdy.
33  int sgn = 1; if (do_lo) sgn = -1;
34  Real c_o_star = Real(sgn)*Real(30.0);
35  ParallelFor(bx, [=,zero_d=zero] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
36  {
37  IntVect ivu1(i,j,k); if ( do_lo) ivu1[dir] -= sgn; // Vel indexed into domain for do_lo
38  IntVect ivu2(i,j,k); if (!do_lo) ivu2[dir] -= sgn; // Vel indexed into domain for do_hi
39 
40  IntVect ivr1(i,j,k); if (!do_lo) ivr1[dir] -= sgn; // Rho indexed into domain for do_hi
41  IntVect ivr2(i,j,k); if ( do_lo) ivr2[dir] += sgn; // Rho indexed out domain for do_lo
42 
43  Real rho_face = myhalf * ( cell_data_arr(ivr1,Rho_comp) + cell_data_arr(ivr2,Rho_comp) );
44  Real mom_star = rho_face * Real(sgn) * max( Real(sgn)*(vel_norm_arr(ivu1) + c_o_star), zero_d );
45  // Physical gradient: m_x d/dxi or m_y d/deta, with the map factor at the interior
46  // cell center where the velocity difference is centered
47  Real vel_grad = ( vel_norm_arr(ivu1) - vel_norm_arr(ivu2) ) * dxInv[dir] * mf_norm(ivr1[0],ivr1[1],0);
48  Real flux = -( mom_star * vel_grad );
49  rhs_arr(i,j,k) = flux;
50  });
51 }
#define Rho_comp
Definition: ERF_IndexDefines.H:61
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:16
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
Here is the call graph for this function:

◆ AdvectionSrcForOpenBC_Tangent()

AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Real AdvectionSrcForOpenBC_Tangent ( const int &  i,
const int &  j,
const int &  k,
const int &  nprim,
const int &  dir,
const Array4< const Real > &  prim_tang_arr,
const Array4< const Real > &  mom_norm_arr,
const Array4< const Real > &  mf_norm,
const Real &  dxInv,
const bool  do_lo,
const bool  avg_x,
const bool  avg_y,
const bool  avg_z 
)

Compute the open-boundary normal-direction source for a tangential primitive variable.

Parameters
[in]ii-index of the target cell
[in]jj-index of the target cell
[in]kk-index of the target cell
[in]nprimprimitive component to update
[in]dircoordinate direction normal to the open boundary
[in]prim_tang_arrprimitive variable tangent to the open boundary
[in]mom_norm_arrmomentum component normal to the open boundary
[in]mf_normmap factor that turns mom_norm_arr into a mass flux (m_y at x-faces, m_x at y-faces); empty when mom_norm_arr is already a mass flux
[in]dxInvinverse grid spacing in the open-boundary normal direction
[in]do_loflag for a low-side open boundary
[in]avg_xaverage mom_norm_arr over i and i-1 (x-momentum location)
[in]avg_yaverage mom_norm_arr over j and j-1 (y-momentum location)
[in]avg_zaverage mom_norm_arr over k and k-1 (z-momentum location)
Returns
source contribution before the wrapper applies its sign convention
445 {
446  // NOTE: Klemp, J. B., and R. Wilhelmson, 1978: The simulation of three-dimensional
447  // convective storm dynamics, J. Atmos. Sci., 35, 1070-Real(1096.)
448  // NOTE: Implementation is for the high bndry side. The low bndry side is obtained
449  // by flipping sgn = -one
450 
451  int sgn = 1; if (do_lo) { sgn = -1; }
452 
453  // NOTE: The indices (i,j,k) passed to this routine correspond to data that resides
454  // 1/2 dx away from the open boundary and into the domain. The momentum is
455  // face centered in dir, so it has one more cell than the scalar and cell
456  // (i,j,k) is bounded by the faces (i,j,k) and (i,j,k)+e_dir. One of those two
457  // faces resides on the physical boundary: the high face at a high open bndry,
458  // the low face at a low open bndry. Averaging and differencing that same pair
459  // of faces therefore yields the cell centered momentum and its exact cell
460  // centered gradient on both sides, so no sgn dependence is needed here.
461  // When the primitive is face centered in a tangential direction (avg_x/y/z),
462  // the same pair of faces offset by -1 in that direction is averaged in too,
463  // matching the interior flux kernels.
464  IntVect ivm1(i,j,k); ivm1[dir] += 1; // Mom on the high face of cell (i,j,k)
465  IntVect ivm2(i,j,k); // Mom on the low face of cell (i,j,k)
466 
467  IntVect ivs1(i,j,k); if ( do_lo) { ivs1[dir] -= sgn; } // Scalar indexed into domain for do_lo
468  IntVect ivs2(i,j,k); if (!do_lo) { ivs2[dir] -= sgn; } // Scalar indexed into domain for do_hi
469 
470  IntVect ivm3 = ivm1;
471  IntVect ivm4 = ivm2;
472  if (avg_x) {
473  ivm3[0] -= 1;
474  ivm4[0] -= 1;
475  }
476  if (avg_y) {
477  ivm3[1] -= 1;
478  ivm4[1] -= 1;
479  }
480  if (avg_z) {
481  ivm3[2] -= 1;
482  ivm4[2] -= 1;
483  }
484 
485  // Mass flux through the two faces (rho u / m_y at x-faces, rho v / m_x at y-faces);
486  // the caller multiplies the result by the m_x m_y prefactor of the variable
487  Real mom1 = mom_norm_arr(ivm1);
488  Real mom2 = mom_norm_arr(ivm2);
489  Real mom3 = mom_norm_arr(ivm3);
490  Real mom4 = mom_norm_arr(ivm4);
491  if (mf_norm) {
492  mom1 /= mf_norm(ivm1[0],ivm1[1],0);
493  mom2 /= mf_norm(ivm2[0],ivm2[1],0);
494  mom3 /= mf_norm(ivm3[0],ivm3[1],0);
495  mom4 /= mf_norm(ivm4[0],ivm4[1],0);
496  }
497 
498  Real mom_at_prim = fourth * (mom1 + mom2 + mom3 + mom4);
499  Real mom_star = Real(sgn) * max( Real(sgn)*mom_at_prim, zero );
500  Real mom_grad = myhalf * ( mom1 - mom2 + mom3 - mom4 ) * dxInv;
501  Real prim_grad = ( prim_tang_arr(ivs1,nprim) - prim_tang_arr(ivs2,nprim) ) * dxInv;
502 
503  // NOTE: Negative sign taken care of by wrapper function
504  Real src = ( mom_star*prim_grad + prim_tang_arr(i,j,k,nprim)*mom_grad );
505  return src;
506 }
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:42

Referenced by AdvectionSrcForOpenBC_Tangent_Scalars(), AdvectionSrcForOpenBC_Tangent_Xmom(), AdvectionSrcForOpenBC_Tangent_Ymom(), and AdvectionSrcForOpenBC_Tangent_Zmom().

Here is the caller graph for this function:

◆ AdvectionSrcForOpenBC_Tangent_Cons()

void AdvectionSrcForOpenBC_Tangent_Cons ( const Box &  bx,
const OpenSide  x_side,
const OpenSide  y_side,
const int &  icomp,
const int &  ncomp,
const Array4< Real > &  cell_rhs,
const Array4< const Real > &  cell_prim,
const Array4< const Real > &  avg_xmom,
const Array4< const Real > &  avg_ymom,
const Array4< const Real > &  avg_zmom,
const Array4< const Real > &  detJ,
const Array4< const Real > &  mf_mx,
const Array4< const Real > &  mf_my,
const GpuArray< Real, AMREX_SPACEDIM > &  cellSizeInv 
)

Adapt the native conserved-state layout to the component-explicit scalar open-BC operation.

400 {
401  AMREX_ALWAYS_ASSERT(icomp > 0);
402  AdvectionSrcForOpenBC_Tangent_Scalars(bx, x_side, y_side,
403  icomp - 1, icomp, ncomp,
404  cell_rhs, cell_prim,
405  avg_xmom, avg_ymom, avg_zmom,
406  detJ, mf_mx, mf_my, cellSizeInv);
407 }
void AdvectionSrcForOpenBC_Tangent_Scalars(const Box &bx, const OpenSide x_side, const OpenSide y_side, const int scalar_icomp, const int rhs_icomp, const int ncomp, const Array4< Real > &cell_rhs, const Array4< const Real > &cell_prim, const Array4< const Real > &avg_xmom, const Array4< const Real > &avg_ymom, const Array4< const Real > &avg_zmom, const Array4< const Real > &detJ, const Array4< const Real > &mf_mx, const Array4< const Real > &mf_my, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv)
Definition: ERF_AdvectionSrcForOpenBC.cpp:311
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
Here is the call graph for this function:

◆ AdvectionSrcForOpenBC_Tangent_Scalars()

void AdvectionSrcForOpenBC_Tangent_Scalars ( const Box &  bx,
const OpenSide  x_side,
const OpenSide  y_side,
const int  scalar_icomp,
const int  rhs_icomp,
const int  ncomp,
const Array4< Real > &  cell_rhs,
const Array4< const Real > &  cell_prim,
const Array4< const Real > &  avg_xmom,
const Array4< const Real > &  avg_ymom,
const Array4< const Real > &  avg_zmom,
const Array4< const Real > &  detJ,
const Array4< const Real > &  mf_mx,
const Array4< const Real > &  mf_my,
const GpuArray< Real, AMREX_SPACEDIM > &  cellSizeInv 
)

Compute second-order advection tendencies for scalar fields tangent to an open boundary.

Parameters
[in]bxbox over which the scalar tendencies are updated
[in]x_sidewhich x boundary the cells lie on, if any
[in]y_sidewhich y boundary the cells lie on, if any
[in]scalar_icompfirst component of the supplied scalar view to read
[in]rhs_icompfirst component of the supplied tendency view to write
[in]ncompnumber of components to update
[out]cell_rhstendency view
[in]cell_primsupplied scalar view
[in]avg_xmomx-component of time-averaged mass flux (already carries 1/m_y)
[in]avg_ymomy-component of time-averaged mass flux (already carries 1/m_x)
[in]avg_zmomz-component of time-averaged mass flux (already carries 1/(m_x m_y))
[in]detJJacobian of the metric transformation
[in]mf_mxx map factor at cell centers
[in]mf_myy map factor at cell centers
[in]cellSizeInvinverse grid spacing
326 {
327  // At a corner both sides are set, and neither x nor y may be differenced across
328  const bool xopen = (x_side != OpenSide::none);
329  const bool yopen = (y_side != OpenSide::none);
330  const bool x_do_lo = (x_side == OpenSide::lo);
331  const bool y_do_lo = (y_side == OpenSide::lo);
332 
333  AMREX_ALWAYS_ASSERT(xopen || yopen);
334 
335  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
336 
337  ParallelFor(bx, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
338  {
339  if (detJ(i,j,k) > zero) {
340  const int scalar_comp = scalar_icomp + n;
341  const int rhs_comp = rhs_icomp + n;
342  Real prim_xlo = myhalf * (cell_prim(i,j,k,scalar_comp) + cell_prim(i-1,j,k,scalar_comp));
343  Real prim_xhi = myhalf * (cell_prim(i,j,k,scalar_comp) + cell_prim(i+1,j,k,scalar_comp));
344  Real xflux_lo = avg_xmom(i ,j,k) * prim_xlo;
345  Real xflux_hi = avg_xmom(i+1,j,k) * prim_xhi;
346 
347  Real prim_ylo = myhalf * (cell_prim(i,j,k,scalar_comp) + cell_prim(i,j-1,k,scalar_comp));
348  Real prim_yhi = myhalf * (cell_prim(i,j,k,scalar_comp) + cell_prim(i,j+1,k,scalar_comp));
349  Real yflux_lo = avg_ymom(i,j ,k) * prim_ylo;
350  Real yflux_hi = avg_ymom(i,j+1,k) * prim_yhi;
351 
352  Real prim_zlo = myhalf * (cell_prim(i,j,k,scalar_comp) + cell_prim(i,j,k-1,scalar_comp));
353  Real prim_zhi = myhalf * (cell_prim(i,j,k,scalar_comp) + cell_prim(i,j,k+1,scalar_comp));
354  Real zflux_lo = avg_zmom(i,j,k ) * prim_zlo;
355  Real zflux_hi = avg_zmom(i,j,k+1) * prim_zhi;
356 
357  // No averaging needed for CC scalars
358  bool avg_x = false;
359  bool avg_y = false;
360  bool avg_z = false;
361 
362  Real x_src = (xopen) ? AdvectionSrcForOpenBC_Tangent(i, j, k,
363  scalar_comp, 0, cell_prim,
364  avg_xmom, Array4<const Real>{},
365  dxInv, x_do_lo, avg_x, avg_y, avg_z) :
366  (xflux_hi - xflux_lo) * dxInv;
367  Real y_src = (yopen) ? AdvectionSrcForOpenBC_Tangent(i, j, k,
368  scalar_comp, 1, cell_prim,
369  avg_ymom, Array4<const Real>{},
370  dyInv, y_do_lo, avg_x, avg_y, avg_z) :
371  (yflux_hi - yflux_lo) * dyInv;
372  Real z_src = (zflux_hi - zflux_lo) * dzInv;
373  // As in ApplyScalarAdvectionFluxDivergence: the averaged fluxes carry the map
374  // factors, so the whole divergence (vertical included) takes the m_x m_y prefactor
375  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
376  Real advectionSrc = (x_src + y_src + z_src) * mfsq;
377  cell_rhs(i,j,k,rhs_comp) = -advectionSrc / detJ(i,j,k);
378  }
379  });
380 }
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Real AdvectionSrcForOpenBC_Tangent(const int &i, const int &j, const int &k, const int &nprim, const int &dir, const Array4< const Real > &prim_tang_arr, const Array4< const Real > &mom_norm_arr, const Array4< const Real > &mf_norm, const Real &dxInv, const bool do_lo, const bool avg_x, const bool avg_y, const bool avg_z)
Definition: ERF_AdvectionSrcForOpenBC.cpp:432

Referenced by AdvectionSrcForOpenBC_Tangent_Cons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AdvectionSrcForOpenBC_Tangent_Xmom()

void AdvectionSrcForOpenBC_Tangent_Xmom ( const Box &  bxx,
const int &  dir,
const Array4< Real > &  rho_u_rhs,
const Array4< const Real > &  u,
const Array4< const Real > &  rho_u,
const Array4< const Real > &  rho_v,
const Array4< const Real > &  Omega,
const Array4< const Real > &  ax,
const Array4< const Real > &  az,
const Array4< const Real > &  detJ,
const Array4< const Real > &  mf_ux,
const Array4< const Real > &  mf_uy,
const Array4< const Real > &  mf_vx,
const GpuArray< Real, AMREX_SPACEDIM > &  cellSizeInv,
const bool  do_lo 
)

Compute second-order advection tendencies for x-momentum tangent to an open boundary.

Parameters
[in]bxxbox over which x-momentum is updated
[in]dircoordinate direction normal to the open boundary
[out]rho_u_rhstendency for the x-momentum equation
[in]ux-component of velocity
[in]rho_ux-component of momentum
[in]rho_vy-component of momentum
[in]Omegacomponent of momentum normal to the z-coordinate surface
[in]axarea fraction of x-faces
[in]azarea fraction of z-faces
[in]detJJacobian of the metric transformation
[in]mf_uxx map factor at x-faces
[in]mf_uyy map factor at x-faces
[in]mf_vxx map factor at y-faces
[in]cellSizeInvinverse grid spacing
[in]do_loflag for a low-side open boundary
88 {
89  AMREX_ALWAYS_ASSERT(dir==1);
90 
91  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
92 
93  ParallelFor(bxx,[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
94  {
95  if (ax(i,j,k) > zero) {
96  // The x-face mass flux is rho u / m_y
97  Real xflux_hi = fourth * (rho_u(i, j , k) / mf_uy(i,j,0) + rho_u(i+1, j , k) / mf_uy(i+1,j,0)) *
98  (u(i+1,j,k) + u(i,j,k)) * myhalf * (ax(i,j,k) + ax(i+1,j,k));
99  Real xflux_lo = fourth * (rho_u(i, j , k) / mf_uy(i,j,0) + rho_u(i-1, j , k) / mf_uy(i-1,j,0)) *
100  (u(i-1,j,k) + u(i,j,k)) * myhalf * (ax(i,j,k) + ax(i-1,j,k));
101 
102  Real zflux_hi = fourth * (Omega(i, j, k+1) + Omega(i-1, j, k+1)) * (u(i,j,k+1) + u(i,j,k)) * az(i,j,k+1);
103  Real zflux_lo = fourth * (Omega(i, j, k ) + Omega(i-1, j, k )) * (u(i,j,k-1) + u(i,j,k)) * az(i,j,k );
104 
105  Real mfsq = mf_ux(i,j,0) * mf_uy(i,j,0);
106 
107  // Average y-momenta to x-vel location
108  bool avg_x = true;
109  bool avg_y = false;
110  bool avg_z = false;
111 
112  Real x_src = (xflux_hi - xflux_lo) * dxInv;
113  Real y_src = AdvectionSrcForOpenBC_Tangent(i, j, k, 0, dir, u, rho_v, mf_vx, dyInv, do_lo, avg_x, avg_y, avg_z);
114  Real z_src = (zflux_hi - zflux_lo) * dzInv;
115  Real advectionSrc = (x_src + y_src) * mfsq + z_src;
116 
117  rho_u_rhs(i, j, k) = -advectionSrc / (myhalf * (detJ(i,j,k) + detJ(i-1,j,k)));
118  } else {
119  rho_u_rhs(i, j, k) = zero;
120  }
121  });
122 }
Here is the call graph for this function:

◆ AdvectionSrcForOpenBC_Tangent_Ymom()

void AdvectionSrcForOpenBC_Tangent_Ymom ( const Box &  bxy,
const int &  dir,
const Array4< Real > &  rho_v_rhs,
const Array4< const Real > &  v,
const Array4< const Real > &  rho_u,
const Array4< const Real > &  rho_v,
const Array4< const Real > &  Omega,
const Array4< const Real > &  ay,
const Array4< const Real > &  az,
const Array4< const Real > &  detJ,
const Array4< const Real > &  mf_vx,
const Array4< const Real > &  mf_vy,
const Array4< const Real > &  mf_uy,
const GpuArray< Real, AMREX_SPACEDIM > &  cellSizeInv,
const bool  do_lo 
)

Compute second-order advection tendencies for y-momentum tangent to an open boundary.

Parameters
[in]bxybox over which y-momentum is updated
[in]dircoordinate direction normal to the open boundary
[out]rho_v_rhstendency for the y-momentum equation
[in]vy-component of velocity
[in]rho_ux-component of momentum
[in]rho_vy-component of momentum
[in]Omegacomponent of momentum normal to the z-coordinate surface
[in]ayarea fraction of y-faces
[in]azarea fraction of z-faces
[in]detJJacobian of the metric transformation
[in]mf_vxx map factor at y-faces
[in]mf_vyy map factor at y-faces
[in]mf_uyy map factor at x-faces
[in]cellSizeInvinverse grid spacing
[in]do_loflag for a low-side open boundary
159 {
160  AMREX_ALWAYS_ASSERT(dir==0);
161 
162  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
163 
164  ParallelFor(bxy,[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
165  {
166  if (ay(i,j,k) > zero) {
167  // The y-face mass flux is rho v / m_x
168  Real yflux_hi = fourth * (rho_v(i ,j+1,k) / mf_vx(i,j+1,0) + rho_v(i ,j ,k) / mf_vx(i,j ,0)) *
169  (v(i,j+1,k) + v(i,j,k)) * myhalf * (ay(i,j,k) + ay(i,j+1,k));
170  Real yflux_lo = fourth * (rho_v(i ,j ,k) / mf_vx(i,j ,0) + rho_v(i ,j-1,k) / mf_vx(i,j-1,0)) *
171  (v(i,j-1,k) + v(i,j,k)) * myhalf * (ay(i,j,k) + ay(i,j-1,k));
172 
173  Real zflux_hi = fourth * (Omega(i, j, k+1) + Omega(i, j-1, k+1)) * (v(i,j,k+1) + v(i,j,k)) * az(i,j,k+1);
174  Real zflux_lo = fourth * (Omega(i, j, k ) + Omega(i, j-1, k )) * (v(i,j,k-1) + v(i,j,k)) * az(i,j,k );
175 
176  Real mfsq = mf_vx(i,j,0) * mf_vy(i,j,0);
177 
178  // Average x-momenta to y-vel location
179  bool avg_x = false;
180  bool avg_y = true;
181  bool avg_z = false;
182 
183  Real x_src = AdvectionSrcForOpenBC_Tangent(i, j, k, 0, dir, v, rho_u, mf_uy, dxInv, do_lo, avg_x, avg_y, avg_z);
184  Real y_src = (yflux_hi - yflux_lo) * dyInv;
185  Real z_src = (zflux_hi - zflux_lo) * dzInv;
186  Real advectionSrc = (x_src + y_src) * mfsq + z_src;
187 
188  rho_v_rhs(i, j, k) = -advectionSrc / (myhalf * (detJ(i,j,k) + detJ(i,j-1,k)));
189  } else {
190  rho_v_rhs(i, j, k) = zero;
191  }
192  });
193 }
Here is the call graph for this function:

◆ AdvectionSrcForOpenBC_Tangent_Zmom()

void AdvectionSrcForOpenBC_Tangent_Zmom ( const Box &  bxz,
const OpenSide  x_side,
const OpenSide  y_side,
const Array4< Real > &  rho_w_rhs,
const Array4< const Real > &  w,
const Array4< const Real > &  rho_u,
const Array4< const Real > &  rho_v,
const Array4< const Real > &  Omega,
const Array4< const Real > &  ax,
const Array4< const Real > &  ay,
const Array4< const Real > &  az,
const Array4< const Real > &  detJ,
const Array4< const Real > &  mf_mx,
const Array4< const Real > &  mf_my,
const Array4< const Real > &  mf_uy,
const Array4< const Real > &  mf_vx,
const GpuArray< Real, AMREX_SPACEDIM > &  cellSizeInv,
const int  domhi_z 
)

Compute second-order advection tendencies for z-momentum tangent to an open boundary.

Parameters
[in]bxzbox over which z-momentum is updated
[in]x_sidewhich x boundary the cells lie on, if any
[in]y_sidewhich y boundary the cells lie on, if any
[out]rho_w_rhstendency for the z-momentum equation
[in]wz-component of velocity
[in]rho_ux-component of momentum
[in]rho_vy-component of momentum
[in]Omegacomponent of momentum normal to the z-coordinate surface
[in]axarea fraction of x-faces
[in]ayarea fraction of y-faces
[in]azarea fraction of z-faces
[in]detJJacobian of the metric transformation
[in]mf_mxx map factor at cell centers
[in]mf_myy map factor at cell centers
[in]mf_uyy map factor at x-faces
[in]mf_vxx map factor at y-faces
[in]cellSizeInvinverse grid spacing
[in]domhi_zmaximum cell-centered k-index in the domain
236 {
237  // At a corner both sides are set, and neither x nor y may be differenced across
238  const bool xopen = (x_side != OpenSide::none);
239  const bool yopen = (y_side != OpenSide::none);
240  const bool x_do_lo = (x_side == OpenSide::lo);
241  const bool y_do_lo = (y_side == OpenSide::lo);
242 
243  AMREX_ALWAYS_ASSERT(xopen || yopen);
244 
245  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
246 
247  ParallelFor(bxz, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
248  {
249  if (az(i,j,k) > zero) {
250  // The x-face mass flux is rho u / m_y and the y-face mass flux is rho v / m_x
251  Real xflux_hi = fourth*(rho_u(i+1,j ,k) + rho_u(i+1, j, k-1)) / mf_uy(i+1,j,0) * (w(i+1,j,k) + w(i,j,k)) *
252  myhalf *(ax(i+1,j,k) + ax(i+1,j,k-1));
253 
254  Real xflux_lo = fourth*(rho_u(i ,j ,k) + rho_u(i , j, k-1)) / mf_uy(i ,j,0) * (w(i-1,j,k) + w(i,j,k)) *
255  myhalf *(ax(i,j,k) + ax(i,j,k-1));
256 
257  Real yflux_hi = fourth*(rho_v(i ,j+1,k) + rho_v(i, j+1, k-1)) / mf_vx(i,j+1,0) * (w(i,j+1,k) + w(i,j,k)) *
258  myhalf *(ay(i,j+1,k) + ay(i,j+1,k-1));
259 
260  Real yflux_lo = fourth*(rho_v(i ,j ,k) + rho_v(i, j , k-1)) / mf_vx(i,j ,0) * (w(i,j-1,k) + w(i,j,k)) *
261  myhalf *(ay(i,j,k) + ay(i,j,k-1));
262 
263  Real zflux_lo = fourth * (Omega(i,j,k) + Omega(i,j,k-1)) * (w(i,j,k) + w(i,j,k-1)) *
264  myhalf *(az(i,j,k) + az(i,j,k-1));
265 
266  Real zflux_hi = (k == domhi_z+1) ? Omega(i,j,k) * w(i,j,k) * az(i,j,k):
267  fourth * (Omega(i,j,k) + Omega(i,j,k+1)) * (w(i,j,k) + w(i,j,k+1)) *
268  myhalf * (az(i,j,k) + az(i,j,k+1));
269 
270  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
271 
272  // Average x/y-momenta to w-vel location
273  bool avg_x = false;
274  bool avg_y = false;
275  bool avg_z = true;
276 
277  Real x_src = (xopen) ? AdvectionSrcForOpenBC_Tangent(i, j, k, 0, 0, w, rho_u, mf_uy, dxInv, x_do_lo, avg_x, avg_y, avg_z) :
278  (xflux_hi - xflux_lo) * dxInv;
279  Real y_src = (yopen) ? AdvectionSrcForOpenBC_Tangent(i, j, k, 0, 1, w, rho_v, mf_vx, dyInv, y_do_lo, avg_x, avg_y, avg_z) :
280  (yflux_hi - yflux_lo) * dyInv;
281  Real z_src = (zflux_hi - zflux_lo) * dzInv;
282  Real advectionSrc = (x_src + y_src) * mfsq + z_src;
283 
284  rho_w_rhs(i, j, k) = -advectionSrc / (myhalf*(detJ(i,j,k) + detJ(i,j,k-1)));
285  } else {
286  rho_w_rhs(i, j, k) = zero;
287  }
288  });
289 }
Here is the call graph for this function: