Impose lateral boundary conditions on conserved variables.
30 const auto& dom_lo = lbound(domain);
31 const auto& dom_hi = ubound(domain);
44 const auto& xvel_lo = lbound(xvel_arr);
45 const auto& xvel_hi = ubound(xvel_arr);
46 const auto& yvel_lo = lbound(yvel_arr);
47 const auto& yvel_hi = ubound(yvel_arr);
58 Vector<BCRec> bcrs(ncomp);
60 GpuArray<GpuArray<Real, AMREX_SPACEDIM*2>,
NBCVAR_max> l_bc_extdir_vals_d;
62 const int* bxlo = bx.loVect();
63 const int* bxhi = bx.hiVect();
64 const int* dlo = domain.loVect();
65 const int* dhi = domain.hiVect();
67 for (
int nc = 0;
nc < ncomp;
nc++)
72 for (
int dir = 0; dir < AMREX_SPACEDIM; dir++)
74 bcrs[
nc].setLo(dir, ( bxlo[dir]<=dlo[dir]
76 bcrs[
nc].setHi(dir, ( bxhi[dir]>=dhi[dir]
80 for (
int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
85 Gpu::DeviceVector<BCRec> bcrs_d(ncomp);
86 Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
87 const BCRec* bc_ptr = bcrs_d.data();
89 GeometryData
const& geomdata =
m_geom.data();
90 bool is_periodic_in_x = geomdata.isPeriodic(0);
91 bool is_periodic_in_y = geomdata.isPeriodic(1);
103 GpuArray<int,6> rho_is_extdir;
104 GpuArray<Real,6> rho_extdir_val;
105 for (
int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
106 const int dir = ori % AMREX_SPACEDIM;
107 const bool low = (ori < AMREX_SPACEDIM);
114 && rho_val >
zero) ? 1 : 0;
115 rho_extdir_val[ori] = rho_val;
122 if (!is_periodic_in_x)
125 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
126 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
131 bx_xlo.grow(2,
ng[2]);
132 bx_xhi.grow(2,
ng[2]);
134 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
136 int dest_comp = icomp+n;
137 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
141 int l_bc_type = bc_ptr[n].lo(0);
146 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[0] != 0) {
150 const Real rho_th = (th_file[0] == 2)
151 ? (rho_is_extdir[0] ? rho_extdir_val[0] : dest_arr(dom_lo.x,j,k,
Rho_comp))
153 dest_arr(i,j,k,dest_comp) = rho_th * th_bc_ptr[k_profile];
155 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][0];
158 Real rho = rho_is_extdir[0] ? rho_extdir_val[0] : dest_arr(dom_lo.x,j,k,
Rho_comp);
159 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[0] == 2) {
160 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
162 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][0];
166 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
168 int dest_comp = icomp+n;
169 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
173 int h_bc_type = bc_ptr[n].hi(0);
178 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[3] != 0) {
182 const Real rho_th = (th_file[3] == 2)
183 ? (rho_is_extdir[3] ? rho_extdir_val[3] : dest_arr(dom_hi.x,j,k,
Rho_comp))
185 dest_arr(i,j,k,dest_comp) = rho_th * th_bc_ptr[k_profile];
187 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][3];
190 Real rho = rho_is_extdir[3] ? rho_extdir_val[3] : dest_arr(dom_hi.x,j,k,
Rho_comp);
191 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[3] == 2) {
192 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
194 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][3];
201 if (!is_periodic_in_y)
204 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
205 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
210 bx_ylo.grow(2,
ng[2]);
211 bx_yhi.grow(2,
ng[2]);
214 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
216 int dest_comp = icomp+n;
217 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
221 int l_bc_type = bc_ptr[n].lo(1);
225 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[1] != 0) {
229 const Real rho_th = (th_file[1] == 2)
230 ? (rho_is_extdir[1] ? rho_extdir_val[1] : dest_arr(i,dom_lo.y,k,
Rho_comp))
232 dest_arr(i,j,k,dest_comp) = rho_th * th_bc_ptr[k_profile];
234 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][1];
237 Real rho = rho_is_extdir[1] ? rho_extdir_val[1] : dest_arr(i,dom_lo.y,k,
Rho_comp);
238 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[1] == 2) {
239 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
241 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][1];
245 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
247 int dest_comp = icomp+n;
248 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
252 int h_bc_type = bc_ptr[n].hi(1);
256 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[4] != 0) {
260 const Real rho_th = (th_file[4] == 2)
261 ? (rho_is_extdir[4] ? rho_extdir_val[4] : dest_arr(i,dom_hi.y,k,
Rho_comp))
263 dest_arr(i,j,k,dest_comp) = rho_th * th_bc_ptr[k_profile];
265 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][4];
268 Real rho = rho_is_extdir[4] ? rho_extdir_val[4] : dest_arr(i,dom_hi.y,k,
Rho_comp);
269 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[4] == 2) {
270 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
272 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][4];
281 if (!is_periodic_in_x)
284 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
285 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
286 if (bx_xlo.smallEnd(2) != domain.smallEnd(2)) bx_xlo.growLo(2,
ng[2]);
287 if (bx_xlo.bigEnd(2) != domain.bigEnd(2)) bx_xlo.growHi(2,
ng[2]);
288 if (bx_xhi.smallEnd(2) != domain.smallEnd(2)) bx_xhi.growLo(2,
ng[2]);
289 if (bx_xhi.bigEnd(2) != domain.bigEnd(2)) bx_xhi.growHi(2,
ng[2]);
291 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
293 int dest_comp = icomp+n;
294 int l_bc_type = bc_ptr[n].lo(0);
295 int iflip = dom_lo.x - 1 - i;
297 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
299 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
301 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
303 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
305 Real delta_i =
static_cast<Real>(dom_lo.x - i);
306 dest_arr(i,j,k,dest_comp) = (
one + delta_i)*dest_arr(dom_lo.x,j,k,dest_comp) - delta_i*dest_arr(dom_lo.x+1,j,k,dest_comp);
309 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
311 int dest_comp = icomp+n;
312 int h_bc_type = bc_ptr[n].hi(0);
313 int iflip = 2*dom_hi.x + 1 - i;
315 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
317 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
319 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
321 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
323 Real delta_i =
static_cast<Real>(i - dom_hi.x);
324 dest_arr(i,j,k,dest_comp) = (
one + delta_i)*dest_arr(dom_hi.x,j,k,dest_comp) - delta_i*dest_arr(dom_hi.x-1,j,k,dest_comp);
330 if (!is_periodic_in_y)
333 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
334 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
335 if (bx_ylo.smallEnd(2) != domain.smallEnd(2)) bx_ylo.growLo(2,
ng[2]);
336 if (bx_ylo.bigEnd(2) != domain.bigEnd(2)) bx_ylo.growHi(2,
ng[2]);
337 if (bx_yhi.smallEnd(2) != domain.smallEnd(2)) bx_yhi.growLo(2,
ng[2]);
338 if (bx_yhi.bigEnd(2) != domain.bigEnd(2)) bx_yhi.growHi(2,
ng[2]);
340 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
342 int dest_comp = icomp+n;
343 int l_bc_type = bc_ptr[n].lo(1);
344 int jflip = dom_lo.y - 1 - j;
346 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
348 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
350 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
352 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
354 Real delta_j =
static_cast<Real>(dom_lo.y - j);
355 dest_arr(i,j,k,dest_comp) = (
one + delta_j)*dest_arr(i,dom_lo.y,k,dest_comp) - delta_j*dest_arr(i,dom_lo.y+1,k,dest_comp);
359 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
361 int dest_comp = icomp+n;
362 int h_bc_type = bc_ptr[n].hi(1);
363 int jflip = 2*dom_hi.y + 1 - j;
365 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
367 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
369 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
371 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
373 Real delta_j =
static_cast<Real>(j - dom_hi.y);
374 dest_arr(i,j,k,dest_comp) = (
one + delta_j)*dest_arr(i,dom_hi.y,k,dest_comp) - delta_j*dest_arr(i,dom_hi.y-1,k,dest_comp);
379 Gpu::streamSynchronize();
#define RhoScalar_comp
Definition: ERF_IndexDefines.H:46
#define Rho_comp
Definition: ERF_IndexDefines.H:42
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:43
#define NBCVAR_max
Definition: ERF_IndexDefines.H:32
#define NSCALARS
Definition: ERF_IndexDefines.H:16
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
amrex::Real Real
Definition: ERF_ShocInterface.H:19
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, const double time)
Definition: ERF_BoundaryConditionsCons.cpp:22
@ RhoScalar_bc_comp
Definition: ERF_IndexDefines.H:96
@ Rho_bc_comp
Definition: ERF_IndexDefines.H:93
@ open
Definition: ERF_IndexDefines.H:307
@ reflect_odd
Definition: ERF_IndexDefines.H:296
@ hoextrap
Definition: ERF_IndexDefines.H:301
@ foextrap
Definition: ERF_IndexDefines.H:299
@ ext_dir
Definition: ERF_IndexDefines.H:300
@ ext_dir_prim
Definition: ERF_IndexDefines.H:303
@ ext_dir_upwind
Definition: ERF_IndexDefines.H:308
@ int_dir
Definition: ERF_IndexDefines.H:297
@ reflect_even
Definition: ERF_IndexDefines.H:298
@ rho
Definition: ERF_Kessler.H:25
@ ng
Definition: ERF_Morrison.H:50
@ nc
Definition: ERF_Morrison.H:46