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; }
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) {
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));
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))));
80 if (h > ray_height + height_tol) {
return true; }
const Real dy
Definition: ERF_InitCustomPert_ABL.H:45
const Real dx
Definition: ERF_InitCustomPert_ABL.H:44
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