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 (OrientationIter oit; oit; ++oit) {
106 const Orientation ori = oit();
115 const bool has_rhotheta = (dest_arr.nComp() >
RhoTheta_comp);
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);
143 const Real rho_ghost = (pi_face[0] && has_rhotheta)
145 ((th_file[0] == 2 && th_bc_ptr) ? th_bc_ptr[k_profile] : pi_theta[0])
151 if ((dest_comp ==
Rho_comp) && !rho_is_extdir[0]) {
154 dest_arr(i,j,k,dest_comp) = rho_ghost;
155 }
else if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[0] != 0) {
159 const Real rho_th = (th_file[0] == 2)
160 ? (rho_is_extdir[0] ? rho_extdir_val[0] : rho_ghost)
162 dest_arr(i,j,k,dest_comp) = rho_th * th_bc_ptr[k_profile];
167 ? rho_ghost : Real(1.0);
168 dest_arr(i,j,k,dest_comp) = rho_v * l_bc_extdir_vals_d[bc_comp][0];
171 Real
rho = rho_is_extdir[0] ? rho_extdir_val[0] : rho_ghost;
172 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[0] == 2) {
173 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
175 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][0];
179 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
182 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
184 int dest_comp = icomp+n;
185 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
189 int h_bc_type = bc_ptr[n].hi(0);
191 const Real rho_ghost = (pi_face[3] && has_rhotheta)
193 ((th_file[3] == 2 && th_bc_ptr) ? th_bc_ptr[k_profile] : pi_theta[3])
199 if ((dest_comp ==
Rho_comp) && !rho_is_extdir[3]) {
202 dest_arr(i,j,k,dest_comp) = rho_ghost;
203 }
else if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[3] != 0) {
207 const Real rho_th = (th_file[3] == 2)
208 ? (rho_is_extdir[3] ? rho_extdir_val[3] : rho_ghost)
210 dest_arr(i,j,k,dest_comp) = rho_th * th_bc_ptr[k_profile];
215 ? rho_ghost : Real(1.0);
216 dest_arr(i,j,k,dest_comp) = rho_v * l_bc_extdir_vals_d[bc_comp][3];
219 Real
rho = rho_is_extdir[3] ? rho_extdir_val[3] : rho_ghost;
220 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[3] == 2) {
221 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
223 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][3];
227 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
233 if (!is_periodic_in_y)
236 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
237 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
242 bx_ylo.grow(2,
ng[2]);
243 bx_yhi.grow(2,
ng[2]);
246 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
248 int dest_comp = icomp+n;
249 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
253 int l_bc_type = bc_ptr[n].lo(1);
255 const Real rho_ghost = (pi_face[1] && has_rhotheta)
257 ((th_file[1] == 2 && th_bc_ptr) ? th_bc_ptr[k_profile] : pi_theta[1])
262 if ((dest_comp ==
Rho_comp) && !rho_is_extdir[1]) {
265 dest_arr(i,j,k,dest_comp) = rho_ghost;
266 }
else if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[1] != 0) {
270 const Real rho_th = (th_file[1] == 2)
271 ? (rho_is_extdir[1] ? rho_extdir_val[1] : rho_ghost)
273 dest_arr(i,j,k,dest_comp) = rho_th * th_bc_ptr[k_profile];
278 ? rho_ghost : Real(1.0);
279 dest_arr(i,j,k,dest_comp) = rho_v * l_bc_extdir_vals_d[bc_comp][1];
282 Real
rho = rho_is_extdir[1] ? rho_extdir_val[1] : rho_ghost;
283 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[1] == 2) {
284 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
286 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][1];
290 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
293 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
295 int dest_comp = icomp+n;
296 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
300 int h_bc_type = bc_ptr[n].hi(1);
302 const Real rho_ghost = (pi_face[4] && has_rhotheta)
304 ((th_file[4] == 2 && th_bc_ptr) ? th_bc_ptr[k_profile] : pi_theta[4])
309 if ((dest_comp ==
Rho_comp) && !rho_is_extdir[4]) {
312 dest_arr(i,j,k,dest_comp) = rho_ghost;
313 }
else if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[4] != 0) {
317 const Real rho_th = (th_file[4] == 2)
318 ? (rho_is_extdir[4] ? rho_extdir_val[4] : rho_ghost)
320 dest_arr(i,j,k,dest_comp) = rho_th * th_bc_ptr[k_profile];
325 ? rho_ghost : Real(1.0);
326 dest_arr(i,j,k,dest_comp) = rho_v * l_bc_extdir_vals_d[bc_comp][4];
329 Real
rho = rho_is_extdir[4] ? rho_extdir_val[4] : rho_ghost;
330 if ((dest_comp ==
RhoTheta_comp) && th_bc_ptr && th_file[4] == 2) {
331 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
333 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][4];
337 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
345 if (!is_periodic_in_x)
348 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
349 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
350 if (bx_xlo.smallEnd(2) != domain.smallEnd(2)) bx_xlo.growLo(2,
ng[2]);
351 if (bx_xlo.bigEnd(2) != domain.bigEnd(2)) bx_xlo.growHi(2,
ng[2]);
352 if (bx_xhi.smallEnd(2) != domain.smallEnd(2)) bx_xhi.growLo(2,
ng[2]);
353 if (bx_xhi.bigEnd(2) != domain.bigEnd(2)) bx_xhi.growHi(2,
ng[2]);
355 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
357 int dest_comp = icomp+n;
358 int l_bc_type = bc_ptr[n].lo(0);
359 int iflip = 2*dom_lo.x - 1 - i;
361 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
363 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
365 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
367 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
369 Real delta_i =
static_cast<Real
>(dom_lo.x - i);
370 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);
373 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
375 int dest_comp = icomp+n;
376 int h_bc_type = bc_ptr[n].hi(0);
377 int iflip = 2*dom_hi.x + 1 - i;
379 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
381 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
383 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
385 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
387 Real delta_i =
static_cast<Real
>(i - dom_hi.x);
388 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);
394 if (!is_periodic_in_y)
397 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
398 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
399 if (bx_ylo.smallEnd(2) != domain.smallEnd(2)) bx_ylo.growLo(2,
ng[2]);
400 if (bx_ylo.bigEnd(2) != domain.bigEnd(2)) bx_ylo.growHi(2,
ng[2]);
401 if (bx_yhi.smallEnd(2) != domain.smallEnd(2)) bx_yhi.growLo(2,
ng[2]);
402 if (bx_yhi.bigEnd(2) != domain.bigEnd(2)) bx_yhi.growHi(2,
ng[2]);
404 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
406 int dest_comp = icomp+n;
407 int l_bc_type = bc_ptr[n].lo(1);
408 int jflip = 2*dom_lo.y - 1 - j;
410 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
412 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
414 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
416 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
418 Real delta_j =
static_cast<Real
>(dom_lo.y - j);
419 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);
423 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
425 int dest_comp = icomp+n;
426 int h_bc_type = bc_ptr[n].hi(1);
427 int jflip = 2*dom_hi.y + 1 - j;
429 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
431 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
433 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
435 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
437 Real delta_j =
static_cast<Real
>(j - dom_hi.y);
438 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);
443 Gpu::streamSynchronize();
GpuArray< int, AMREX_SPACEDIM > dhi
Definition: ERF_ActuatorSpreading.cpp:132
GpuArray< int, AMREX_SPACEDIM > dlo
Definition: ERF_ActuatorSpreading.cpp:132
#define RhoScalar_comp
Definition: ERF_IndexDefines.H:65
#define NBCVAR_max
Definition: ERF_IndexDefines.H:50
#define NSCALARS
Definition: ERF_IndexDefines.H:34
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM *2 > m_pi_inflow_theta
Definition: ERF_PhysBCFunct.H:227
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
amrex::GpuArray< int, AMREX_SPACEDIM *2 > m_pi_inflow_face
Definition: ERF_PhysBCFunct.H:226
@ RhoScalar_bc_comp
Definition: ERF_IndexDefines.H:126
@ open
Definition: ERF_IndexDefines.H:324
@ reflect_odd
Definition: ERF_IndexDefines.H:313
@ hoextrap
Definition: ERF_IndexDefines.H:318
@ foextrap
Definition: ERF_IndexDefines.H:316
@ ext_dir_prim
Definition: ERF_IndexDefines.H:320
@ int_dir
Definition: ERF_IndexDefines.H:314
@ reflect_even
Definition: ERF_IndexDefines.H:315
@ ng
Definition: ERF_Morrison.H:51
@ nc
Definition: ERF_Morrison.H:47