ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ERF_AdvectionSrcForMom_T.H File Reference
Include dependency graph for ERF_AdvectionSrcForMom_T.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename InterpType_H , typename InterpType_V >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForXMom (int i, int j, int k, 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 > &, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, InterpType_H interp_u_h, InterpType_V interp_u_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_ux_inv, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv)
 
template<typename InterpType_H , typename InterpType_V >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForYMom (int i, int j, int k, 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 > &, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, InterpType_H interp_v_h, InterpType_V interp_v_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv, const amrex::Array4< const amrex::Real > &mf_vy_inv)
 
template<typename InterpType_H , typename InterpType_V , typename WallInterpType >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForZMom (int i, int j, int k, 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 > &w, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, InterpType_H interp_omega_h, InterpType_V interp_omega_v, WallInterpType interp_omega_wall, 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_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv, const AdvType vert_adv_type, const int lo_z_face, const int hi_z_face)
 
template<typename InterpType_H , typename InterpType_V , typename WallInterpType >
void AdvectionSrcForMomWrapper (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 > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, 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 > &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_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vy_inv, const amrex::Real upw_frac_h, const amrex::Real upw_frac_v, const AdvType vert_adv_type, const int lo_z_face, const int hi_z_face)
 
template<typename InterpType_H >
void AdvectionSrcForMomVert (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 > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, 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 > &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_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vy_inv, const amrex::Real upw_frac_h, const amrex::Real upw_frac_v, const AdvType vert_adv_type, const int lo_z_face, const int hi_z_face)
 

Function Documentation

◆ AdvectionSrcForMomVert()

template<typename InterpType_H >
void AdvectionSrcForMomVert ( 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 > &  rho_u,
const amrex::Array4< const amrex::Real > &  rho_v,
const amrex::Array4< const amrex::Real > &  Omega,
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 > &  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_inv,
const amrex::Array4< const amrex::Real > &  mf_vx_inv,
const amrex::Array4< const amrex::Real > &  mf_my,
const amrex::Array4< const amrex::Real > &  mf_uy_inv,
const amrex::Array4< const amrex::Real > &  mf_vy_inv,
const amrex::Real  upw_frac_h,
const amrex::Real  upw_frac_v,
const AdvType  vert_adv_type,
const int  lo_z_face,
const int  hi_z_face 
)

Wrapper function for computing the advective tendency w/ spatial order > 2.

440 {
441  if (vert_adv_type == AdvType::Centered_2nd) {
442  AdvectionSrcForMomWrapper<InterpType_H,CENTERED2,UPWINDALL>(bxx, bxy, bxz,
443  rho_u_rhs, rho_v_rhs, rho_w_rhs,
444  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
445  cellSizeInv,
446  mf_mx, mf_ux_inv, mf_vx_inv,
447  mf_my, mf_uy_inv, mf_vy_inv,
448  upw_frac_h, upw_frac_v,
449  vert_adv_type, lo_z_face, hi_z_face);
450  } else if (vert_adv_type == AdvType::Upwind_3rd) {
451  AdvectionSrcForMomWrapper<InterpType_H,UPWIND3,UPWINDALL>(bxx, bxy, bxz,
452  rho_u_rhs, rho_v_rhs, rho_w_rhs,
453  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
454  cellSizeInv,
455  mf_mx, mf_ux_inv, mf_vx_inv,
456  mf_my, mf_uy_inv, mf_vy_inv,
457  upw_frac_h, upw_frac_v,
458  vert_adv_type, lo_z_face, hi_z_face);
459  } else if (vert_adv_type == AdvType::Centered_4th) {
460  AdvectionSrcForMomWrapper<InterpType_H,CENTERED4,UPWINDALL>(bxx, bxy, bxz,
461  rho_u_rhs, rho_v_rhs, rho_w_rhs,
462  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
463  cellSizeInv,
464  mf_mx, mf_ux_inv, mf_vx_inv,
465  mf_my, mf_uy_inv, mf_vy_inv,
466  upw_frac_h, upw_frac_v,
467  vert_adv_type, lo_z_face, hi_z_face);
468  } else if (vert_adv_type == AdvType::Upwind_5th) {
469  AdvectionSrcForMomWrapper<InterpType_H,UPWIND5,UPWINDALL>(bxx, bxy, bxz,
470  rho_u_rhs, rho_v_rhs, rho_w_rhs,
471  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
472  cellSizeInv,
473  mf_mx, mf_ux_inv, mf_vx_inv,
474  mf_my, mf_uy_inv, mf_vy_inv,
475  upw_frac_h, upw_frac_v,
476  vert_adv_type, lo_z_face, hi_z_face);
477  } else if (vert_adv_type == AdvType::Centered_6th) {
478  AdvectionSrcForMomWrapper<InterpType_H,CENTERED6,UPWINDALL>(bxx, bxy, bxz,
479  rho_u_rhs, rho_v_rhs, rho_w_rhs,
480  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
481  cellSizeInv,
482  mf_mx, mf_ux_inv, mf_vx_inv,
483  mf_my, mf_uy_inv, mf_vy_inv,
484  upw_frac_h, upw_frac_v,
485  vert_adv_type, lo_z_face, hi_z_face);
486  } else {
487  AMREX_ASSERT_WITH_MESSAGE(false, "Unknown advection scheme!");
488  }
489 }
@ Centered_4th
@ Centered_6th
@ Centered_2nd

