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_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::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::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.

431 {
432  if (vert_adv_type == AdvType::Centered_2nd) {
433  AdvectionSrcForMomWrapper<InterpType_H,CENTERED2,UPWINDALL>(bxx, bxy, bxz,
434  rho_u_rhs, rho_v_rhs, rho_w_rhs,
435  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
436  cellSizeInv, mf_m,
437  mf_u_inv, mf_v_inv,
438  upw_frac_h, upw_frac_v,
439  vert_adv_type, lo_z_face, hi_z_face);
440  } else if (vert_adv_type == AdvType::Upwind_3rd) {
441  AdvectionSrcForMomWrapper<InterpType_H,UPWIND3,UPWINDALL>(bxx, bxy, bxz,
442  rho_u_rhs, rho_v_rhs, rho_w_rhs,
443  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
444  cellSizeInv, mf_m,
445  mf_u_inv, mf_v_inv,
446  upw_frac_h, upw_frac_v,
447  vert_adv_type, lo_z_face, hi_z_face);
448  } else if (vert_adv_type == AdvType::Centered_4th) {
449  AdvectionSrcForMomWrapper<InterpType_H,CENTERED4,UPWINDALL>(bxx, bxy, bxz,
450  rho_u_rhs, rho_v_rhs, rho_w_rhs,
451  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
452  cellSizeInv, mf_m,
453  mf_u_inv, mf_v_inv,
454  upw_frac_h, upw_frac_v,
455  vert_adv_type, lo_z_face, hi_z_face);
456  } else if (vert_adv_type == AdvType::Upwind_5th) {
457  AdvectionSrcForMomWrapper<InterpType_H,UPWIND5,UPWINDALL>(bxx, bxy, bxz,
458  rho_u_rhs, rho_v_rhs, rho_w_rhs,
459  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
460  cellSizeInv, mf_m,
461  mf_u_inv, mf_v_inv,
462  upw_frac_h, upw_frac_v,
463  vert_adv_type, lo_z_face, hi_z_face);
464  } else if (vert_adv_type == AdvType::Centered_6th) {
465  AdvectionSrcForMomWrapper<InterpType_H,CENTERED6,UPWINDALL>(bxx, bxy, bxz,
466  rho_u_rhs, rho_v_rhs, rho_w_rhs,
467  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
468  cellSizeInv, mf_m,
469  mf_u_inv, mf_v_inv,
470  upw_frac_h, upw_frac_v,
471  vert_adv_type, lo_z_face, hi_z_face);
472  } else {
473  AMREX_ASSERT_WITH_MESSAGE(false, "Unknown advection scheme!");
474  }
475 }
@ 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.

370 {
371  // Instantiate the appropriate structs
372  InterpType_H interp_u_h(u, upw_frac_h); InterpType_V interp_u_v(u, upw_frac_v); // X-MOM
373  InterpType_H interp_v_h(v, upw_frac_h); InterpType_V interp_v_v(v, upw_frac_v); // Y-MOM
374  InterpType_H interp_w_h(w, upw_frac_h); InterpType_V interp_w_v(w, upw_frac_v); // Z-MOM
375  WallInterpType interp_w_wall(w, upw_frac_v); // Z-MOM @ wall
376 
377  amrex::ParallelFor(bxx,
378  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
379  {
380  rho_u_rhs(i, j, k) = -AdvectionSrcForXMom(i, j, k, rho_u, rho_v, Omega, z_nd, ax, ay, az, detJ,
381  interp_u_h, interp_u_v,
382  cellSizeInv, mf_u_inv, mf_v_inv);
383  });
384 
385  amrex::ParallelFor(bxy,
386  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
387  {
388  rho_v_rhs(i, j, k) = -AdvectionSrcForYMom(i, j, k, rho_u, rho_v, Omega, z_nd, ax, ay, az, detJ,
389  interp_v_h, interp_v_v,
390  cellSizeInv, mf_u_inv, mf_v_inv);
391  });
392 
393  amrex::ParallelFor(bxz,
394  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
395  {
396  rho_w_rhs(i, j, k) = -AdvectionSrcForZMom(i, j, k, rho_u, rho_v, Omega, w, z_nd, ax, ay, az, detJ,
397  interp_w_h, interp_w_v, interp_w_wall,
398  cellSizeInv, mf_m, mf_u_inv, mf_v_inv,
399  vert_adv_type, lo_z_face, hi_z_face);
400  });
401 }
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_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:218
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_u_inv, const amrex::Array4< const amrex::Real > &mf_v_inv)
Definition: ERF_AdvectionSrcForMom_T.H:120
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_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::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
40 {
41  amrex::Real advectionSrc;
42  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
43 
44  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
45  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
46  amrex::Real Omega_avg_lo, Omega_avg_hi;
47 
48  amrex::Real interp_hi(0.), interp_lo(0.);
49 
50  // ****************************************************************************************
51  // X-fluxes (at cell centers)
52  // ****************************************************************************************
53 
54  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));
55  interp_u_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi);
56 
57  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));
58  interp_u_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo);
59 
60  amrex::Real centFluxXXNext = rho_u_avg_hi * interp_hi * 0.5 * (ax(i,j,k) + ax(i+1,j,k));
61  amrex::Real centFluxXXPrev = rho_u_avg_lo * interp_lo * 0.5 * (ax(i,j,k) + ax(i-1,j,k));
62 
63  // ****************************************************************************************
64  // Y-fluxes (at edges in k-direction)
65  // ****************************************************************************************
66  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));
67  interp_u_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi);
68 
69  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));
70  interp_u_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo);
71 
72  amrex::Real edgeFluxXYNext = rho_v_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterK(i,j+1,k,cellSizeInv,z_nd);
73  amrex::Real edgeFluxXYPrev = rho_v_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterK(i,j ,k,cellSizeInv,z_nd);
74 
75  // ****************************************************************************************
76  // Z-fluxes (at edges in j-direction)
77  // ****************************************************************************************
78  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));
79  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 ));
80 
81  interp_u_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi);
82  interp_u_v.InterpolateInZ(i,j,k ,0,interp_lo,Omega_avg_lo);
83 
84  amrex::Real edgeFluxXZNext = Omega_avg_hi * interp_hi;
85  amrex::Real edgeFluxXZPrev = Omega_avg_lo * interp_lo;
86 
87  // ****************************************************************************************
88 
89  amrex::Real mfsq = 1 / (mf_u_inv(i,j,0) * mf_u_inv(i,j,0));
90 
91  advectionSrc = (centFluxXXNext - centFluxXXPrev) * dxInv * mfsq
92  + (edgeFluxXYNext - edgeFluxXYPrev) * dyInv * mfsq
93  + (edgeFluxXZNext - edgeFluxXZPrev) * dzInv;
94  advectionSrc /= 0.5*(detJ(i,j,k) + detJ(i-1,j,k));
95 
96  return advectionSrc;
97 }
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:228

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

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

Referenced by AdvectionSrcForMomWrapper().

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