174 const auto& dom_lo = lbound(domain);
175 const auto& dom_hi = ubound(domain);
177 Box per_grown_domain(domain);
178 int growx = (
m_geom.isPeriodic(0)) ? 1 : 0;
179 int growy = (
m_geom.isPeriodic(1)) ? 1 : 0;
180 per_grown_domain.grow(IntVect(growx,growy,0));
181 const auto& perdom_lo = lbound(per_grown_domain);
182 const auto& perdom_hi = ubound(per_grown_domain);
187 Vector<BCRec> bcrs(1);
197 Gpu::DeviceVector<BCRec> bcrs_d(1);
198 Gpu::copyAsync(Gpu::hostToDevice, bcrs.begin(), bcrs.end(), bcrs_d.begin());
199 const BCRec* bc_ptr = bcrs_d.data();
201 GpuArray<GpuArray<Real, AMREX_SPACEDIM*2>, 1> l_bc_extdir_vals_d;
203 for (
int ori = 0; ori < 2*AMREX_SPACEDIM; ori++) {
207 GeometryData
const& geomdata =
m_geom.data();
211 Box bx_zlo(bx); bx_zlo.setBig (2,dom_lo.z-1);
212 Box bx_zhi(bx); bx_zhi.setSmall(2,dom_hi.z+1);
213 ParallelFor(bx_zlo, bx_zhi,
214 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
215 int kflip = dom_lo.z - 1 - k;
217 dest_arr(i,j,k) = l_bc_extdir_vals_d[0][2];
219 dest_arr(i,j,k) = dest_arr(i,j,dom_lo.z);
221 dest_arr(i,j,k) = dest_arr(i,j,dom_lo.z);
223 dest_arr(i,j,k) = dest_arr(i,j,kflip);
225 dest_arr(i,j,k) = -dest_arr(i,j,kflip);
228 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
229 int kflip = 2*dom_hi.z + 1 - k;
231 dest_arr(i,j,k) = l_bc_extdir_vals_d[0][5];
233 dest_arr(i,j,k) = dest_arr(i,j,dom_hi.z);
235 dest_arr(i,j,k) = dest_arr(i,j,dom_hi.z);
237 dest_arr(i,j,k) = dest_arr(i,j,kflip);
239 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_AtJface(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:144
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtJface(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:130
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_eta_AtJface(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:158
void impose_vertical_yvel_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)
Definition: ERF_BoundaryConditionsYvel.cpp:167