221 const Box dom = l.geom.Domain();
222 const int ilo = dom.smallEnd(0), ihi = dom.bigEnd(0);
223 const int jlo = dom.smallEnd(1), jhi = dom.bigEnd(1);
224 const bool px = l.geom.isPeriodic(0), py = l.geom.isPeriodic(1);
225 const auto dx = l.geom.CellSizeArray();
226 const double calday = l.calday, declin = l.declin;
227 Array4<const Real> terrain;
228 for (MFIter mfi(l.patch); mfi.isValid(); ++mfi) { terrain = l.patch.const_array(mfi); }
229 for (MFIter mfi(l.raw); mfi.isValid(); ++mfi) {
230 auto g = l.ground.const_array(mfi);
231 auto r = l.raw.const_array(mfi);
232 auto diag = l.diagnostic.array(mfi);
233 GpuArray<Array4<Real>,
NRad> out;
234 for (
int n = 0; n <
NRad; ++n) {
235 out[n] = n < int(destinations.size()) && destinations[n]
236 ? destinations[n]->array(mfi) : Array4<Real>{};
238 ParallelFor(mfi.validbox(), [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
243 s = {h*std::sin(az), h*std::cos(az), choice.
fixed_mu};
245 const Real east = s.x, north = s.y;
253 const Real hx = (terrain(ip,j,0)-terrain(im,j,0))/(dxp*(px ? 2 : amrex::max(1,ip-im)));
254 const Real hy = (terrain(i,jp,0)-terrain(i,jm,0))/(dyp*(py ? 2 : amrex::max(1,jp-jm)));
259 const bool has_direct_sun = mu0 >
Real(1.e-4);
260 const bool midpoint_daytime = s.z >
Real(1.e-4);
262 const bool shadow = has_direct_sun && choice.
topo_shading &&
264 i,j,terrain,ilo,ihi,jlo,jhi,px,py,dxp,dyp,s,choice.
shadlen));
265 const Real factor = shadow ?
Real(0) :
266 ((has_direct_sun && choice.slope_rad) ? inc/mu0 :
Real(1));
277 for (
int n = 0; n <
NRad; ++n) {
const Real dx
Definition: ERF_InitCustomPert_ABL.H:44
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::Real Real
Definition: ERF_ShocInterface.H:19
amrex::Vector< std::unique_ptr< Level > > m_levels
Definition: ERF_TopographicShading.H:47
bool geometry_ready(int lev) const
Definition: ERF_TopographicShading.cpp:89
bool forcing_ready(int lev) const
Definition: ERF_TopographicShading.cpp:94
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:106
amrex::Real fixed_mu
Definition: ERF_RadStruct.H:107
amrex::Real fixed_azimuth
Definition: ERF_RadStruct.H:108
bool topo_shading
Definition: ERF_RadStruct.H:105