1 #ifndef ERF_KESSLER_UTILS_H_
2 #define ERF_KESSLER_UTILS_H_
8 #include <AMReX_GpuQualifiers.H>
9 #include <AMReX_REAL.H>
36 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
38 const int k_hi) noexcept
40 return (k == k_hi + 1) ? k - 1 : k;
43 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
53 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
58 return rho * terminal_velocity *
qp;
61 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
71 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
76 return precip_mass_per_area
81 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
85 return std::fabs(value) < 1e-14;
88 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
101 if ((
qv > qsat) && do_cond) {
102 source_terms.dq_vapor_to_cloud = std::min(
qv, (
qv - qsat) / (
amrex::Real(1) + fac));
107 source_terms.dq_cloud_to_vapor = std::min(
qc, (qsat -
qv) / (
amrex::Real(1) + fac));
113 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
129 face_state.rho = rho_km1;
130 face_state.qp = qp_km1;
132 face_state.rho = rho_k;
133 face_state.qp = qp_k;
135 face_state.rho =
amrex::Real(0.5) * (rho_km1 + rho_k);
136 face_state.qp = qp_k;
140 face_state.qp = std::max(
amrex::Real(0), face_state.qp);
144 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
155 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
190 && (qv_eff < qsat) && (remaining_capacity >
amrex::Real(0))) {
200 source_terms.dq_rain_to_vapor = amrex::min(
qp, amrex::min(raw_rain_to_vapor, remaining_capacity));
218 source_terms.dq_cloud_to_rain = dt * (accrr * qcc + auto_r * (qcc -
qcw0));
219 source_terms.dq_cloud_to_rain = amrex::min(source_terms.dq_cloud_to_rain, available_cloud);
static constexpr amrex::Real kessler_sedimentation_cfl_max
Definition: ERF_KesslerUtils.H:32
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE KesslerSaturationAdjustment kessler_saturation_adjustment(const amrex::Real qv, const amrex::Real qc, const amrex::Real qsat, const amrex::Real dtqsat, const bool do_cond, const amrex::Real latent_over_cp) noexcept
Definition: ERF_KesslerUtils.H:89
static constexpr amrex::Real kessler_water_depth_m_per_kg_m2
Definition: ERF_KesslerUtils.H:33
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int kessler_num_sedimentation_substeps(const amrex::Real current_reduced_value, const amrex::Real dt, const amrex::Real dzmin) noexcept
Definition: ERF_KesslerUtils.H:62
static constexpr amrex::Real kessler_millimeters_per_meter
Definition: ERF_KesslerUtils.H:34
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE KesslerFaceState kessler_face_state(const int k, const int k_hi, const amrex::Real rho_km1, const amrex::Real rho_k, const amrex::Real qp_km1, const amrex::Real qp_k) noexcept
Definition: ERF_KesslerUtils.H:114
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE KesslerSourceTerms kessler_warm_rain_sources(const amrex::Real qv, const amrex::Real qc, const amrex::Real qp, const amrex::Real rho, const amrex::Real pressure_current_units, const amrex::Real qsat, const amrex::Real dtqsat, const amrex::Real dt, const bool do_cond, const amrex::Real latent_over_cp) noexcept
Definition: ERF_KesslerUtils.H:156
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real kessler_sedimentation_tendency(const amrex::Real fz_hi, const amrex::Real fz_lo, const amrex::Real rho, const amrex::Real dJinv, const amrex::Real coef) noexcept
Definition: ERF_KesslerUtils.H:145
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real kessler_terminal_velocity(const amrex::Real rho, const amrex::Real qp) noexcept
Definition: ERF_KesslerUtils.H:44
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real kessler_rain_accumulation_increment(const amrex::Real precip_mass_per_area) noexcept
Definition: ERF_KesslerUtils.H:72
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real kessler_precip_flux(const amrex::Real rho, const amrex::Real terminal_velocity, const amrex::Real qp) noexcept
Definition: ERF_KesslerUtils.H:54
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool kessler_is_small_sedimentation_value(const amrex::Real value) noexcept
Definition: ERF_KesslerUtils.H:82
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int kessler_face_donor_k(const int k, const int k_hi) noexcept
Definition: ERF_KesslerUtils.H:37
Physical constants and tuning parameters used only by the moisture and cloud-physics code.
constexpr amrex::Real alphaelq
Definition: ERF_MicrophysicsConstants.H:78
constexpr amrex::Real qcw0
Definition: ERF_MicrophysicsConstants.H:76
constexpr amrex::Real rhor
Definition: ERF_MicrophysicsConstants.H:39
Dimensionless numeric literals and pure mathematical constants.
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:34
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ qp
Definition: ERF_Kessler.H:34
@ rho
Definition: ERF_Kessler.H:25
@ qv
Definition: ERF_Kessler.H:31
@ qc
Definition: ERF_SatAdj.H:42
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12
Definition: ERF_KesslerUtils.H:27
amrex::Real rho
Definition: ERF_KesslerUtils.H:28
amrex::Real qp
Definition: ERF_KesslerUtils.H:29
Definition: ERF_KesslerUtils.H:22
amrex::Real dq_cloud_to_vapor
Definition: ERF_KesslerUtils.H:24
amrex::Real dq_vapor_to_cloud
Definition: ERF_KesslerUtils.H:23
Definition: ERF_KesslerUtils.H:15
amrex::Real dq_rain_to_vapor
Definition: ERF_KesslerUtils.H:19
amrex::Real dq_cloud_to_vapor
Definition: ERF_KesslerUtils.H:17
amrex::Real dq_cloud_to_rain
Definition: ERF_KesslerUtils.H:18
amrex::Real dq_vapor_to_cloud
Definition: ERF_KesslerUtils.H:16