ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_AdvectionSrcForMom_N.H File Reference
Include dependency graph for ERF_AdvectionSrcForMom_N.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_N (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 > &rho_w, 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_N (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 > &rho_w, 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_N (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 > &rho_w, const amrex::Array4< const amrex::Real > &w, InterpType_H interp_w_h, InterpType_V interp_w_v, WallInterpType interp_w_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_N (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 > &rho_w, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, 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_N (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 > &rho_w, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, 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_N()

template<typename InterpType_H >
void AdvectionSrcForMomVert_N ( 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 > &  rho_w,
const amrex::Array4< const amrex::Real > &  u,
const amrex::Array4< const amrex::Real > &  v,
const amrex::Array4< const amrex::Real > &  w,
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.

358 {
359  if (vert_adv_type == AdvType::Centered_2nd) {
360  AdvectionSrcForMomWrapper_N<InterpType_H,CENTERED2,UPWINDALL>(bxx, bxy, bxz,
361  rho_u_rhs, rho_v_rhs, rho_w_rhs,
362  rho_u, rho_v, rho_w, u, v, w,
363  cellSizeInv, mf_m,
364  mf_u_inv, mf_v_inv,
365  upw_frac_h, upw_frac_v,
366  vert_adv_type,
367  lo_z_face, hi_z_face);
368  } else if (vert_adv_type == AdvType::Upwind_3rd) {
369  AdvectionSrcForMomWrapper_N<InterpType_H,UPWIND3,UPWINDALL>(bxx, bxy, bxz,
370  rho_u_rhs, rho_v_rhs, rho_w_rhs,
371  rho_u, rho_v, rho_w, u, v, w,
372  cellSizeInv, mf_m,
373  mf_u_inv, mf_v_inv,
374  upw_frac_h, upw_frac_v,
375  vert_adv_type,
376  lo_z_face, hi_z_face);
377  } else if (vert_adv_type == AdvType::Centered_4th) {
378  AdvectionSrcForMomWrapper_N<InterpType_H,CENTERED4,UPWINDALL>(bxx, bxy, bxz,
379  rho_u_rhs, rho_v_rhs, rho_w_rhs,
380  rho_u, rho_v, rho_w, u, v, w,
381  cellSizeInv, mf_m,
382  mf_u_inv, mf_v_inv,
383  upw_frac_h, upw_frac_v,
384  vert_adv_type,
385  lo_z_face, hi_z_face);
386  } else if (vert_adv_type == AdvType::Upwind_5th) {
387  AdvectionSrcForMomWrapper_N<InterpType_H,UPWIND5,UPWINDALL>(bxx, bxy, bxz,
388  rho_u_rhs, rho_v_rhs, rho_w_rhs,
389  rho_u, rho_v, rho_w, u, v, w,
390  cellSizeInv, mf_m,
391  mf_u_inv, mf_v_inv,
392  upw_frac_h, upw_frac_v,
393  vert_adv_type,
394  lo_z_face, hi_z_face);
395  } else if (vert_adv_type == AdvType::Centered_6th) {
396  AdvectionSrcForMomWrapper_N<InterpType_H,CENTERED6,UPWINDALL>(bxx, bxy, bxz,
397  rho_u_rhs, rho_v_rhs, rho_w_rhs,
398  rho_u, rho_v, rho_w, u, v, w,
399  cellSizeInv, mf_m,
400  mf_u_inv, mf_v_inv,
401  upw_frac_h, upw_frac_v,
402  vert_adv_type,
403  lo_z_face, hi_z_face);
404  } else {
405  AMREX_ASSERT_WITH_MESSAGE(false, "Unknown advection scheme!");
406  }
407 }
@ Centered_4th
@ Centered_6th
@ Centered_2nd

◆ AdvectionSrcForMomWrapper_N()

template<typename InterpType_H , typename InterpType_V , typename WallInterpType >
void AdvectionSrcForMomWrapper_N ( 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 > &  rho_w,
const amrex::Array4< const amrex::Real > &  u,
const amrex::Array4< const amrex::Real > &  v,
const amrex::Array4< const amrex::Real > &  w,
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.

299 {
300  // Instantiate the appropriate structs
301  InterpType_H interp_u_h(u); InterpType_V interp_u_v(u); // X-MOM
302  InterpType_H interp_v_h(v); InterpType_V interp_v_v(v); // Y-MOM
303  InterpType_H interp_w_h(w); InterpType_V interp_w_v(w); // Z-MOM
304  WallInterpType interp_w_wall(w); // Z-MOM @ wall
305 
306  amrex::ParallelFor(bxx,
307  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
308  {
309  rho_u_rhs(i, j, k) = -AdvectionSrcForXMom_N(i, j, k, rho_u, rho_v, rho_w,
310  interp_u_h, interp_u_v,
311  upw_frac_h, upw_frac_v,
312  cellSizeInv, mf_u_inv, mf_v_inv);
313  });
314 
315  amrex::ParallelFor(bxy,
316  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
317  {
318  rho_v_rhs(i, j, k) = -AdvectionSrcForYMom_N(i, j, k, rho_u, rho_v, rho_w,
319  interp_v_h, interp_v_v,
320  upw_frac_h, upw_frac_v,
321  cellSizeInv, mf_u_inv, mf_v_inv);
322  });
323 
324  amrex::ParallelFor(bxz,
325  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
326  {
327  rho_w_rhs(i, j, k) = -AdvectionSrcForZMom_N(i, j, k, rho_u, rho_v, rho_w, w,
328  interp_w_h, interp_w_v, interp_w_wall,
329  upw_frac_h, upw_frac_v,
330  cellSizeInv, mf_m, mf_u_inv, mf_v_inv,
331  vert_adv_type, lo_z_face, hi_z_face);
332  });
333 }
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForXMom_N(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 > &rho_w, 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_N.H:21
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForYMom_N(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 > &rho_w, 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_N.H:96
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForZMom_N(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 > &rho_w, const amrex::Array4< const amrex::Real > &w, InterpType_H interp_w_h, InterpType_V interp_w_v, WallInterpType interp_w_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_N.H:173
Here is the call graph for this function:

◆ AdvectionSrcForXMom_N()

template<typename InterpType_H , typename InterpType_V >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForXMom_N ( 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 > &  rho_w,
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 without metric terms and for higher-order stencils

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]rho_wz-component of momentum
[in]ux-component of velocity
[in]cellSizeInvinverse of the mesh spacing
[in]mf_umap factor on x-faces
[in]mf_vmap factor on y-faces
32 {
33  amrex::Real advectionSrc;
34  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
35 
36  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
37  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
38  amrex::Real rho_w_avg_lo, rho_w_avg_hi;
39 
40  amrex::Real xflux_hi; amrex::Real xflux_lo;
41  amrex::Real yflux_hi; amrex::Real yflux_lo;
42  amrex::Real zflux_hi; amrex::Real zflux_lo;
43 
44  amrex::Real interp_hi(0.), interp_lo(0.);
45 
46  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));
47  interp_u_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi,upw_frac_h);
48  xflux_hi = rho_u_avg_hi * interp_hi;
49 
50  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));
51  interp_u_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo,upw_frac_h);
52  xflux_lo = rho_u_avg_lo * interp_lo;
53 
54  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));
55  interp_u_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi,upw_frac_h);
56  yflux_hi = rho_v_avg_hi * interp_hi;
57 
58  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));
59  interp_u_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo,upw_frac_h);
60  yflux_lo = rho_v_avg_lo * interp_lo;
61 
62  rho_w_avg_hi = 0.5 * (rho_w(i, j, k+1) + rho_w(i-1, j, k+1));
63  interp_u_v.InterpolateInZ(i,j,k+1,0,interp_hi,rho_w_avg_hi,upw_frac_v);
64  zflux_hi = rho_w_avg_hi * interp_hi;
65 
66  rho_w_avg_lo = 0.5 * (rho_w(i, j, k ) + rho_w(i-1, j, k ));
67  interp_u_v.InterpolateInZ(i,j,k,0,interp_lo,rho_w_avg_lo,upw_frac_v);
68  zflux_lo = rho_w_avg_lo * interp_lo;
69 
70  amrex::Real mfsq = 1 / (mf_u_inv(i,j,0) * mf_u_inv(i,j,0));
71 
72  advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
73  + (yflux_hi - yflux_lo) * dyInv * mfsq
74  + (zflux_hi - zflux_lo) * dzInv;
75 
76  return advectionSrc;
77 }

