ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ERF_AdvectionSrcForMom_T.H
Go to the documentation of this file.
1 #include <ERF_IndexDefines.H>
2 #include <ERF_TerrainMetrics.H>
3 #include <ERF_Interpolation.H>
4 
5 /**
6  * Function for computing the advective tendency for the x-component of momentum
7  * with metric terms and for spatial order > 2
8  *
9  * @param[in] i,j,k indices of x-face at which to create tendency
10  * @param[in] rho_u x-component of momentum
11  * @param[in] rho_v y-component of momentum
12  * @param[in] Omega component of the momentum normal to the z-coordinate surface
13  * @param[in] z_nd height coordinate at nodes
14  * @param[in] ax Area fractions on x-faces
15  * @param[in] ay Area fractions on y-faces
16  * @param[in] az Area fractions on z-faces
17  * @param[in] detJ Jacobian of the metric transformation (= 1 if use_terrain is false)
18  * @param[in] cellSizeInv inverse of the mesh spacing
19  * @param[in] mf_u map factor on x-faces
20  * @param[in] mf_v map factor on y-faces
21  */
22 template<typename InterpType_H, typename InterpType_V>
23 AMREX_GPU_DEVICE
24 AMREX_FORCE_INLINE
25 amrex::Real
26 AdvectionSrcForXMom (int i, int j, int k,
27  const amrex::Array4<const amrex::Real>& rho_u,
28  const amrex::Array4<const amrex::Real>& rho_v,
29  const amrex::Array4<const amrex::Real>& Omega,
30  const amrex::Array4<const amrex::Real>& z_nd,
31  const amrex::Array4<const amrex::Real>& ax,
32  const amrex::Array4<const amrex::Real>& /*ay*/,
33  const amrex::Array4<const amrex::Real>& az,
34  const amrex::Array4<const amrex::Real>& detJ,
35  InterpType_H interp_u_h,
36  InterpType_V interp_u_v,
37  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
38  const amrex::Array4<const amrex::Real>& mf_ux_inv,
39  const amrex::Array4<const amrex::Real>& mf_uy_inv,
40  const amrex::Array4<const amrex::Real>& mf_vx_inv)
41 {
42  amrex::Real advectionSrc;
43  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
44 
45  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
46  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
47  amrex::Real Omega_avg_lo, Omega_avg_hi;
48 
49  amrex::Real interp_hi(0.), interp_lo(0.);
50 
51  // ****************************************************************************************
52  // X-fluxes (at cell centers)
53  // ****************************************************************************************
54 
55  rho_u_avg_hi = 0.5 * (rho_u(i+1, j, k) * mf_uy_inv(i+1,j ,0) + rho_u(i, j, k) * mf_uy_inv(i ,j ,0));
56  interp_u_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi);
57 
58  rho_u_avg_lo = 0.5 * (rho_u(i-1, j, k) * mf_uy_inv(i-1,j ,0) + rho_u(i, j, k) * mf_uy_inv(i ,j ,0));
59  interp_u_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo);
60 
61  amrex::Real centFluxXXNext = rho_u_avg_hi * interp_hi * 0.5 * (ax(i,j,k) + ax(i+1,j,k));
62  amrex::Real centFluxXXPrev = rho_u_avg_lo * interp_lo * 0.5 * (ax(i,j,k) + ax(i-1,j,k));
63 
64  // ****************************************************************************************
65  // Y-fluxes (at edges in k-direction)
66  // ****************************************************************************************
67  rho_v_avg_hi = 0.5 * (rho_v(i, j+1, k) * mf_vx_inv(i ,j+1,0) + rho_v(i-1, j+1, k) * mf_vx_inv(i-1,j+1,0));
68  interp_u_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi);
69 
70  rho_v_avg_lo = 0.5 * (rho_v(i, j , k) * mf_vx_inv(i ,j ,0) + rho_v(i-1, j , k) * mf_vx_inv(i-1,j ,0));
71  interp_u_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo);
72 
73  amrex::Real edgeFluxXYNext = rho_v_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterK(i,j+1,k,cellSizeInv,z_nd);
74  amrex::Real edgeFluxXYPrev = rho_v_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterK(i,j ,k,cellSizeInv,z_nd);
75 
76  // ****************************************************************************************
77  // Z-fluxes (at edges in j-direction)
78  // ****************************************************************************************
79  Omega_avg_hi = 0.5 * (Omega(i, j, k+1) + Omega(i-1, j, k+1)) * 0.5 * (az(i,j,k+1) + az(i-1,j,k+1));
80  Omega_avg_lo = 0.5 * (Omega(i, j, k ) + Omega(i-1, j, k )) * 0.5 * (az(i,j,k ) + az(i-1,j,k ));
81 
82  interp_u_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi);
83  interp_u_v.InterpolateInZ(i,j,k ,0,interp_lo,Omega_avg_lo);
84 
85  amrex::Real edgeFluxXZNext = Omega_avg_hi * interp_hi;
86  amrex::Real edgeFluxXZPrev = Omega_avg_lo * interp_lo;
87 
88  // ****************************************************************************************
89 
90  amrex::Real mfsq = 1. / (mf_ux_inv(i,j,0) * mf_uy_inv(i,j,0));
91 
92  advectionSrc = (centFluxXXNext - centFluxXXPrev) * dxInv * mfsq
93  + (edgeFluxXYNext - edgeFluxXYPrev) * dyInv * mfsq
94  + (edgeFluxXZNext - edgeFluxXZPrev) * dzInv;
95  advectionSrc /= 0.5*(detJ(i,j,k) + detJ(i-1,j,k));
96 
97  return advectionSrc;
98 }
99 
100 /**
101  * Function for computing the advective tendency for the y-component of momentum
102  * with metric terms and for spatial order > 2
103  *
104  * @param[in] i,j,k indices of y-face at which to create tendency
105  * @param[in] rho_u x-component of momentum
106  * @param[in] rho_v y-component of momentum
107  * @param[in] Omega component of the momentum normal to the z-coordinate surface
108  * @param[in] z_nd height coordinate at nodes
109  * @param[in] ax Area fractions on x-faces
110  * @param[in] ay Area fractions on y-faces
111  * @param[in] az Area fractions on z-faces
112  * @param[in] detJ Jacobian of the metric transformation (= 1 if use_terrain is false)
113  * @param[in] cellSizeInv inverse of the mesh spacing
114  * @param[in] mf_u map factor on x-faces
115  * @param[in] mf_v map factor on y-faces
116  */
117 template<typename InterpType_H, typename InterpType_V>
118 AMREX_GPU_DEVICE
119 AMREX_FORCE_INLINE
120 amrex::Real
121 AdvectionSrcForYMom (int i, int j, int k,
122  const amrex::Array4<const amrex::Real>& rho_u,
123  const amrex::Array4<const amrex::Real>& rho_v,
124  const amrex::Array4<const amrex::Real>& Omega,
125  const amrex::Array4<const amrex::Real>& z_nd,
126  const amrex::Array4<const amrex::Real>& /*ax*/,
127  const amrex::Array4<const amrex::Real>& ay,
128  const amrex::Array4<const amrex::Real>& az,
129  const amrex::Array4<const amrex::Real>& detJ,
130  InterpType_H interp_v_h,
131  InterpType_V interp_v_v,
132  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
133  const amrex::Array4<const amrex::Real>& mf_uy_inv,
134  const amrex::Array4<const amrex::Real>& mf_vx_inv,
135  const amrex::Array4<const amrex::Real>& mf_vy_inv)
136 {
137  amrex::Real advectionSrc;
138  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
139 
140  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
141  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
142  amrex::Real Omega_avg_lo, Omega_avg_hi;
143 
144  amrex::Real interp_hi(0.), interp_lo(0.);
145 
146  // ****************************************************************************************
147  // x-fluxes (at edges in k-direction)
148  // ****************************************************************************************
149  rho_u_avg_hi = 0.5 * (rho_u(i+1,j,k) * mf_uy_inv(i+1,j,0) + rho_u(i+1,j-1,k) * mf_uy_inv(i+1,j-1,0));
150  rho_u_avg_lo = 0.5 * (rho_u(i ,j,k) * mf_uy_inv(i ,j,0) + rho_u(i ,j-1,k) * mf_uy_inv(i ,j-1,0));
151 
152  interp_v_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi);
153  interp_v_h.InterpolateInX(i ,j,k,0,interp_lo,rho_u_avg_lo);
154 
155  amrex::Real edgeFluxYXNext = rho_u_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterK(i+1,j,k,cellSizeInv,z_nd);
156  amrex::Real edgeFluxYXPrev = rho_u_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterK(i ,j,k,cellSizeInv,z_nd);
157 
158  // ****************************************************************************************
159  // y-fluxes (at cell centers)
160  // ****************************************************************************************
161  rho_v_avg_hi = 0.5 * (rho_v(i,j,k) * mf_vx_inv(i,j,0) + rho_v(i,j+1,k) * mf_vx_inv(i,j+1,0));
162  rho_v_avg_lo = 0.5 * (rho_v(i,j,k) * mf_vx_inv(i,j,0) + rho_v(i,j-1,k) * mf_vx_inv(i,j-1,0));
163 
164  interp_v_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi);
165  interp_v_h.InterpolateInY(i,j ,k,0,interp_lo,rho_v_avg_lo);
166 
167  amrex::Real centFluxYYNext = rho_v_avg_hi * 0.5 * (ay(i,j,k) + ay(i,j+1,k)) * interp_hi;
168  amrex::Real centFluxYYPrev = rho_v_avg_lo * 0.5 * (ay(i,j,k) + ay(i,j-1,k)) * interp_lo;
169 
170  // ****************************************************************************************
171  // Z-fluxes (at edges in j-direction)
172  // ****************************************************************************************
173  Omega_avg_hi = 0.5 * (Omega(i, j, k+1) + Omega(i, j-1, k+1)) * 0.5 * (az(i,j,k+1) + az(i,j-1,k+1));
174  Omega_avg_lo = 0.5 * (Omega(i, j, k ) + Omega(i, j-1, k )) * 0.5 * (az(i,j,k ) + az(i,j-1,k ));
175 
176  interp_v_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi);
177  interp_v_v.InterpolateInZ(i,j,k ,0,interp_lo,Omega_avg_lo);
178 
179  amrex::Real edgeFluxYZNext = Omega_avg_hi * interp_hi;
180  amrex::Real edgeFluxYZPrev = Omega_avg_lo * interp_lo;
181 
182  // ****************************************************************************************
183 
184  amrex::Real mfsq = 1 / (mf_vx_inv(i,j,0) * mf_vy_inv(i,j,0));
185 
186  advectionSrc = (edgeFluxYXNext - edgeFluxYXPrev) * dxInv * mfsq
187  + (centFluxYYNext - centFluxYYPrev) * dyInv * mfsq
188  + (edgeFluxYZNext - edgeFluxYZPrev) * dzInv;
189  advectionSrc /= 0.5*(detJ(i,j,k) + detJ(i,j-1,k));
190 
191  return advectionSrc;
192 }
193 
194 /**
195  * Function for computing the advective tendency for the z-component of momentum
196  * with metric terms and for spatial order > 2
197  *
198  * @param[in] i,j,k indices of z-face at which to create tendency
199  * @param[in] rho_u x-component of momentum
200  * @param[in] rho_v y-component of momentum
201  * @param[in] Omega component of the momentum normal to the z-coordinate surface
202  * @param[in] w z-component of velocity
203  * @param[in] z_nd height coordinate at nodes
204  * @param[in] ax Area fractions on x-faces
205  * @param[in] ay Area fractions on y-faces
206  * @param[in] az Area fractions on z-faces
207  * @param[in] detJ Jacobian of the metric transformation (= 1 if use_terrain is false)
208  * @param[in] cellSizeInv inverse of the mesh spacing
209  * @param[in] mf_m map factor on cell centers
210  * @param[in] mf_u map factor on x-faces
211  * @param[in] mf_v map factor on y-faces
212  * @param[in] vert_adv_type int that defines advection stencil
213  * @param[in] lo_z_face minimum k value (z-face-centered)_in the domain at this level
214  * @param[in] hi_z_face maximum k value (z-face-centered) in the domain at this level
215  */
216 template<typename InterpType_H, typename InterpType_V, typename WallInterpType>
217 AMREX_GPU_DEVICE
218 AMREX_FORCE_INLINE
219 amrex::Real
220 AdvectionSrcForZMom (int i, int j, int k,
221  const amrex::Array4<const amrex::Real>& rho_u,
222  const amrex::Array4<const amrex::Real>& rho_v,
223  const amrex::Array4<const amrex::Real>& Omega,
224  const amrex::Array4<const amrex::Real>& w,
225  const amrex::Array4<const amrex::Real>& z_nd,
226  const amrex::Array4<const amrex::Real>& /*ax*/,
227  const amrex::Array4<const amrex::Real>& /*ay*/,
228  const amrex::Array4<const amrex::Real>& az,
229  const amrex::Array4<const amrex::Real>& detJ,
230  InterpType_H interp_omega_h,
231  InterpType_V interp_omega_v,
232  WallInterpType interp_omega_wall,
233  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
234  const amrex::Array4<const amrex::Real>& mf_mx,
235  const amrex::Array4<const amrex::Real>& mf_my,
236  const amrex::Array4<const amrex::Real>& mf_uy_inv,
237  const amrex::Array4<const amrex::Real>& mf_vx_inv,
238  const AdvType vert_adv_type,
239  const int lo_z_face, const int hi_z_face)
240 {
241  amrex::Real advectionSrc;
242  auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
243 
244  amrex::Real rho_u_avg_lo, rho_u_avg_hi;
245  amrex::Real rho_v_avg_lo, rho_v_avg_hi;
246  amrex::Real Omega_avg_lo, Omega_avg_hi;
247 
248  amrex::Real interp_hi(0.), interp_lo(0.);
249 
250  // ****************************************************************************************
251  // x-fluxes (at edges in j-direction)
252  // ****************************************************************************************
253  rho_u_avg_hi = 0.5 * (rho_u(i+1, j, k) + rho_u(i+1, j, k-1)) * mf_uy_inv(i+1,j ,0);
254  rho_u_avg_lo = 0.5 * (rho_u(i , j, k) + rho_u(i , j, k-1)) * mf_uy_inv(i ,j ,0);
255 
256  interp_omega_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi);
257  interp_omega_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo);
258 
259  amrex::Real edgeFluxZXNext = rho_u_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterJ(i+1,j,k,cellSizeInv,z_nd);
260  amrex::Real edgeFluxZXPrev = rho_u_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterJ(i ,j,k,cellSizeInv,z_nd);
261 
262  // ****************************************************************************************
263  // y-fluxes (at edges in i-direction)
264  // ****************************************************************************************
265  rho_v_avg_hi = 0.5 * (rho_v(i, j+1, k) + rho_v(i, j+1, k-1)) * mf_vx_inv(i ,j+1,0);
266  interp_omega_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi);
267 
268  rho_v_avg_lo = 0.5 * (rho_v(i, j , k) + rho_v(i, j , k-1)) * mf_vx_inv(i ,j ,0);
269  interp_omega_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo);
270 
271  amrex::Real edgeFluxZYNext = rho_v_avg_hi * interp_hi * Compute_h_zeta_AtEdgeCenterI(i,j+1,k,cellSizeInv,z_nd);
272  amrex::Real edgeFluxZYPrev = rho_v_avg_lo * interp_lo * Compute_h_zeta_AtEdgeCenterI(i,j ,k,cellSizeInv,z_nd);
273 
274  // ****************************************************************************************
275  // z-fluxes (at cell centers)
276  // ****************************************************************************************
277 
278  Omega_avg_hi = (k == hi_z_face) ? Omega(i,j,k) * az(i,j,k) :
279  0.25 * (Omega(i,j,k) + Omega(i,j,k+1)) * (az(i,j,k) + az(i,j,k+1));
280  amrex::Real centFluxZZNext = Omega_avg_hi;
281 
282  // int l_spatial_order_hi = std::min(std::min(vert_spatial_order, 2*(hi_z_face-k)), 2*(k+1));
283  // If k == hi_z_face-1, l_spatial_order_hi = 2
284  // If k == hi_z_face-2, l_spatial_order_hi = std::min(vert_spatial_order, 4);
285  // If k == lo_z_face+11 , l_spatial_order_hi = std::min(vert_spatial_order, 4);
286  if (k == hi_z_face) {
287  centFluxZZNext *= w(i,j,k);
288  } else {
289  if (k == hi_z_face-1)
290  {
291  interp_omega_wall.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,AdvType::Centered_2nd);
292  } else if (k == hi_z_face-2 || k == lo_z_face+1) {
293  if (vert_adv_type != AdvType::Centered_2nd && vert_adv_type != AdvType::Upwind_3rd) {
294  interp_omega_wall.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,AdvType::Centered_4th);
295  } else {
296  interp_omega_wall.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,vert_adv_type);
297  }
298  } else {
299  interp_omega_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi);
300  }
301  centFluxZZNext *= interp_hi;
302  }
303 
304  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
305 
306  Omega_avg_lo = (k == 0) ? Omega(i,j,k) * az(i,j,k) :
307  0.25 * (Omega(i,j,k) + Omega(i,j,k-1)) * (az(i,j,k) + az(i,j,k-1));
308  amrex::Real centFluxZZPrev = Omega_avg_lo;
309 
310  // int l_spatial_order_lo = std::min(std::min(vert_spatial_order, 2*(hi_z_face+1-k)), 2*k);
311  // If k == hi_z_face-1, l_spatial_order_hi = 2
312  // If k == hi_z_face-2, l_spatial_order_hi = std::min(vert_spatial_order, 4);
313  // If k == lo_z_face+1, l_spatial_order_hi = std::min(vert_spatial_order, 4);
314  if (k == 0) {
315  centFluxZZPrev *= w(i,j,k);
316  } else {
317  if (k == lo_z_face+1) {
318  interp_omega_wall.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,AdvType::Centered_2nd);
319  } else if (k == lo_z_face+2 || k == hi_z_face-1) {
320  if (vert_adv_type != AdvType::Centered_2nd && vert_adv_type != AdvType::Upwind_3rd) {
321  interp_omega_wall.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,AdvType::Centered_4th);
322  } else {
323  interp_omega_wall.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,vert_adv_type);
324  }
325  } else {
326  interp_omega_v.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo);
327  }
328  centFluxZZPrev *= interp_lo;
329  }
330 
331  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
332 
333  amrex::Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
334 
335  advectionSrc = (edgeFluxZXNext - edgeFluxZXPrev) * dxInv * mfsq
336  + (edgeFluxZYNext - edgeFluxZYPrev) * dyInv * mfsq
337  + (centFluxZZNext - centFluxZZPrev) * dzInv;
338 
339  amrex::Real denom = 0.5*(detJ(i,j,k) + detJ(i,j,k-1));
340  advectionSrc /= denom;
341 
342  return advectionSrc;
343 }
344 
345 /**
346  * Wrapper function for computing the advective tendency w/ spatial order > 2.
347  */
348 template<typename InterpType_H, typename InterpType_V, typename WallInterpType>
349 void
350 AdvectionSrcForMomWrapper (const amrex::Box& bxx, const amrex::Box& bxy, const amrex::Box& bxz,
351  const amrex::Array4<amrex::Real>& rho_u_rhs,
352  const amrex::Array4<amrex::Real>& rho_v_rhs,
353  const amrex::Array4<amrex::Real>& rho_w_rhs,
354  const amrex::Array4<const amrex::Real>& rho_u,
355  const amrex::Array4<const amrex::Real>& rho_v,
356  const amrex::Array4<const amrex::Real>& Omega,
357  const amrex::Array4<const amrex::Real>& u,
358  const amrex::Array4<const amrex::Real>& v,
359  const amrex::Array4<const amrex::Real>& w,
360  const amrex::Array4<const amrex::Real>& z_nd,
361  const amrex::Array4<const amrex::Real>& ax,
362  const amrex::Array4<const amrex::Real>& ay,
363  const amrex::Array4<const amrex::Real>& az,
364  const amrex::Array4<const amrex::Real>& detJ,
365  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
366  const amrex::Array4<const amrex::Real>& mf_mx,
367  const amrex::Array4<const amrex::Real>& mf_ux_inv,
368  const amrex::Array4<const amrex::Real>& mf_vx_inv,
369  const amrex::Array4<const amrex::Real>& mf_my,
370  const amrex::Array4<const amrex::Real>& mf_uy_inv,
371  const amrex::Array4<const amrex::Real>& mf_vy_inv,
372  const amrex::Real upw_frac_h,
373  const amrex::Real upw_frac_v,
374  const AdvType vert_adv_type,
375  const int lo_z_face, const int hi_z_face)
376 {
377  // Instantiate the appropriate structs
378  InterpType_H interp_u_h(u, upw_frac_h); InterpType_V interp_u_v(u, upw_frac_v); // X-MOM
379  InterpType_H interp_v_h(v, upw_frac_h); InterpType_V interp_v_v(v, upw_frac_v); // Y-MOM
380  InterpType_H interp_w_h(w, upw_frac_h); InterpType_V interp_w_v(w, upw_frac_v); // Z-MOM
381  WallInterpType interp_w_wall(w, upw_frac_v); // Z-MOM @ wall
382 
383  amrex::ParallelFor(bxx,
384  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
385  {
386  rho_u_rhs(i, j, k) = -AdvectionSrcForXMom(i, j, k, rho_u, rho_v, Omega, z_nd, ax, ay, az, detJ,
387  interp_u_h, interp_u_v,
388  cellSizeInv, mf_ux_inv, mf_uy_inv, mf_vx_inv);
389  });
390 
391  amrex::ParallelFor(bxy,
392  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
393  {
394  rho_v_rhs(i, j, k) = -AdvectionSrcForYMom(i, j, k, rho_u, rho_v, Omega, z_nd, ax, ay, az, detJ,
395  interp_v_h, interp_v_v,
396  cellSizeInv, mf_uy_inv, mf_vx_inv, mf_vy_inv);
397  });
398 
399  amrex::ParallelFor(bxz,
400  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
401  {
402  rho_w_rhs(i, j, k) = -AdvectionSrcForZMom(i, j, k, rho_u, rho_v, Omega, w, z_nd, ax, ay, az, detJ,
403  interp_w_h, interp_w_v, interp_w_wall,
404  cellSizeInv, mf_mx, mf_my, mf_uy_inv, mf_vx_inv,
405  vert_adv_type, lo_z_face, hi_z_face);
406  });
407 }
408 
409 /**
410  * Wrapper function for computing the advective tendency w/ spatial order > 2.
411  */
412 template<typename InterpType_H>
413 void
414 AdvectionSrcForMomVert (const amrex::Box& bxx, const amrex::Box& bxy, const amrex::Box& bxz,
415  const amrex::Array4<amrex::Real>& rho_u_rhs,
416  const amrex::Array4<amrex::Real>& rho_v_rhs,
417  const amrex::Array4<amrex::Real>& rho_w_rhs,
418  const amrex::Array4<const amrex::Real>& rho_u,
419  const amrex::Array4<const amrex::Real>& rho_v,
420  const amrex::Array4<const amrex::Real>& Omega,
421  const amrex::Array4<const amrex::Real>& u,
422  const amrex::Array4<const amrex::Real>& v,
423  const amrex::Array4<const amrex::Real>& w,
424  const amrex::Array4<const amrex::Real>& z_nd,
425  const amrex::Array4<const amrex::Real>& ax,
426  const amrex::Array4<const amrex::Real>& ay,
427  const amrex::Array4<const amrex::Real>& az,
428  const amrex::Array4<const amrex::Real>& detJ,
429  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
430  const amrex::Array4<const amrex::Real>& mf_mx,
431  const amrex::Array4<const amrex::Real>& mf_ux_inv,
432  const amrex::Array4<const amrex::Real>& mf_vx_inv,
433  const amrex::Array4<const amrex::Real>& mf_my,
434  const amrex::Array4<const amrex::Real>& mf_uy_inv,
435  const amrex::Array4<const amrex::Real>& mf_vy_inv,
436  const amrex::Real upw_frac_h,
437  const amrex::Real upw_frac_v,
438  const AdvType vert_adv_type,
439  const int lo_z_face, const int hi_z_face)
440 {
441  if (vert_adv_type == AdvType::Centered_2nd) {
442  AdvectionSrcForMomWrapper<InterpType_H,CENTERED2,UPWINDALL>(bxx, bxy, bxz,
443  rho_u_rhs, rho_v_rhs, rho_w_rhs,
444  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
445  cellSizeInv,
446  mf_mx, mf_ux_inv, mf_vx_inv,
447  mf_my, mf_uy_inv, mf_vy_inv,
448  upw_frac_h, upw_frac_v,
449  vert_adv_type, lo_z_face, hi_z_face);
450  } else if (vert_adv_type == AdvType::Upwind_3rd) {
451  AdvectionSrcForMomWrapper<InterpType_H,UPWIND3,UPWINDALL>(bxx, bxy, bxz,
452  rho_u_rhs, rho_v_rhs, rho_w_rhs,
453  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
454  cellSizeInv,
455  mf_mx, mf_ux_inv, mf_vx_inv,
456  mf_my, mf_uy_inv, mf_vy_inv,
457  upw_frac_h, upw_frac_v,
458  vert_adv_type, lo_z_face, hi_z_face);
459  } else if (vert_adv_type == AdvType::Centered_4th) {
460  AdvectionSrcForMomWrapper<InterpType_H,CENTERED4,UPWINDALL>(bxx, bxy, bxz,
461  rho_u_rhs, rho_v_rhs, rho_w_rhs,
462  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
463  cellSizeInv,
464  mf_mx, mf_ux_inv, mf_vx_inv,
465  mf_my, mf_uy_inv, mf_vy_inv,
466  upw_frac_h, upw_frac_v,
467  vert_adv_type, lo_z_face, hi_z_face);
468  } else if (vert_adv_type == AdvType::Upwind_5th) {
469  AdvectionSrcForMomWrapper<InterpType_H,UPWIND5,UPWINDALL>(bxx, bxy, bxz,
470  rho_u_rhs, rho_v_rhs, rho_w_rhs,
471  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
472  cellSizeInv,
473  mf_mx, mf_ux_inv, mf_vx_inv,
474  mf_my, mf_uy_inv, mf_vy_inv,
475  upw_frac_h, upw_frac_v,
476  vert_adv_type, lo_z_face, hi_z_face);
477  } else if (vert_adv_type == AdvType::Centered_6th) {
478  AdvectionSrcForMomWrapper<InterpType_H,CENTERED6,UPWINDALL>(bxx, bxy, bxz,
479  rho_u_rhs, rho_v_rhs, rho_w_rhs,
480  rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
481  cellSizeInv,
482  mf_mx, mf_ux_inv, mf_vx_inv,
483  mf_my, mf_uy_inv, mf_vy_inv,
484  upw_frac_h, upw_frac_v,
485  vert_adv_type, lo_z_face, hi_z_face);
486  } else {
487  AMREX_ASSERT_WITH_MESSAGE(false, "Unknown advection scheme!");
488  }
489 }
void AdvectionSrcForMomWrapper(const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vy_inv, const amrex::Real upw_frac_h, const amrex::Real upw_frac_v, const AdvType vert_adv_type, const int lo_z_face, const int hi_z_face)
Definition: ERF_AdvectionSrcForMom_T.H:350
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForZMom(int i, int j, int k, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, InterpType_H interp_omega_h, InterpType_V interp_omega_v, WallInterpType interp_omega_wall, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv, const AdvType vert_adv_type, const int lo_z_face, const int hi_z_face)
Definition: ERF_AdvectionSrcForMom_T.H:220
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForYMom(int i, int j, int k, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, InterpType_H interp_v_h, InterpType_V interp_v_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv, const amrex::Array4< const amrex::Real > &mf_vy_inv)
Definition: ERF_AdvectionSrcForMom_T.H:121
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real AdvectionSrcForXMom(int i, int j, int k, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, InterpType_H interp_u_h, InterpType_V interp_u_v, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_ux_inv, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv)
Definition: ERF_AdvectionSrcForMom_T.H:26
void AdvectionSrcForMomVert(const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux_inv, const amrex::Array4< const amrex::Real > &mf_vx_inv, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy_inv, const amrex::Array4< const amrex::Real > &mf_vy_inv, const amrex::Real upw_frac_h, const amrex::Real upw_frac_v, const AdvType vert_adv_type, const int lo_z_face, const int hi_z_face)
Definition: ERF_AdvectionSrcForMom_T.H:414
AdvType
Definition: ERF_IndexDefines.H:221
@ 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:276
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtEdgeCenterK(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:231
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtEdgeCenterI(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:320