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

Functions

void AdvectionSrcForMom (const Box &bx, const Box &bxx, const Box &bxy, const Box &bxz, const Array4< Real > &rho_u_rhs, const Array4< Real > &rho_v_rhs, const Array4< Real > &rho_w_rhs, const Array4< const Real > &cell_data, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Array4< const Real > &Omega, const Array4< const Real > &z_nd, const Array4< const Real > &ax, const Array4< const Real > &ay, const Array4< const Real > &az, const Array4< const Real > &detJ, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const Array4< const Real > &mf_m, const Array4< const Real > &mf_u, const Array4< const Real > &mf_v, const AdvType horiz_adv_type, const AdvType vert_adv_type, const Real horiz_upw_frac, const Real vert_upw_frac, const bool use_terrain, const int lo_z_face, const int hi_z_face, const Box &domain, const BCRec *bc_ptr_h)
 

Function Documentation

◆ AdvectionSrcForMom()

void AdvectionSrcForMom ( const Box &  bx,
const Box &  bxx,
const Box &  bxy,
const Box &  bxz,
const Array4< Real > &  rho_u_rhs,
const Array4< Real > &  rho_v_rhs,
const Array4< Real > &  rho_w_rhs,
const Array4< const Real > &  cell_data,
const Array4< const Real > &  u,
const Array4< const Real > &  v,
const Array4< const Real > &  w,
const Array4< const Real > &  rho_u,
const Array4< const Real > &  rho_v,
const Array4< const Real > &  Omega,
const Array4< const Real > &  z_nd,
const Array4< const Real > &  ax,
const Array4< const Real > &  ay,
const Array4< const Real > &  az,
const Array4< const Real > &  detJ,
const GpuArray< Real, AMREX_SPACEDIM > &  cellSizeInv,
const Array4< const Real > &  mf_m,
const Array4< const Real > &  mf_u,
const Array4< const Real > &  mf_v,
const AdvType  horiz_adv_type,
const AdvType  vert_adv_type,
const Real  horiz_upw_frac,
const Real  vert_upw_frac,
const bool  use_terrain,
const int  lo_z_face,
const int  hi_z_face,
const Box &  domain,
const BCRec *  bc_ptr_h 
)

Function for computing the advective tendency for the momentum equations This routine has explicit expressions for all cases (terrain or not) when the horizontal and vertical spatial orders are <= 2, and calls more specialized functions when either (or both) spatial order(s) is greater than 2.

