21 const auto& dom_lo = lbound(domain);
22 const auto& dom_hi = ubound(domain);
33 Vector<BCRec> bcrs(ncomp);
35 GpuArray<GpuArray<Real, AMREX_SPACEDIM*2>,
NBCVAR_max> l_bc_extdir_vals_d;
37 const int* bxlo = bx.loVect();
38 const int* bxhi = bx.hiVect();
39 const int* dlo = domain.loVect();
40 const int* dhi = domain.hiVect();
42 for (
int nc = 0; nc < ncomp; nc++)
47 for (
int dir = 0; dir < AMREX_SPACEDIM; dir++)
49 bcrs[nc].setLo(dir, ( bxlo[dir]<=dlo[dir]
51 bcrs[nc].setHi(dir, ( bxhi[dir]>=dhi[dir]
55 for (
int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
60 Gpu::DeviceVector<BCRec> bcrs_d(ncomp);
61 Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
62 const BCRec* bc_ptr = bcrs_d.data();
64 GeometryData
const& geomdata =
m_geom.data();
65 bool is_periodic_in_x = geomdata.isPeriodic(0);
66 bool is_periodic_in_y = geomdata.isPeriodic(1);
69 if (!is_periodic_in_x)
71 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
72 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
80 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
82 int dest_comp = icomp+n;
86 int l_bc_type = bc_ptr[n].lo(0);
89 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][0];
92 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][0];
95 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
97 int dest_comp = icomp+n;
101 int h_bc_type = bc_ptr[n].hi(0);
104 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][3];
107 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][3];
113 if (!is_periodic_in_y)
115 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
116 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
121 bx_ylo.grow(2,ng[2]);
122 bx_yhi.grow(2,ng[2]);
125 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
127 int dest_comp = icomp+n;
131 int l_bc_type = bc_ptr[n].lo(1);
133 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][1];
136 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][1];
139 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
141 int dest_comp = icomp+n;
145 int h_bc_type = bc_ptr[n].hi(1);
147 dest_arr(i,j,k,dest_comp) = l_bc_extdir_vals_d[bc_comp][4];
150 dest_arr(i,j,k,dest_comp) =
rho * l_bc_extdir_vals_d[bc_comp][4];
158 if (!is_periodic_in_x)
161 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
162 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
163 if (bx_xlo.smallEnd(2) != domain.smallEnd(2)) bx_xlo.growLo(2,ng[2]);
164 if (bx_xlo.bigEnd(2) != domain.bigEnd(2)) bx_xlo.growHi(2,ng[2]);
165 if (bx_xhi.smallEnd(2) != domain.smallEnd(2)) bx_xhi.growLo(2,ng[2]);
166 if (bx_xhi.bigEnd(2) != domain.bigEnd(2)) bx_xhi.growHi(2,ng[2]);
168 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
170 int dest_comp = icomp+n;
171 int l_bc_type = bc_ptr[n].lo(0);
172 int iflip = dom_lo.x - 1 - i;
174 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
176 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
178 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
180 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
182 Real delta_i = (dom_lo.x - i);
183 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) ;
186 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
188 int dest_comp = icomp+n;
189 int h_bc_type = bc_ptr[n].hi(0);
190 int iflip = 2*dom_hi.x + 1 - i;
192 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
194 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
196 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
198 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
200 Real delta_i = (i - dom_hi.x);
201 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) ;
207 if (!is_periodic_in_y)
210 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
211 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
212 if (bx_ylo.smallEnd(2) != domain.smallEnd(2)) bx_ylo.growLo(2,ng[2]);
213 if (bx_ylo.bigEnd(2) != domain.bigEnd(2)) bx_ylo.growHi(2,ng[2]);
214 if (bx_yhi.smallEnd(2) != domain.smallEnd(2)) bx_yhi.growLo(2,ng[2]);
215 if (bx_yhi.bigEnd(2) != domain.bigEnd(2)) bx_yhi.growHi(2,ng[2]);
217 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
219 int dest_comp = icomp+n;
220 int l_bc_type = bc_ptr[n].lo(1);
221 int jflip = dom_lo.y - 1 - j;
223 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
225 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
227 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
229 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
231 Real delta_j = (dom_lo.y - j);
232 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) ;
236 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
238 int dest_comp = icomp+n;
239 int h_bc_type = bc_ptr[n].hi(1);
240 int jflip = 2*dom_hi.y + 1 - j;
242 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
244 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
246 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
248 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
250 Real delta_j = (j - dom_hi.y);
251 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);
256 Gpu::streamSynchronize();
#define RhoScalar_comp
Definition: ERF_IndexDefines.H:40
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#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::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:186
@ reflect_odd
Definition: ERF_IndexDefines.H:176
@ foextrap
Definition: ERF_IndexDefines.H:179
@ ext_dir
Definition: ERF_IndexDefines.H:180
@ ext_dir_prim
Definition: ERF_IndexDefines.H:182
@ hoextrapcc
Definition: ERF_IndexDefines.H:187
@ int_dir
Definition: ERF_IndexDefines.H:177
@ reflect_even
Definition: ERF_IndexDefines.H:178
@ rho
Definition: ERF_Kessler.H:30