6 #include <AMReX_Vector.H>
12 template<
typename InterpType_H,
typename InterpType_V>
15 const int& ncomp,
const int& icomp,
16 const amrex::GpuArray<
const amrex::Array4<amrex::Real>, AMREX_SPACEDIM> flx_arr,
17 const amrex::Array4<const amrex::Real>& cell_prim,
18 const amrex::Array4<const amrex::Real>& avg_xmom,
19 const amrex::Array4<const amrex::Real>& avg_ymom,
20 const amrex::Array4<const amrex::Real>& avg_zmom,
21 const amrex::Array4<const amrex::EBCellFlag>& cellflag,
22 const amrex::Array4<const amrex::Real>& ax_arr,
23 const amrex::Array4<const amrex::Real>& ay_arr,
24 const amrex::Array4<const amrex::Real>& az_arr,
25 const amrex::Real horiz_upw_frac,
26 const amrex::Real vert_upw_frac)
29 InterpType_H interp_prim_h(cell_prim);
30 InterpType_V interp_prim_v(cell_prim);
32 const int ncells_h = interp_prim_h.GetUpwindCellNumber();
33 const int ncells_v = interp_prim_v.GetUpwindCellNumber();
37 UPWIND3 interp_prim_UPW3(cell_prim);
39 const amrex::Box xbx = amrex::surroundingNodes(bx,0);
40 const amrex::Box ybx = amrex::surroundingNodes(bx,1);
41 const amrex::Box zbx = amrex::surroundingNodes(bx,2);
43 amrex::ParallelFor(xbx, ncomp,[=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n) noexcept
45 const int cons_index = icomp + n;
47 if ( ax_arr(i,j,k) > 0. )
53 if (avg_xmom(i,j,k)>0.)
55 for (icell=0; icell<ncells_h; ++icell) {
56 if (cellflag(i-icell-1,j,k).isCovered()) {
61 else if (avg_xmom(i,j,k)<0.)
63 for (icell=0; icell<ncells_h; ++icell) {
64 if (cellflag(i+icell,j,k).isCovered()) {
72 const int prim_index = cons_index - 1;
73 amrex::Real interpx(0.);
75 if (icell==ncells_h-1) {
76 interp_prim_h.InterpolateInX(i,j,k,prim_index,interpx,avg_xmom(i,j,k),horiz_upw_frac);
79 interp_prim_CEN2.
InterpolateInX(i,j,k,prim_index,interpx,avg_xmom(i,j,k),horiz_upw_frac);
80 }
else if (icell==2) {
81 interp_prim_UPW3.
InterpolateInX(i,j,k,prim_index,interpx,avg_xmom(i,j,k),horiz_upw_frac);
84 (flx_arr[0])(i,j,k,cons_index) = avg_xmom(i,j,k) * interpx;
88 (flx_arr[0])(i,j,k,cons_index) = 0.;
92 amrex::ParallelFor(ybx, ncomp,[=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n) noexcept
94 const int cons_index = icomp + n;
96 if ( ay_arr(i,j,k) > 0. )
102 if (avg_ymom(i,j,k)>0.)
104 for (jcell=0; jcell<ncells_h; ++jcell) {
105 if (cellflag(i,j-jcell-1,k).isCovered()) {
110 else if (avg_ymom(i,j,k)<0.)
112 for (jcell=0; jcell<ncells_h; ++jcell) {
113 if (cellflag(i,j+jcell,k).isCovered()) {
121 const int prim_index = cons_index - 1;
122 amrex::Real interpy(0.);
124 if (jcell==ncells_h-1) {
125 interp_prim_h.InterpolateInY(i,j,k,prim_index,interpy,avg_ymom(i,j,k),horiz_upw_frac);
128 interp_prim_CEN2.
InterpolateInY(i,j,k,prim_index,interpy,avg_ymom(i,j,k),horiz_upw_frac);
129 }
else if (jcell==2) {
130 interp_prim_UPW3.
InterpolateInY(i,j,k,prim_index,interpy,avg_ymom(i,j,k),horiz_upw_frac);
133 (flx_arr[1])(i,j,k,cons_index) = avg_ymom(i,j,k) * interpy;
137 (flx_arr[1])(i,j,k,cons_index) = 0.;
141 amrex::ParallelFor(zbx, ncomp,[=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n) noexcept
143 const int cons_index = icomp + n;
145 if ( az_arr(i,j,k) > 0. )
151 if (avg_zmom(i,j,k)>0.)
153 for (kcell=0; kcell<ncells_v; ++kcell) {
154 if (cellflag(i,j,k-kcell-1).isCovered()) {
159 else if (avg_zmom(i,j,k)<0.)
161 for (kcell=0; kcell<ncells_v; ++kcell) {
162 if (cellflag(i,j,k+kcell).isCovered()) {
170 const int prim_index = cons_index - 1;
171 amrex::Real interpz(0.);
173 if (kcell==ncells_v-1) {
174 interp_prim_v.InterpolateInZ(i,j,k,prim_index,interpz,avg_zmom(i,j,k),vert_upw_frac);
177 interp_prim_CEN2.
InterpolateInZ(i,j,k,prim_index,interpz,avg_zmom(i,j,k),vert_upw_frac);
178 }
else if (kcell==2) {
179 interp_prim_UPW3.
InterpolateInZ(i,j,k,prim_index,interpz,avg_zmom(i,j,k),vert_upw_frac);
182 (flx_arr[2])(i,j,k,cons_index) = avg_zmom(i,j,k) * interpz;
186 (flx_arr[2])(i,j,k,cons_index) = 0.;
196 template<
typename InterpType_H>
199 const int& ncomp,
const int& icomp,
200 const amrex::GpuArray<
const amrex::Array4<amrex::Real>, AMREX_SPACEDIM> flx_arr,
201 const amrex::Array4<const amrex::Real>& cell_prim,
202 const amrex::Array4<const amrex::Real>& avg_xmom,
203 const amrex::Array4<const amrex::Real>& avg_ymom,
204 const amrex::Array4<const amrex::Real>& avg_zmom,
205 const amrex::Array4<const amrex::EBCellFlag>& cellflag,
206 const amrex::Array4<const amrex::Real>& ax_arr,
207 const amrex::Array4<const amrex::Real>& ay_arr,
208 const amrex::Array4<const amrex::Real>& az_arr,
209 const amrex::Real horiz_upw_frac,
210 const amrex::Real vert_upw_frac,
213 switch(vert_adv_type) {
215 EBAdvectionSrcForScalarsWrapper<InterpType_H,CENTERED2>(bx, ncomp, icomp,
217 avg_xmom, avg_ymom, avg_zmom,
218 cellflag, ax_arr, ay_arr, az_arr,
219 horiz_upw_frac, vert_upw_frac);
222 EBAdvectionSrcForScalarsWrapper<InterpType_H,UPWIND3>(bx, ncomp, icomp,
224 avg_xmom, avg_ymom, avg_zmom,
225 cellflag, ax_arr, ay_arr, az_arr,
226 horiz_upw_frac, vert_upw_frac);
229 EBAdvectionSrcForScalarsWrapper<InterpType_H,CENTERED4>(bx, ncomp, icomp,
231 avg_xmom, avg_ymom, avg_zmom,
232 cellflag, ax_arr, ay_arr, az_arr,
233 horiz_upw_frac, vert_upw_frac);
236 EBAdvectionSrcForScalarsWrapper<InterpType_H,UPWIND5>(bx, ncomp, icomp,
238 avg_xmom, avg_ymom, avg_zmom,
239 cellflag, ax_arr, ay_arr, az_arr,
240 horiz_upw_frac, vert_upw_frac);
243 EBAdvectionSrcForScalarsWrapper<InterpType_H,CENTERED6>(bx, ncomp, icomp,
245 avg_xmom, avg_ymom, avg_zmom,
246 cellflag, ax_arr, ay_arr, az_arr,
247 horiz_upw_frac, vert_upw_frac);
250 AMREX_ASSERT_WITH_MESSAGE(
false,
"Unknown vertical advection scheme!");
void EBAdvectionSrcForScalarsVert(const amrex::Box &bx, const int &ncomp, const int &icomp, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > flx_arr, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::EBCellFlag > &cellflag, const amrex::Array4< const amrex::Real > &ax_arr, const amrex::Array4< const amrex::Real > &ay_arr, const amrex::Array4< const amrex::Real > &az_arr, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const AdvType vert_adv_type)
Definition: ERF_EBAdvectionSrcForScalars.H:198
void EBAdvectionSrcForScalarsWrapper(const amrex::Box &bx, const int &ncomp, const int &icomp, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > flx_arr, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::EBCellFlag > &cellflag, const amrex::Array4< const amrex::Real > &ax_arr, const amrex::Array4< const amrex::Real > &ay_arr, const amrex::Array4< const amrex::Real > &az_arr, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac)
Definition: ERF_EBAdvectionSrcForScalars.H:14
AdvType
Definition: ERF_IndexDefines.H:191
Definition: ERF_Interpolation_UPW.H:10
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInZ(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real, const amrex::Real) const
Definition: ERF_Interpolation_UPW.H:55
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInY(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real, const amrex::Real) const
Definition: ERF_Interpolation_UPW.H:36
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInX(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real, const amrex::Real) const
Definition: ERF_Interpolation_UPW.H:17
Definition: ERF_Interpolation_UPW.H:95
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInY(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo, const amrex::Real upw_frac) const
Definition: ERF_Interpolation_UPW.H:129
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInX(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo, const amrex::Real upw_frac) const
Definition: ERF_Interpolation_UPW.H:102
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void InterpolateInZ(const int &i, const int &j, const int &k, const int &qty_index, amrex::Real &val_lo, amrex::Real upw_lo, const amrex::Real upw_frac) const
Definition: ERF_Interpolation_UPW.H:156