222 const Box dom = l.geom.Domain();
223 const int ilo = dom.smallEnd(0), ihi = dom.bigEnd(0);
224 const int jlo = dom.smallEnd(1), jhi = dom.bigEnd(1);
225 const bool px = l.geom.isPeriodic(0), py = l.geom.isPeriodic(1);
226 const auto dx = l.geom.CellSizeArray();
227 const double calday = l.calday, declin = l.declin;
228 Array4<const Real> terrain;
229 for (MFIter mfi(l.patch); mfi.isValid(); ++mfi) { terrain = l.patch.const_array(mfi); }
230 for (MFIter mfi(l.raw); mfi.isValid(); ++mfi) {
231 auto g = l.ground.const_array(mfi);
232 auto r = l.raw.const_array(mfi);
233 auto diag = l.diagnostic.array(mfi);
234 GpuArray<Array4<Real>,
NRad> out;
235 for (
int n = 0; n <
NRad; ++n) {
236 out[n] = n < int(destinations.size()) && destinations[n]
237 ? destinations[n]->array(mfi) : Array4<Real>{};
239 ParallelFor(mfi.validbox(), [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
244 s = {h*std::sin(az), h*std::cos(az), choice.
fixed_mu};
246 const Real east = s.x, north = s.y;
254 const Real hx = (terrain(ip,j,0)-terrain(im,j,0))/(dxp*(px ? 2 : amrex::max(1,ip-im)));
255 const Real hy = (terrain(i,jp,0)-terrain(i,jm,0))/(dyp*(py ? 2 : amrex::max(1,jp-jm)));
259 const Real mu0 = r(i,j,k,
CosZen);
260 const bool has_direct_sun = mu0 > Real(1.e-4);
261 const bool midpoint_daytime = s.z > Real(1.e-4);
263 const bool shadow = has_direct_sun && choice.
topo_shading &&
265 i,j,terrain,ilo,ihi,jlo,jhi,px,py,dxp,dyp,s,choice.
shadlen));
266 const Real factor = shadow ? Real(0) :
267 ((has_direct_sun && choice.slope_rad) ? inc/mu0 : Real(1));
271 const Real sw = factor == Real(1) ? r(i,j,k,
Shortwave) :
273 diag(i,j,k,
Shadow) = shadow ? Real(1) : Real(0);
278 for (
int n = 0; n <
NRad; ++n) {
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
amrex::Vector< std::unique_ptr< Level > > m_levels
Definition: ERF_TopographicShading.H:47
bool geometry_ready(int lev) const
Definition: ERF_TopographicShading.cpp:90
bool forcing_ready(int lev) const
Definition: ERF_TopographicShading.cpp:95
Definition: ERF_ConsoleIO.cpp:17
Definition: ERF_TopographicShadingKernels.H:10
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool shadowed(int i, int j, const amrex::Array4< const Real > &terrain, int ilo, int ihi, int jlo, int jhi, bool periodic_x, bool periodic_y, Real dx, Real dy, Sun s, Real search_length)
Definition: ERF_TopographicShadingKernels.H:43
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real incidence(Real hx, Real hy, Sun s)
Definition: ERF_TopographicShadingKernels.H:30
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int wrap(int i, int lo, int n)
Definition: ERF_TopographicShadingKernels.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Sun sun_direction(double calday, double declin, Real lat_deg, Real lon_deg)
Definition: ERF_TopographicShadingKernels.H:19
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real corrected_shortwave(Real direct, Real diffuse, Real factor)
Definition: ERF_TopographicShadingKernels.H:86
real(c_double), parameter g
Definition: ERF_module_model_constants.F90:19
amrex::Real shadlen
Definition: ERF_RadStruct.H:116
amrex::Real fixed_mu
Definition: ERF_RadStruct.H:117
amrex::Real fixed_azimuth
Definition: ERF_RadStruct.H:118
bool topo_shading
Definition: ERF_RadStruct.H:115