Impose lateral boundary conditions on base-state variables.
25 BL_PROFILE_VAR(
"impose_lateral_base_bcs()",impose_lateral_base_bcs);
31 const int* bxlo = bx.loVect();
32 const int* bxhi = bx.hiVect();
34 const int* dlo = domain.loVect();
35 const int* dhi = domain.hiVect();
37 const auto& dom_lo = lbound(domain);
38 const auto& dom_hi = ubound(domain);
49 Vector<BCRec> bcrs(ncomp);
53 for (
int nc = 0;
nc < ncomp;
nc++)
55 for (
int dir = 0; dir < AMREX_SPACEDIM; dir++)
57 bcrs[
nc].setLo(dir, ( bxlo[dir]<=dlo[dir]
59 bcrs[
nc].setHi(dir, ( bxhi[dir]>=dhi[dir]
64 Gpu::DeviceVector<BCRec> bcrs_d(ncomp);
65 Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
66 const BCRec* bc_ptr = bcrs_d.data();
68 GeometryData
const& geomdata =
m_geom.data();
69 bool is_periodic_in_x = geomdata.isPeriodic(0);
70 bool is_periodic_in_y = geomdata.isPeriodic(1);
74 if (!is_periodic_in_x)
77 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
78 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
81 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
84 int l_bc_type = bc_ptr[n].lo(0);
85 int iflip = dom_lo.x - 1 - i;
87 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
89 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
91 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
94 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
97 int h_bc_type = bc_ptr[n].hi(0);
98 int iflip = 2*dom_hi.x + 1 - i;
100 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
102 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
104 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
110 if (!is_periodic_in_y)
113 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
114 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
115 if (bx_ylo.smallEnd(2) != domain.smallEnd(2)) bx_ylo.growLo(2,nghost[2]);
116 if (bx_ylo.bigEnd(2) != domain.bigEnd(2)) bx_ylo.growHi(2,nghost[2]);
117 if (bx_yhi.smallEnd(2) != domain.smallEnd(2)) bx_yhi.growLo(2,nghost[2]);
118 if (bx_yhi.bigEnd(2) != domain.bigEnd(2)) bx_yhi.growHi(2,nghost[2]);
120 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
123 int l_bc_type = bc_ptr[n].lo(1);
124 int jflip = dom_lo.y - 1 - j;
126 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
128 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
130 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
134 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
137 int h_bc_type = bc_ptr[n].hi(1);
138 int jflip = 2*dom_hi.y + 1 - j;
140 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
142 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
144 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
152 if (!is_periodic_in_x)
155 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
156 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
157 if (bx_xlo.smallEnd(2) != domain.smallEnd(2)) bx_xlo.growLo(2,nghost[2]);
158 if (bx_xlo.bigEnd(2) != domain.bigEnd(2)) bx_xlo.growHi(2,nghost[2]);
159 if (bx_xhi.smallEnd(2) != domain.smallEnd(2)) bx_xhi.growLo(2,nghost[2]);
160 if (bx_xhi.bigEnd(2) != domain.bigEnd(2)) bx_xhi.growHi(2,nghost[2]);
162 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
165 int l_bc_type = bc_ptr[n].lo(0);
166 int iflip = dom_lo.x - 1 - i;
168 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
170 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
172 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
174 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
176 Real delta_i =
static_cast<Real>(dom_lo.x - i);
177 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) ;
180 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
183 int h_bc_type = bc_ptr[n].hi(0);
184 int iflip = 2*dom_hi.x + 1 - i;
186 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
188 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
190 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
192 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
194 Real delta_i =
static_cast<Real>(i - dom_hi.x);
195 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) ;
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);
206 if (bx_ylo.smallEnd(2) != domain.smallEnd(2)) bx_ylo.growLo(2,nghost[2]);
207 if (bx_ylo.bigEnd(2) != domain.bigEnd(2)) bx_ylo.growHi(2,nghost[2]);
208 if (bx_yhi.smallEnd(2) != domain.smallEnd(2)) bx_yhi.growLo(2,nghost[2]);
209 if (bx_yhi.bigEnd(2) != domain.bigEnd(2)) bx_yhi.growHi(2,nghost[2]);
211 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
214 int l_bc_type = bc_ptr[n].lo(1);
215 int jflip = dom_lo.y - 1 - j;
217 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
219 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
221 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
223 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
225 Real delta_j =
static_cast<Real>(dom_lo.y - j);
226 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) ;
230 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
233 int h_bc_type = bc_ptr[n].hi(1);
234 int jflip = 2*dom_hi.y + 1 - j;
236 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
238 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
240 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
242 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
244 Real delta_j =
static_cast<Real>(j - dom_hi.y);
245 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);
270 auto is_ext_bc = [] (
int bc_type) {
274 const bool xlo_ext = !is_periodic_in_x && is_ext_bc(bcrs[0].
lo(0));
275 const bool xhi_ext = !is_periodic_in_x && is_ext_bc(bcrs[0].
hi(0));
276 const bool ylo_ext = !is_periodic_in_y && is_ext_bc(bcrs[0].
lo(1));
277 const bool yhi_ext = !is_periodic_in_y && is_ext_bc(bcrs[0].
hi(1));
279 if (xlo_ext || xhi_ext || ylo_ext || yhi_ext)
287 if (gbx.smallEnd(2) != domain.smallEnd(2)) gbx.growLo(2,nghost[2]);
288 if (gbx.bigEnd(2) != domain.bigEnd(2)) gbx.growHi(2,nghost[2]);
289 gbx.setSmall(2, amrex::max(gbx.smallEnd(2), dom_lo.z));
290 gbx.setBig (2, amrex::min(gbx.bigEnd(2) , dom_hi.z));
295 ParallelFor(gbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
302 const bool out_xlo = (i < dom_lo.x);
303 const bool out_xhi = (i > dom_hi.x);
304 const bool out_ylo = (j < dom_lo.y);
305 const bool out_yhi = (j > dom_hi.y);
307 if (!(out_xlo || out_xhi || out_ylo || out_yhi)) {
return; }
310 if (out_xlo && !xlo_ext) {
return; }
311 if (out_xhi && !xhi_ext) {
return; }
312 if (out_ylo && !ylo_ext) {
return; }
313 if (out_yhi && !yhi_ext) {
return; }
315 const int ir = amrex::min(amrex::max(i,dom_lo.x),dom_hi.x);
316 const int jr = amrex::min(amrex::max(j,dom_lo.y),dom_hi.y);
318 auto zcc = [=] (
int ii,
int jj,
int kk) {
319 return Real(0.125) * ( z_nd(ii,jj ,kk ) + z_nd(ii+1,jj ,kk )
320 + z_nd(ii,jj+1,kk ) + z_nd(ii+1,jj+1,kk )
321 + z_nd(ii,jj ,kk+1) + z_nd(ii+1,jj ,kk+1)
322 + z_nd(ii,jj+1,kk+1) + z_nd(ii+1,jj+1,kk+1) );
325 const Real dz_offset = zcc(i,j,k) - zcc(ir,jr,k);
328 if (dz_offset ==
Real(0.0)) {
return; }
340 if (!(p0_ref >
Real(0.0)) || !(r0_ref >
Real(0.0)) || !(th0_ref >
Real(0.0))) {
return; }
346 const Real p0_new = p0_ref * std::exp(-l_gravity * dz_offset * r0_ref / p0_ref);
367 Gpu::streamSynchronize();
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhogivenThetaPress(const amrex::Real th, const amrex::Real p, const amrex::Real rdOcp, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:96
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getExnergivenP(const amrex::Real P, const amrex::Real rdOcp)
Definition: ERF_EOS.H:141
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:30
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ rho0_bc_comp
Definition: ERF_IndexDefines.H:116
@ num_comps
Definition: ERF_IndexDefines.H:81
@ qv0_comp
Definition: ERF_IndexDefines.H:80
@ pi0_comp
Definition: ERF_IndexDefines.H:78
@ p0_comp
Definition: ERF_IndexDefines.H:77
@ th0_comp
Definition: ERF_IndexDefines.H:79
@ r0_comp
Definition: ERF_IndexDefines.H:76
@ open
Definition: ERF_IndexDefines.H:304
@ reflect_odd
Definition: ERF_IndexDefines.H:293
@ hoextrap
Definition: ERF_IndexDefines.H:298
@ foextrap
Definition: ERF_IndexDefines.H:296
@ int_dir
Definition: ERF_IndexDefines.H:294
@ reflect_even
Definition: ERF_IndexDefines.H:295
@ nc
Definition: ERF_Morrison.H:46