47 const Real horizontal = std::sqrt(s.x*s.x + s.y*s.y);
51 if (s.z <= Real(1.e-4) || horizontal <= std::sqrt(
real_eps)) {
return false; }
54 constexpr Real angular_eps = Real(8)*
real_eps;
55 const Real
di = std::abs(s.x) < angular_eps*horizontal ? Real(0) : s.
x / (horizontal *
dx);
56 const Real dj = std::abs(s.y) < angular_eps*horizontal ? Real(0) : s.
y / (horizontal *
dy);
57 const Real
ds = Real(1) / amrex::max(std::abs(
di), std::abs(dj));
58 const Real
z = terrain(i,j,0,0);
59 for (Real r =
ds; r <= search_length; r +=
ds) {
60 const Real
x = Real(i) + r*
di,
y = Real(j) + r*dj;
61 if ((!periodic_x && (x < ilo || x > ihi)) ||
62 (!periodic_y && (y < jlo || y > jhi))) {
break; }
63 int ix = int(std::floor(x)), jy = int(std::floor(y));
64 const Real wx =
x-Real(ix), wy =
y-Real(jy);
65 int ip = ix+1, jp = jy+1;
66 if (periodic_x) { ix =
wrap(ix,ilo,ihi-ilo+1); ip =
wrap(ip,ilo,ihi-ilo+1); }
67 else { ip = amrex::min(ip,ihi); }
68 if (periodic_y) { jy =
wrap(jy,jlo,jhi-jlo+1); jp =
wrap(jp,jlo,jhi-jlo+1); }
69 else { jp = amrex::min(jp,jhi); }
70 AMREX_ASSERT(terrain.contains(ix,jy,0) && terrain.contains(ip,jp,0));
71 const Real h = (Real(1)-wy)*((Real(1)-wx)*terrain(ix,jy,0,0) + wx*terrain(ip,jy,0,0))
72 + wy*((Real(1)-wx)*terrain(ix,jp,0,0) + wx*terrain(ip,jp,0,0));
75 const Real ray_height =
z + r*s.z/horizontal;
77 const Real height_scale = amrex::max(Real(1),
78 amrex::max(std::abs(z), amrex::max(std::abs(h), std::abs(ray_height))));
79 const Real height_tol = Real(8)*
real_eps*height_scale;
80 if (h > ray_height + height_tol) {
return true; }
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
const Real dy
Definition: ERF_InitCustomPert_ABL.H:101
constexpr amrex::Real real_eps
Definition: ERF_NumericalConstants.H:34
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int wrap(int i, int lo, int n)
Definition: ERF_TopographicShadingKernels.H:36
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12
real(c_double), private ds
Definition: ERF_module_mp_morr_two_moment.F90:203
real(c_double), private di
Definition: ERF_module_mp_morr_two_moment.F90:203