22 template<
typename InterpType_H,
typename InterpType_V>
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>& ,
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::Real upw_frac_h,
38 const amrex::Real upw_frac_v,
39 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
40 const amrex::Array4<const amrex::Real>& mf_u_inv,
41 const amrex::Array4<const amrex::Real>& mf_v_inv)
43 amrex::Real advectionSrc;
44 auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
46 amrex::Real rho_u_avg_lo, rho_u_avg_hi;
47 amrex::Real rho_v_avg_lo, rho_v_avg_hi;
48 amrex::Real Omega_avg_lo, Omega_avg_hi;
50 amrex::Real interp_hi(0.), interp_lo(0.);
56 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));
57 interp_u_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi,upw_frac_h);
59 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));
60 interp_u_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo,upw_frac_h);
62 amrex::Real centFluxXXNext = rho_u_avg_hi * interp_hi * 0.5 * (ax(i,j,k) + ax(i+1,j,k));
63 amrex::Real centFluxXXPrev = rho_u_avg_lo * interp_lo * 0.5 * (ax(i,j,k) + ax(i-1,j,k));
68 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));
69 interp_u_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi,upw_frac_h);
71 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));
72 interp_u_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo,upw_frac_h);
80 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));
81 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 ));
83 interp_u_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,upw_frac_v);
84 interp_u_v.InterpolateInZ(i,j,k ,0,interp_lo,Omega_avg_lo,upw_frac_v);
86 amrex::Real edgeFluxXZNext = Omega_avg_hi * interp_hi;
87 amrex::Real edgeFluxXZPrev = Omega_avg_lo * interp_lo;
91 amrex::Real mfsq = 1 / (mf_u_inv(i,j,0) * mf_u_inv(i,j,0));
93 advectionSrc = (centFluxXXNext - centFluxXXPrev) * dxInv * mfsq
94 + (edgeFluxXYNext - edgeFluxXYPrev) * dyInv * mfsq
95 + (edgeFluxXZNext - edgeFluxXZPrev) * dzInv;
96 advectionSrc /= 0.5*(detJ(i,j,k) + detJ(i-1,j,k));
118 template<
typename InterpType_H,
typename InterpType_V>
123 const amrex::Array4<const amrex::Real>& rho_u,
124 const amrex::Array4<const amrex::Real>& rho_v,
125 const amrex::Array4<const amrex::Real>& Omega,
126 const amrex::Array4<const amrex::Real>& z_nd,
127 const amrex::Array4<const amrex::Real>& ,
128 const amrex::Array4<const amrex::Real>& ay,
129 const amrex::Array4<const amrex::Real>& az,
130 const amrex::Array4<const amrex::Real>& detJ,
131 InterpType_H interp_v_h,
132 InterpType_V interp_v_v,
133 const amrex::Real upw_frac_h,
134 const amrex::Real upw_frac_v,
135 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
136 const amrex::Array4<const amrex::Real>& mf_u_inv,
137 const amrex::Array4<const amrex::Real>& mf_v_inv)
139 amrex::Real advectionSrc;
140 auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
142 amrex::Real rho_u_avg_lo, rho_u_avg_hi;
143 amrex::Real rho_v_avg_lo, rho_v_avg_hi;
144 amrex::Real Omega_avg_lo, Omega_avg_hi;
146 amrex::Real interp_hi(0.), interp_lo(0.);
151 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));
152 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));
154 interp_v_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi,upw_frac_h);
155 interp_v_h.InterpolateInX(i ,j,k,0,interp_lo,rho_u_avg_lo,upw_frac_h);
163 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));
164 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));
166 interp_v_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi,upw_frac_h);
167 interp_v_h.InterpolateInY(i,j ,k,0,interp_lo,rho_v_avg_lo,upw_frac_h);
169 amrex::Real centFluxYYNext = rho_v_avg_hi * 0.5 * (ay(i,j,k) + ay(i,j+1,k)) * interp_hi;
170 amrex::Real centFluxYYPrev = rho_v_avg_lo * 0.5 * (ay(i,j,k) + ay(i,j-1,k)) * interp_lo;
175 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));
176 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 ));
178 interp_v_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,upw_frac_v);
179 interp_v_v.InterpolateInZ(i,j,k ,0,interp_lo,Omega_avg_lo,upw_frac_v);
181 amrex::Real edgeFluxYZNext = Omega_avg_hi * interp_hi;
182 amrex::Real edgeFluxYZPrev = Omega_avg_lo * interp_lo;
186 amrex::Real mfsq = 1 / (mf_v_inv(i,j,0) * mf_v_inv(i,j,0));
188 advectionSrc = (edgeFluxYXNext - edgeFluxYXPrev) * dxInv * mfsq
189 + (centFluxYYNext - centFluxYYPrev) * dyInv * mfsq
190 + (edgeFluxYZNext - edgeFluxYZPrev) * dzInv;
191 advectionSrc /= 0.5*(detJ(i,j,k) + detJ(i,j-1,k));
218 template<
typename InterpType_H,
typename InterpType_V,
typename WallInterpType>
223 const amrex::Array4<const amrex::Real>& rho_u,
224 const amrex::Array4<const amrex::Real>& rho_v,
225 const amrex::Array4<const amrex::Real>& Omega,
226 const amrex::Array4<const amrex::Real>& w,
227 const amrex::Array4<const amrex::Real>& z_nd,
228 const amrex::Array4<const amrex::Real>& ,
229 const amrex::Array4<const amrex::Real>& ,
230 const amrex::Array4<const amrex::Real>& az,
231 const amrex::Array4<const amrex::Real>& detJ,
232 InterpType_H interp_omega_h,
233 InterpType_V interp_omega_v,
234 WallInterpType interp_omega_wall,
235 const amrex::Real upw_frac_h,
236 const amrex::Real upw_frac_v,
237 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
238 const amrex::Array4<const amrex::Real>& mf_m,
239 const amrex::Array4<const amrex::Real>& mf_u_inv,
240 const amrex::Array4<const amrex::Real>& mf_v_inv,
242 const int lo_z_face,
const int hi_z_face)
244 amrex::Real advectionSrc;
245 auto dxInv = cellSizeInv[0], dyInv = cellSizeInv[1], dzInv = cellSizeInv[2];
247 amrex::Real rho_u_avg_lo, rho_u_avg_hi;
248 amrex::Real rho_v_avg_lo, rho_v_avg_hi;
249 amrex::Real Omega_avg_lo, Omega_avg_hi;
251 amrex::Real interp_hi(0.), interp_lo(0.);
256 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);
257 rho_u_avg_lo = 0.5 * (rho_u(i , j, k) + rho_u(i , j, k-1)) * mf_u_inv(i ,j ,0);
259 interp_omega_h.InterpolateInX(i+1,j,k,0,interp_hi,rho_u_avg_hi,upw_frac_h);
260 interp_omega_h.InterpolateInX(i,j,k,0,interp_lo,rho_u_avg_lo,upw_frac_h);
268 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);
269 interp_omega_h.InterpolateInY(i,j+1,k,0,interp_hi,rho_v_avg_hi,upw_frac_h);
271 rho_v_avg_lo = 0.5 * (rho_v(i, j , k) + rho_v(i, j , k-1)) * mf_v_inv(i ,j ,0);
272 interp_omega_h.InterpolateInY(i,j,k,0,interp_lo,rho_v_avg_lo,upw_frac_h);
281 Omega_avg_hi = (k == hi_z_face) ? Omega(i,j,k) * az(i,j,k) :
282 0.25 * (Omega(i,j,k) + Omega(i,j,k+1)) * (az(i,j,k) + az(i,j,k+1));
283 amrex::Real centFluxZZNext = Omega_avg_hi;
289 if (k == hi_z_face) {
290 centFluxZZNext *= w(i,j,k);
292 if (k == hi_z_face-1)
295 }
else if (k == hi_z_face-2 || k == lo_z_face+1) {
299 interp_omega_wall.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,upw_frac_v,vert_adv_type);
302 interp_omega_v.InterpolateInZ(i,j,k+1,0,interp_hi,Omega_avg_hi,upw_frac_v);
304 centFluxZZNext *= interp_hi;
309 Omega_avg_lo = (k == 0) ? Omega(i,j,k) * az(i,j,k) :
310 0.25 * (Omega(i,j,k) + Omega(i,j,k-1)) * (az(i,j,k) + az(i,j,k-1));
311 amrex::Real centFluxZZPrev = Omega_avg_lo;
318 centFluxZZPrev *= w(i,j,k);
320 if (k == lo_z_face+1) {
322 }
else if (k == lo_z_face+2 || k == hi_z_face-1) {
326 interp_omega_wall.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,upw_frac_v,vert_adv_type);
329 interp_omega_v.InterpolateInZ(i,j,k,0,interp_lo,Omega_avg_lo,upw_frac_v);
331 centFluxZZPrev *= interp_lo;
336 amrex::Real mfsq = mf_m(i,j,0) * mf_m(i,j,0);
338 advectionSrc = (edgeFluxZXNext - edgeFluxZXPrev) * dxInv * mfsq
339 + (edgeFluxZYNext - edgeFluxZYPrev) * dyInv * mfsq
340 + (centFluxZZNext - centFluxZZPrev) * dzInv;
342 amrex::Real denom = 0.5*(detJ(i,j,k) + detJ(i,j,k-1));
343 advectionSrc /= denom;
351 template<
typename InterpType_H,
typename InterpType_V,
typename WallInterpType>
354 const amrex::Array4<amrex::Real>& rho_u_rhs,
355 const amrex::Array4<amrex::Real>& rho_v_rhs,
356 const amrex::Array4<amrex::Real>& rho_w_rhs,
357 const amrex::Array4<const amrex::Real>& rho_u,
358 const amrex::Array4<const amrex::Real>& rho_v,
359 const amrex::Array4<const amrex::Real>& Omega,
360 const amrex::Array4<const amrex::Real>& u,
361 const amrex::Array4<const amrex::Real>& v,
362 const amrex::Array4<const amrex::Real>& w,
363 const amrex::Array4<const amrex::Real>& z_nd,
364 const amrex::Array4<const amrex::Real>& ax,
365 const amrex::Array4<const amrex::Real>& ay,
366 const amrex::Array4<const amrex::Real>& az,
367 const amrex::Array4<const amrex::Real>& detJ,
368 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
369 const amrex::Array4<const amrex::Real>& mf_m,
370 const amrex::Array4<const amrex::Real>& mf_u_inv,
371 const amrex::Array4<const amrex::Real>& mf_v_inv,
372 const amrex::Real upw_frac_h,
373 const amrex::Real upw_frac_v,
375 const int lo_z_face,
const int hi_z_face)
378 InterpType_H interp_u_h(u); InterpType_V interp_u_v(u);
379 InterpType_H interp_v_h(v); InterpType_V interp_v_v(v);
380 InterpType_H interp_w_h(w); InterpType_V interp_w_v(w);
381 WallInterpType interp_w_wall(w);
383 amrex::ParallelFor(bxx,
384 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
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 upw_frac_h, upw_frac_v,
389 cellSizeInv, mf_u_inv, mf_v_inv);
392 amrex::ParallelFor(bxy,
393 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
395 rho_v_rhs(i, j, k) = -
AdvectionSrcForYMom(i, j, k, rho_u, rho_v, Omega, z_nd, ax, ay, az, detJ,
396 interp_v_h, interp_v_v,
397 upw_frac_h, upw_frac_v,
398 cellSizeInv, mf_u_inv, mf_v_inv);
401 amrex::ParallelFor(bxz,
402 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
404 rho_w_rhs(i, j, k) = -
AdvectionSrcForZMom(i, j, k, rho_u, rho_v, Omega, w, z_nd, ax, ay, az, detJ,
405 interp_w_h, interp_w_v, interp_w_wall,
406 upw_frac_h, upw_frac_v,
407 cellSizeInv, mf_m, mf_u_inv, mf_v_inv,
408 vert_adv_type, lo_z_face, hi_z_face);
415 template<
typename InterpType_H>
418 const amrex::Array4<amrex::Real>& rho_u_rhs,
419 const amrex::Array4<amrex::Real>& rho_v_rhs,
420 const amrex::Array4<amrex::Real>& rho_w_rhs,
421 const amrex::Array4<const amrex::Real>& rho_u,
422 const amrex::Array4<const amrex::Real>& rho_v,
423 const amrex::Array4<const amrex::Real>& Omega,
424 const amrex::Array4<const amrex::Real>& u,
425 const amrex::Array4<const amrex::Real>& v,
426 const amrex::Array4<const amrex::Real>& w,
427 const amrex::Array4<const amrex::Real>& z_nd,
428 const amrex::Array4<const amrex::Real>& ax,
429 const amrex::Array4<const amrex::Real>& ay,
430 const amrex::Array4<const amrex::Real>& az,
431 const amrex::Array4<const amrex::Real>& detJ,
432 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
433 const amrex::Array4<const amrex::Real>& mf_m,
434 const amrex::Array4<const amrex::Real>& mf_u_inv,
435 const amrex::Array4<const amrex::Real>& mf_v_inv,
436 const amrex::Real upw_frac_h,
437 const amrex::Real upw_frac_v,
439 const int lo_z_face,
const int hi_z_face)
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,
447 upw_frac_h, upw_frac_v,
448 vert_adv_type, lo_z_face, hi_z_face);
450 AdvectionSrcForMomWrapper<InterpType_H,UPWIND3,UPWINDALL>(bxx, bxy, bxz,
451 rho_u_rhs, rho_v_rhs, rho_w_rhs,
452 rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
455 upw_frac_h, upw_frac_v,
456 vert_adv_type, lo_z_face, hi_z_face);
458 AdvectionSrcForMomWrapper<InterpType_H,CENTERED4,UPWINDALL>(bxx, bxy, bxz,
459 rho_u_rhs, rho_v_rhs, rho_w_rhs,
460 rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
463 upw_frac_h, upw_frac_v,
464 vert_adv_type, lo_z_face, hi_z_face);
466 AdvectionSrcForMomWrapper<InterpType_H,UPWIND5,UPWINDALL>(bxx, bxy, bxz,
467 rho_u_rhs, rho_v_rhs, rho_w_rhs,
468 rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
471 upw_frac_h, upw_frac_v,
472 vert_adv_type, lo_z_face, hi_z_face);
474 AdvectionSrcForMomWrapper<InterpType_H,CENTERED6,UPWINDALL>(bxx, bxy, bxz,
475 rho_u_rhs, rho_v_rhs, rho_w_rhs,
476 rho_u, rho_v, Omega, u, v, w, z_nd, ax, ay, az, detJ,
479 upw_frac_h, upw_frac_v,
480 vert_adv_type, lo_z_face, hi_z_face);
482 AMREX_ASSERT_WITH_MESSAGE(
false,
"Unknown advection scheme!");
AdvType
Definition: ERF_IndexDefines.H:191
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