◆ AdvectionSrcForMomWrapper()

template<typename InterpType_H , typename InterpType_V , typename WallInterpType >
void AdvectionSrcForMomWrapper ( 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 > &  rho_u,
const amrex::Array4< const amrex::Real > &  rho_v,
const amrex::Array4< const amrex::Real > &  Omega,
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 > &  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_inv,
const amrex::Array4< const amrex::Real > &  mf_vx_inv,
const amrex::Array4< const amrex::Real > &  mf_my,
const amrex::Array4< const amrex::Real > &  mf_uy_inv,
const amrex::Array4< const amrex::Real > &  mf_vy_inv,
const amrex::Real  upw_frac_h,
const amrex::Real  upw_frac_v,
const AdvType  vert_adv_type,
const int  lo_z_face,
const int  hi_z_face 
)

Wrapper function for computing the advective tendency w/ spatial order > 2.

376 {
377  // Instantiate the appropriate structs
378  InterpType_H interp_u_h(u, upw_frac_h); InterpType_V interp_u_v(u, upw_frac_v); // X-MOM
379  InterpType_H interp_v_h(v, upw_frac_h); InterpType_V interp_v_v(v, upw_frac_v); // Y-MOM
380  InterpType_H interp_w_h(w, upw_frac_h); InterpType_V interp_w_v(w, upw_frac_v); // Z-MOM
381  WallInterpType interp_w_wall(w, upw_frac_v); // Z-MOM @ wall
382 
383  amrex::ParallelFor(bxx,
384  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
385  {
386  rho_u_rhs(i, j, k) = -AdvectionSrcForXMom(i, j, k, rho_u, rho_v, Omega, z_nd, ax, ay, az, detJ,
387  interp_u_h, interp_u_v,
388  cellSizeInv, mf_ux_inv, mf_uy_inv, mf_vx_inv);
389  });
390 
391  amrex::ParallelFor(bxy,
392  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
393  {
394  rho_v_rhs(i, j, k) = -AdvectionSrcForYMom(i, j, k, rho_u, rho_v, Omega, z_nd, ax, ay, az, detJ,
395  interp_v_h, interp_v_v,
396  cellSizeInv, mf_uy_inv, mf_vx_inv, mf_vy_inv);
397  });
398 
399  amrex::ParallelFor(bxz,
400  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
401  {
402  rho_w_rhs(i, j, k) = -AdvectionSrcForZMom(i, j, k, rho_u, rho_v, Omega, w, z_nd, ax, ay, az, detJ,
403  interp_w_h, interp_w_v, interp_w_wall,
404  cellSizeInv, mf_mx, mf_my, mf_uy_inv, mf_vx_inv,
405  vert_adv_type, lo_z_face, hi_z_face);
406  });
407 }
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForZMom(int i, int j, int k, 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 > &w, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, InterpType_H interp_omega_h, InterpType_V interp_omega_v, WallInterpType interp_omega_wall, 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_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv, const AdvType vert_adv_type, const int lo_z_face, const int hi_z_face)
Definition: ERF_AdvectionSrcForMom_T.H:220
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForYMom(int i, int j, int k, 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 > &, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, InterpType_H interp_v_h, InterpType_V interp_v_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv, const amrex::Array4< const amrex::Real > &mf_vy_inv)
Definition: ERF_AdvectionSrcForMom_T.H:121
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForXMom(int i, int j, int k, 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 > &, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, InterpType_H interp_u_h, InterpType_V interp_u_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_ux_inv, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv)
Definition: ERF_AdvectionSrcForMom_T.H:26
Here is the call graph for this function:

