17 template<
typename InterpType_H,
typename InterpType_V>
22 const amrex::Array4<const amrex::Real>& rho_u,
23 const amrex::Array4<const amrex::Real>& rho_v,
24 const amrex::Array4<const amrex::Real>& rho_w,
25 InterpType_H interp_u_h,
26 InterpType_V interp_u_v,
27 const amrex::Real upw_frac_h,
28 const amrex::Real upw_frac_v,
29 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
30 const amrex::Array4<const amrex::Real>& mf_u_inv,
31 const amrex::Array4<const amrex::Real>& mf_v_inv)
33 amrex::Real advectionSrc;
34 auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
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;
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;
44 amrex::Real interp_hi(0.), interp_lo(0.);
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;
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;
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;
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;
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;
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;
70 amrex::Real mfsq = 1 / (mf_u_inv(i,j,0) * mf_u_inv(i,j,0));
72 advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
73 + (yflux_hi - yflux_lo) * dyInv * mfsq
74 + (zflux_hi - zflux_lo) * dzInv;
92 template<
typename InterpType_H,
typename InterpType_V>
97 const amrex::Array4<const amrex::Real>& rho_u,
98 const amrex::Array4<const amrex::Real>& rho_v,
99 const amrex::Array4<const amrex::Real>& rho_w,
100 InterpType_H interp_v_h,
101 InterpType_V interp_v_v,
102 const amrex::Real upw_frac_h,
103 const amrex::Real upw_frac_v,
104 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
105 const amrex::Array4<const amrex::Real>& mf_u_inv,
106 const amrex::Array4<const amrex::Real>& mf_v_inv)
108 amrex::Real advectionSrc;
109 auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
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;
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;
119 amrex::Real interp_hi(0.), interp_lo(0.);
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;
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;
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;
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;
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;
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;
145 amrex::Real mfsq = 1 / (mf_v_inv(i,j,0) * mf_v_inv(i,j,0));
147 advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
148 + (yflux_hi - yflux_lo) * dyInv * mfsq
149 + (zflux_hi - zflux_lo) * dzInv;
169 template<
typename InterpType_H,
typename InterpType_V,
typename WallInterpType>
174 const amrex::Array4<const amrex::Real>& rho_u,
175 const amrex::Array4<const amrex::Real>& rho_v,
176 const amrex::Array4<const amrex::Real>& rho_w,
177 const amrex::Array4<const amrex::Real>& w,
178 InterpType_H interp_w_h,
179 InterpType_V interp_w_v,
180 WallInterpType interp_w_wall,
181 const amrex::Real upw_frac_h,
182 const amrex::Real upw_frac_v,
183 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
184 const amrex::Array4<const amrex::Real>& mf_m,
185 const amrex::Array4<const amrex::Real>& mf_u_inv,
186 const amrex::Array4<const amrex::Real>& mf_v_inv,
188 const int lo_z_face,
const int hi_z_face)
191 amrex::Real advectionSrc;
192 auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
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;
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;
202 amrex::Real interp_hi(0.), interp_lo(0.);
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;
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;
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;
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;
225 if (k == hi_z_face) {
226 zflux_hi = rho_w(i,j,k) * w(i,j,k);
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)
232 }
else if (k == hi_z_face-2 || k == lo_z_face+1) {
236 interp_w_wall.InterpolateInZ(i,j,k+1,0,interp_hi,rho_w_avg_hi,upw_frac_v,vert_adv_type);
239 interp_w_v.InterpolateInZ(i,j,k+1,0,interp_hi,rho_w_avg_hi,upw_frac_v);
241 zflux_hi = rho_w_avg_hi * interp_hi;
249 if (k == lo_z_face) {
250 zflux_lo = rho_w(i,j,k) * w(i,j,k);
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) {
255 }
else if (k == lo_z_face+2 || k == hi_z_face-1) {
259 interp_w_wall.InterpolateInZ(i,j,k,0,interp_lo,rho_w_avg_lo,upw_frac_v,vert_adv_type);
262 interp_w_v.InterpolateInZ(i,j,k,0,interp_lo,rho_w_avg_lo,upw_frac_v);
264 zflux_lo = rho_w_avg_lo * interp_lo;
267 amrex::Real mfsq = mf_m(i,j,0) * mf_m(i,j,0);
269 advectionSrc = (xflux_hi - xflux_lo) * dxInv * mfsq
270 + (yflux_hi - yflux_lo) * dyInv * mfsq
271 + (zflux_hi - zflux_lo) * dzInv;
279 template<
typename InterpType_H,
typename InterpType_V,
typename WallInterpType>
282 const amrex::Array4<amrex::Real>& rho_u_rhs,
283 const amrex::Array4<amrex::Real>& rho_v_rhs,
284 const amrex::Array4<amrex::Real>& rho_w_rhs,
285 const amrex::Array4<const amrex::Real>& rho_u,
286 const amrex::Array4<const amrex::Real>& rho_v,
287 const amrex::Array4<const amrex::Real>& rho_w,
288 const amrex::Array4<const amrex::Real>& u,
289 const amrex::Array4<const amrex::Real>& v,
290 const amrex::Array4<const amrex::Real>& w,
291 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
292 const amrex::Array4<const amrex::Real>& mf_m,
293 const amrex::Array4<const amrex::Real>& mf_u_inv,
294 const amrex::Array4<const amrex::Real>& mf_v_inv,
295 const amrex::Real upw_frac_h,
296 const amrex::Real upw_frac_v,
298 const int lo_z_face,
const int hi_z_face)
301 InterpType_H interp_u_h(u); InterpType_V interp_u_v(u);
302 InterpType_H interp_v_h(v); InterpType_V interp_v_v(v);
303 InterpType_H interp_w_h(w); InterpType_V interp_w_v(w);
304 WallInterpType interp_w_wall(w);
306 amrex::ParallelFor(bxx,
307 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
310 interp_u_h, interp_u_v,
311 upw_frac_h, upw_frac_v,
312 cellSizeInv, mf_u_inv, mf_v_inv);
315 amrex::ParallelFor(bxy,
316 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
319 interp_v_h, interp_v_v,
320 upw_frac_h, upw_frac_v,
321 cellSizeInv, mf_u_inv, mf_v_inv);
324 amrex::ParallelFor(bxz,
325 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
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);
338 template<
typename InterpType_H>
341 const amrex::Array4<amrex::Real>& rho_u_rhs,
342 const amrex::Array4<amrex::Real>& rho_v_rhs,
343 const amrex::Array4<amrex::Real>& rho_w_rhs,
344 const amrex::Array4<const amrex::Real>& rho_u,
345 const amrex::Array4<const amrex::Real>& rho_v,
346 const amrex::Array4<const amrex::Real>& rho_w,
347 const amrex::Array4<const amrex::Real>& u,
348 const amrex::Array4<const amrex::Real>& v,
349 const amrex::Array4<const amrex::Real>& w,
350 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
351 const amrex::Array4<const amrex::Real>& mf_m,
352 const amrex::Array4<const amrex::Real>& mf_u_inv,
353 const amrex::Array4<const amrex::Real>& mf_v_inv,
354 const amrex::Real upw_frac_h,
355 const amrex::Real upw_frac_v,
357 const int lo_z_face,
const int hi_z_face)
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,
365 upw_frac_h, upw_frac_v,
367 lo_z_face, hi_z_face);
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,
374 upw_frac_h, upw_frac_v,
376 lo_z_face, hi_z_face);
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,
383 upw_frac_h, upw_frac_v,
385 lo_z_face, hi_z_face);
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,
392 upw_frac_h, upw_frac_v,
394 lo_z_face, hi_z_face);
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,
401 upw_frac_h, upw_frac_v,
403 lo_z_face, hi_z_face);
405 AMREX_ASSERT_WITH_MESSAGE(
false,
"Unknown advection scheme!");
AdvType
Definition: ERF_IndexDefines.H:191