ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_TwoStreamRadiation.H
Go to the documentation of this file.
1 #ifndef ERF_TWO_STREAM_RADIATION_H_
2 #define ERF_TWO_STREAM_RADIATION_H_
3 
4 #include <memory>
5 #include <string>
6 
7 #include <AMReX_BoxArray.H>
8 #include <AMReX_DistributionMapping.H>
9 #include <AMReX_Geometry.H>
10 #include <AMReX_iMultiFab.H>
11 #include <AMReX_MultiFab.H>
12 #include <AMReX_REAL.H>
13 #include <AMReX_Vector.H>
14 
15 #include <ERF_RadStruct.H>
16 #include <ERF_LandSurface.H>
22 
23 /**
24  * @brief The two-stream radiation model (erf.radiation_model = TwoStream).
25  *
26  * Owns everything the model keeps between steps: the per-level surface
27  * property fields it falls back on when no land-surface model supplies
28  * them, the surface-energy-balance (SEB) fields and force-restore state,
29  * and the domain-mean flux diagnostics of the last column sweep. ERF holds
30  * one instance and calls it only after testing
31  * `solverChoice.rad_type == RadiationType::TwoStream`; every method
32  * here checks the same predicate and returns without acting otherwise.
33  *
34  * Lifecycle:
35  * - resize(nlevs) once at construction (before the inputs are read);
36  * - define_level(lev, radChoice, rdOcp, ba2d, dm, ba, domain, supply_land_forcing)
37  * whenever a level is (re)built;
38  * - advance(...) twice per step: "pre_dycore" runs the column sweep on the
39  * old state and writes the heating rates, "post_dycore" reuses that
40  * sweep's flux diagnostics and advances the SEB state by dt_step;
41  * - write_land_forcing(...) after a sweep, when a land-surface model integrates
42  * on the radiation this model computes (see supply_land_forcing);
43  * - supply_canopy_forcing(...) once, when the building faces of the
44  * immersed-boundary balance take their radiation from the sweep
45  * (erf.ibseb.radiation = two_stream), and canopy_forcing(...) after each sweep;
46  * - set_building_cover(...) once, when the columns are to see the buildings of the
47  * immersed-boundary balance (erf.ibseb.two_stream_buildings), and
48  * ground_shadow_for_step(...) every step, for the balance to fill with the
49  * buildings' shadow on the ground;
50  * - write_checkpoint / read_checkpoint for the prognostic surface state;
51  * - with the force-restore hydrology (RadChoice::seb_hydrology_enabled()),
52  * hydrology_begin_step(...) at the start of each step of a level and
53  * hydrology_end_step(...) before its post-dycore call, which give the rain of the step.
54  *
55  * The heating-rate MultiFab itself stays in ERF, since RRTMGP writes the
56  * same 2-component (SW, LW) array and the RhoTheta source term and the
57  * plotfile read it without caring which model filled it.
58  */
60 {
61 public:
62  TwoStreamRadiation () = default;
63 
64  /** @brief Size the per-level containers; no allocation happens here. */
65  void resize (int nlevs_max);
66 
67  /** @brief True once a level has been defined with the model selected. */
68  [[nodiscard]] bool active () const {
69  return (m_rad != nullptr) && m_rad->enabled;
70  }
71 
72  /** @brief Read-only view of the per-level prognostic surface-temperature state. */
73  [[nodiscard]] const amrex::MultiFab* prognostic_surface_temperature_state (int lev) const noexcept {
74  return (lev >= 0 && lev < static_cast<int>(m_t_sfc.size()))
75  ? m_t_sfc[lev].get() : nullptr;
76  }
77 
78  /**
79  * @brief Allocate the 2D surface fields of one level on the given
80  * horizontal BoxArray and fill them with the scalar defaults. A no-op
81  * unless rad_choice.rad_type == TwoStream.
82  *
83  * The column sweep needs every box of @p ba to span @p domain in z,
84  * because it applies the top-of-atmosphere and surface boundary
85  * conditions at the ends of a box. A fine level that does not takes its
86  * fields from its parent; a level 0 that does not is rejected before this
87  * is called (ERF::check_rad_level_grids), and is only asserted here.
88  *
89  * @param lev level
90  * @param rad_choice the model's inputs
91  * @param ba2d horizontal BoxArray the 2D surface fields live on
92  * @param dm distribution mapping shared with the level's state
93  * @param ba the level's 3D BoxArray (z span asserted on level 0)
94  * @param domain the level's domain Box
95  * @param supply_land_forcing allocate the downwelling SW, downwelling LW and
96  * cos(zenith) fields the sweep fills for a land-surface model
97  * (SolverChoice::rad_feeds_lsm()); off, the sweep does no
98  * extra work and the fields do not exist
99  */
100  void define_level (int lev,
101  const RadChoice& rad_choice,
102  amrex::Real rdOcp,
103  const amrex::BoxArray& ba2d,
104  const amrex::DistributionMapping& dm,
105  const amrex::BoxArray& ba,
106  const amrex::Box& domain,
107  bool supply_land_forcing = false);
108 
109  /**
110  * @brief One radiation call at one level.
111  *
112  * @param lev level
113  * @param nstep step number, used as the diagnostics row index
114  * @param time time logged with the diagnostics row [s]
115  * @param dt_step step size, used by the SEB Euler update [s]
116  * @param call_site "pre_dycore" (column sweep + diagnostics) or
117  * "post_dycore" (cached diagnostics + SEB update)
118  * @param cons_old old-state conserved variables of this level
119  * @param z_phys_nd nodal heights (layer interfaces), or nullptr on a uniform grid
120  * @param geom geometry of this level
121  * @param lsm land-surface model (queried for per-column fields)
122  * @param radiation_inputs canonical surface-property inputs, in fixed order
123  * @param noahmp_active whether Noah-MP diagnostics may be queried
124  * @param qheating 2-component (SW, LW) heating-rate MultiFab of this
125  * level, written at the pre-dycore call; may be nullptr
126  * @param rad_fluxes 4-component (SW up, SW down, LW up, LW down) interface
127  * fluxes of this level in RRTMGP's level layout (index k
128  * the lower interface of layer k, the top of the
129  * atmosphere in the z-ghost cell above the top layer),
130  * written at the pre-dycore call; may be nullptr
131  * @param t_surf the surface layer's surface temperature, or nullptr;
132  * used as the longwave boundary condition where no
133  * land-surface field exists, as RRTMGP does
134  * @param sfc_sens_flux the conservative heat flux (rho w'theta', z faces)
135  * the zlo surface layer applies to this level, or
136  * nullptr when it applies none; the surface energy
137  * balance's H where no land-surface model supplies one
138  * (see ERF_SEBTurbulentFlux.H)
139  * @param sfc_laten_flux the moisture flux (rho w'qv', z faces) likewise,
140  * for LE; nullptr without a moisture model
141  * @param lat_m per-column latitude [degrees], or nullptr (then
142  * erf.rad_cons_lat); only the WRF/metgrid inits fill it
143  * @param lon_m per-column longitude [degrees], likewise
144  * @param epoch_time seconds since 1970-01-01 00:00 UTC of this call
145  * (start_time + time), the RRTMGP time base; double, as
146  * RRTMGP keeps it, since a float cannot resolve a time
147  * of day at ~1.7e9 s
148  * @param have_datetime true when start_datetime (or a WRF/metgrid start
149  * date) fixed the calendar; without it a dynamic sun
150  * cannot be placed and the call aborts
151  * @param land_mask the level's land mask (ERF::lmask_lev: 0 water, 1 land, 2 a
152  * building's column), one 2D box at k = 0 for each box of the
153  * state, or nullptr (every column is land). The force-restore
154  * balance is a model of soil, so a water column (mask 0) is not
155  * its ground: its state is held (the snow layer's water is set to
156  * zero), it is left out of the balance's
157  * means and of the hydrology, and the sweep takes its surface
158  * temperature from @p t_surf (the surface layer's sea surface
159  * temperature) and not from the balance's skin.
160  */
161  void advance (int lev,
162  int nstep,
163  amrex::Real time,
164  amrex::Real dt_step,
165  const std::string& call_site,
166  const amrex::MultiFab& cons_old,
167  const amrex::MultiFab* z_phys_nd,
168  const amrex::Geometry& geom,
169  LandSurface& lsm,
170  const amrex::Vector<const amrex::MultiFab*>& radiation_inputs,
171  bool noahmp_active,
172  amrex::MultiFab* qheating,
173  amrex::MultiFab* rad_fluxes,
174  const amrex::MultiFab* t_surf,
175  const amrex::MultiFab* sfc_sens_flux,
176  const amrex::MultiFab* sfc_laten_flux,
177  const amrex::MultiFab* lat_m,
178  const amrex::MultiFab* lon_m,
179  double epoch_time,
180  bool have_datetime,
181  const amrex::iMultiFab* land_mask = nullptr);
182 
183  /**
184  * @brief The prognostic surface state of one level, or nullptr when the SEB is
185  * off or the level has not been built.
186  *
187  * Exposed so ERF can average t_sfc and q_sfc down after the finer levels have
188  * advanced. Every level evolves its own copy, and without that transfer the two
189  * estimates of one surface drift apart -- which would give the longwave boundary
190  * condition two different values for the same ground. ERF owns refRatio and the
191  * level geometries; this class does not, and should not grow them for one call.
192  */
193  [[nodiscard]] amrex::MultiFab* seb_t_sfc (int lev) {
194  return (active() && m_rad->seb_enable && lev < m_t_sfc.size()) ? m_t_sfc[lev].get() : nullptr;
195  }
196  [[nodiscard]] amrex::MultiFab* seb_q_sfc (int lev) {
197  return (active() && m_rad->seb_enable && lev < m_q_sfc.size()) ? m_q_sfc[lev].get() : nullptr;
198  }
199 
200  /**
201  * @brief The sensible and latent heat fluxes [W/m^2] the surface energy balance
202  * of one level last used, or nullptr when the SEB is off or the level has not
203  * been built. Read-only: for output.
204  */
205  [[nodiscard]] const amrex::MultiFab* seb_hfx (int lev) const {
206  return (active() && m_rad->seb_enable && lev < m_hfx_sfc.size()) ? m_hfx_sfc[lev].get() : nullptr;
207  }
208  [[nodiscard]] const amrex::MultiFab* seb_lh (int lev) const {
209  return (active() && m_rad->seb_enable && lev < m_lh_sfc.size()) ? m_lh_sfc[lev].get() : nullptr;
210  }
211 
212  /**
213  * @brief What level lev's surface hands the surface layer for its surface mixing ratio
214  * (erf.radiation.seb_surface_layer_uses_moisture), per column, in the components of
215  * erf_surface_moisture::Component: the soil-water factor (seb_moisture_availability
216  * of the current q_s); with erf.radiation.seb_soil_type, the bare-soil resistance and
217  * the relative humidity of its pore air at the skin temperature; and
218  * with erf.radiation.seb_vegetation_type as well, the vegetated fraction and the canopy
219  * resistance without its vapor-deficit factor (from the net shortwave the balance
220  * holds divided by (1 - surface albedo) -- the sweep's with seb_use_radiation_fluxes,
221  * seb_sw_flux_default otherwise -- and the skin temperature). Absent pieces are a
222  * fraction of 0 and resistances of 1e6 s/m. nullptr
223  * when the option is off or the level has not been built. Recomputed on every call,
224  * on the valid cells; the halo is not filled.
225  */
226  [[nodiscard]] const amrex::MultiFab* seb_surface_moisture (int lev);
227 
228  /**
229  * @brief Every field of the force-restore state of @p lev that evolves and so must
230  * survive a regrid, be filled from the coarse level on a new level and be averaged
231  * down: t_sfc and q_sfc; with erf.radiation.seb_deep_prognostic_enable, t_deep and
232  * q_deep; with erf.radiation.seb_init_t_deep_from_file, t_deep (it does not evolve
233  * then, but it differs from column to column); with the hydrology, its running totals
234  * (several components); with the snow layer, its water equivalent and totals. Empty
235  * when the state is not evolved. Each is a 2D field (k = 0) on the level's horizontal
236  * grids.
237  */
238  [[nodiscard]] amrex::Vector<amrex::MultiFab*> seb_prognostic_fields (int lev);
239 
240  /**
241  * @brief Store the surface precipitation accumulation of @p lev at the start of its
242  * step (ERF::Advance, before the dycore and microphysics). A no-op without
243  * erf.radiation.seb_precipitation_source = microphysics.
244  */
245  void hydrology_begin_step (int lev, const SurfacePrecipAccumulationSources& sources, int klo);
246 
247  /**
248  * @brief The rain rate of the step of @p lev just taken, from the accumulation now and
249  * the one hydrology_begin_step stored; called before the post-dycore advance. A no-op
250  * without erf.radiation.seb_precipitation_source = microphysics.
251  */
252  void hydrology_end_step (int lev, const SurfacePrecipAccumulationSources& sources, int klo,
253  amrex::Real dt);
254 
255  /**
256  * @brief The force-restore soil of @p lev, read-only (see ForceRestoreSoil), or an empty
257  * view (every pointer nullptr) when the force-restore state is not evolved there.
258  */
259  [[nodiscard]] ForceRestoreSoil force_restore_soil (int lev) const;
260 
261  /**
262  * @brief True when the deep temperature is part of the state: it evolves
263  * (erf.radiation.seb_deep_prognostic_enable) or it was set per column from the initial
264  * file (erf.radiation.seb_init_t_deep_from_file). It is then not reset to
265  * erf.radiation.seb_t_deep_default at a radiation step, it is one of
266  * seb_prognostic_fields and it is written to the checkpoint and read back.
267  */
268  [[nodiscard]] bool seb_t_deep_is_state () const {
269  return active() && m_rad->seb_enable &&
272  }
273 
274  /**
275  * @brief The deep temperature [K] of @p lev for ERF::init_seb_t_deep_from_file to
276  * write, or nullptr when it is not part of the state (seb_t_deep_is_state) or the
277  * level has not been built.
278  */
279  [[nodiscard]] amrex::MultiFab* seb_t_deep_state (int lev) {
280  return (seb_t_deep_is_state() && lev >= 0 && lev < static_cast<int>(m_t_deep.size()))
281  ? m_t_deep[lev].get() : nullptr;
282  }
283 
284  /**
285  * @brief True when the deep water content is part of the state: it evolves
286  * (erf.radiation.seb_deep_prognostic_enable) or it was set per column from the initial
287  * file (erf.radiation.seb_init_soil_moisture_from_file). It is then not reset to
288  * erf.radiation.seb_q_deep_default at a radiation step, it is one of
289  * seb_prognostic_fields and it is written to the checkpoint and read back.
290  */
291  [[nodiscard]] bool seb_q_deep_is_state () const {
292  return active() && m_rad->seb_enable &&
295  }
296 
297  /**
298  * @brief The surface water content q_s [m^3/m^3] of @p lev for
299  * ERF::init_seb_soil_moisture_from_file to write, or nullptr when the prognostic
300  * balance does not run or the level has not been built.
301  */
302  [[nodiscard]] amrex::MultiFab* seb_q_sfc_state (int lev) {
303  return (seb_prognostic_active() && lev >= 0 && lev < static_cast<int>(m_q_sfc.size()))
304  ? m_q_sfc[lev].get() : nullptr;
305  }
306 
307  /**
308  * @brief The deep water content [m^3/m^3] of @p lev for
309  * ERF::init_seb_soil_moisture_from_file to write, or nullptr when it is not part of
310  * the state (seb_q_deep_is_state) or the level has not been built.
311  */
312  [[nodiscard]] amrex::MultiFab* seb_q_deep_state (int lev) {
313  return (seb_q_deep_is_state() && lev >= 0 && lev < static_cast<int>(m_q_deep.size()))
314  ? m_q_deep[lev].get() : nullptr;
315  }
316 
317  /** @brief The deep temperature [K] and column water content of @p lev, or nullptr. Read-only: for output. */
318  [[nodiscard]] const amrex::MultiFab* seb_t_deep (int lev) const {
319  return (active() && m_rad->seb_enable && lev < static_cast<int>(m_t_deep.size())) ? m_t_deep[lev].get() : nullptr;
320  }
321  [[nodiscard]] const amrex::MultiFab* seb_q_deep (int lev) const {
322  return (active() && m_rad->seb_enable && lev < static_cast<int>(m_q_deep.size())) ? m_q_deep[lev].get() : nullptr;
323  }
324 
325  /** @brief The hydrology's rain rate of the last step [kg/m^2/s], in component 0 (nullptr without seb_precipitation_source) and running totals [kg/m^2] (nullptr without the hydrology). Read-only: for output. */
326  [[nodiscard]] const amrex::MultiFab* hydrology_rain_rate (int lev) const {
327  return m_precip.rate(lev);
328  }
329  [[nodiscard]] const amrex::MultiFab* hydrology_totals (int lev) {
330  return m_hydro.totals(lev);
331  }
332 
333  /** @brief The snow water equivalent [kg/m^2] and the snow layer's running totals (ForceRestoreSnow::Total components) [kg/m^2]; nullptr without erf.radiation.seb_snow_enable. Read-only: for output. */
334  [[nodiscard]] const amrex::MultiFab* snow_swe (int lev) { return m_snow.swe(lev); }
335  [[nodiscard]] const amrex::MultiFab* snow_totals (int lev) { return m_snow.totals(lev); }
336 
337  /** @brief True when the force-restore state is being evolved and so needs transferring. */
338  [[nodiscard]] bool seb_prognostic_active () const {
340  }
341 
342  /** @brief True when define_level allocated the land-model forcing fields on @p lev. */
343  [[nodiscard]] bool supplies_land_forcing (int lev) const noexcept {
344  return lev >= 0 && lev < static_cast<int>(m_sw_dn_sfc.size()) && m_sw_dn_sfc[lev] != nullptr;
345  }
346 
347  /**
348  * @brief The surface forcing of the last sweep on @p lev (2D: i,j), or nullptr when
349  * the level does not supply it: total downwelling shortwave [W/m^2], downwelling
350  * longwave [W/m^2] and the cosine of the solar zenith angle floored at zero [1].
351  * lsm_undefined until a sweep has run on the level, so a copy made before one is
352  * caught by the land model's missing-input check instead of reading as zero.
353  */
354  [[nodiscard]] const amrex::MultiFab* land_forcing_sw_dn (int lev) const noexcept {
355  return supplies_land_forcing(lev) ? m_sw_dn_sfc[lev].get() : nullptr;
356  }
357  [[nodiscard]] const amrex::MultiFab* land_forcing_lw_dn (int lev) const noexcept {
358  return supplies_land_forcing(lev) ? m_lw_dn_sfc[lev].get() : nullptr;
359  }
360  [[nodiscard]] const amrex::MultiFab* land_forcing_cos_zenith (int lev) const noexcept {
361  return supplies_land_forcing(lev) ? m_cos_zenith[lev].get() : nullptr;
362  }
363 
364  /**
365  * @brief Copy the surface forcing of the last sweep on @p lev into a land-surface
366  * model's radiation inputs (SurfaceModel's "sw_flux_dn", "lw_flux_dn" and
367  * "cos_zenith_angle" outputs). A null destination is skipped. Each destination
368  * must lie on this level's horizontal grids; see copy_surface_plane. Before the
369  * level's first sweep this copies the lsm_undefined sentinel, not zero.
370  */
371  void write_land_forcing (int lev,
372  amrex::MultiFab* sw_flux_dn,
373  amrex::MultiFab* lw_flux_dn,
374  amrex::MultiFab* cos_zenith_angle) const;
375 
376  /**
377  * @brief Have every later sweep on @p lev write what the building faces need
378  * besides the interface fluxes (erf.ibseb.radiation = two_stream;
379  * ERF_TwoStreamCanopyForcing.H): the direct beam on a horizontal surface at the
380  * interfaces 0 .. @p m_top of each column, counted from the surface, and the
381  * cosine of the zenith. Allocates one field on the level's horizontal grids given
382  * those interfaces in z and one 2D field. Call after define_level(); a later
383  * define_level() of the level (a regrid) drops the request.
384  *
385  * @param lev level, which must have been defined; its sweep asserts that the
386  * columns reach @p m_top
387  * @param m_top highest interface the faces read (IBFaceSet::top_sample_interface()),
388  * in [0, number of cells in z]
389  * @param ground_albedo also keep the direct-beam albedo the sweep gives each column's
390  * ground (one more 2D field, TwoStreamCanopyView::ground_albedo_dir), for
391  * the faces of erf.ibseb.ground_view_shadow; without it that pointer is null
392  */
393  void supply_canopy_forcing (int lev, int m_top, bool ground_albedo = false);
394 
395  /** @brief True when supply_canopy_forcing() was called for @p lev since its last define_level(). */
396  [[nodiscard]] bool supplies_canopy_forcing (int lev) const noexcept {
397  return lev >= 0 && lev < static_cast<int>(m_canopy.size()) && m_canopy[lev] != nullptr;
398  }
399 
400  /**
401  * @brief The beam and the cosine of the zenith of @p lev as the sweep of step
402  * @p nstep wrote them (the view's fluxes are left for the caller, who owns
403  * rad_fluxes), or an empty view when the level does not supply them or has not
404  * swept at that step: the faces must not take a previous step's radiation, nor
405  * the zeros of a level whose radiation came from its parent.
406  */
407  [[nodiscard]] TwoStreamCanopyView canopy_forcing (int lev, int nstep) const noexcept {
409  if (supplies_canopy_forcing(lev) && m_canopy_step[lev] == nstep) {
410  v.beam = m_canopy[lev].get();
411  v.cos_zenith = m_canopy_cosz[lev].get();
412  v.ground_albedo_dir = m_canopy_alb[lev].get();
413  }
414  return v;
415  }
416 
417  /**
418  * @brief Have the columns of @p lev see the buildings of the immersed-boundary
419  * balance (erf.ibseb.two_stream_buildings). From now on, on this level:
420  * - the sweep writes no heating rate in a solid cell (blanking at or above 0.5):
421  * the light a building's cells would absorb is the roof's and the walls',
422  * which the balance takes at their own heights;
423  * - the ground balance (seb_enable) leaves a column whose bottom cell is solid,
424  * a building's footprint, alone: its state is held, it absorbs no shortwave and
425  * it is left out of the balance's means;
426  * - with the shortwave from the sweep (seb_use_radiation_fluxes, shortwave on) on a
427  * level that sweeps its own columns, the open ground loses the direct beam where
428  * the field of ground_shadow_for_step() says a building shades it, at the update
429  * after the dycore.
430  * Copies what it needs from @p blanking (the solid cells up to the tallest building,
431  * 4 bytes a cell, and the footprints), so the field may change or go afterwards.
432  * Call after define_level(); a later define_level() of the level drops it.
433  *
434  * @param lev level, which must have been defined
435  * @param blanking the level's cell-centered blanking (ERF::terrain_blanking), on the
436  * state's grids: 0 in the air, 1 inside a building
437  * @param domain the level's domain Box; its bottom cell is the ground's
438  * @param take_ground_walls also take, at the update after the dycore, what the walls
439  * send to the open ground (erf.ibseb.ground_sky_view, the field of
440  * ground_walls_for_step()): only where the ground takes the shadow
441  * and the longwave is on (takes_ground_walls())
442  */
443  void set_building_cover (int lev, const amrex::MultiFab& blanking, const amrex::Box& domain,
444  bool take_ground_walls = false, bool start_on_roofs = false);
445 
446  /// Components of the field of roofs_for_step().
447  enum Roof : int { ROOF_SET = 0, ROOF_ALBEDO = 1, ROOF_EMISSIVITY = 2, ROOF_TEMPERATURE = 3, ROOF_LIT = 4, ROOF_NCOMP = 5 };
448 
449  /**
450  * @brief True when the columns of @p lev under a building start on its roof
451  * (erf.ibseb.two_stream_roofs; set_building_cover() with start_on_roofs, on a level
452  * that sweeps its own columns): the one condition for the fields and for the sweep.
453  */
454  [[nodiscard]] bool starts_on_roofs (int lev) const noexcept {
455  return lev >= 0 && lev < static_cast<int>(m_roof.size()) && m_roof[lev] != nullptr;
456  }
457 
458  /**
459  * @brief For each column of @p lev, the first cell above the building that stands on
460  * its ground (the cell on the roof), or the bottom cell on open ground (2D: i,j);
461  * nullptr unless starts_on_roofs(). A cell above the level's top means the building
462  * fills the column. Solid cells above an air gap (an overhang) are not a roof here:
463  * under an overhang above open ground the cell is the bottom cell, and under an
464  * overhang above a lower roof it is the cell on that lower roof.
465  */
466  [[nodiscard]] const amrex::iMultiFab* roof_cell (int lev) const noexcept {
467  return starts_on_roofs(lev) ? m_roof_k[lev].get() : nullptr;
468  }
469 
470  /**
471  * @brief The field the immersed-boundary balance fills, before the sweep of step
472  * @p nstep, with the roof face of each column under a building (2D: i,j; ROOF_SET 1
473  * where a roof face stands on roof_cell(), then its albedo, emissivity, skin
474  * temperature and the share of the beam that reaches it), or nullptr unless
475  * starts_on_roofs(). Marks the field as that step's:
476  * the sweep stops unless the roofs are of its own step. Where ROOF_SET is 0 the
477  * column keeps the ground as its lower boundary.
478  */
479  [[nodiscard]] amrex::MultiFab* roofs_for_step (int lev, int nstep);
480 
481  /** @brief True once roofs_for_step() has been called for @p lev since its building cover was set. */
482  [[nodiscard]] bool roofs_given (int lev) const noexcept {
483  return starts_on_roofs(lev) && m_roof_step[lev] >= 0;
484  }
485 
486  /** @brief True when the ground balance of @p lev takes what the walls send it (see set_building_cover()): the one condition for the field, what the sweep keeps for it, and the shortwave and longwave terms. */
487  [[nodiscard]] bool takes_ground_walls (int lev) const noexcept {
488  return lev >= 0 && lev < static_cast<int>(m_ground_walls.size()) && m_ground_walls[lev] != nullptr;
489  }
490 
491  /** @brief True when set_building_cover() was called for @p lev since its last define_level(). */
492  [[nodiscard]] bool has_building_cover (int lev) const noexcept {
493  return lev >= 0 && lev < static_cast<int>(m_has_cover.size()) && m_has_cover[lev] != 0;
494  }
495 
496  /**
497  * @brief The field the immersed-boundary balance fills with the buildings' shadow
498  * on the ground of @p lev for step @p nstep (1 where the ray from the ground toward
499  * the sun meets a building, 0 where the sun reaches it; 2D: i,j), or nullptr when the
500  * level's ground balance takes no shadow (no building cover; no balance on the sweep's
501  * shortwave, or the shortwave off; or a level whose rates come from its parent). Marks
502  * the field as that step's: the update after the dycore stops unless the shadow is of
503  * the step its sweep ran in.
504  */
505  [[nodiscard]] amrex::MultiFab* ground_shadow_for_step (int lev, int nstep);
506 
507  /**
508  * @brief The field the immersed-boundary balance fills with what the walls send to
509  * the ground of @p lev for step @p nstep (IBFaceSet::compute_ground_walls(): the
510  * walls' share of the ground's view, their reflected shortwave and their longwave
511  * arriving on the ground, W/m^2), or nullptr when the level's ground balance takes
512  * none (takes_ground_walls()). Marks the
513  * field as that step's. At the update after the dycore the open ground then keeps
514  * its absorbed diffuse shortwave and the sky's longwave through the part of its
515  * view the walls leave open, and takes the walls' through the rest:
516  * SW += (1 - alb_dif) SW_walls - v (SW - SW_beam), LW += emis (LW_walls - v LW_down),
517  * with v the walls' share (two_stream_ground_wall_terms()).
518  */
519  [[nodiscard]] amrex::MultiFab* ground_walls_for_step (int lev, int nstep);
520 
521  /** @brief What the walls sent to the ground of @p lev last (see ground_walls_for_step()), or nullptr before any or when the level takes none. Read-only: for output. */
522  [[nodiscard]] const amrex::MultiFab* ground_walls (int lev) const noexcept {
523  return (lev >= 0 && lev < static_cast<int>(m_ground_walls.size()) && m_walls_step[lev] >= 0)
524  ? m_ground_walls[lev].get() : nullptr;
525  }
526 
527  /**
528  * @brief The net longwave [W/m^2] the ground balance of @p lev used at its last update
529  * after the dycore (with the walls' longwave of erf.ibseb.ground_sky_view); nullptr as
530  * for seb_sw_net(). Read-only: for output.
531  */
532  [[nodiscard]] const amrex::MultiFab* seb_lw_net (int lev) const {
533  return (active() && m_rad->seb_enable && lev < static_cast<int>(m_lw_flux_sfc.size()) && m_seb_updated[lev] != 0)
534  ? m_lw_flux_sfc[lev].get() : nullptr;
535  }
536 
537  /** @brief The ground's shadow last given for @p lev (see ground_shadow_for_step()), or nullptr before one is given or when the level takes none. Read-only: for output. */
538  [[nodiscard]] const amrex::MultiFab* ground_shadow (int lev) const noexcept {
539  return (lev >= 0 && lev < static_cast<int>(m_ground_shadow.size()) && m_shadow_step[lev] >= 0)
540  ? m_ground_shadow[lev].get() : nullptr;
541  }
542 
543  /**
544  * @brief Set the heating rates of @p lev to zero in the solid cells of its building
545  * cover (a no-op without one): for a level whose rates come from its parent by
546  * interpolation, where no sweep of its own masks them.
547  */
548  void mask_building_heating (int lev, amrex::MultiFab& qheating) const;
549 
550  /**
551  * @brief The net shortwave [W/m^2] the ground balance of @p lev used at its last update
552  * after the dycore, with the building cover's footprints and shadow applied; nullptr
553  * when the SEB is off, before the level's first such update after a sweep (the initial
554  * plotfile, the one a restart writes), or on a level that does not sweep. Read-only: for output.
555  */
556  [[nodiscard]] const amrex::MultiFab* seb_sw_net (int lev) const {
557  return (active() && m_rad->seb_enable && lev < static_cast<int>(m_sw_flux_sfc.size()) && m_seb_updated[lev] != 0)
558  ? m_sw_flux_sfc[lev].get() : nullptr;
559  }
560 
561  /** @brief Write the prognostic surface state of one level (SEB on). */
562  void write_checkpoint (int lev, const std::string& checkpointname) const;
563 
564  /** @brief Read it back when the checkpoint carries it; else keep defaults. */
565  void read_checkpoint (int lev, const std::string& restart_chkfile,
566  const amrex::Periodicity& period);
567 
568  // Orbital elements of the current year (Berger 1978, or the erf.rad_orbital_*
569  // overrides), computed once per year rather than every step, and the
570  // one-time note about an unscaled irradiance. Public so the file-local
571  // solar-state helper and two_stream_sun_date() can fill it.
572  struct OrbitalCache {
573  int year = -9999;
574  double eccen = 0.0;
575  double obliqr = 0.0;
576  double lambm0 = 0.0;
577  double mvelpp = 0.0;
578  bool noted_unscaled = false;
579  };
580 
581 private:
582  // Domain-mean flux diagnostics of the last column sweep, per level, so the
583  // post-dycore call can report them without sweeping again.
584  struct FluxDiag {
585  // False until a column sweep has filled this level's entry. The post-dycore call
586  // reports the cached values rather than sweeping again, and a level whose
587  // pre-dycore sweep was skipped -- the interp-from-coarse-pending path, which
588  // returns before the sweep -- would otherwise report the zero-initialized struct
589  // as though the fluxes really were zero.
590  bool valid = false;
591  amrex::Real SW_surface = 0.0;
592  amrex::Real SW_TOA = 0.0; // domain-mean incident SW at the top
593  amrex::Real SW_up_TOA = 0.0;
594  amrex::Real LW_net_surface = 0.0;
595  amrex::Real LW_up_TOA = 0.0;
596  amrex::Real heating_rate_max = 0.0;
597  };
598 
599  const RadChoice* m_rad = nullptr;
600  amrex::Real m_rdOcp = RdoCp;
602 
603  // CSV / console diagnostics writer, one per level, created on that level's
604  // first advance() so its header and duplicate-row state persist across
605  // calls. Per level because every level of a hierarchy reports the same
606  // step, call_site and time, and a shared duplicate guard would suppress
607  // all but the first to report.
608  amrex::Vector<std::unique_ptr<RadiationDiagnostics>> m_diag;
609 
610  // Fallback surface properties when no LSM supplies them (2D: i,j).
611  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_alb_sw;
612  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_emiss_lw;
613  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_t_sfc; // prognostic when the SEB evolves it
614 
615  // Surface-energy-balance fields (2D: i,j), allocated when seb_enable.
616  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_sw_flux_sfc; // net absorbed shortwave [W/m^2]
617  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_lw_flux_sfc; // net absorbed longwave [W/m^2]
618  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_hfx_sfc; // sensible heat flux [W/m^2]
619  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_lh_sfc; // latent heat flux [W/m^2]
620  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_grdflx_sfc; // ground heat flux [W/m^2]
621  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_q_sfc; // surface moisture, prognostic (see RadChoice::seb_q_sfc_default)
622  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_t_deep; // deep-soil temperature [K]
623  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_q_deep; // deep-soil moisture q_s restores to
624  // (both constant at their defaults unless erf.radiation.seb_deep_prognostic_enable; the
625  // deep temperature is also kept per column with erf.radiation.seb_init_t_deep_from_file)
626  ForceRestorePrecipRate m_precip; // rain and snowfall of the step (ERF_ForceRestorePrecipRate.H)
627  ForceRestoreHydrology m_hydro; // rain, runoff, drainage (ERF_ForceRestoreHydrologyState.H)
628  ForceRestoreSnow m_snow; // snow water equivalent (ERF_ForceRestoreSnowState.H)
629  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_moisture; // seb_surface_moisture (seb_surface_layer_uses_moisture)
630 
631  // What the sweep hands to a land-surface model (2D: i,j), allocated when
632  // define_level is asked to supply it. These are the DOWNWELLING fluxes, as opposed to
633  // the net fluxes above that the SEB consumes: a land model applies its own albedo
634  // and emissivity, so they cannot be recovered from the net fields.
635  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_sw_dn_sfc; // downwelling shortwave at the surface [W/m^2]
636  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_lw_dn_sfc; // downwelling longwave at the surface [W/m^2]
637  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_cos_zenith; // cosine of the solar zenith angle, >= 0 [1]
638 
639  // The canopy forcing of the building faces (see supply_canopy_forcing), its top
640  // interface counted from the surface, and the step of the sweep that last wrote it
641  // (-1 before any).
642  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_canopy; // the beam, interfaces 0 .. m_top
643  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_canopy_cosz; // cos z, floored at zero (2D)
644  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_canopy_alb; // the ground's direct-beam albedo of the sweep (2D)
645  amrex::Vector<int> m_canopy_m;
646  amrex::Vector<int> m_canopy_step;
647 
648  // The buildings as the columns see them (see set_building_cover): whether the level
649  // has them, the solid cells (the state's boxes cut at the tallest building, no ghost
650  // cells), the footprints (2D: 1 where the bottom cell is solid), the shadow on the
651  // ground the balance gave for step
652  // m_shadow_step, and the absorbed direct beam at the ground of the sweep of step
653  // m_sweep_step (2D, written only with a ground balance taking the sweep's
654  // shortwave). m_shaded_step is the sweep whose beam the update after the dycore
655  // has already taken off the shaded ground, so a second call cannot take it twice.
656  amrex::Vector<std::unique_ptr<amrex::iMultiFab>> m_solid;
657  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_footprint;
658  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_ground_shadow;
659  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_sw_beam_sfc;
660  // erf.ibseb.ground_sky_view: what the walls send to the ground (ground_walls_for_step(),
661  // three components) of step m_walls_step, and what the sweep keeps for it per column
662  // (2D): the longwave down at the ground, the ground's diffuse absorptance 1 - alb_dif,
663  // and its longwave emissivity.
664  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_ground_walls;
665  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_ground_keep;
666  amrex::Vector<int> m_walls_step;
667  // erf.ibseb.two_stream_roofs: the cell on the roof of each column (roof_cell()) and the
668  // roof faces the balance gave for step m_roof_step (roofs_for_step()).
669  amrex::Vector<std::unique_ptr<amrex::iMultiFab>> m_roof_k;
670  amrex::Vector<std::unique_ptr<amrex::MultiFab>> m_roof;
671  amrex::Vector<int> m_roof_step;
672  amrex::Vector<int> m_shadow_step;
673  amrex::Vector<int> m_sweep_step;
674  amrex::Vector<int> m_shaded_step;
675  amrex::Vector<int> m_has_cover;
676  // Whether the ground balance of the level has updated after a sweep (seb_sw_net()).
677  amrex::Vector<int> m_seb_updated;
678  // Whether advance() has looked at the level's land mask for its one message about
679  // water columns: 1 water was found and reported, 0 none was found, -1 not looked at
680  // yet (set by define_level(): the level may have new grids). A message only: every
681  // decision reads the mask itself (ERF_SEBLandMask.H).
682  amrex::Vector<int> m_water_message;
683 
684  amrex::Vector<FluxDiag> m_flux_diag;
685 };
686 
687 /**
688  * @brief Copy a 2D field (k = 0 only) into the k = 0 plane of a surface-model field.
689  *
690  * Surface-model fields keep their surface values in the k = 0 plane, which may lie in
691  * the field's z ghost region (SLM stores soil layers at k < 0), and carry x/y ghost cells
692  * the source need not have. Only the i,j extent of each destination VALID box is
693  * written, so ghost columns and every other k are left alone. The two fields must share
694  * a horizontal layout: the destination's boxes flattened to k = 0 equal the source's,
695  * on the same DistributionMapping -- which holds for ERF's ba2d and a land model's
696  * data built from the same level grids, and is asserted rather than assumed.
697  */
698 void copy_surface_plane (const amrex::MultiFab& src2d, amrex::MultiFab& dst);
699 
700 /** @brief RRTMGP's reference total solar irradiance [W/m^2], scaled by the date's Earth-Sun distance factor. */
701 inline constexpr amrex::Real two_stream_tsi_reference = 1360.9;
702 
703 /** @brief The calendar sun of the two-stream model at one time (see two_stream_sun_date()). */
705  double calday = 1.0; ///< Day of the year (1 = 1 January), UTC time of day as the fraction
706  double declin = 0.0; ///< Solar declination [rad]
707  double eccf = 1.0; ///< Earth-Sun distance factor (d0/d)^2
708 };
709 
710 /**
711  * @brief The calendar sun of the two-stream model at a UTC epoch time (start_time + t).
712  *
713  * The date as the RRTMGP interface forms it, the orbit of the year (or the
714  * erf.rad_orbital_* overrides) cached in @p orbit, and the declination and distance
715  * factor of ERF_OrbCosZenith.H. The two-stream sweep places its sun from this, with the
716  * column's position, and so does the immersed-boundary balance with
717  * erf.ibseb.sun_mode = two_stream.
718  */
720  double epoch_time);
721 
722 #endif // ERF_TWO_STREAM_RADIATION_H_
GpuArray< Real, AMREX_SPACEDIM > period
Definition: ERF_ActuatorSpreading.cpp:131
constexpr amrex::Real RdoCp
Definition: ERF_Constants.H:57
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:128
const int klo
Definition: ERF_InitCustomPert_KE.H:9
Radiation model type and control parameters.
Radiation module diagnostic output and CSV logging.
What the two-stream sweep hands the building faces of the immersed-boundary surface energy balance (e...
constexpr amrex::Real two_stream_tsi_reference
RRTMGP's reference total solar irradiance [W/m^2], scaled by the date's Earth-Sun distance factor.
Definition: ERF_TwoStreamRadiation.H:701
TwoStreamSunDate two_stream_sun_date(const RadChoice &rc, TwoStreamRadiation::OrbitalCache &orbit, double epoch_time)
The calendar sun of the two-stream model at a UTC epoch time (start_time + t).
Definition: ERF_TwoStreamRadiation.cpp:103
void copy_surface_plane(const amrex::MultiFab &src2d, amrex::MultiFab &dst)
Copy a 2D field (k = 0 only) into the k = 0 plane of a surface-model field.
The per-level state of the force-restore hydrology (ERF_ForceRestoreHydrology.H): the running totals ...
Definition: ERF_ForceRestoreHydrologyState.H:48
amrex::MultiFab * totals(int lev) noexcept
The running totals (Total components) [kg/m^2], or nullptr.
Definition: ERF_ForceRestoreHydrologyState.H:109
The surface precipitation rate of each level's step, for the force-restore hydrology (ERF_ForceRestor...
Definition: ERF_ForceRestorePrecipRate.H:50
const amrex::MultiFab * rate(int lev) const noexcept
The rate of the last end_step [kg/m^2/s] (Comp components), or nullptr. For output.
Definition: ERF_ForceRestorePrecipRate.H:100
The per-level state of the force-restore snow layer (ERF_ForceRestoreSnow.H, erf.radiation....
Definition: ERF_ForceRestoreSnowState.H:33
amrex::MultiFab * totals(int lev) noexcept
The running totals (Total components) [kg/m^2], or nullptr.
Definition: ERF_ForceRestoreSnowState.H:106
amrex::MultiFab * swe(int lev) noexcept
The snow water equivalent [kg/m^2], or nullptr.
Definition: ERF_ForceRestoreSnowState.H:101
Wrapper class for managing land surface models across AMR levels.
Definition: ERF_LandSurface.H:19
The two-stream radiation model (erf.radiation_model = TwoStream).
Definition: ERF_TwoStreamRadiation.H:60
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_footprint
Definition: ERF_TwoStreamRadiation.H:657
const amrex::iMultiFab * roof_cell(int lev) const noexcept
For each column of lev, the first cell above the building that stands on its ground (the cell on the ...
Definition: ERF_TwoStreamRadiation.H:466
void write_land_forcing(int lev, amrex::MultiFab *sw_flux_dn, amrex::MultiFab *lw_flux_dn, amrex::MultiFab *cos_zenith_angle) const
Copy the surface forcing of the last sweep on lev into a land-surface model's radiation inputs (Surfa...
Definition: ERF_TwoStreamRadiation.cpp:683
bool supplies_canopy_forcing(int lev) const noexcept
True when supply_canopy_forcing() was called for lev since its last define_level().
Definition: ERF_TwoStreamRadiation.H:396
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_canopy_cosz
Definition: ERF_TwoStreamRadiation.H:643
bool supplies_land_forcing(int lev) const noexcept
True when define_level allocated the land-model forcing fields on lev.
Definition: ERF_TwoStreamRadiation.H:343
void hydrology_end_step(int lev, const SurfacePrecipAccumulationSources &sources, int klo, amrex::Real dt)
The rain rate of the step of lev just taken, from the accumulation now and the one hydrology_begin_st...
Definition: ERF_TwoStreamRadiation.cpp:861
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_q_sfc
Definition: ERF_TwoStreamRadiation.H:621
const amrex::MultiFab * seb_hfx(int lev) const
The sensible and latent heat fluxes [W/m^2] the surface energy balance of one level last used,...
Definition: ERF_TwoStreamRadiation.H:205
void supply_canopy_forcing(int lev, int m_top, bool ground_albedo=false)
Have every later sweep on lev write what the building faces need besides the interface fluxes (erf....
Definition: ERF_TwoStreamRadiation.cpp:397
amrex::MultiFab * seb_q_sfc(int lev)
Definition: ERF_TwoStreamRadiation.H:196
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_canopy_alb
Definition: ERF_TwoStreamRadiation.H:644
void mask_building_heating(int lev, amrex::MultiFab &qheating) const
Set the heating rates of lev to zero in the solid cells of its building cover (a no-op without one): ...
Definition: ERF_TwoStreamRadiation.cpp:569
const amrex::MultiFab * hydrology_totals(int lev)
Definition: ERF_TwoStreamRadiation.H:329
bool takes_ground_walls(int lev) const noexcept
True when the ground balance of lev takes what the walls send it (see set_building_cover()): the one ...
Definition: ERF_TwoStreamRadiation.H:487
TwoStreamRadiation()=default
const amrex::MultiFab * seb_q_deep(int lev) const
Definition: ERF_TwoStreamRadiation.H:321
void define_level(int lev, const RadChoice &rad_choice, amrex::Real rdOcp, const amrex::BoxArray &ba2d, const amrex::DistributionMapping &dm, const amrex::BoxArray &ba, const amrex::Box &domain, bool supply_land_forcing=false)
Allocate the 2D surface fields of one level on the given horizontal BoxArray and fill them with the s...
Definition: ERF_TwoStreamRadiation.cpp:281
ForceRestorePrecipRate m_precip
Definition: ERF_TwoStreamRadiation.H:626
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_roof
Definition: ERF_TwoStreamRadiation.H:670
bool has_building_cover(int lev) const noexcept
True when set_building_cover() was called for lev since its last define_level().
Definition: ERF_TwoStreamRadiation.H:492
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > m_roof_k
Definition: ERF_TwoStreamRadiation.H:669
amrex::Vector< int > m_has_cover
Definition: ERF_TwoStreamRadiation.H:675
const amrex::MultiFab * ground_walls(int lev) const noexcept
What the walls sent to the ground of lev last (see ground_walls_for_step()), or nullptr before any or...
Definition: ERF_TwoStreamRadiation.H:522
amrex::Vector< int > m_roof_step
Definition: ERF_TwoStreamRadiation.H:671
amrex::MultiFab * roofs_for_step(int lev, int nstep)
The field the immersed-boundary balance fills, before the sweep of step nstep, with the roof face of ...
Definition: ERF_TwoStreamRadiation.cpp:545
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_canopy
Definition: ERF_TwoStreamRadiation.H:642
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_grdflx_sfc
Definition: ERF_TwoStreamRadiation.H:620
void write_checkpoint(int lev, const std::string &checkpointname) const
Write the prognostic surface state of one level (SEB on).
Definition: ERF_TwoStreamRadiation.cpp:697
void advance(int lev, int nstep, amrex::Real time, amrex::Real dt_step, const std::string &call_site, const amrex::MultiFab &cons_old, const amrex::MultiFab *z_phys_nd, const amrex::Geometry &geom, LandSurface &lsm, const amrex::Vector< const amrex::MultiFab * > &radiation_inputs, bool noahmp_active, amrex::MultiFab *qheating, amrex::MultiFab *rad_fluxes, const amrex::MultiFab *t_surf, const amrex::MultiFab *sfc_sens_flux, const amrex::MultiFab *sfc_laten_flux, const amrex::MultiFab *lat_m, const amrex::MultiFab *lon_m, double epoch_time, bool have_datetime, const amrex::iMultiFab *land_mask=nullptr)
One radiation call at one level.
Definition: ERF_TwoStreamRadiation.cpp:892
const amrex::MultiFab * ground_shadow(int lev) const noexcept
The ground's shadow last given for lev (see ground_shadow_for_step()), or nullptr before one is given...
Definition: ERF_TwoStreamRadiation.H:538
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_ground_walls
Definition: ERF_TwoStreamRadiation.H:664
const amrex::MultiFab * seb_sw_net(int lev) const
The net shortwave [W/m^2] the ground balance of lev used at its last update after the dycore,...
Definition: ERF_TwoStreamRadiation.H:556
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_lw_flux_sfc
Definition: ERF_TwoStreamRadiation.H:617
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_moisture
Definition: ERF_TwoStreamRadiation.H:629
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_q_deep
Definition: ERF_TwoStreamRadiation.H:623
const amrex::MultiFab * seb_surface_moisture(int lev)
What level lev's surface hands the surface layer for its surface mixing ratio (erf....
Definition: ERF_TwoStreamRadiation.cpp:606
amrex::MultiFab * seb_t_sfc(int lev)
The prognostic surface state of one level, or nullptr when the SEB is off or the level has not been b...
Definition: ERF_TwoStreamRadiation.H:193
bool seb_q_deep_is_state() const
True when the deep water content is part of the state: it evolves (erf.radiation.seb_deep_prognostic_...
Definition: ERF_TwoStreamRadiation.H:291
amrex::Real m_rdOcp
Definition: ERF_TwoStreamRadiation.H:600
amrex::Vector< FluxDiag > m_flux_diag
Definition: ERF_TwoStreamRadiation.H:684
const amrex::MultiFab * snow_swe(int lev)
The snow water equivalent [kg/m^2] and the snow layer's running totals (ForceRestoreSnow::Total compo...
Definition: ERF_TwoStreamRadiation.H:334
amrex::MultiFab * ground_walls_for_step(int lev, int nstep)
The field the immersed-boundary balance fills with what the walls send to the ground of lev for step ...
Definition: ERF_TwoStreamRadiation.cpp:553
bool active() const
True once a level has been defined with the model selected.
Definition: ERF_TwoStreamRadiation.H:68
bool seb_t_deep_is_state() const
True when the deep temperature is part of the state: it evolves (erf.radiation.seb_deep_prognostic_en...
Definition: ERF_TwoStreamRadiation.H:268
const amrex::MultiFab * seb_lh(int lev) const
Definition: ERF_TwoStreamRadiation.H:208
const amrex::MultiFab * land_forcing_lw_dn(int lev) const noexcept
Definition: ERF_TwoStreamRadiation.H:357
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_ground_keep
Definition: ERF_TwoStreamRadiation.H:665
ForceRestoreHydrology m_hydro
Definition: ERF_TwoStreamRadiation.H:627
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_emiss_lw
Definition: ERF_TwoStreamRadiation.H:612
amrex::Vector< int > m_walls_step
Definition: ERF_TwoStreamRadiation.H:666
void hydrology_begin_step(int lev, const SurfacePrecipAccumulationSources &sources, int klo)
Store the surface precipitation accumulation of lev at the start of its step (ERF::Advance,...
Definition: ERF_TwoStreamRadiation.cpp:853
amrex::MultiFab * seb_t_deep_state(int lev)
The deep temperature [K] of lev for ERF::init_seb_t_deep_from_file to write, or nullptr when it is no...
Definition: ERF_TwoStreamRadiation.H:279
void resize(int nlevs_max)
Size the per-level containers; no allocation happens here.
Definition: ERF_TwoStreamRadiation.cpp:235
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_t_sfc
Definition: ERF_TwoStreamRadiation.H:613
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_lw_dn_sfc
Definition: ERF_TwoStreamRadiation.H:636
const amrex::MultiFab * hydrology_rain_rate(int lev) const
The hydrology's rain rate of the last step [kg/m^2/s], in component 0 (nullptr without seb_precipitat...
Definition: ERF_TwoStreamRadiation.H:326
const amrex::MultiFab * land_forcing_sw_dn(int lev) const noexcept
The surface forcing of the last sweep on lev (2D: i,j), or nullptr when the level does not supply it:...
Definition: ERF_TwoStreamRadiation.H:354
amrex::MultiFab * seb_q_deep_state(int lev)
The deep water content [m^3/m^3] of lev for ERF::init_seb_soil_moisture_from_file to write,...
Definition: ERF_TwoStreamRadiation.H:312
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_lh_sfc
Definition: ERF_TwoStreamRadiation.H:619
TwoStreamCanopyView canopy_forcing(int lev, int nstep) const noexcept
The beam and the cosine of the zenith of lev as the sweep of step nstep wrote them (the view's fluxes...
Definition: ERF_TwoStreamRadiation.H:407
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_alb_sw
Definition: ERF_TwoStreamRadiation.H:611
bool starts_on_roofs(int lev) const noexcept
True when the columns of lev under a building start on its roof (erf.ibseb.two_stream_roofs; set_buil...
Definition: ERF_TwoStreamRadiation.H:454
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_sw_flux_sfc
Definition: ERF_TwoStreamRadiation.H:616
const amrex::MultiFab * prognostic_surface_temperature_state(int lev) const noexcept
Read-only view of the per-level prognostic surface-temperature state.
Definition: ERF_TwoStreamRadiation.H:73
ForceRestoreSnow m_snow
Definition: ERF_TwoStreamRadiation.H:628
amrex::MultiFab * ground_shadow_for_step(int lev, int nstep)
The field the immersed-boundary balance fills with the buildings' shadow on the ground of lev for ste...
Definition: ERF_TwoStreamRadiation.cpp:561
OrbitalCache m_orbit
Definition: ERF_TwoStreamRadiation.H:601
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_t_deep
Definition: ERF_TwoStreamRadiation.H:622
const amrex::MultiFab * seb_t_deep(int lev) const
The deep temperature [K] and column water content of lev, or nullptr. Read-only: for output.
Definition: ERF_TwoStreamRadiation.H:318
const amrex::MultiFab * snow_totals(int lev)
Definition: ERF_TwoStreamRadiation.H:335
ForceRestoreSoil force_restore_soil(int lev) const
The force-restore soil of lev, read-only (see ForceRestoreSoil), or an empty view (every pointer null...
Definition: ERF_TwoStreamRadiation.cpp:869
amrex::Vector< std::unique_ptr< RadiationDiagnostics > > m_diag
Definition: ERF_TwoStreamRadiation.H:608
const amrex::MultiFab * seb_lw_net(int lev) const
The net longwave [W/m^2] the ground balance of lev used at its last update after the dycore (with the...
Definition: ERF_TwoStreamRadiation.H:532
amrex::Vector< int > m_shadow_step
Definition: ERF_TwoStreamRadiation.H:672
bool seb_prognostic_active() const
True when the force-restore state is being evolved and so needs transferring.
Definition: ERF_TwoStreamRadiation.H:338
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_ground_shadow
Definition: ERF_TwoStreamRadiation.H:658
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_sw_dn_sfc
Definition: ERF_TwoStreamRadiation.H:635
amrex::Vector< int > m_seb_updated
Definition: ERF_TwoStreamRadiation.H:677
void read_checkpoint(int lev, const std::string &restart_chkfile, const amrex::Periodicity &period)
Read it back when the checkpoint carries it; else keep defaults.
Definition: ERF_TwoStreamRadiation.cpp:731
bool roofs_given(int lev) const noexcept
True once roofs_for_step() has been called for lev since its building cover was set.
Definition: ERF_TwoStreamRadiation.H:482
amrex::Vector< amrex::MultiFab * > seb_prognostic_fields(int lev)
Every field of the force-restore state of lev that evolves and so must survive a regrid,...
Definition: ERF_TwoStreamRadiation.cpp:834
amrex::Vector< int > m_sweep_step
Definition: ERF_TwoStreamRadiation.H:673
void set_building_cover(int lev, const amrex::MultiFab &blanking, const amrex::Box &domain, bool take_ground_walls=false, bool start_on_roofs=false)
Have the columns of lev see the buildings of the immersed-boundary balance (erf.ibseb....
Definition: ERF_TwoStreamRadiation.cpp:428
const amrex::MultiFab * land_forcing_cos_zenith(int lev) const noexcept
Definition: ERF_TwoStreamRadiation.H:360
amrex::Vector< int > m_shaded_step
Definition: ERF_TwoStreamRadiation.H:674
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > m_solid
Definition: ERF_TwoStreamRadiation.H:656
amrex::MultiFab * seb_q_sfc_state(int lev)
The surface water content q_s [m^3/m^3] of lev for ERF::init_seb_soil_moisture_from_file to write,...
Definition: ERF_TwoStreamRadiation.H:302
const RadChoice * m_rad
Definition: ERF_TwoStreamRadiation.H:599
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_sw_beam_sfc
Definition: ERF_TwoStreamRadiation.H:659
amrex::Vector< int > m_canopy_step
Definition: ERF_TwoStreamRadiation.H:646
amrex::Vector< int > m_water_message
Definition: ERF_TwoStreamRadiation.H:682
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_hfx_sfc
Definition: ERF_TwoStreamRadiation.H:618
amrex::Vector< int > m_canopy_m
Definition: ERF_TwoStreamRadiation.H:645
Roof
Components of the field of roofs_for_step().
Definition: ERF_TwoStreamRadiation.H:447
@ ROOF_SET
Definition: ERF_TwoStreamRadiation.H:447
@ ROOF_ALBEDO
Definition: ERF_TwoStreamRadiation.H:447
@ ROOF_TEMPERATURE
Definition: ERF_TwoStreamRadiation.H:447
@ ROOF_EMISSIVITY
Definition: ERF_TwoStreamRadiation.H:447
@ ROOF_LIT
Definition: ERF_TwoStreamRadiation.H:447
@ ROOF_NCOMP
Definition: ERF_TwoStreamRadiation.H:447
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_cos_zenith
Definition: ERF_TwoStreamRadiation.H:637
constexpr std::array< amrex::Real, num_veg_params > rc
Definition: ERF_SLM_DefaultParams.H:22
The force-restore soil of one level, read-only, for a model that reads the ground (the dust coupling'...
Definition: ERF_ForceRestoreHydrologyState.H:24
Container holding radiation-related choices and parameters.
Definition: ERF_RadStruct.H:142
bool seb_init_t_deep_from_file
At a fresh start, the deep (restoring) temperature T_deep of a land column is the deep soil temperatu...
Definition: ERF_RadStruct.H:494
bool seb_prognostic_enable
Enable prognostic SEB surface temperature and moisture evolution. When true, integrates SEB residual ...
Definition: ERF_RadStruct.H:649
bool seb_init_soil_moisture_from_file
At a fresh start, the soil water of a land column is the soil moisture profile of the wrfinput file (...
Definition: ERF_RadStruct.H:511
bool seb_deep_prognostic_enable
Make seb_q_deep and seb_t_deep prognostic (ERF_ForceRestoreHydrology.H): q_deep becomes the mean wate...
Definition: ERF_RadStruct.H:746
bool seb_enable
Master switch for simplified SEB infrastructure. When false (default), no SEB MultiFabs are allocated...
Definition: ERF_RadStruct.H:433
bool enabled
True when erf.radiation_model = TwoStream. Set by init_params from the model SolverChoice read; the e...
Definition: ERF_RadStruct.H:148
Definition: ERF_SurfacePrecipitation.H:40
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 * 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
const amrex::MultiFab * ground_albedo_dir
Definition: ERF_TwoStreamCanopyForcing.H:53
Definition: ERF_TwoStreamRadiation.H:584
amrex::Real LW_net_surface
Definition: ERF_TwoStreamRadiation.H:594
amrex::Real SW_TOA
Definition: ERF_TwoStreamRadiation.H:592
amrex::Real SW_surface
Definition: ERF_TwoStreamRadiation.H:591
amrex::Real heating_rate_max
Definition: ERF_TwoStreamRadiation.H:596
bool valid
Definition: ERF_TwoStreamRadiation.H:590
amrex::Real LW_up_TOA
Definition: ERF_TwoStreamRadiation.H:595
amrex::Real SW_up_TOA
Definition: ERF_TwoStreamRadiation.H:593
Definition: ERF_TwoStreamRadiation.H:572
bool noted_unscaled
Definition: ERF_TwoStreamRadiation.H:578
double obliqr
Definition: ERF_TwoStreamRadiation.H:575
int year
Definition: ERF_TwoStreamRadiation.H:573
double lambm0
Definition: ERF_TwoStreamRadiation.H:576
double mvelpp
Definition: ERF_TwoStreamRadiation.H:577
double eccen
Definition: ERF_TwoStreamRadiation.H:574
The calendar sun of the two-stream model at one time (see two_stream_sun_date()).
Definition: ERF_TwoStreamRadiation.H:704
double eccf
Earth-Sun distance factor (d0/d)^2.
Definition: ERF_TwoStreamRadiation.H:707
double declin
Solar declination [rad].
Definition: ERF_TwoStreamRadiation.H:706
double calday
Day of the year (1 = 1 January), UTC time of day as the fraction.
Definition: ERF_TwoStreamRadiation.H:705