◆ AdvectionSrcForXMom()

template<typename InterpType_H , typename InterpType_V >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForXMom ( int  i,
int  j,
int  k,
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 > &  ,
const amrex::Array4< const amrex::Real > &  az,
const amrex::Array4< const amrex::Real > &  detJ,
InterpType_H  interp_u_h,
InterpType_V  interp_u_v,
const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  cellSizeInv,
const amrex::Array4< const amrex::Real > &  mf_ux_inv,
const amrex::Array4< const amrex::Real > &  mf_uy_inv,
const amrex::Array4< const amrex::Real > &  mf_vx_inv 
)

Function for computing the advective tendency for the x-component of momentum with metric terms and for spatial order > 2

Parameters
[in]i,j,kindices of x-face at which to create tendency
[in]rho_ux-component of momentum
[in]rho_vy-component of momentum
[in]Omegacomponent of the momentum normal to the z-coordinate surface
[in]z_ndheight coordinate at nodes
[in]axArea fractions on x-faces
[in]ayArea fractions on y-faces
[in]azArea fractions on z-faces
[in]detJJacobian of the metric transformation (= 1 if use_terrain is false)
[in]cellSizeInvinverse of the mesh spacing
[in]mf_umap factor on x-faces
[in]mf_vmap factor on y-faces
41 {
42  amrex::Real advectionSrc;
43  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
44 
45  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
46  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
47  amrex::Real Omega_avg_lo, Omega_avg_hi;
48 
49  amrex::Real interp_hi(0.), interp_lo(0.);
50 
51  // ****************************************************************************************
52  // X-fluxes (at cell centers)
53  // ****************************************************************************************
54 
55  rho_u_avg_hi = 0.5 * (rho_u(i+1, j, k) * mf_uy_inv(i+1,j ,0) + rho_u(i, j, k) * mf_uy_inv(i ,j ,0));
56  interp_u_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi);
57 
58  rho_u_avg_lo = 0.5 * (rho_u(i-1, j, k) * mf_uy_inv(i-1,j ,0) + rho_u(i, j, k) * mf_uy_inv(i ,j ,0));
59  interp_u_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo);
60 
61  amrex::Real centFluxXXNext = rho_u_avg_hi * interp_hi * 0.5 * (ax(i,j,k) + ax(i+1,j,k));
62  amrex::Real centFluxXXPrev = rho_u_avg_lo * interp_lo * 0.5 * (ax(i,j,k) + ax(i-1,j,k));
63 
64  // ****************************************************************************************
65  // Y-fluxes (at edges in k-direction)
66  // ****************************************************************************************
67  rho_v_avg_hi = 0.5 * (rho_v(i, j+1, k) * mf_vx_inv(i ,j+1,0) + rho_v(i-1, j+1, k) * mf_vx_inv(i-1,j+1,0));
68  interp_u_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi);
69 
70  rho_v_avg_lo = 0.5 * (rho_v(i, j , k) * mf_vx_inv(i ,j ,0) + rho_v(i-1, j , k) * mf_vx_inv(i-1,j ,0));
71  interp_u_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo);
72 
73  amrex::Real edgeFluxXYNext = rho_v_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterK(i,j+1,k,cellSizeInv,z_nd);
74  amrex::Real edgeFluxXYPrev = rho_v_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterK(i,j ,k,cellSizeInv,z_nd);
75 
76  // ****************************************************************************************
77  // Z-fluxes (at edges in j-direction)
78  // ****************************************************************************************
79  Omega_avg_hi = 0.5 * (Omega(i, j, k+1) + Omega(i-1, j, k+1)) * 0.5 * (az(i,j,k+1) + az(i-1,j,k+1));
80  Omega_avg_lo = 0.5 * (Omega(i, j, k ) + Omega(i-1, j, k )) * 0.5 * (az(i,j,k ) + az(i-1,j,k ));
81 
82  interp_u_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi);
83  interp_u_v.InterpolateInZ(i,j,k ,0,interp_lo,Omega_avg_lo);
84 
85  amrex::Real edgeFluxXZNext = Omega_avg_hi * interp_hi;
86  amrex::Real edgeFluxXZPrev = Omega_avg_lo * interp_lo;
87 
88  // ****************************************************************************************
89 
90  amrex::Real mfsq = 1. / (mf_ux_inv(i,j,0) * mf_uy_inv(i,j,0));
91 
92  advectionSrc = (centFluxXXNext - centFluxXXPrev) * dxInv * mfsq
93  + (edgeFluxXYNext - edgeFluxXYPrev) * dyInv * mfsq
94  + (edgeFluxXZNext - edgeFluxXZPrev) * dzInv;
95  advectionSrc /= 0.5*(detJ(i,j,k) + detJ(i-1,j,k));
96 
97  return advectionSrc;
98 }
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:231

Referenced by AdvectionSrcForMomWrapper().

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

◆ AdvectionSrcForYMom()

template<typename InterpType_H , typename InterpType_V >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForYMom ( int  i,
int  j,
int  k,
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 > &  ,
const amrex::Array4< const amrex::Real > &  ay,
const amrex::Array4< const amrex::Real > &  az,
const amrex::Array4< const amrex::Real > &  detJ,
InterpType_H  interp_v_h,
InterpType_V  interp_v_v,
const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  cellSizeInv,
const amrex::Array4< const amrex::Real > &  mf_uy_inv,
const amrex::Array4< const amrex::Real > &  mf_vx_inv,
const amrex::Array4< const amrex::Real > &  mf_vy_inv 
)

Function for computing the advective tendency for the y-component of momentum with metric terms and for spatial order > 2

Parameters
[in]i,j,kindices of y-face at which to create tendency
[in]rho_ux-component of momentum
[in]rho_vy-component of momentum
[in]Omegacomponent of the momentum normal to the z-coordinate surface
[in]z_ndheight coordinate at nodes
[in]axArea fractions on x-faces
[in]ayArea fractions on y-faces
[in]azArea fractions on z-faces
[in]detJJacobian of the metric transformation (= 1 if use_terrain is false)
[in]cellSizeInvinverse of the mesh spacing
[in]mf_umap factor on x-faces
[in]mf_vmap factor on y-faces
136 {
137  amrex::Real advectionSrc;
138  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
139 
140  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
141  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
142  amrex::Real Omega_avg_lo, Omega_avg_hi;
143 
144  amrex::Real interp_hi(0.), interp_lo(0.);
145 
146  // ****************************************************************************************
147  // x-fluxes (at edges in k-direction)
148  // ****************************************************************************************
149  rho_u_avg_hi = 0.5 * (rho_u(i+1,j,k) * mf_uy_inv(i+1,j,0) + rho_u(i+1,j-1,k) * mf_uy_inv(i+1,j-1,0));
150  rho_u_avg_lo = 0.5 * (rho_u(i ,j,k) * mf_uy_inv(i ,j,0) + rho_u(i ,j-1,k) * mf_uy_inv(i ,j-1,0));
151 
152  interp_v_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi);
153  interp_v_h.InterpolateInX(i ,j,k,0,interp_lo,rho_u_avg_lo);
154 
155  amrex::Real edgeFluxYXNext = rho_u_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterK(i+1,j,k,cellSizeInv,z_nd);
156  amrex::Real edgeFluxYXPrev = rho_u_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterK(i ,j,k,cellSizeInv,z_nd);
157 
158  // ****************************************************************************************
159  // y-fluxes (at cell centers)
160  // ****************************************************************************************
161  rho_v_avg_hi = 0.5 * (rho_v(i,j,k) * mf_vx_inv(i,j,0) + rho_v(i,j+1,k) * mf_vx_inv(i,j+1,0));
162  rho_v_avg_lo = 0.5 * (rho_v(i,j,k) * mf_vx_inv(i,j,0) + rho_v(i,j-1,k) * mf_vx_inv(i,j-1,0));
163 
164  interp_v_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi);
165  interp_v_h.InterpolateInY(i,j ,k,0,interp_lo,rho_v_avg_lo);
166 
167  amrex::Real centFluxYYNext = rho_v_avg_hi * 0.5 * (ay(i,j,k) + ay(i,j+1,k)) * interp_hi;
168  amrex::Real centFluxYYPrev = rho_v_avg_lo * 0.5 * (ay(i,j,k) + ay(i,j-1,k)) * interp_lo;
169 
170  // ****************************************************************************************
171  // Z-fluxes (at edges in j-direction)
172  // ****************************************************************************************
173  Omega_avg_hi = 0.5 * (Omega(i, j, k+1) + Omega(i, j-1, k+1)) * 0.5 * (az(i,j,k+1) + az(i,j-1,k+1));
174  Omega_avg_lo = 0.5 * (Omega(i, j, k ) + Omega(i, j-1, k )) * 0.5 * (az(i,j,k ) + az(i,j-1,k ));
175 
176  interp_v_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi);
177  interp_v_v.InterpolateInZ(i,j,k ,0,interp_lo,Omega_avg_lo);
178 
179  amrex::Real edgeFluxYZNext = Omega_avg_hi * interp_hi;
180  amrex::Real edgeFluxYZPrev = Omega_avg_lo * interp_lo;
181 
182  // ****************************************************************************************
183 
184  amrex::Real mfsq = 1 / (mf_vx_inv(i,j,0) * mf_vy_inv(i,j,0));
185 
186  advectionSrc = (edgeFluxYXNext - edgeFluxYXPrev) * dxInv * mfsq
187  + (centFluxYYNext - centFluxYYPrev) * dyInv * mfsq
188  + (edgeFluxYZNext - edgeFluxYZPrev) * dzInv;
189  advectionSrc /= 0.5*(detJ(i,j,k) + detJ(i,j-1,k));
190 
191  return advectionSrc;
192 }

