1 #ifndef ERF_TWO_STREAM_CANOPY_FORCING_H_
2 #define ERF_TWO_STREAM_CANOPY_FORCING_H_
4 #include <AMReX_Array4.H>
5 #include <AMReX_Extension.H>
6 #include <AMReX_GpuQualifiers.H>
7 #include <AMReX_MultiFab.H>
8 #include <AMReX_REAL.H>
46 const amrex::MultiFab*
beam =
nullptr;
48 const amrex::MultiFab*
fluxes =
nullptr;
76 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
78 const amrex::Array4<const amrex::Real>& scratch,
int f_dir_comp,
80 const amrex::Array4<amrex::Real>& beam)
82 const bool lit = sw_on && (cos_zenith >
amrex::Real(0.0));
83 for (
int m = 0; m <= m_top; ++m) {
85 beam(i, j, m) = blend ? (1.0 - cloud_fraction) * beam(i, j, m) + cloud_fraction * b : b;
103 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
107 return k - k0 + ((dir == 2 && side > 0) ? 1 : 0);
132 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
134 const amrex::Array4<const amrex::Real>& beam,
135 const amrex::Array4<const amrex::Real>& cosz,
136 const amrex::Array4<const amrex::Real>& fluxes)
142 const amrex::Real beam_h = w_lo * beam(i, j, ms) + w_up * beam(i, j,
mu);
143 const amrex::Real sw_dn = w_lo * fluxes(i, j, k0 + ms, 1) + w_up * fluxes(i, j, k0 +
mu, 1);
150 s.
lw_down = w_lo * fluxes(i, j, k0 + ms, 3) + w_up * fluxes(i, j, k0 +
mu, 3);
151 s.
sw_up = w_lo * fluxes(i, j, k0 + ms, 0) + w_up * fluxes(i, j, k0 +
mu, 0);
152 s.
lw_up = w_lo * fluxes(i, j, k0 + ms, 2) + w_up * fluxes(i, j, k0 +
mu, 2);
amrex::Real Real
Definition: ERF_ShocInterface.H:19
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void two_stream_canopy_beam(int i, int j, int kmin, int m_top, const amrex::Array4< const amrex::Real > &scratch, int f_dir_comp, bool sw_on, amrex::Real cos_zenith, amrex::Real cloud_fraction, bool blend, const amrex::Array4< amrex::Real > &beam)
Write the direct beam on a horizontal surface at the interfaces 0 .. m_top of column (i,...
Definition: ERF_TwoStreamCanopyForcing.H:77
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE TwoStreamFaceSky two_stream_face_sky(int i, int j, int k, int k0, int dir, int side, const amrex::Array4< const amrex::Real > &beam, const amrex::Array4< const amrex::Real > &cosz, const amrex::Array4< const amrex::Real > &fluxes)
The column radiation a face at fluid cell (i,j,k) of direction dir, with its solid on side side,...
Definition: ERF_TwoStreamCanopyForcing.H:133
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int two_stream_canopy_sample(int k, int k0, int dir, int side, amrex::Real &w_up)
Sample interface of a face and the weight of the one above. A z face takes the interface it lies on: ...
Definition: ERF_TwoStreamCanopyForcing.H:104
@ mu
Definition: ERF_AdvanceMorrison.cpp:92
The fields a level's faces read for one step: the beam and the cosine of the zenith the sweep of that...
Definition: ERF_TwoStreamCanopyForcing.H:45
const amrex::MultiFab * fluxes
The level's rad_fluxes (SW up, SW down, LW up, LW down) [W/m^2].
Definition: ERF_TwoStreamCanopyForcing.H:48
const amrex::MultiFab * beam
Direct beam on a horizontal surface, interfaces 0 .. m_top [W/m^2].
Definition: ERF_TwoStreamCanopyForcing.H:46
const amrex::MultiFab * cos_zenith
Cosine of the zenith of the sweep, floored at zero (2D) [1].
Definition: ERF_TwoStreamCanopyForcing.H:47
bool valid() const noexcept
Definition: ERF_TwoStreamCanopyForcing.H:49
What one face takes from its column (all W/m^2).
Definition: ERF_TwoStreamCanopyForcing.H:112
amrex::Real sw_up
Shortwave up at the face's height (the ground's reflection, seen from there)
Definition: ERF_TwoStreamCanopyForcing.H:116
amrex::Real diffuse
Diffuse shortwave down at the face's height.
Definition: ERF_TwoStreamCanopyForcing.H:114
amrex::Real lw_up
Longwave up at the face's height (the ground's emission and the air's below)
Definition: ERF_TwoStreamCanopyForcing.H:117
amrex::Real lw_down
Longwave down at the face's height.
Definition: ERF_TwoStreamCanopyForcing.H:115
amrex::Real dni
Direct-normal irradiance at the face's height.
Definition: ERF_TwoStreamCanopyForcing.H:113