Referenced by AdvectionSrcForMomWrapper_N().

Here is the caller graph for this function:

◆ AdvectionSrcForYMom_N()

template<typename InterpType_H , typename InterpType_V >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForYMom_N ( 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 > &  rho_w,
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 without metric terms and for higher-order stencils

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]rho_wz-component of momentum
[in]vy-component of velocity
[in]cellSizeInvinverse of the mesh spacing
[in]mf_umap factor on x-faces
[in]mf_vmap factor on y-faces
107 {
108  amrex::Real advectionSrc;
109  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
110 
111  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
112  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
113  amrex::Real rho_w_avg_lo, rho_w_avg_hi;
114 
115  amrex::Real xflux_hi; amrex::Real xflux_lo;
116  amrex::Real yflux_hi; amrex::Real yflux_lo;
117  amrex::Real zflux_hi; amrex::Real zflux_lo;
118 
119  amrex::Real interp_hi(0.), interp_lo(0.);
120 
121  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));
122  interp_v_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi,upw_frac_h);
123  xflux_hi = rho_u_avg_hi * interp_hi;
124 
125  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));
126  interp_v_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo,upw_frac_h);
127  xflux_lo = rho_u_avg_lo * interp_lo;
128 
129  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));
130  interp_v_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi,upw_frac_h);
131  yflux_hi = rho_v_avg_hi * interp_hi;
132 
133  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));
134  interp_v_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo,upw_frac_h);
135  yflux_lo = rho_v_avg_lo * interp_lo;
136 
137  rho_w_avg_hi = 0.5 * (rho_w(i, j, k+1) + rho_w(i, j-1, k+1));
138  interp_v_v.InterpolateInZ(i,j,k+1,0,interp_hi,rho_w_avg_hi,upw_frac_v);
139  zflux_hi = rho_w_avg_hi * interp_hi;
140 
141  rho_w_avg_lo = 0.5 * (rho_w(i, j, k ) + rho_w(i, j-1, k ));
142  interp_v_v.InterpolateInZ(i,j,k ,0,interp_lo,rho_w_avg_lo,upw_frac_v);
143  zflux_lo = rho_w_avg_lo * interp_lo;
144 
145  amrex::Real mfsq = 1 / (mf_v_inv(i,j,0) * mf_v_inv(i,j,0));
146 
147  advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
148  + (yflux_hi - yflux_lo) * dyInv * mfsq
149  + (zflux_hi - zflux_lo) * dzInv;
150 
151  return advectionSrc;
152 }