Referenced by AdvectionSrcForMomWrapper().

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

◆ AdvectionSrcForZMom()

template<typename InterpType_H , typename InterpType_V , typename WallInterpType >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForZMom ( int  i,
int  j,
int  k,
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 > &  w,
const amrex::Array4< const amrex::Real > &  z_nd,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  ,
const amrex::Array4< const amrex::Real > &  az,
const amrex::Array4< const amrex::Real > &  detJ,
InterpType_H  interp_omega_h,
InterpType_V  interp_omega_v,
WallInterpType  interp_omega_wall,
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_inv,
const amrex::Array4< const amrex::Real > &  mf_vx_inv,
const AdvType  vert_adv_type,
const int  lo_z_face,
const int  hi_z_face 
)

Function for computing the advective tendency for the z-component of momentum with metric terms and for spatial order > 2

Parameters
[in]i,j,kindices of z-face at which to create tendency
[in]rho_ux-component of momentum
[in]rho_vy-component of momentum
[in]Omegacomponent of the momentum normal to the z-coordinate surface
[in]wz-component of velocity
[in]z_ndheight coordinate at nodes
[in]axArea fractions on x-faces
[in]ayArea fractions on y-faces
[in]azArea fractions on z-faces
[in]detJJacobian of the metric transformation (= 1 if use_terrain is false)
[in]cellSizeInvinverse of the mesh spacing
[in]mf_mmap factor on cell centers
[in]mf_umap factor on x-faces
[in]mf_vmap factor on y-faces
[in]vert_adv_typeint that defines advection stencil
[in]lo_z_faceminimum k value (z-face-centered)_in the domain at this level
[in]hi_z_facemaximum k value (z-face-centered) in the domain at this level
240 {
241  amrex::Real advectionSrc;
242  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
243 
244  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
245  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
246  amrex::Real Omega_avg_lo, Omega_avg_hi;
247 
248  amrex::Real interp_hi(0.), interp_lo(0.);
249 
250  // ****************************************************************************************
251  // x-fluxes (at edges in j-direction)
252  // ****************************************************************************************
253  rho_u_avg_hi = 0.5 * (rho_u(i+1, j, k) + rho_u(i+1, j, k-1)) * mf_uy_inv(i+1,j ,0);
254  rho_u_avg_lo = 0.5 * (rho_u(i , j, k) + rho_u(i , j, k-1)) * mf_uy_inv(i ,j ,0);
255 
256  interp_omega_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi);
257  interp_omega_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo);
258 
259  amrex::Real edgeFluxZXNext = rho_u_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterJ(i+1,j,k,cellSizeInv,z_nd);
260  amrex::Real edgeFluxZXPrev = rho_u_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterJ(i ,j,k,cellSizeInv,z_nd);
261 
262  // ****************************************************************************************
263  // y-fluxes (at edges in i-direction)
264  // ****************************************************************************************
265  rho_v_avg_hi = 0.5 * (rho_v(i, j+1, k) + rho_v(i, j+1, k-1)) * mf_vx_inv(i ,j+1,0);
266  interp_omega_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi);
267 
268  rho_v_avg_lo = 0.5 * (rho_v(i, j , k) + rho_v(i, j , k-1)) * mf_vx_inv(i ,j ,0);
269  interp_omega_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo);
270 
271  amrex::Real edgeFluxZYNext = rho_v_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterI(i,j+1,k,cellSizeInv,z_nd);
272  amrex::Real edgeFluxZYPrev = rho_v_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterI(i,j ,k,cellSizeInv,z_nd);
273 
274  // ****************************************************************************************
275  // z-fluxes (at cell centers)
276  // ****************************************************************************************
277 
278  Omega_avg_hi = (k == hi_z_face) ? Omega(i,j,k) * az(i,j,k) :
279  0.25 * (Omega(i,j,k) + Omega(i,j,k+1)) * (az(i,j,k) + az(i,j,k+1));
280  amrex::Real centFluxZZNext = Omega_avg_hi;
281 
282  // int l_spatial_order_hi = std::min(std::min(vert_spatial_order, 2*(hi_z_face-k)), 2*(k+1));
283  // If k == hi_z_face-1, l_spatial_order_hi = 2
284  // If k == hi_z_face-2, l_spatial_order_hi = std::min(vert_spatial_order, 4);
285  // If k == lo_z_face+11 , l_spatial_order_hi = std::min(vert_spatial_order, 4);
286  if (k == hi_z_face) {
287  centFluxZZNext *= w(i,j,k);
288  } else {
289  if (k == hi_z_face-1)
290  {
291  interp_omega_wall.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,AdvType::Centered_2nd);
292  } else if (k == hi_z_face-2 || k == lo_z_face+1) {
293  if (vert_adv_type != AdvType::Centered_2nd && vert_adv_type != AdvType::Upwind_3rd) {
294  interp_omega_wall.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,AdvType::Centered_4th);
295  } else {
296  interp_omega_wall.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,vert_adv_type);
297  }
298  } else {
299  interp_omega_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi);
300  }
301  centFluxZZNext *= interp_hi;
302  }
303 
304  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
305 
306  Omega_avg_lo = (k == 0) ? Omega(i,j,k) * az(i,j,k) :
307  0.25 * (Omega(i,j,k) + Omega(i,j,k-1)) * (az(i,j,k) + az(i,j,k-1));
308  amrex::Real centFluxZZPrev = Omega_avg_lo;
309 
310  // int l_spatial_order_lo = std::min(std::min(vert_spatial_order, 2*(hi_z_face+1-k)), 2*k);
311  // If k == hi_z_face-1, l_spatial_order_hi = 2
312  // If k == hi_z_face-2, l_spatial_order_hi = std::min(vert_spatial_order, 4);
313  // If k == lo_z_face+1, l_spatial_order_hi = std::min(vert_spatial_order, 4);
314  if (k == 0) {
315  centFluxZZPrev *= w(i,j,k);
316  } else {
317  if (k == lo_z_face+1) {
318  interp_omega_wall.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,AdvType::Centered_2nd);
319  } else if (k == lo_z_face+2 || k == hi_z_face-1) {
320  if (vert_adv_type != AdvType::Centered_2nd && vert_adv_type != AdvType::Upwind_3rd) {
321  interp_omega_wall.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,AdvType::Centered_4th);
322  } else {
323  interp_omega_wall.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,vert_adv_type);
324  }
325  } else {
326  interp_omega_v.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo);
327  }
328  centFluxZZPrev *= interp_lo;
329  }
330 
331  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
332 
333  amrex::Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
334 
335  advectionSrc = (edgeFluxZXNext - edgeFluxZXPrev) * dxInv * mfsq
336  + (edgeFluxZYNext - edgeFluxZYPrev) * dyInv * mfsq
337  + (centFluxZZNext - centFluxZZPrev) * dzInv;
338 
339  amrex::Real denom = 0.5*(detJ(i,j,k) + detJ(i,j,k-1));
340  advectionSrc /= denom;
341 
342  return advectionSrc;
343 }
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:276
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:320

Referenced by AdvectionSrcForMomWrapper().

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