Impose lateral boundary conditions on conserved variables.
30 const auto& dom_lo = lbound(domain);
31 const auto& dom_hi = ubound(domain);
42 Vector<BCRec> bcrs(ncomp);
44 GpuArray<GpuArray<Real, AMREX_SPACEDIM*2>,
NBCVAR_max> l_bc_extdir_vals_d;
46 const int* bxlo = bx.loVect();
47 const int* bxhi = bx.hiVect();
48 const int* dlo = domain.loVect();
49 const int* dhi = domain.hiVect();
51 for (
int nc = 0;
nc < ncomp;
nc++)
56 for (
int dir = 0; dir < AMREX_SPACEDIM; dir++)
58 bcrs[
nc].setLo(dir, ( bxlo[dir]<=dlo[dir]
60 bcrs[
nc].setHi(dir, ( bxhi[dir]>=dhi[dir]
64 for (
int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
69 Gpu::DeviceVector<BCRec> bcrs_d(ncomp);
70 Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
71 const BCRec* bc_ptr = bcrs_d.data();
73 GeometryData
const& geomdata =
m_geom.data();
74 bool is_periodic_in_x = geomdata.isPeriodic(0);
75 bool is_periodic_in_y = geomdata.isPeriodic(1);
78 if (!is_periodic_in_x)
81 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
82 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
90 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
92 int dest_comp = icomp+n;
93 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
97 int l_bc_type = bc_ptr[n].lo(0);
103 dest_arr(i,j,k,dest_comp) = th_bc_ptr[k_profile];
105 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][0];
110 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
112 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][0];
116 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
118 int dest_comp = icomp+n;
119 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
123 int h_bc_type = bc_ptr[n].hi(0);
129 dest_arr(i,j,k,dest_comp) = th_bc_ptr[k_profile];
131 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][3];
136 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
138 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][3];
145 if (!is_periodic_in_y)
148 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
149 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
154 bx_ylo.grow(2,
ng[2]);
155 bx_yhi.grow(2,
ng[2]);
158 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
160 int dest_comp = icomp+n;
161 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
165 int l_bc_type = bc_ptr[n].lo(1);
170 dest_arr(i,j,k,dest_comp) = th_bc_ptr[k_profile];
172 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][1];
177 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
179 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][1];
183 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
185 int dest_comp = icomp+n;
186 int k_profile = amrex::min(amrex::max(k, dom_lo.z), dom_hi.z) - dom_lo.z;
190 int h_bc_type = bc_ptr[n].hi(1);
195 dest_arr(i,j,k,dest_comp) = th_bc_ptr[k_profile];
197 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][4];
202 dest_arr(i,j,k,dest_comp) =
rho * th_bc_ptr[k_profile];
204 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][4];
213 if (!is_periodic_in_x)
216 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
217 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
218 if (bx_xlo.smallEnd(2) != domain.smallEnd(2)) bx_xlo.growLo(2,
ng[2]);
219 if (bx_xlo.bigEnd(2) != domain.bigEnd(2)) bx_xlo.growHi(2,
ng[2]);
220 if (bx_xhi.smallEnd(2) != domain.smallEnd(2)) bx_xhi.growLo(2,
ng[2]);
221 if (bx_xhi.bigEnd(2) != domain.bigEnd(2)) bx_xhi.growHi(2,
ng[2]);
223 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
225 int dest_comp = icomp+n;
226 int l_bc_type = bc_ptr[n].lo(0);
227 int iflip = dom_lo.x - 1 - i;
229 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
231 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
233 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
235 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
237 Real delta_i =
static_cast<Real>(dom_lo.x - i);
238 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);
241 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
243 int dest_comp = icomp+n;
244 int h_bc_type = bc_ptr[n].hi(0);
245 int iflip = 2*dom_hi.x + 1 - i;
247 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
249 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
251 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
253 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
255 Real delta_i =
static_cast<Real>(i - dom_hi.x);
256 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);
262 if (!is_periodic_in_y)
265 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
266 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
267 if (bx_ylo.smallEnd(2) != domain.smallEnd(2)) bx_ylo.growLo(2,
ng[2]);
268 if (bx_ylo.bigEnd(2) != domain.bigEnd(2)) bx_ylo.growHi(2,
ng[2]);
269 if (bx_yhi.smallEnd(2) != domain.smallEnd(2)) bx_yhi.growLo(2,
ng[2]);
270 if (bx_yhi.bigEnd(2) != domain.bigEnd(2)) bx_yhi.growHi(2,
ng[2]);
272 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
274 int dest_comp = icomp+n;
275 int l_bc_type = bc_ptr[n].lo(1);
276 int jflip = dom_lo.y - 1 - j;
278 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
280 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
282 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
284 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
286 Real delta_j =
static_cast<Real>(dom_lo.y - j);
287 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);
291 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
293 int dest_comp = icomp+n;
294 int h_bc_type = bc_ptr[n].hi(1);
295 int jflip = 2*dom_hi.y + 1 - j;
297 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
299 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
301 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
303 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
305 Real delta_j =
static_cast<Real>(j - dom_hi.y);
306 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);
311 Gpu::streamSynchronize();
constexpr amrex::Real one
Definition: ERF_Constants.H:9
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
#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
rho
Definition: ERF_InitCustomPert_Bubble.H:107
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);})
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:90
@ open
Definition: ERF_IndexDefines.H:256
@ reflect_odd
Definition: ERF_IndexDefines.H:245
@ hoextrap
Definition: ERF_IndexDefines.H:250
@ foextrap
Definition: ERF_IndexDefines.H:248
@ ext_dir
Definition: ERF_IndexDefines.H:249
@ ext_dir_prim
Definition: ERF_IndexDefines.H:252
@ ext_dir_upwind
Definition: ERF_IndexDefines.H:257
@ int_dir
Definition: ERF_IndexDefines.H:246
@ reflect_even
Definition: ERF_IndexDefines.H:247
@ ng
Definition: ERF_Morrison.H:49
@ nc
Definition: ERF_Morrison.H:45