Referenced by AdvectionSrcForMomWrapper_N().

Here is the caller graph for this function:

◆ AdvectionSrcForZMom_N()

template<typename InterpType_H , typename InterpType_V , typename WallInterpType >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForZMom_N ( 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 > &  rho_w,
const amrex::Array4< const amrex::Real > &  w,
InterpType_H  interp_w_h,
InterpType_V  interp_w_v,
WallInterpType  interp_w_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 without metric terms and for higher-order stencils

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]rho_wz-component of momentum
[in]wz-component of velocity
[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]domhi_zmaximum k value in the domain
189 {
190 
191  amrex::Real advectionSrc;
192  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
193 
194  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
195  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
196  amrex::Real rho_w_avg_lo, rho_w_avg_hi;
197 
198  amrex::Real xflux_hi; amrex::Real xflux_lo;
199  amrex::Real yflux_hi; amrex::Real yflux_lo;
200  amrex::Real zflux_hi; amrex::Real zflux_lo;
201 
202  amrex::Real interp_hi(0.), interp_lo(0.);
203 
204  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);
205  interp_w_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi,upw_frac_h);
206  xflux_hi = rho_u_avg_hi * interp_hi;
207 
208  rho_u_avg_lo = 0.5 * (rho_u(i , j, k) + rho_u(i , j, k-1)) * mf_u_inv(i ,j ,0);
209  interp_w_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo,upw_frac_h);
210  xflux_lo = rho_u_avg_lo * interp_lo;
211 
212  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);
213  interp_w_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi,upw_frac_h);
214  yflux_hi = rho_v_avg_hi * interp_hi;
215 
216  rho_v_avg_lo = 0.5 * (rho_v(i, j , k) + rho_v(i, j , k-1)) * mf_v_inv(i ,j ,0);
217  interp_w_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo,upw_frac_h);
218  yflux_lo = rho_v_avg_lo * interp_lo;
219 
220  // int l_spatial_order_hi = std::min(std::min(vert_spatial_order, 2*(hi_z_face-k)), 2*(k+1));
221  // If k == hi_z_face-1, l_spatial_order_hi = 2
222  // If k == hi_z_face-2, l_spatial_order_hi = std::min(vert_spatial_order, 4);
223  // If k == lo_z+face+1, l_spatial_order_hi = std::min(vert_spatial_order, 4);
224 
225  if (k == hi_z_face) {
226  zflux_hi = rho_w(i,j,k) * w(i,j,k);
227  } else {
228  rho_w_avg_hi = 0.5 * (rho_w(i,j,k) + rho_w(i,j,k+1));
229  if (k == hi_z_face-1)
230  {
231  interp_w_wall.InterpolateInZ(i,j,k+1,0,interp_hi,rho_w_avg_hi,0,AdvType::Centered_2nd);
232  } else if (k == hi_z_face-2 || k == lo_z_face+1) {
233  if (vert_adv_type != AdvType::Centered_2nd && vert_adv_type != AdvType::Upwind_3rd) {
234  interp_w_wall.InterpolateInZ(i,j,k+1,0,interp_hi,rho_w_avg_hi,0,AdvType::Centered_4th);
235  } else {
236  interp_w_wall.InterpolateInZ(i,j,k+1,0,interp_hi,rho_w_avg_hi,upw_frac_v,vert_adv_type);
237  }
238  } else {
239  interp_w_v.InterpolateInZ(i,j,k+1,0,interp_hi,rho_w_avg_hi,upw_frac_v);
240  }
241  zflux_hi = rho_w_avg_hi * interp_hi;
242  }
243 
244  // int l_spatial_order_lo = std::min(std::min(vert_spatial_order, 2*(hi_z_face+1-k)), 2*k);
245  // If k == lo_z_face+1, l_spatial_order_hi = 2
246  // If k == lo_z_face+2, l_spatial_order_hi = std::min(vert_spatial_order, 4);
247  // If k == hi_z_face-1, l_spatial_order_hi = std::min(vert_spatial_order, 4);
248 
249  if (k == lo_z_face) {
250  zflux_lo = rho_w(i,j,k) * w(i,j,k);
251  } else {
252  rho_w_avg_lo = 0.5 * (rho_w(i,j,k) + rho_w(i,j,k-1));
253  if (k == lo_z_face+1) {
254  interp_w_wall.InterpolateInZ(i,j,k,0,interp_lo,rho_w_avg_lo,0,AdvType::Centered_2nd);
255  } else if (k == lo_z_face+2 || k == hi_z_face-1) {
256  if (vert_adv_type != AdvType::Centered_2nd && vert_adv_type != AdvType::Upwind_3rd) {
257  interp_w_wall.InterpolateInZ(i,j,k,0,interp_lo,rho_w_avg_lo,0,AdvType::Centered_4th);
258  } else {
259  interp_w_wall.InterpolateInZ(i,j,k,0,interp_lo,rho_w_avg_lo,upw_frac_v,vert_adv_type);
260  }
261  } else {
262  interp_w_v.InterpolateInZ(i,j,k,0,interp_lo,rho_w_avg_lo,upw_frac_v);
263  }
264  zflux_lo = rho_w_avg_lo * interp_lo;
265  }
266 
267  amrex::Real mfsq = mf_m(i,j,0) * mf_m(i,j,0);
268 
269  advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
270  + (yflux_hi - yflux_lo) * dyInv * mfsq
271  + (zflux_hi - zflux_lo) * dzInv;
272 
273  return advectionSrc;
274 }

Referenced by AdvectionSrcForMomWrapper_N().

Here is the caller graph for this function: