205 const auto&
dom_lo = lbound(domain);
206 const auto&
dom_hi = ubound(domain);
208 Box per_grown_domain(domain);
209 int growx = (
m_geom.isPeriodic(0)) ? 1 : 0;
210 int growy = (
m_geom.isPeriodic(1)) ? 1 : 0;
211 per_grown_domain.grow(IntVect(growx,growy,0));
212 const auto& perdom_lo = lbound(per_grown_domain);
213 const auto& perdom_hi = ubound(per_grown_domain);
215 GeometryData
const& geomdata =
m_geom.data();
220 Vector<BCRec> bcrs(1);
223 Gpu::DeviceVector<BCRec> bcrs_d(1);
224 Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
225 const BCRec* bc_ptr = bcrs_d.data();
227 GpuArray<GpuArray<Real, AMREX_SPACEDIM*2>,1> l_bc_extdir_vals_d;
229 for (
int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
235 Box bx_zlo(bx); bx_zlo.setBig (2,
dom_lo.z-1);
236 Box bx_zhi(bx); bx_zhi.setSmall(2,
dom_hi.z+1);
237 ParallelFor(bx_zlo, bx_zhi,
238 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
239 int kflip =
dom_lo.z - 1 - k;
241 #ifdef ERF_USE_TERRAIN_VELOCITY
242 dest_arr(i,j,k) = prob->compute_terrain_velocity(time);
244 dest_arr(i,j,k) = l_bc_extdir_vals_d[0][2];
247 dest_arr(i,j,k) = dest_arr(i,j,
dom_lo.z);
249 dest_arr(i,j,k) = dest_arr(i,j,
dom_lo.z);
251 dest_arr(i,j,k) = dest_arr(i,j,kflip);
253 dest_arr(i,j,k) = -dest_arr(i,j,kflip);
255 Real delta_k = (
dom_lo.z - k);
256 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);
259 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
260 int kflip = 2*
dom_hi.z + 1 - k;
262 dest_arr(i,j,k) = l_bc_extdir_vals_d[0][5];
264 dest_arr(i,j,k) = dest_arr(i,j,
dom_hi.z);
266 dest_arr(i,j,k) = dest_arr(i,j,
dom_hi.z);
268 dest_arr(i,j,k) = dest_arr(i,j,kflip);
270 dest_arr(i,j,k) = -dest_arr(i,j,kflip);
272 Real delta_k = (k -
dom_hi.z);
273 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);
280 const auto& bx_lo = lbound(bx);
281 const auto& bx_hi = ubound(bx);
283 const auto& zphys_lo = lbound(Box(z_phys_nd));
284 const auto& zphys_hi = ubound(Box(z_phys_nd));
296 xybx.setSmall(2,bx.smallEnd()[2]);
300 Real dz = geomdata.CellSize(2);
303 ParallelFor(xybx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
306 int ii = amrex::min(amrex::max(i,perdom_lo.x),perdom_hi.x);
307 ii = amrex::min(amrex::max(ii,zphys_lo.x),zphys_hi.x);
308 int jj = amrex::min(amrex::max(j,perdom_lo.y),perdom_hi.y);
309 jj = amrex::min(amrex::max(jj,zphys_lo.y),zphys_hi.y);
318 Real GradVarx, GradVary;
319 if ( i < dom_lo.x-1 || i >
dom_hi.x+1 || (i+1 > bx_hi.x && i-1 < bx_lo.x) ) {
321 }
else if (i+1 > bx_hi.x) {
322 GradVarx = dxInv[0] * (dest_arr(i ,j,k0) - dest_arr(i-1,j,k0));
323 }
else if (i-1 < bx_lo.x) {
324 GradVarx = dxInv[0] * (dest_arr(i+1,j,k0) - dest_arr(i ,j,k0));
326 GradVarx = 0.5 * dxInv[0] * (dest_arr(i+1,j,k0) - dest_arr(i-1,j,k0));
331 if ( j < dom_lo.y-1 || j >
dom_hi.y+1 || (j+1 > bx_hi.y && j-1 < bx_lo.y) ) {
333 }
else if (j+1 > bx_hi.y) {
334 GradVary = dxInv[1] * (dest_arr(i,j ,k0) - dest_arr(i,j-1,k0));
335 }
else if (j-1 < bx_lo.y) {
336 GradVary = dxInv[1] * (dest_arr(i,j+1,k0) - dest_arr(i,j ,k0));
338 GradVary = 0.5 * dxInv[1] * (dest_arr(i,j+1,k0) - dest_arr(i,j-1,k0));
342 Real met_fac = met_h_zeta / ( met_h_xi*met_h_xi + met_h_eta*met_h_eta + 1. );
345 dest_arr(i,j,k) -= dz * met_fac * ( met_h_xi * GradVarx + met_h_eta * GradVary );
349 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:193