ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_FirePrecip.H
Go to the documentation of this file.
1 #ifndef ERF_FIRE_PRECIP_H
2 #define ERF_FIRE_PRECIP_H
3 
4 #include <AMReX_GpuQualifiers.H>
5 #include <AMReX_MultiFab.H>
6 #include <AMReX_MFIter.H>
7 #include <AMReX_REAL.H>
9 
10 /**
11  * @file ERF_FirePrecip.H
12  * @brief Rain per column for the fuel moisture model from the microphysics
13  * surface precipitation accumulators, for an engine that reads the rain
14  * (FireEngine::wants_surface_precip).
15  *
16  * Every Eulerian microphysics scheme with precipitation keeps a cumulative
17  * surface accumulator per atmospheric column (Kessler's rain_accum, SAM's and
18  * Morrison's rain, snow and graupel accumulations, ...), exposed through
19  * Microphysics::Get_Surface_Precip_Accumulation_Ptrs() with a factor that
20  * turns the scheme's native unit into kg/m2 of liquid water. One kg/m2 of
21  * liquid water is one millimeter of depth, so the change of the accumulation
22  * over a step, divided by the step, is the rain rate in mm/hr that the
23  * time-lag and stick moisture updates take. The fire layer keeps the
24  * accumulation it saw at the end of its previous step (checkpointed) and
25  * forms that difference every step; a fresh start begins at zero, which is
26  * where every scheme starts its accumulators.
27  *
28  * Snow, graupel and hail count with their liquid-water equivalent: the fuel
29  * models have no frozen-precipitation branch. There is no canopy interception.
30  */
31 
32 /**
33  * @brief Rain rate [mm/hr] from the change of the surface accumulation over one step.
34  *
35  * @param[in] accum_now_kgm2 accumulation at the end of the step [kg/m2 == mm]
36  * @param[in] accum_prev_kgm2 accumulation at the end of the previous step [kg/m2]
37  * @param[in] dt_s the step [s]
38  * @return (now - prev) * 3600 / dt; zero for a non-positive step or a non-positive
39  * change (an accumulator that was reset, or round-off), and zero for NaN.
40  */
41 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
42 amrex::Real fire_precip_rate_mm_hr (amrex::Real accum_now_kgm2,
43  amrex::Real accum_prev_kgm2,
44  amrex::Real dt_s) noexcept
45 {
46  if (!(dt_s > amrex::Real(0.0))) { return amrex::Real(0.0); }
47  const amrex::Real d = accum_now_kgm2 - accum_prev_kgm2;
48  if (!(d > amrex::Real(0.0))) { return amrex::Real(0.0); }
49  return d * amrex::Real(3600.0) / dt_s;
50 }
51 
52 /**
53  * @brief Total liquid-water-equivalent surface precipitation accumulation [kg/m2]
54  * of every column: surface_precip_accum_k0 (ERF_SurfacePrecipitation.H).
55  */
56 inline void fire_surface_precip_accum_k0 (amrex::MultiFab& accum_2d,
57  const SurfacePrecipAccumulationSources& sources,
58  int klo)
59 {
60  surface_precip_accum_k0(accum_2d, sources, klo);
61 }
62 
63 /**
64  * @brief Rain rate [mm/hr] of every column over the step just taken, and roll
65  * the snapshot forward.
66  *
67  * rate_2d = fire_precip_rate_mm_hr(now, prev, dt) per column when prev_valid,
68  * zero otherwise (a restart from a checkpoint without the snapshot); then
69  * prev_2d = now_2d. All three MultiFabs share boxes and distribution.
70  */
71 inline void fire_precip_rate_from_accum (amrex::MultiFab& rate_2d,
72  amrex::MultiFab& prev_2d,
73  const amrex::MultiFab& now_2d,
74  amrex::Real dt_s,
75  bool prev_valid)
76 {
77  using namespace amrex;
78  for (MFIter mfi(rate_2d, false); mfi.isValid(); ++mfi) {
79  Array4<Real> r = rate_2d.array(mfi);
80  Array4<Real> p = prev_2d.array(mfi);
81  Array4<const Real> n = now_2d.const_array(mfi);
82  ParallelFor(mfi.tilebox(), [=] AMREX_GPU_DEVICE (const IntVect& iv) noexcept
83  {
84  const int i = iv[0], j = iv[1];
85  r(i, j, 0) = prev_valid ? fire_precip_rate_mm_hr(n(i, j, 0), p(i, j, 0), dt_s) : Real(0.0);
86  p(i, j, 0) = n(i, j, 0);
87  });
88  }
89 }
90 
91 #endif // ERF_FIRE_PRECIP_H
void fire_precip_rate_from_accum(amrex::MultiFab &rate_2d, amrex::MultiFab &prev_2d, const amrex::MultiFab &now_2d, amrex::Real dt_s, bool prev_valid)
Rain rate [mm/hr] of every column over the step just taken, and roll the snapshot forward.
Definition: ERF_FirePrecip.H:71
void fire_surface_precip_accum_k0(amrex::MultiFab &accum_2d, const SurfacePrecipAccumulationSources &sources, int klo)
Total liquid-water-equivalent surface precipitation accumulation [kg/m2] of every column: surface_pre...
Definition: ERF_FirePrecip.H:56
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real fire_precip_rate_mm_hr(amrex::Real accum_now_kgm2, amrex::Real accum_prev_kgm2, amrex::Real dt_s) noexcept
Rain rate [mm/hr] from the change of the surface accumulation over one step.
Definition: ERF_FirePrecip.H:42
const int klo
Definition: ERF_InitCustomPert_KE.H:9
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);})
void surface_precip_accum_k0(amrex::MultiFab &accum_2d, const SurfacePrecipAccumulationSources &sources, int klo, SurfacePrecipPhase phase=SurfacePrecipPhase::Total)
Total liquid-water-equivalent surface precipitation accumulation [kg/m2] of every column,...
Definition: ERF_SurfacePrecipitation.H:207
@ p
Definition: ERF_WSM6.H:303
Definition: ERF_ConsoleIO.cpp:17
Definition: ERF_SurfacePrecipitation.H:40