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);
58 auto base_bc_type = [] (
int t) {
64 for (
int nc = 0;
nc < ncomp;
nc++)
66 for (
int dir = 0; dir < AMREX_SPACEDIM; dir++)
70 if (dir < 2) { lo_t = base_bc_type(lo_t); hi_t = base_bc_type(hi_t); }
76 Gpu::DeviceVector<BCRec> bcrs_d(ncomp);
77 Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
78 const BCRec* bc_ptr = bcrs_d.data();
80 GeometryData
const& geomdata =
m_geom.data();
81 bool is_periodic_in_x = geomdata.isPeriodic(0);
82 bool is_periodic_in_y = geomdata.isPeriodic(1);
86 if (!is_periodic_in_x)
89 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
90 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
93 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
96 int l_bc_type = bc_ptr[n].lo(0);
97 int iflip = 2*dom_lo.x - 1 - i;
99 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
101 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
103 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
106 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
109 int h_bc_type = bc_ptr[n].hi(0);
110 int iflip = 2*dom_hi.x + 1 - i;
112 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
114 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
116 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
122 if (!is_periodic_in_y)
125 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
126 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
127 if (bx_ylo.smallEnd(2) != domain.smallEnd(2)) bx_ylo.growLo(2,nghost[2]);
128 if (bx_ylo.bigEnd(2) != domain.bigEnd(2)) bx_ylo.growHi(2,nghost[2]);
129 if (bx_yhi.smallEnd(2) != domain.smallEnd(2)) bx_yhi.growLo(2,nghost[2]);
130 if (bx_yhi.bigEnd(2) != domain.bigEnd(2)) bx_yhi.growHi(2,nghost[2]);
132 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
135 int l_bc_type = bc_ptr[n].lo(1);
136 int jflip = 2*dom_lo.y - 1 - j;
138 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
140 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
142 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
146 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
149 int h_bc_type = bc_ptr[n].hi(1);
150 int jflip = 2*dom_hi.y + 1 - j;
152 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
154 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
156 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
164 if (!is_periodic_in_x)
167 Box bx_xlo(bx); bx_xlo.setBig (0,dom_lo.x-1);
168 Box bx_xhi(bx); bx_xhi.setSmall(0,dom_hi.x+1);
169 if (bx_xlo.smallEnd(2) != domain.smallEnd(2)) bx_xlo.growLo(2,nghost[2]);
170 if (bx_xlo.bigEnd(2) != domain.bigEnd(2)) bx_xlo.growHi(2,nghost[2]);
171 if (bx_xhi.smallEnd(2) != domain.smallEnd(2)) bx_xhi.growLo(2,nghost[2]);
172 if (bx_xhi.bigEnd(2) != domain.bigEnd(2)) bx_xhi.growHi(2,nghost[2]);
174 bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
177 int l_bc_type = bc_ptr[n].lo(0);
178 int iflip = 2*dom_lo.x - 1 - i;
180 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
182 dest_arr(i,j,k,dest_comp) = dest_arr(dom_lo.x,j,k,dest_comp);
184 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
186 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
188 Real delta_i =
static_cast<Real
>(dom_lo.x - i);
189 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) ;
192 bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
195 int h_bc_type = bc_ptr[n].hi(0);
196 int iflip = 2*dom_hi.x + 1 - i;
198 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
200 dest_arr(i,j,k,dest_comp) = dest_arr(dom_hi.x,j,k,dest_comp);
202 dest_arr(i,j,k,dest_comp) = dest_arr(iflip,j,k,dest_comp);
204 dest_arr(i,j,k,dest_comp) = -dest_arr(iflip,j,k,dest_comp);
206 Real delta_i =
static_cast<Real
>(i - dom_hi.x);
207 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) ;
213 if (!is_periodic_in_y)
216 Box bx_ylo(bx); bx_ylo.setBig (1,dom_lo.y-1);
217 Box bx_yhi(bx); bx_yhi.setSmall(1,dom_hi.y+1);
218 if (bx_ylo.smallEnd(2) != domain.smallEnd(2)) bx_ylo.growLo(2,nghost[2]);
219 if (bx_ylo.bigEnd(2) != domain.bigEnd(2)) bx_ylo.growHi(2,nghost[2]);
220 if (bx_yhi.smallEnd(2) != domain.smallEnd(2)) bx_yhi.growLo(2,nghost[2]);
221 if (bx_yhi.bigEnd(2) != domain.bigEnd(2)) bx_yhi.growHi(2,nghost[2]);
223 bx_ylo, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
226 int l_bc_type = bc_ptr[n].lo(1);
227 int jflip = 2*dom_lo.y - 1 - j;
229 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
231 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_lo.y,k,dest_comp);
233 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
235 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
237 Real delta_j =
static_cast<Real
>(dom_lo.y - j);
238 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) ;
242 bx_yhi, ncomp, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int n)
245 int h_bc_type = bc_ptr[n].hi(1);
246 int jflip = 2*dom_hi.y + 1 - j;
248 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
250 dest_arr(i,j,k,dest_comp) = dest_arr(i,dom_hi.y,k,dest_comp);
252 dest_arr(i,j,k,dest_comp) = dest_arr(i,jflip,k,dest_comp);
254 dest_arr(i,j,k,dest_comp) = -dest_arr(i,jflip,k,dest_comp);
256 Real delta_j =
static_cast<Real
>(j - dom_hi.y);
257 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);
282 auto is_ext_bc = [] (
int bc_type) {
286 const bool xlo_ext = !is_periodic_in_x && is_ext_bc(bcrs[0].
lo(0));
287 const bool xhi_ext = !is_periodic_in_x && is_ext_bc(bcrs[0].
hi(0));
288 const bool ylo_ext = !is_periodic_in_y && is_ext_bc(bcrs[0].
lo(1));
289 const bool yhi_ext = !is_periodic_in_y && is_ext_bc(bcrs[0].
hi(1));
291 if (xlo_ext || xhi_ext || ylo_ext || yhi_ext)
299 if (gbx.smallEnd(2) != domain.smallEnd(2)) gbx.growLo(2,nghost[2]);
300 if (gbx.bigEnd(2) != domain.bigEnd(2)) gbx.growHi(2,nghost[2]);
301 gbx.setSmall(2, amrex::max(gbx.smallEnd(2), dom_lo.z));
302 gbx.setBig (2, amrex::min(gbx.bigEnd(2) , dom_hi.z));
307 ParallelFor(gbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
314 const bool out_xlo = (i < dom_lo.x);
315 const bool out_xhi = (i > dom_hi.x);
316 const bool out_ylo = (j < dom_lo.y);
317 const bool out_yhi = (j > dom_hi.y);
319 if (!(out_xlo || out_xhi || out_ylo || out_yhi)) {
return; }
322 if (out_xlo && !xlo_ext) {
return; }
323 if (out_xhi && !xhi_ext) {
return; }
324 if (out_ylo && !ylo_ext) {
return; }
325 if (out_yhi && !yhi_ext) {
return; }
327 const int ir = amrex::min(amrex::max(i,dom_lo.x),dom_hi.x);
328 const int jr = amrex::min(amrex::max(j,dom_lo.y),dom_hi.y);
330 auto zcc = [=] (
int ii,
int jj,
int kk) {
331 return Real(0.125) * ( z_nd(ii,jj ,kk ) + z_nd(ii+1,jj ,kk )
332 + z_nd(ii,jj+1,kk ) + z_nd(ii+1,jj+1,kk )
333 + z_nd(ii,jj ,kk+1) + z_nd(ii+1,jj ,kk+1)
334 + z_nd(ii,jj+1,kk+1) + z_nd(ii+1,jj+1,kk+1) );
337 const Real dz_offset = zcc(i,j,k) - zcc(ir,jr,k);
340 if (dz_offset == Real(0.0)) {
return; }
352 if (!(p0_ref > Real(0.0)) || !(r0_ref > Real(0.0)) || !(th0_ref > Real(0.0))) {
return; }
358 const Real p0_new = p0_ref * std::exp(-l_gravity * dz_offset * r0_ref / p0_ref);
379 Gpu::streamSynchronize();
GpuArray< int, AMREX_SPACEDIM > dhi
Definition: ERF_ActuatorSpreading.cpp:132
GpuArray< int, AMREX_SPACEDIM > dlo
Definition: ERF_ActuatorSpreading.cpp:132
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:37
@ rho0_bc_comp
Definition: ERF_IndexDefines.H:168
@ num_comps
Definition: ERF_IndexDefines.H:114
@ qv0_comp
Definition: ERF_IndexDefines.H:113
@ pi0_comp
Definition: ERF_IndexDefines.H:111
@ p0_comp
Definition: ERF_IndexDefines.H:110
@ th0_comp
Definition: ERF_IndexDefines.H:112
@ r0_comp
Definition: ERF_IndexDefines.H:109
@ 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
@ int_dir
Definition: ERF_IndexDefines.H:314
@ reflect_even
Definition: ERF_IndexDefines.H:315
@ nc
Definition: ERF_Morrison.H:47
@ t
Definition: ERF_WSM6.H:295