24 const auto& dom_lo = lbound(domain);
25 const auto& dom_hi = ubound(domain);
36 Vector<BCRec> bcrs(ncomp);
38 GpuArray<GpuArray<Real, AMREX_SPACEDIM*2>,
NBCVAR_max> l_bc_extdir_vals_d;
40 const int* bxlo = bx.loVect();
41 const int* bxhi = bx.hiVect();
42 const int* dlo = domain.loVect();
43 const int* dhi = domain.hiVect();
45 for (
int nc = 0; nc < ncomp; nc++)
50 for (
int dir = 0; dir < AMREX_SPACEDIM; dir++)
52 bcrs[nc].setLo(dir, ( bxlo[dir]<=dlo[dir]
54 bcrs[nc].setHi(dir, ( bxhi[dir]>=dhi[dir]
58 for (
int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
63 Gpu::DeviceVector<BCRec> bcrs_d(ncomp);
64 Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
65 const BCRec* bc_ptr = bcrs_d.data();
67 GeometryData
const& geomdata =
m_geom.data();
68 bool is_periodic_in_x = geomdata.isPeriodic(0);
69 bool is_periodic_in_y = geomdata.isPeriodic(1);
72 if (!is_periodic_in_x)
75 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
76 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
84 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
86 int dest_comp = icomp+n;
90 int l_bc_type = bc_ptr[n].lo(0);
96 dest_arr(i,j,k,dest_comp) = th_bc_ptr[k];
98 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][0];
103 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k];
105 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][0];
109 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
111 int dest_comp = icomp+n;
115 int h_bc_type = bc_ptr[n].hi(0);
121 dest_arr(i,j,k,dest_comp) = th_bc_ptr[k];
123 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][3];
128 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k];
130 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][3];
137 if (!is_periodic_in_y)
140 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
141 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
146 bx_ylo.grow(2,ng[2]);
147 bx_yhi.grow(2,ng[2]);
150 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
152 int dest_comp = icomp+n;
156 int l_bc_type = bc_ptr[n].lo(1);
161 dest_arr(i,j,k,dest_comp) = th_bc_ptr[k];
163 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][1];
168 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k];
170 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][1];
174 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
176 int dest_comp = icomp+n;
180 int h_bc_type = bc_ptr[n].hi(1);
185 dest_arr(i,j,k,dest_comp) = th_bc_ptr[k];
187 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][4];
192 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k];
194 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][4];
203 if (!is_periodic_in_x)
206 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
207 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
208 if (bx_xlo.smallEnd(2) != domain.smallEnd(2)) bx_xlo.growLo(2,ng[2]);
209 if (bx_xlo.bigEnd(2) != domain.bigEnd(2)) bx_xlo.growHi(2,ng[2]);
210 if (bx_xhi.smallEnd(2) != domain.smallEnd(2)) bx_xhi.growLo(2,ng[2]);
211 if (bx_xhi.bigEnd(2) != domain.bigEnd(2)) bx_xhi.growHi(2,ng[2]);
213 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
215 int dest_comp = icomp+n;
216 int l_bc_type = bc_ptr[n].lo(0);
217 int iflip = dom_lo.x - 1 - i;
219 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
221 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
223 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
225 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
227 Real delta_i = (dom_lo.x - i);
228 dest_arr(i,j,k,dest_comp) = (1.0 + delta_i)*dest_arr(dom_lo.x,j,k,dest_comp) - delta_i*dest_arr(dom_lo.x+1,j,k,dest_comp) ;
231 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
233 int dest_comp = icomp+n;
234 int h_bc_type = bc_ptr[n].hi(0);
235 int iflip = 2*dom_hi.x + 1 - i;
237 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
239 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
241 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
243 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
245 Real delta_i = (i - dom_hi.x);
246 dest_arr(i,j,k,dest_comp) = (1.0 + delta_i)*dest_arr(dom_hi.x,j,k,dest_comp) - delta_i*dest_arr(dom_hi.x-1,j,k,dest_comp) ;
252 if (!is_periodic_in_y)
255 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
256 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
257 if (bx_ylo.smallEnd(2) != domain.smallEnd(2)) bx_ylo.growLo(2,ng[2]);
258 if (bx_ylo.bigEnd(2) != domain.bigEnd(2)) bx_ylo.growHi(2,ng[2]);
259 if (bx_yhi.smallEnd(2) != domain.smallEnd(2)) bx_yhi.growLo(2,ng[2]);
260 if (bx_yhi.bigEnd(2) != domain.bigEnd(2)) bx_yhi.growHi(2,ng[2]);
262 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
264 int dest_comp = icomp+n;
265 int l_bc_type = bc_ptr[n].lo(1);
266 int jflip = dom_lo.y - 1 - j;
268 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
270 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
272 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
274 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
276 Real delta_j = (dom_lo.y - j);
277 dest_arr(i,j,k,dest_comp) = (1.0 + delta_j)*dest_arr(i,dom_lo.y,k,dest_comp) - delta_j*dest_arr(i,dom_lo.y+1,k,dest_comp) ;
281 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
283 int dest_comp = icomp+n;
284 int h_bc_type = bc_ptr[n].hi(1);
285 int jflip = 2*dom_hi.y + 1 - j;
287 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
289 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
291 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
293 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
295 Real delta_j = (j - dom_hi.y);
296 dest_arr(i,j,k,dest_comp) = (1.0 + delta_j)*dest_arr(i,dom_hi.y,k,dest_comp) - delta_j*dest_arr(i,dom_hi.y-1,k,dest_comp);
301 Gpu::streamSynchronize();
#define RhoScalar_comp
Definition: ERF_IndexDefines.H:40
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
#define NBCVAR_max
Definition: ERF_IndexDefines.H:29
#define NSCALARS
Definition: ERF_IndexDefines.H:16
void impose_lateral_cons_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Array4< amrex::Real const > &xvel_arr, const amrex::Array4< amrex::Real const > &yvel_arr, const amrex::Box &bx, const amrex::Box &domain, int icomp, int ncomp, amrex::IntVect ng)
Definition: ERF_BoundaryConditionsCons.cpp:17
@ RhoScalar_bc_comp
Definition: ERF_IndexDefines.H:80
@ open
Definition: ERF_IndexDefines.H:197
@ reflect_odd
Definition: ERF_IndexDefines.H:187
@ foextrap
Definition: ERF_IndexDefines.H:190
@ ext_dir
Definition: ERF_IndexDefines.H:191
@ ext_dir_prim
Definition: ERF_IndexDefines.H:193
@ hoextrapcc
Definition: ERF_IndexDefines.H:198
@ ext_dir_upwind
Definition: ERF_IndexDefines.H:199
@ int_dir
Definition: ERF_IndexDefines.H:188
@ reflect_even
Definition: ERF_IndexDefines.H:189
@ rho
Definition: ERF_Kessler.H:22