Parameters
[in]bxxbox over which the x-momentum is updated
[in]bxybox over which the y-momentum is updated
[in]bxzbox over which the z-momentum is updated
[out]rho_u_rhstendency for the x-momentum equation
[out]rho_v_rhstendency for the y-momentum equation
[out]rho_w_rhstendency for the z-momentum equation
[in]ux-component of the velocity
[in]vy-component of the velocity
[in]wz-component of the velocity
[in]rho_ux-component of the momentum
[in]rho_vy-component of the momentum
[in]Omegacomponent of the momentum normal to the z-coordinate surface
[in]z_ndheight coordinate at nodes
[in]axArea fraction of x-faces
[in]ayArea fraction of y-faces
[in]azArea fraction of z-faces
[in]detJJacobian of the metric transformation (= 1 if use_terrain is false)
[in]cellSizeInvinverse of the mesh spacing
[in]mf_mmap factor at cell centers
[in]mf_umap factor at x-faces
[in]mf_vmap factor at y-faces
[in]horiz_adv_typesets the spatial order to be used for lateral derivatives
[in]vert_adv_typesets the spatial order to be used for vertical derivatives
[in]use_terrainif true, use the terrain-aware derivatives (with metric terms)
70 {
71  BL_PROFILE_VAR("AdvectionSrcForMom", AdvectionSrcForMom);
72 
73  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
74 
75  AMREX_ALWAYS_ASSERT(bxz.smallEnd(2) > 0);
76 
77  // compute mapfactor inverses
78  Box box2d_u(bxx); box2d_u.setRange(2,0); box2d_u.grow({3,3,0});
79  Box box2d_v(bxy); box2d_v.setRange(2,0); box2d_v.grow({3,3,0});
80  FArrayBox mf_u_invFAB(box2d_u,1,The_Async_Arena());
81  FArrayBox mf_v_invFAB(box2d_v,1,The_Async_Arena());
82  const Array4<Real>& mf_u_inv = mf_u_invFAB.array();
83  const Array4<Real>& mf_v_inv = mf_v_invFAB.array();
84 
85  ParallelFor(box2d_u, box2d_v,
86  [=] AMREX_GPU_DEVICE (int i, int j, int) noexcept
87  {
88  mf_u_inv(i,j,0) = 1. / mf_u(i,j,0);
89  },
90  [=] AMREX_GPU_DEVICE (int i, int j, int) noexcept
91  {
92  mf_v_inv(i,j,0) = 1. / mf_v(i,j,0);
93  });
94 
95 #ifdef ERF_USE_EB
96  amrex::ignore_unused(use_terrain);
97  ParallelFor(bxx, bxy, bxz,
98  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
99  {
100  rho_u_rhs(i, j, k) = 0.0;
101  },
102  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
103  {
104  rho_v_rhs(i, j, k) = 0.0;
105  },
106  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
107  {
108  rho_w_rhs(i, j, k) = 0.0;
109  });
110 #else
111  if (!use_terrain) {
112  // Inline with 2nd order for efficiency
113  if (horiz_adv_type == AdvType::Centered_2nd && vert_adv_type == AdvType::Centered_2nd)
114  {
115  ParallelFor(bxx, bxy, bxz,
116  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
117  {
118  Real xflux_hi = 0.25 * (rho_u(i, j , k) * mf_u_inv(i,j,0) + rho_u(i+1, j , k) * mf_u_inv(i+1,j,0)) * (u(i+1,j,k) + u(i,j,k));
119  Real xflux_lo = 0.25 * (rho_u(i, j , k) * mf_u_inv(i,j,0) + rho_u(i-1, j , k) * mf_u_inv(i-1,j,0)) * (u(i-1,j,k) + u(i,j,k));
120 
121  Real yflux_hi = 0.25 * (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)) * (u(i,j+1,k) + u(i,j,k));
122  Real yflux_lo = 0.25 * (rho_v(i, j , k) * mf_v_inv(i,j ,0) + rho_v(i-1, j , k) * mf_v_inv(i-1,j ,0)) * (u(i,j-1,k) + u(i,j,k));
123 
124  Real zflux_hi = 0.25 * (Omega(i, j, k+1) + Omega(i-1, j, k+1)) * (u(i,j,k+1) + u(i,j,k));
125  Real zflux_lo = 0.25 * (Omega(i, j, k ) + Omega(i-1, j, k )) * (u(i,j,k-1) + u(i,j,k));
126 
127  Real mfsq = mf_u(i,j,0) * mf_u(i,j,0);
128 
129  Real advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
130  + (yflux_hi - yflux_lo) * dyInv * mfsq
131  + (zflux_hi - zflux_lo) * dzInv;
132  rho_u_rhs(i, j, k) = -advectionSrc;
133  },
134  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
135  {
136  Real xflux_hi = 0.25 * (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)) * (v(i+1,j,k) + v(i,j,k));
137  Real xflux_lo = 0.25 * (rho_u(i , j, k) * mf_u_inv(i ,j,0) + rho_u(i , j-1, k) * mf_u_inv(i ,j-1,0)) * (v(i-1,j,k) + v(i,j,k));
138 
139  Real yflux_hi = 0.25 * (rho_v(i ,j+1,k) * mf_v_inv(i,j+1,0) + rho_v(i ,j ,k) * mf_v_inv(i,j ,0)) * (v(i,j+1,k) + v(i,j,k));
140  Real yflux_lo = 0.25 * (rho_v(i ,j ,k) * mf_v_inv(i,j ,0) + rho_v(i ,j-1,k) * mf_v_inv(i,j-1,0) ) * (v(i,j-1,k) + v(i,j,k));
141 
142  Real zflux_hi = 0.25 * (Omega(i, j, k+1) + Omega(i, j-1, k+1)) * (v(i,j,k+1) + v(i,j,k));
143  Real zflux_lo = 0.25 * (Omega(i, j, k ) + Omega(i, j-1, k )) * (v(i,j,k-1) + v(i,j,k));
144 
145  Real mfsq = mf_v(i,j,0) * mf_v(i,j,0);
146 
147  Real advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
148  + (yflux_hi - yflux_lo) * dyInv * mfsq
149  + (zflux_hi - zflux_lo) * dzInv;
150  rho_v_rhs(i, j, k) = -advectionSrc;
151  },
152  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
153  {
154  Real xflux_hi = 0.25*(rho_u(i+1,j ,k) + rho_u(i+1, j, k-1)) * mf_u_inv(i+1,j ,0) * (w(i+1,j,k) + w(i,j,k));
155  Real xflux_lo = 0.25*(rho_u(i ,j ,k) + rho_u(i , j, k-1)) * mf_u_inv(i ,j ,0) * (w(i-1,j,k) + w(i,j,k));
156 
157  Real yflux_hi = 0.25*(rho_v(i ,j+1,k) + rho_v(i, j+1, k-1)) * mf_v_inv(i ,j+1,0) * (w(i,j+1,k) + w(i,j,k));
158  Real yflux_lo = 0.25*(rho_v(i ,j ,k) + rho_v(i, j , k-1)) * mf_v_inv(i ,j ,0) * (w(i,j-1,k) + w(i,j,k));
159 
160  Real zflux_lo = 0.25 * (Omega(i,j,k) + Omega(i,j,k-1)) * (w(i,j,k) + w(i,j,k-1));
161 
162  Real zflux_hi = (k == hi_z_face) ? Omega(i,j,k) * w(i,j,k) :
163  0.25 * (Omega(i,j,k) + Omega(i,j,k+1)) * (w(i,j,k) + w(i,j,k+1));
164 
165  Real mfsq = mf_m(i,j,0) * mf_m(i,j,0);
166 
167  Real advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
168  + (yflux_hi - yflux_lo) * dyInv * mfsq
169  + (zflux_hi - zflux_lo) * dzInv;
170  rho_w_rhs(i, j, k) = -advectionSrc;
171  });
172  // Template higher order methods
173  } else {
174  if (horiz_adv_type == AdvType::Centered_2nd) {
175  AdvectionSrcForMomVert_N<CENTERED2>(bxx, bxy, bxz,
176  rho_u_rhs, rho_v_rhs, rho_w_rhs,
177  rho_u, rho_v, Omega, u, v, w,
178  cellSizeInv, mf_m,
179  mf_u_inv, mf_v_inv,
180  horiz_upw_frac, vert_upw_frac,
181  vert_adv_type, lo_z_face, hi_z_face);
182  } else if (horiz_adv_type == AdvType::Upwind_3rd) {
183  AdvectionSrcForMomVert_N<UPWIND3>(bxx, bxy, bxz,
184  rho_u_rhs, rho_v_rhs, rho_w_rhs,
185  rho_u, rho_v, Omega, u, v, w,
186  cellSizeInv, mf_m,
187  mf_u_inv, mf_v_inv,
188  horiz_upw_frac, vert_upw_frac,
189  vert_adv_type, lo_z_face, hi_z_face);
190  } else if (horiz_adv_type == AdvType::Centered_4th) {
191  AdvectionSrcForMomVert_N<CENTERED4>(bxx, bxy, bxz,
192  rho_u_rhs, rho_v_rhs, rho_w_rhs,
193  rho_u, rho_v, Omega, u, v, w,
194  cellSizeInv, mf_m,
195  mf_u_inv, mf_v_inv,
196  horiz_upw_frac, vert_upw_frac,
197  vert_adv_type, lo_z_face, hi_z_face);
198  } else if (horiz_adv_type == AdvType::Upwind_5th) {
199  AdvectionSrcForMomVert_N<UPWIND5>(bxx, bxy, bxz,
200  rho_u_rhs, rho_v_rhs, rho_w_rhs,
201  rho_u, rho_v, Omega, u, v, w,
202  cellSizeInv, mf_m,
203  mf_u_inv, mf_v_inv,
204  horiz_upw_frac, vert_upw_frac,
205  vert_adv_type, lo_z_face, hi_z_face);
206  } else if (horiz_adv_type == AdvType::Centered_6th) {
207  AdvectionSrcForMomVert_N<CENTERED6>(bxx, bxy, bxz,
208  rho_u_rhs, rho_v_rhs, rho_w_rhs,
209  rho_u, rho_v, Omega, u, v, w,
210  cellSizeInv, mf_m,
211  mf_u_inv, mf_v_inv,
212  horiz_upw_frac, vert_upw_frac,
213  vert_adv_type, lo_z_face, hi_z_face);
214  } else {
215  AMREX_ASSERT_WITH_MESSAGE(false, "Unknown advection scheme!");
216  }
217  }
218  } // end of use_terrain == false
219  else
220  { // now do use_terrain = true
221  // Inline with 2nd order for efficiency
222  if (horiz_adv_type == AdvType::Centered_2nd && vert_adv_type == AdvType::Centered_2nd)
223  {
224  ParallelFor(bxx, bxy, bxz,
225  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
226  {
227  Real xflux_hi = 0.25 * (rho_u(i,j,k) * mf_u_inv(i,j,0) + rho_u(i+1,j,k) * mf_u_inv(i+1,j,0)) *
228  (u(i+1,j,k) + u(i,j,k)) * 0.5 * (ax(i,j,k) + ax(i+1,j,k));
229 
230  Real xflux_lo = 0.25 * (rho_u(i,j,k) * mf_u_inv(i,j,0) + rho_u(i-1,j,k) * mf_u_inv(i-1,j,0)) *
231  (u(i-1,j,k) + u(i,j,k)) * 0.5 * (ax(i,j,k) + ax(i-1,j,k));
232 
233  Real met_h_zeta_yhi = Compute_h_zeta_AtEdgeCenterK(i,j+1,k,cellSizeInv,z_nd);
234  Real yflux_hi = 0.25 * (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)) *
235  (u(i,j+1,k) + u(i,j,k)) * met_h_zeta_yhi;
236 
237  Real met_h_zeta_ylo = Compute_h_zeta_AtEdgeCenterK(i,j ,k,cellSizeInv,z_nd);
238  Real yflux_lo = 0.25 * (rho_v(i,j ,k)*mf_v_inv(i,j ,0) + rho_v(i-1,j ,k)*mf_v_inv(i-1,j ,0)) *
239  (u(i,j-1,k) + u(i,j,k)) * met_h_zeta_ylo;
240 
241  Real zflux_hi = 0.25 * (Omega(i,j,k+1) + Omega(i-1,j,k+1)) * (u(i,j,k+1) + u(i,j,k)) *
242  0.5 * (az(i,j,k+1) + az(i-1,j,k+1));
243  Real zflux_lo = 0.25 * (Omega(i,j,k ) + Omega(i-1,j,k )) * (u(i,j,k-1) + u(i,j,k)) *
244  0.5 * (az(i,j,k ) + az(i-1,j,k ));
245 
246  Real mfsq = mf_u(i,j,0) * mf_u(i,j,0);
247 
248  Real advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
249  + (yflux_hi - yflux_lo) * dyInv * mfsq
250  + (zflux_hi - zflux_lo) * dzInv;
251 
252  rho_u_rhs(i, j, k) = -advectionSrc / (0.5 * (detJ(i,j,k) + detJ(i-1,j,k)));
253  },
254  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
255  {
256 
257  Real met_h_zeta_xhi = Compute_h_zeta_AtEdgeCenterK(i+1,j,k,cellSizeInv,z_nd);
258  Real xflux_hi = 0.25 * (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)) *
259  (v(i+1,j,k) + v(i,j,k)) * met_h_zeta_xhi;
260 
261  Real met_h_zeta_xlo = Compute_h_zeta_AtEdgeCenterK(i ,j,k,cellSizeInv,z_nd);
262  Real xflux_lo = 0.25 * (rho_u(i, j, k)*mf_u_inv(i ,j,0) + rho_u(i ,j-1,k)*mf_u_inv(i-1,j ,0)) *
263  (v(i-1,j,k) + v(i,j,k)) * met_h_zeta_xlo;
264 
265  Real yflux_hi = 0.25 * (rho_v(i,j+1,k)*mf_v_inv(i,j+1,0) + rho_v(i,j ,k) * mf_v_inv(i,j ,0)) *
266  (v(i,j+1,k) + v(i,j,k)) * 0.5 * (ay(i,j,k) + ay(i,j+1,k));
267 
268  Real yflux_lo = 0.25 * (rho_v(i,j ,k)*mf_v_inv(i,j ,0) + rho_v(i,j-1,k) * mf_v_inv(i,j-1,0)) *
269  (v(i,j-1,k) + v(i,j,k)) * 0.5 * (ay(i,j,k) + ay(i,j-1,k));
270 
271  Real zflux_hi = 0.25 * (Omega(i,j,k+1) + Omega(i, j-1, k+1)) * (v(i,j,k+1) + v(i,j,k)) *
272  0.5 * (az(i,j,k+1) + az(i,j-1,k+1));
273  Real zflux_lo = 0.25 * (Omega(i,j,k ) + Omega(i, j-1, k )) * (v(i,j,k-1) + v(i,j,k)) *
274  0.5 * (az(i,j,k ) + az(i,j-1,k ));
275 
276  Real mfsq = mf_v(i,j,0) * mf_v(i,j,0);
277 
278  Real advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
279  + (yflux_hi - yflux_lo) * dyInv * mfsq
280  + (zflux_hi - zflux_lo) * dzInv;
281 
282  rho_v_rhs(i, j, k) = -advectionSrc / (0.5 * (detJ(i,j,k) + detJ(i,j-1,k)));
283  },
284  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
285  {
286  Real met_h_zeta_xhi = Compute_h_zeta_AtEdgeCenterJ(i+1,j ,k ,cellSizeInv,z_nd);
287  Real xflux_hi = 0.25*(rho_u(i+1,j ,k) + rho_u(i+1,j,k-1)) * mf_u_inv(i+1,j,0) *
288  (w(i+1,j,k) + w(i,j,k)) * met_h_zeta_xhi;
289 
290  Real met_h_zeta_xlo = Compute_h_zeta_AtEdgeCenterJ(i ,j ,k ,cellSizeInv,z_nd);
291  Real xflux_lo = 0.25*(rho_u(i ,j ,k) + rho_u(i ,j,k-1)) * mf_u_inv(i ,j,0) *
292  (w(i-1,j,k) + w(i,j,k)) * met_h_zeta_xlo;
293 
294  Real met_h_zeta_yhi = Compute_h_zeta_AtEdgeCenterI(i ,j+1,k ,cellSizeInv,z_nd);
295  Real yflux_hi = 0.25*(rho_v(i,j+1,k) + rho_v(i,j+1,k-1)) * mf_v_inv(i,j+1,0) *
296  (w(i,j+1,k) + w(i,j,k)) * met_h_zeta_yhi;
297 
298  Real met_h_zeta_ylo = Compute_h_zeta_AtEdgeCenterI(i ,j ,k ,cellSizeInv,z_nd);
299  Real yflux_lo = 0.25*(rho_v(i,j ,k) + rho_v(i,j ,k-1)) * mf_v_inv(i,j ,0) *
300  (w(i,j-1,k) + w(i,j,k)) * met_h_zeta_ylo;
301 
302  Real zflux_lo = 0.25 * (Omega(i,j,k) + Omega(i,j,k-1)) * (w(i,j,k) + w(i,j,k-1));
303 
304  Real zflux_hi = (k == hi_z_face) ? Omega(i,j,k) * w(i,j,k) * az(i,j,k):
305  0.25 * (Omega(i,j,k) + Omega(i,j,k+1)) * (w(i,j,k) + w(i,j,k+1)) *
306  0.5 * (az(i,j,k) + az(i,j,k+1));
307 
308  Real mfsq = mf_m(i,j,0) * mf_m(i,j,0);
309 
310  Real advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
311  + (yflux_hi - yflux_lo) * dyInv * mfsq
312  + (zflux_hi - zflux_lo) * dzInv;
313 
314  rho_w_rhs(i, j, k) = -advectionSrc / (0.5*(detJ(i,j,k) + detJ(i,j,k-1)));
315  });
316  // Template higher order methods
317  } else {
318  if (horiz_adv_type == AdvType::Centered_2nd) {
319  AdvectionSrcForMomVert<CENTERED2>(bxx, bxy, bxz,
320  rho_u_rhs, rho_v_rhs, rho_w_rhs,
321  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
322  cellSizeInv, mf_m, mf_u_inv, mf_v_inv,
323  horiz_upw_frac, vert_upw_frac,
324  vert_adv_type, lo_z_face, hi_z_face);
325  } else if (horiz_adv_type == AdvType::Upwind_3rd) {
326  AdvectionSrcForMomVert<UPWIND3>(bxx, bxy, bxz,
327  rho_u_rhs, rho_v_rhs, rho_w_rhs,
328  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
329  cellSizeInv, mf_m, mf_u_inv, mf_v_inv,
330  horiz_upw_frac, vert_upw_frac,
331  vert_adv_type, lo_z_face, hi_z_face);
332  } else if (horiz_adv_type == AdvType::Centered_4th) {
333  AdvectionSrcForMomVert<CENTERED4>(bxx, bxy, bxz,
334  rho_u_rhs, rho_v_rhs, rho_w_rhs,
335  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
336  cellSizeInv, mf_m, mf_u_inv, mf_v_inv,
337  horiz_upw_frac, vert_upw_frac,
338  vert_adv_type, lo_z_face, hi_z_face);
339  } else if (horiz_adv_type == AdvType::Upwind_5th) {
340  AdvectionSrcForMomVert<UPWIND5>(bxx, bxy, bxz,
341  rho_u_rhs, rho_v_rhs, rho_w_rhs,
342  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
343  cellSizeInv, mf_m, mf_u_inv, mf_v_inv,
344  horiz_upw_frac, vert_upw_frac,
345  vert_adv_type, lo_z_face, hi_z_face);
346  } else if (horiz_adv_type == AdvType::Centered_6th) {
347  AdvectionSrcForMomVert<CENTERED6>(bxx, bxy, bxz,
348  rho_u_rhs, rho_v_rhs, rho_w_rhs,
349  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
350  cellSizeInv, mf_m, mf_u_inv, mf_v_inv,
351  horiz_upw_frac, vert_upw_frac,
352  vert_adv_type, lo_z_face, hi_z_face);
353  } else {
354  AMREX_ASSERT_WITH_MESSAGE(false, "Unknown advection scheme!");
355  }
356  } // higher order
357  } // terrain
358 
359  // Open bc will be imposed upon all vars (we only access cons here for simplicity)
360  const bool xlo_open = (bc_ptr_h[BCVars::cons_bc].lo(0) == ERFBCType::open);
361  const bool xhi_open = (bc_ptr_h[BCVars::cons_bc].hi(0) == ERFBCType::open);
362  const bool ylo_open = (bc_ptr_h[BCVars::cons_bc].lo(1) == ERFBCType::open);
363  const bool yhi_open = (bc_ptr_h[BCVars::cons_bc].hi(1) == ERFBCType::open);
364 
365  // We recreate tbx, tbz, tbz here rather than using bxx, bxy, bxz because those
366  // have already been shrunk by one in the case of open BCs.
367  Box tbx(surroundingNodes(bx,0));
368  Box tby(surroundingNodes(bx,1));
369  Box tbz(surroundingNodes(bx,2)); tbz.growLo(2,-1); tbz.growHi(2,-1);
370 
371  const int domhi_z = domain.bigEnd(2);
372 
373  // Special advection operator for open BC (bndry normal/tangent operations)
374  if (xlo_open)
375  {
376  Box tbx_xlo, tby_xlo, tbz_xlo;
377  if (tbx.smallEnd(0) == domain.smallEnd(0)) { tbx_xlo = makeSlab(tbx,0,domain.smallEnd(0));}
378  if (tby.smallEnd(0) == domain.smallEnd(0)) { tby_xlo = makeSlab(tby,0,domain.smallEnd(0));}
379  if (tbz.smallEnd(0) == domain.smallEnd(0)) { tbz_xlo = makeSlab(tbz,0,domain.smallEnd(0));}
380 
381  bool do_lo = true;
382 
383  AdvectionSrcForOpenBC_Normal(tbx_xlo, 0, rho_u_rhs, u, cell_data, cellSizeInv, do_lo);
384  AdvectionSrcForOpenBC_Tangent_Ymom(tby_xlo, 0, rho_v_rhs, v,
385  rho_u, rho_v, Omega,
386  ay, az, detJ, cellSizeInv,
387  do_lo);
388  AdvectionSrcForOpenBC_Tangent_Zmom(tbz_xlo, 0, rho_w_rhs, w,
389  rho_u, rho_v, Omega,
390  ax, ay, az, detJ, cellSizeInv,
391  domhi_z, do_lo);
392  }
393  if (xhi_open)
394  {
395  Box tbx_xhi, tby_xhi, tbz_xhi;
396  if (tbx.bigEnd(0) == domain.bigEnd(0)+1) { tbx_xhi = makeSlab(tbx,0,domain.bigEnd(0)+1);}
397  if (tby.bigEnd(0) == domain.bigEnd(0)) { tby_xhi = makeSlab(tby,0,domain.bigEnd(0) );}
398  if (tbz.bigEnd(0) == domain.bigEnd(0)) { tbz_xhi = makeSlab(tbz,0,domain.bigEnd(0) );}
399 
400  AdvectionSrcForOpenBC_Normal(tbx_xhi, 0, rho_u_rhs, u, cell_data, cellSizeInv);
401  AdvectionSrcForOpenBC_Tangent_Ymom(tby_xhi, 0, rho_v_rhs, v,
402  rho_u, rho_v, Omega,
403  ay, az, detJ, cellSizeInv);
404  AdvectionSrcForOpenBC_Tangent_Zmom(tbz_xhi, 0, rho_w_rhs, w,
405  rho_u, rho_v, Omega,
406  ax, ay, az, detJ, cellSizeInv,
407  domhi_z);
408  }
409  if (ylo_open)
410  {
411  Box tbx_ylo, tby_ylo, tbz_ylo;
412  if (tbx.smallEnd(1) == domain.smallEnd(1)) { tbx_ylo = makeSlab(tbx,1,domain.smallEnd(1));}
413  if (tby.smallEnd(1) == domain.smallEnd(1)) { tby_ylo = makeSlab(tby,1,domain.smallEnd(1));}
414  if (tbz.smallEnd(1) == domain.smallEnd(1)) { tbz_ylo = makeSlab(tbz,1,domain.smallEnd(1));}
415 
416  bool do_lo = true;
417  AdvectionSrcForOpenBC_Tangent_Xmom(tbx_ylo, 1, rho_u_rhs, u,
418  rho_u, rho_v, Omega,
419  ax, az, detJ, cellSizeInv,
420  do_lo);
421  AdvectionSrcForOpenBC_Normal(tby_ylo, 1, rho_v_rhs, v, cell_data, cellSizeInv, do_lo);
422  AdvectionSrcForOpenBC_Tangent_Zmom(tbz_ylo, 1, rho_w_rhs, w,
423  rho_u, rho_v, Omega,
424  ax, ay, az, detJ, cellSizeInv,
425  domhi_z, do_lo);
426  }
427  if (yhi_open)
428  {
429  Box tbx_yhi, tby_yhi, tbz_yhi;
430  if (tbx.bigEnd(1) == domain.bigEnd(1)) { tbx_yhi = makeSlab(tbx,1,domain.bigEnd(1) );}
431  if (tby.bigEnd(1) == domain.bigEnd(1)+1) { tby_yhi = makeSlab(tby,1,domain.bigEnd(1)+1);}
432  if (tbz.bigEnd(1) == domain.bigEnd(1)) { tbz_yhi = makeSlab(tbz,1,domain.bigEnd(1) );}
433 
434  AdvectionSrcForOpenBC_Tangent_Xmom(tbx_yhi, 1, rho_u_rhs, u,
435  rho_u, rho_v, Omega,
436  ax, az, detJ, cellSizeInv);
437  AdvectionSrcForOpenBC_Normal(tby_yhi, 1, rho_v_rhs, v, cell_data, cellSizeInv);
438  AdvectionSrcForOpenBC_Tangent_Zmom(tbz_yhi, 1, rho_w_rhs, w,
439  rho_u, rho_v, Omega,
440  ax, ay, az, detJ, cellSizeInv,
441  domhi_z);
442  }
443 #endif
444 }
void AdvectionSrcForMom(const Box &bx, const Box &bxx, const Box &bxy, const Box &bxz, const Array4< Real > &rho_u_rhs, const Array4< Real > &rho_v_rhs, const Array4< Real > &rho_w_rhs, const Array4< const Real > &cell_data, const Array4< const Real > &u, const Array4< const Real > &v, const Array4< const Real > &w, const Array4< const Real > &rho_u, const Array4< const Real > &rho_v, const Array4< const Real > &Omega, const Array4< const Real > &z_nd, const Array4< const Real > &ax, const Array4< const Real > &ay, const Array4< const Real > &az, const Array4< const Real > &detJ, const GpuArray< Real, AMREX_SPACEDIM > &cellSizeInv, const Array4< const Real > &mf_m, const Array4< const Real > &mf_u, const Array4< const Real > &mf_v, const AdvType horiz_adv_type, const AdvType vert_adv_type, const Real horiz_upw_frac, const Real vert_upw_frac, const bool use_terrain, const int lo_z_face, const int hi_z_face, const Box &domain, const BCRec *bc_ptr_h)
Definition: ERF_AdvectionSrcForMom.cpp:41
void AdvectionSrcForOpenBC_Tangent_Ymom(const amrex::Box &bxy, const int &dir, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< const amrex::Real > &v, 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 > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const bool do_lo=false)
void AdvectionSrcForOpenBC_Tangent_Xmom(const amrex::Box &bxx, const int &dir, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< const amrex::Real > &u, 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 > &ax, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const bool do_lo=false)
void AdvectionSrcForOpenBC_Normal(const amrex::Box &bx, const int &dir, const amrex::Array4< amrex::Real > &rhs_arr, const amrex::Array4< const amrex::Real > &vel_norm_arr, const amrex::Array4< const amrex::Real > &cell_data_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const bool do_lo=false)
void AdvectionSrcForOpenBC_Tangent_Zmom(const amrex::Box &bxz, const int &dir, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &w, 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 > &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 int domhi_z, const bool do_lo=false)
@ Centered_4th
@ Centered_6th
@ Centered_2nd
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_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
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
@ cons_bc
Definition: ERF_IndexDefines.H:76
@ open
Definition: ERF_IndexDefines.H:186
Here is the call graph for this function: