ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
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::Real upw_frac_h, const amrex::Real upw_frac_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_u_inv, const amrex::Array4< const amrex::Real > &mf_v_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::Real upw_frac_h, const amrex::Real upw_frac_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_u_inv, const amrex::Array4< const amrex::Real > &mf_v_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::Real upw_frac_h, const amrex::Real upw_frac_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_m, const amrex::Array4< const amrex::Real > &mf_u_inv, const amrex::Array4< const amrex::Real > &mf_v_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_m, const amrex::Array4< const amrex::Real > &mf_u_inv, const amrex::Array4< const amrex::Real > &mf_v_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_m, const amrex::Array4< const amrex::Real > &mf_u_inv, const amrex::Array4< const amrex::Real > &mf_v_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_m,
const amrex::Array4< const amrex::Real > &  mf_u_inv,
const amrex::Array4< const amrex::Real > &  mf_v_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, mf_m,
446  mf_u_inv, mf_v_inv,
447  upw_frac_h, upw_frac_v,
448  vert_adv_type, lo_z_face, hi_z_face);
449  } else if (vert_adv_type == AdvType::Upwind_3rd) {
450  AdvectionSrcForMomWrapper<InterpType_H,UPWIND3,UPWINDALL>(bxx, bxy, bxz,
451  rho_u_rhs, rho_v_rhs, rho_w_rhs,
452  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
453  cellSizeInv, mf_m,
454  mf_u_inv, mf_v_inv,
455  upw_frac_h, upw_frac_v,
456  vert_adv_type, lo_z_face, hi_z_face);
457  } else if (vert_adv_type == AdvType::Centered_4th) {
458  AdvectionSrcForMomWrapper<InterpType_H,CENTERED4,UPWINDALL>(bxx, bxy, bxz,
459  rho_u_rhs, rho_v_rhs, rho_w_rhs,
460  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
461  cellSizeInv, mf_m,
462  mf_u_inv, mf_v_inv,
463  upw_frac_h, upw_frac_v,
464  vert_adv_type, lo_z_face, hi_z_face);
465  } else if (vert_adv_type == AdvType::Upwind_5th) {
466  AdvectionSrcForMomWrapper<InterpType_H,UPWIND5,UPWINDALL>(bxx, bxy, bxz,
467  rho_u_rhs, rho_v_rhs, rho_w_rhs,
468  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
469  cellSizeInv, mf_m,
470  mf_u_inv, mf_v_inv,
471  upw_frac_h, upw_frac_v,
472  vert_adv_type, lo_z_face, hi_z_face);
473  } else if (vert_adv_type == AdvType::Centered_6th) {
474  AdvectionSrcForMomWrapper<InterpType_H,CENTERED6,UPWINDALL>(bxx, bxy, bxz,
475  rho_u_rhs, rho_v_rhs, rho_w_rhs,
476  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
477  cellSizeInv, mf_m,
478  mf_u_inv, mf_v_inv,
479  upw_frac_h, upw_frac_v,
480  vert_adv_type, lo_z_face, hi_z_face);
481  } else {
482  AMREX_ASSERT_WITH_MESSAGE(false, "Unknown advection scheme!");
483  }
484 }
@ 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_m,
const amrex::Array4< const amrex::Real > &  mf_u_inv,
const amrex::Array4< const amrex::Real > &  mf_v_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); InterpType_V interp_u_v(u); // X-MOM
379  InterpType_H interp_v_h(v); InterpType_V interp_v_v(v); // Y-MOM
380  InterpType_H interp_w_h(w); InterpType_V interp_w_v(w); // Z-MOM
381  WallInterpType interp_w_wall(w); // 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  upw_frac_h, upw_frac_v,
389  cellSizeInv, mf_u_inv, mf_v_inv);
390  });
391 
392  amrex::ParallelFor(bxy,
393  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
394  {
395  rho_v_rhs(i, j, k) = -AdvectionSrcForYMom(i, j, k, rho_u, rho_v, Omega, z_nd, ax, ay, az, detJ,
396  interp_v_h, interp_v_v,
397  upw_frac_h, upw_frac_v,
398  cellSizeInv, mf_u_inv, mf_v_inv);
399  });
400 
401  amrex::ParallelFor(bxz,
402  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
403  {
404  rho_w_rhs(i, j, k) = -AdvectionSrcForZMom(i, j, k, rho_u, rho_v, Omega, w, z_nd, ax, ay, az, detJ,
405  interp_w_h, interp_w_v, interp_w_wall,
406  upw_frac_h, upw_frac_v,
407  cellSizeInv, mf_m, mf_u_inv, mf_v_inv,
408  vert_adv_type, lo_z_face, hi_z_face);
409  });
410 }
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::Real upw_frac_h, const amrex::Real upw_frac_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_u_inv, const amrex::Array4< const amrex::Real > &mf_v_inv)
Definition: ERF_AdvectionSrcForMom_T.H:122
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::Real upw_frac_h, const amrex::Real upw_frac_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_m, const amrex::Array4< const amrex::Real > &mf_u_inv, const amrex::Array4< const amrex::Real > &mf_v_inv, const AdvType vert_adv_type, const int lo_z_face, const int hi_z_face)
Definition: ERF_AdvectionSrcForMom_T.H:222
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::Real upw_frac_h, const amrex::Real upw_frac_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_u_inv, const amrex::Array4< const amrex::Real > &mf_v_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::Real  upw_frac_h,
const amrex::Real  upw_frac_v,
const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  cellSizeInv,
const amrex::Array4< const amrex::Real > &  mf_u_inv,
const amrex::Array4< const amrex::Real > &  mf_v_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
42 {
43  amrex::Real advectionSrc;
44  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
45 
46  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
47  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
48  amrex::Real Omega_avg_lo, Omega_avg_hi;
49 
50  amrex::Real interp_hi(0.), interp_lo(0.);
51 
52  // ****************************************************************************************
53  // X-fluxes (at cell centers)
54  // ****************************************************************************************
55 
56  rho_u_avg_hi = 0.5 * (rho_u(i+1, j, k) * mf_u_inv(i+1,j ,0) + rho_u(i, j, k) * mf_u_inv(i ,j ,0));
57  interp_u_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi,upw_frac_h);
58 
59  rho_u_avg_lo = 0.5 * (rho_u(i-1, j, k) * mf_u_inv(i-1,j ,0) + rho_u(i, j, k) * mf_u_inv(i ,j ,0));
60  interp_u_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo,upw_frac_h);
61 
62  amrex::Real centFluxXXNext = rho_u_avg_hi * interp_hi * 0.5 * (ax(i,j,k) + ax(i+1,j,k));
63  amrex::Real centFluxXXPrev = rho_u_avg_lo * interp_lo * 0.5 * (ax(i,j,k) + ax(i-1,j,k));
64 
65  // ****************************************************************************************
66  // Y-fluxes (at edges in k-direction)
67  // ****************************************************************************************
68  rho_v_avg_hi = 0.5 * (rho_v(i, j+1, k) * mf_v_inv(i ,j+1,0) + rho_v(i-1, j+1, k) * mf_v_inv(i-1,j+1,0));
69  interp_u_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi,upw_frac_h);
70 
71  rho_v_avg_lo = 0.5 * (rho_v(i, j , k) * mf_v_inv(i ,j ,0) + rho_v(i-1, j , k) * mf_v_inv(i-1,j ,0));
72  interp_u_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo,upw_frac_h);
73 
74  amrex::Real edgeFluxXYNext = rho_v_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterK(i,j+1,k,cellSizeInv,z_nd);
75  amrex::Real edgeFluxXYPrev = rho_v_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterK(i,j ,k,cellSizeInv,z_nd);
76 
77  // ****************************************************************************************
78  // Z-fluxes (at edges in j-direction)
79  // ****************************************************************************************
80  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));
81  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 ));
82 
83  interp_u_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,upw_frac_v);
84  interp_u_v.InterpolateInZ(i,j,k ,0,interp_lo,Omega_avg_lo,upw_frac_v);
85 
86  amrex::Real edgeFluxXZNext = Omega_avg_hi * interp_hi;
87  amrex::Real edgeFluxXZPrev = Omega_avg_lo * interp_lo;
88 
89  // ****************************************************************************************
90 
91  amrex::Real mfsq = 1 / (mf_u_inv(i,j,0) * mf_u_inv(i,j,0));
92 
93  advectionSrc = (centFluxXXNext - centFluxXXPrev) * dxInv * mfsq
94  + (edgeFluxXYNext - edgeFluxXYPrev) * dyInv * mfsq
95  + (edgeFluxXZNext - edgeFluxXZPrev) * dzInv;
96  advectionSrc /= 0.5*(detJ(i,j,k) + detJ(i-1,j,k));
97 
98  return advectionSrc;
99 }
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:221

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::Real  upw_frac_h,
const amrex::Real  upw_frac_v,
const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  cellSizeInv,
const amrex::Array4< const amrex::Real > &  mf_u_inv,
const amrex::Array4< const amrex::Real > &  mf_v_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
138 {
139  amrex::Real advectionSrc;
140  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
141 
142  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
143  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
144  amrex::Real Omega_avg_lo, Omega_avg_hi;
145 
146  amrex::Real interp_hi(0.), interp_lo(0.);
147 
148  // ****************************************************************************************
149  // x-fluxes (at edges in k-direction)
150  // ****************************************************************************************
151  rho_u_avg_hi = 0.5 * (rho_u(i+1,j,k) * mf_u_inv(i+1,j,0) + rho_u(i+1,j-1,k) * mf_u_inv(i+1,j-1,0));
152  rho_u_avg_lo = 0.5 * (rho_u(i ,j,k) * mf_u_inv(i ,j,0) + rho_u(i ,j-1,k) * mf_u_inv(i ,j-1,0));
153 
154  interp_v_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi,upw_frac_h);
155  interp_v_h.InterpolateInX(i ,j,k,0,interp_lo,rho_u_avg_lo,upw_frac_h);
156 
157  amrex::Real edgeFluxYXNext = rho_u_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterK(i+1,j,k,cellSizeInv,z_nd);
158  amrex::Real edgeFluxYXPrev = rho_u_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterK(i ,j,k,cellSizeInv,z_nd);
159 
160  // ****************************************************************************************
161  // y-fluxes (at cell centers)
162  // ****************************************************************************************
163  rho_v_avg_hi = 0.5 * (rho_v(i,j,k) * mf_v_inv(i,j,0) + rho_v(i,j+1,k) * mf_v_inv(i,j+1,0));
164  rho_v_avg_lo = 0.5 * (rho_v(i,j,k) * mf_v_inv(i,j,0) + rho_v(i,j-1,k) * mf_v_inv(i,j-1,0));
165 
166  interp_v_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi,upw_frac_h);
167  interp_v_h.InterpolateInY(i,j ,k,0,interp_lo,rho_v_avg_lo,upw_frac_h);
168 
169  amrex::Real centFluxYYNext = rho_v_avg_hi * 0.5 * (ay(i,j,k) + ay(i,j+1,k)) * interp_hi;
170  amrex::Real centFluxYYPrev = rho_v_avg_lo * 0.5 * (ay(i,j,k) + ay(i,j-1,k)) * interp_lo;
171 
172  // ****************************************************************************************
173  // Z-fluxes (at edges in j-direction)
174  // ****************************************************************************************
175  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));
176  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 ));
177 
178  interp_v_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,upw_frac_v);
179  interp_v_v.InterpolateInZ(i,j,k ,0,interp_lo,Omega_avg_lo,upw_frac_v);
180 
181  amrex::Real edgeFluxYZNext = Omega_avg_hi * interp_hi;
182  amrex::Real edgeFluxYZPrev = Omega_avg_lo * interp_lo;
183 
184  // ****************************************************************************************
185 
186  amrex::Real mfsq = 1 / (mf_v_inv(i,j,0) * mf_v_inv(i,j,0));
187 
188  advectionSrc = (edgeFluxYXNext - edgeFluxYXPrev) * dxInv * mfsq
189  + (centFluxYYNext - centFluxYYPrev) * dyInv * mfsq
190  + (edgeFluxYZNext - edgeFluxYZPrev) * dzInv;
191  advectionSrc /= 0.5*(detJ(i,j,k) + detJ(i,j-1,k));
192 
193  return advectionSrc;
194 }

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::Real  upw_frac_h,
const amrex::Real  upw_frac_v,
const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  cellSizeInv,
const amrex::Array4< const amrex::Real > &  mf_m,
const amrex::Array4< const amrex::Real > &  mf_u_inv,
const amrex::Array4< const amrex::Real > &  mf_v_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
243 {
244  amrex::Real advectionSrc;
245  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
246 
247  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
248  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
249  amrex::Real Omega_avg_lo, Omega_avg_hi;
250 
251  amrex::Real interp_hi(0.), interp_lo(0.);
252 
253  // ****************************************************************************************
254  // x-fluxes (at edges in j-direction)
255  // ****************************************************************************************
256  rho_u_avg_hi = 0.5 * (rho_u(i+1, j, k) + rho_u(i+1, j, k-1)) * mf_u_inv(i+1,j ,0);
257  rho_u_avg_lo = 0.5 * (rho_u(i , j, k) + rho_u(i , j, k-1)) * mf_u_inv(i ,j ,0);
258 
259  interp_omega_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi,upw_frac_h);
260  interp_omega_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo,upw_frac_h);
261 
262  amrex::Real edgeFluxZXNext = rho_u_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterJ(i+1,j,k,cellSizeInv,z_nd);
263  amrex::Real edgeFluxZXPrev = rho_u_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterJ(i ,j,k,cellSizeInv,z_nd);
264 
265  // ****************************************************************************************
266  // y-fluxes (at edges in i-direction)
267  // ****************************************************************************************
268  rho_v_avg_hi = 0.5 * (rho_v(i, j+1, k) + rho_v(i, j+1, k-1)) * mf_v_inv(i ,j+1,0);
269  interp_omega_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi,upw_frac_h);
270 
271  rho_v_avg_lo = 0.5 * (rho_v(i, j , k) + rho_v(i, j , k-1)) * mf_v_inv(i ,j ,0);
272  interp_omega_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo,upw_frac_h);
273 
274  amrex::Real edgeFluxZYNext = rho_v_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterI(i,j+1,k,cellSizeInv,z_nd);
275  amrex::Real edgeFluxZYPrev = rho_v_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterI(i,j ,k,cellSizeInv,z_nd);
276 
277  // ****************************************************************************************
278  // z-fluxes (at cell centers)
279  // ****************************************************************************************
280 
281  Omega_avg_hi = (k == hi_z_face) ? Omega(i,j,k) * az(i,j,k) :
282  0.25 * (Omega(i,j,k) + Omega(i,j,k+1)) * (az(i,j,k) + az(i,j,k+1));
283  amrex::Real centFluxZZNext = Omega_avg_hi;
284 
285  // int l_spatial_order_hi = std::min(std::min(vert_spatial_order, 2*(hi_z_face-k)), 2*(k+1));
286  // If k == hi_z_face-1, l_spatial_order_hi = 2
287  // If k == hi_z_face-2, l_spatial_order_hi = std::min(vert_spatial_order, 4);
288  // If k == lo_z_face+11 , l_spatial_order_hi = std::min(vert_spatial_order, 4);
289  if (k == hi_z_face) {
290  centFluxZZNext *= w(i,j,k);
291  } else {
292  if (k == hi_z_face-1)
293  {
294  interp_omega_wall.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,0,AdvType::Centered_2nd);
295  } else if (k == hi_z_face-2 || k == lo_z_face+1) {
296  if (vert_adv_type != AdvType::Centered_2nd && vert_adv_type != AdvType::Upwind_3rd) {
297  interp_omega_wall.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,0,AdvType::Centered_4th);
298  } else {
299  interp_omega_wall.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,upw_frac_v,vert_adv_type);
300  }
301  } else {
302  interp_omega_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,upw_frac_v);
303  }
304  centFluxZZNext *= interp_hi;
305  }
306 
307  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
308 
309  Omega_avg_lo = (k == 0) ? Omega(i,j,k) * az(i,j,k) :
310  0.25 * (Omega(i,j,k) + Omega(i,j,k-1)) * (az(i,j,k) + az(i,j,k-1));
311  amrex::Real centFluxZZPrev = Omega_avg_lo;
312 
313  // int l_spatial_order_lo = std::min(std::min(vert_spatial_order, 2*(hi_z_face+1-k)), 2*k);
314  // If k == hi_z_face-1, l_spatial_order_hi = 2
315  // If k == hi_z_face-2, l_spatial_order_hi = std::min(vert_spatial_order, 4);
316  // If k == lo_z_face+1, l_spatial_order_hi = std::min(vert_spatial_order, 4);
317  if (k == 0) {
318  centFluxZZPrev *= w(i,j,k);
319  } else {
320  if (k == lo_z_face+1) {
321  interp_omega_wall.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,0,AdvType::Centered_2nd);
322  } else if (k == lo_z_face+2 || k == hi_z_face-1) {
323  if (vert_adv_type != AdvType::Centered_2nd && vert_adv_type != AdvType::Upwind_3rd) {
324  interp_omega_wall.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,0,AdvType::Centered_4th);
325  } else {
326  interp_omega_wall.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,upw_frac_v,vert_adv_type);
327  }
328  } else {
329  interp_omega_v.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,upw_frac_v);
330  }
331  centFluxZZPrev *= interp_lo;
332  }
333 
334  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
335 
336  amrex::Real mfsq = mf_m(i,j,0) * mf_m(i,j,0);
337 
338  advectionSrc = (edgeFluxZXNext - edgeFluxZXPrev) * dxInv * mfsq
339  + (edgeFluxZYNext - edgeFluxZYPrev) * dyInv * mfsq
340  + (centFluxZZNext - centFluxZZPrev) * dzInv;
341 
342  amrex::Real denom = 0.5*(detJ(i,j,k) + detJ(i,j,k-1));
343  advectionSrc /= denom;
344 
345  return advectionSrc;
346 }
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:266
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:310

Referenced by AdvectionSrcForMomWrapper().

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