204 const auto&
dom_lo = lbound(domain);
205 const auto&
dom_hi = ubound(domain);
207 Box per_grown_domain(domain);
208 int growx = (
m_geom.isPeriodic(0)) ? 1 : 0;
209 int growy = (
m_geom.isPeriodic(1)) ? 1 : 0;
210 per_grown_domain.grow(IntVect(growx,growy,0));
211 const auto& perdom_lo = lbound(per_grown_domain);
212 const auto& perdom_hi = ubound(per_grown_domain);
214 GeometryData
const& geomdata =
m_geom.data();
219 Vector<BCRec> bcrs(1);
222 Gpu::DeviceVector<BCRec> bcrs_d(1);
223 Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
224 const BCRec* bc_ptr = bcrs_d.data();
226 GpuArray<GpuArray<Real, AMREX_SPACEDIM*2>,1> l_bc_extdir_vals_d;
228 for (
int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
234 Box bx_zlo(bx); bx_zlo.setBig (2,
dom_lo.z-1);
235 Box bx_zhi(bx); bx_zhi.setSmall(2,
dom_hi.z+1);
236 ParallelFor(bx_zlo, bx_zhi,
237 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
238 int kflip =
dom_lo.z - 1 - k;
240 #ifdef ERF_USE_TERRAIN_VELOCITY
241 dest_arr(i,j,k) = prob->compute_terrain_velocity(time);
243 dest_arr(i,j,k) = l_bc_extdir_vals_d[0][2];
246 dest_arr(i,j,k) = dest_arr(i,j,
dom_lo.z);
248 dest_arr(i,j,k) = dest_arr(i,j,
dom_lo.z);
250 dest_arr(i,j,k) = dest_arr(i,j,kflip);
252 dest_arr(i,j,k) = -dest_arr(i,j,kflip);
254 Real delta_k = (
dom_lo.z - k);
255 dest_arr(i,j,k) = (1.0 + delta_k)*dest_arr(i,j,
dom_lo.z) - delta_k*dest_arr(i,j,
dom_lo.z+1);
258 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
259 int kflip = 2*
dom_hi.z + 1 - k;
261 dest_arr(i,j,k) = l_bc_extdir_vals_d[0][5];
263 dest_arr(i,j,k) = dest_arr(i,j,
dom_hi.z);
265 dest_arr(i,j,k) = dest_arr(i,j,
dom_hi.z);
267 dest_arr(i,j,k) = dest_arr(i,j,kflip);
269 dest_arr(i,j,k) = -dest_arr(i,j,kflip);
271 Real delta_k = (k -
dom_hi.z);
272 dest_arr(i,j,k) = (1.0 + delta_k)*dest_arr(i,j,
dom_hi.z) - delta_k*dest_arr(i,j,
dom_hi.z-1);
279 const auto& bx_lo = lbound(bx);
280 const auto& bx_hi = ubound(bx);
282 const auto& zphys_lo = lbound(Box(z_phys_nd));
283 const auto& zphys_hi = ubound(Box(z_phys_nd));
295 xybx.setSmall(2,bx.smallEnd()[2]);
299 Real dz = geomdata.CellSize(2);
302 ParallelFor(xybx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
305 int ii = amrex::min(amrex::max(i,perdom_lo.x),perdom_hi.x);
306 ii = amrex::min(amrex::max(ii,zphys_lo.x),zphys_hi.x);
307 int jj = amrex::min(amrex::max(j,perdom_lo.y),perdom_hi.y);
308 jj = amrex::min(amrex::max(jj,zphys_lo.y),zphys_hi.y);
317 Real GradVarx, GradVary;
318 if ( i < dom_lo.x-1 || i >
dom_hi.x+1 || (i+1 > bx_hi.x && i-1 < bx_lo.x) ) {
320 }
else if (i+1 > bx_hi.x) {
321 GradVarx = dxInv[0] * (dest_arr(i ,j,k0) - dest_arr(i-1,j,k0));
322 }
else if (i-1 < bx_lo.x) {
323 GradVarx = dxInv[0] * (dest_arr(i+1,j,k0) - dest_arr(i ,j,k0));
325 GradVarx = 0.5 * dxInv[0] * (dest_arr(i+1,j,k0) - dest_arr(i-1,j,k0));
330 if ( j < dom_lo.y-1 || j >
dom_hi.y+1 || (j+1 > bx_hi.y && j-1 < bx_lo.y) ) {
332 }
else if (j+1 > bx_hi.y) {
333 GradVary = dxInv[1] * (dest_arr(i,j ,k0) - dest_arr(i,j-1,k0));
334 }
else if (j-1 < bx_lo.y) {
335 GradVary = dxInv[1] * (dest_arr(i,j+1,k0) - dest_arr(i,j ,k0));
337 GradVary = 0.5 * dxInv[1] * (dest_arr(i,j+1,k0) - dest_arr(i,j-1,k0));
341 Real met_fac = met_h_zeta / ( met_h_xi*met_h_xi + met_h_eta*met_h_eta + 1. );
344 dest_arr(i,j,k) -= dz * met_fac * ( met_h_xi * GradVarx + met_h_eta * GradVary );
348 Gpu::streamSynchronize();
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_xi_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:110
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:96
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:125
void impose_vertical_xvel_bcs(const amrex::Array4< amrex::Real > &dest_arr, const amrex::Box &bx, const amrex::Box &domain, const amrex::Array4< amrex::Real const > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > dxInv, int bccomp, const amrex::Real time)
Definition: ERF_BoundaryConditionsXvel.cpp:192