178 const auto& dom_lo = lbound(domain);
179 const auto& dom_hi = ubound(domain);
181 Box per_grown_domain(domain);
182 int growx = (
m_geom.isPeriodic(0)) ? 1 : 0;
183 int growy = (
m_geom.isPeriodic(1)) ? 1 : 0;
184 per_grown_domain.grow(IntVect(growx,growy,0));
185 const auto& perdom_lo = lbound(per_grown_domain);
186 const auto& perdom_hi = ubound(per_grown_domain);
188 GeometryData
const& geomdata =
m_geom.data();
193 Vector<BCRec> bcrs(1);
196 Gpu::DeviceVector<BCRec> bcrs_d(1);
197 Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
198 const BCRec* bc_ptr = bcrs_d.data();
200 GpuArray<GpuArray<Real, AMREX_SPACEDIM*2>,1> l_bc_extdir_vals_d;
202 for (
int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
208 Box bx_zlo(bx); bx_zlo.setBig (2,dom_lo.z-1);
209 Box bx_zhi(bx); bx_zhi.setSmall(2,dom_hi.z+1);
210 ParallelFor(bx_zlo, bx_zhi,
211 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
212 int kflip = dom_lo.z - 1 - k;
214 #ifdef ERF_USE_TERRAIN_VELOCITY
215 dest_arr(i,j,k) = prob->compute_terrain_velocity(time);
217 dest_arr(i,j,k) = l_bc_extdir_vals_d[0][2];
220 dest_arr(i,j,k) = dest_arr(i,j,dom_lo.z);
222 dest_arr(i,j,k) = dest_arr(i,j,dom_lo.z);
224 dest_arr(i,j,k) = dest_arr(i,j,kflip);
226 dest_arr(i,j,k) = -dest_arr(i,j,kflip);
229 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
230 int kflip = 2*dom_hi.z + 1 - k;
232 dest_arr(i,j,k) = l_bc_extdir_vals_d[0][5];
234 dest_arr(i,j,k) = dest_arr(i,j,dom_hi.z);
236 dest_arr(i,j,k) = dest_arr(i,j,dom_hi.z);
238 dest_arr(i,j,k) = dest_arr(i,j,kflip);
240 dest_arr(i,j,k) = -dest_arr(i,j,kflip);
247 const auto& bx_lo = lbound(bx);
248 const auto& bx_hi = ubound(bx);
250 const auto& zphys_lo = lbound(Box(z_phys_nd));
251 const auto& zphys_hi = ubound(Box(z_phys_nd));
263 xybx.setSmall(2,bx.smallEnd()[2]);
267 Real dz = geomdata.CellSize(2);
270 ParallelFor(xybx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
273 int ii = amrex::min(amrex::max(i,perdom_lo.x),perdom_hi.x);
274 ii = amrex::min(amrex::max(ii,zphys_lo.x),zphys_hi.x);
275 int jj = amrex::min(amrex::max(j,perdom_lo.y),perdom_hi.y);
276 jj = amrex::min(amrex::max(jj,zphys_lo.y),zphys_hi.y);
285 Real GradVarx, GradVary;
286 if ( i < dom_lo.x-1 || i > dom_hi.x+1 || (i+1 > bx_hi.x && i-1 < bx_lo.x) ) {
288 }
else if (i+1 > bx_hi.x) {
289 GradVarx = dxInv[0] * (dest_arr(i ,j,k0) - dest_arr(i-1,j,k0));
290 }
else if (i-1 < bx_lo.x) {
291 GradVarx = dxInv[0] * (dest_arr(i+1,j,k0) - dest_arr(i ,j,k0));
293 GradVarx = 0.5 * dxInv[0] * (dest_arr(i+1,j,k0) - dest_arr(i-1,j,k0));
298 if ( j < dom_lo.y-1 || j > dom_hi.y+1 || (j+1 > bx_hi.y && j-1 < bx_lo.y) ) {
300 }
else if (j+1 > bx_hi.y) {
301 GradVary = dxInv[1] * (dest_arr(i,j ,k0) - dest_arr(i,j-1,k0));
302 }
else if (j-1 < bx_lo.y) {
303 GradVary = dxInv[1] * (dest_arr(i,j+1,k0) - dest_arr(i,j ,k0));
305 GradVary = 0.5 * dxInv[1] * (dest_arr(i,j+1,k0) - dest_arr(i,j-1,k0));
309 Real met_fac = met_h_zeta / ( met_h_xi*met_h_xi + met_h_eta*met_h_eta + 1. );
312 dest_arr(i,j,k) -= dz * met_fac * ( met_h_xi * GradVarx + met_h_eta * GradVary );
316 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:101
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:87
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:116
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:166