18 auto domain =
m_geom.Domain();
19 int k_lo = domain.smallEnd(2);
20 int k_hi = domain.bigEnd(2);
24 auto ba =
tabs->boxArray();
25 auto dm =
tabs->DistributionMap();
26 fz.define(convert(ba, IntVect(0,0,1)), dm, 1, 0);
31 for ( MFIter mfi(*
tabs,TilingIfNotGPU()); mfi.isValid(); ++mfi) {
41 auto tbx = mfi.tilebox();
45 ParallelFor(tbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
47 qv_array(i,j,k) = std::max(
Real(0), qv_array(i,j,k));
48 qc_array(i,j,k) = std::max(
Real(0), qc_array(i,j,k));
49 qp_array(i,j,k) = std::max(
Real(0), qp_array(i,j,k));
51 Real qsat_local, dtqsat_local;
52 Real pressure = pres_array(i,j,k);
54 erf_qsatw(tabs_array(i,j,k), pressure, qsat_local);
55 erf_dtqsatw(tabs_array(i,j,k), pressure, dtqsat_local);
57 if (qsat_local <=
Real(0)) {
58 amrex::Warning(
"qsat computed as non-positive; setting to Real(0)!");
63 qv_array(i,j,k), qc_array(i,j,k), qp_array(i,j,k), rho_array(i,j,k),
64 pressure, qsat_local, dtqsat_local, dtn, do_cond, d_fac_cond);
75 Real theta_over_T = theta_array(i,j,k)/tabs_array(i,j,k);
76 theta_array(i,j,k) += theta_over_T * d_fac_cond
81 qv_array(i,j,k) = std::max(
Real(0), qv_array(i,j,k));
82 qc_array(i,j,k) = std::max(
Real(0), qc_array(i,j,k));
83 qp_array(i,j,k) = std::max(
Real(0), qp_array(i,j,k));
85 qt_array(i,j,k) = qv_array(i,j,k) + qc_array(i,j,k);
89 for ( MFIter mfi(fz, TilingIfNotGPU()); mfi.isValid(); ++mfi ){
93 auto fz_array = fz.array(mfi);
94 const Box& tbz = mfi.tilebox();
96 ParallelFor(tbz, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
98 const Real rho_km1 = (k == k_lo) ? rho_array(i,j,k) : rho_array(i,j,k-1);
99 const Real rho_k = (k == k_hi+1) ? rho_array(i,j,k-1) : rho_array(i,j,k);
100 const Real qp_km1 = (k == k_lo) ? qp_array(i,j,k) : qp_array(i,j,k-1);
101 const Real qp_k = (k == k_hi+1) ? qp_array(i,j,k-1) : qp_array(i,j,k);
115 GpuTuple<Real> max_terminal_velocity = ParReduce(TypeList<ReduceOpMax>{},
118 [=] AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k) noexcept
121 const auto&
rho_arr = ma_rho_arr[box_no];
122 const auto& qp_arr = ma_qp_arr[box_no];
125 const Real qp_km1 = (k == k_lo) ? qp_arr(i,j,k) : qp_arr(i,j,k-1);
126 const Real qp_k = (k == k_hi+1) ? qp_arr(i,j,k-1) : qp_arr(i,j,k);
133 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(n_substep >= 1,
134 "Kessler: Number of precipitation substeps must be greater than 0!");
135 coef /=
Real(n_substep);
136 dtn /=
Real(n_substep);
138 for (
int nsub(0); nsub<n_substep; ++nsub) {
139 for ( MFIter mfi(*
tabs, TilingIfNotGPU()); mfi.isValid(); ++mfi ){
143 auto fz_array = fz.array(mfi);
145 const auto dJ_array = (
m_detJ_cc) ?
m_detJ_cc->const_array(mfi) : Array4<const Real>{};
147 const Box& tbx = mfi.tilebox();
148 const Box& tbz = mfi.tilebox(IntVect(0,0,1),IntVect(0));
150 ParallelFor(tbz, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
152 const Real rho_km1 = (k == k_lo) ? rho_array(i,j,k) : rho_array(i,j,k-1);
153 const Real rho_k = (k == k_hi+1) ? rho_array(i,j,k-1) : rho_array(i,j,k);
154 const Real qp_km1 = (k == k_lo) ? qp_array(i,j,k) : qp_array(i,j,k-1);
155 const Real qp_k = (k == k_hi+1) ? qp_array(i,j,k-1) : qp_array(i,j,k);
161 const Real donor_rho = rho_array(i,j,donor_k);
162 const Real donor_qp = std::max(
Real(0), qp_array(i,j,donor_k));
163 const Real donor_detJ = (dJ_array) ? dJ_array(i,j,donor_k) :
Real(1);
170 const Real max_flux = donor_rho * donor_qp * donor_detJ / coef;
171 fz_array(i,j,k) = amrex::min(
177 rain_accum_array(i,j,k) = rain_accum_array(i,j,k)
182 ParallelFor(tbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
184 Real dJinv = (dJ_array) ?
Real(1)/dJ_array(i,j,k) :
Real(1);
189 Real f_hi = fz_array(i,j,k+1);
190 Real f_lo = fz_array(i,j,k );
199 f_hi, f_lo, rho_array(i,j,k), dJinv, coef);
204 qp_array(i,j,k) += dq_sed;
205 qp_array(i,j,k) = std::max(
Real(0), qp_array(i,j,k));
211 if (solverChoice.
moisture_type == MoistureType::Kessler_NoRain) {
212 if (!do_cond) {
return; }
213 for ( MFIter mfi(*
tabs,TilingIfNotGPU()); mfi.isValid(); ++mfi) {
221 auto tbx = mfi.tilebox();
225 ParallelFor(tbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
227 qc_array(i,j,k) = std::max(
Real(0), qc_array(i,j,k));
231 Real pressure = pres_array(i,j,k);
233 erf_qsatw(tabs_array(i,j,k), pressure, qsat);
238 do_cond, d_fac_cond);
245 Real theta_over_T = theta_array(i,j,k)/tabs_array(i,j,k);
246 theta_array(i,j,k) += theta_over_T * d_fac_cond
249 qv_array(i,j,k) = std::max(
Real(0), qv_array(i,j,k));
250 qc_array(i,j,k) = std::max(
Real(0), qc_array(i,j,k));
252 qt_array(i,j,k) = qv_array(i,j,k) + qc_array(i,j,k);
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:88
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:61
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:113
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:155
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:144
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:43
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:71
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:53
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool kessler_is_small_sedimentation_value(const amrex::Real value) noexcept
Definition: ERF_KesslerUtils.H:81
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int kessler_face_donor_k(const int k, const int k_hi) noexcept
Definition: ERF_KesslerUtils.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_dtqsatw(amrex::Real t, amrex::Real p, amrex::Real &dtqsatw)
Definition: ERF_MicrophysicsUtils.H:244
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsatw(amrex::Real t, amrex::Real p, amrex::Real &qsatw)
Definition: ERF_MicrophysicsUtils.H:228
ParallelFor(grown_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);})
amrex::Real Real
Definition: ERF_ShocInterface.H:19
auto rho_arr
Definition: ERF_UpdateWSubsidence_SineMassFlux.H:3
amrex::Geometry m_geom
Definition: ERF_Kessler.H:157
amrex::MultiFab * m_detJ_cc
Definition: ERF_Kessler.H:174
amrex::Real m_dzmin
Definition: ERF_Kessler.H:163
amrex::Real m_fac_cond
Definition: ERF_Kessler.H:169
bool m_do_cond
Definition: ERF_Kessler.H:170
amrex::Array< FabPtr, MicVar_Kess::NumVars > mic_fab_vars
Definition: ERF_Kessler.H:177
@ qp
Definition: ERF_Kessler.H:32
@ qcl
Definition: ERF_Kessler.H:30
@ tabs
Definition: ERF_Kessler.H:25
@ pres
Definition: ERF_Kessler.H:26
@ rho
Definition: ERF_Kessler.H:23
@ theta
Definition: ERF_Kessler.H:24
@ qt
Definition: ERF_Kessler.H:28
@ rain_accum
Definition: ERF_Kessler.H:34
@ qv
Definition: ERF_Kessler.H:29
Definition: ERF_KesslerUtils.H:26
amrex::Real rho
Definition: ERF_KesslerUtils.H:27
amrex::Real qp
Definition: ERF_KesslerUtils.H:28
Definition: ERF_KesslerUtils.H:21
amrex::Real dq_cloud_to_vapor
Definition: ERF_KesslerUtils.H:23
amrex::Real dq_vapor_to_cloud
Definition: ERF_KesslerUtils.H:22
Definition: ERF_KesslerUtils.H:14
amrex::Real dq_rain_to_vapor
Definition: ERF_KesslerUtils.H:18
amrex::Real dq_cloud_to_vapor
Definition: ERF_KesslerUtils.H:16
amrex::Real dq_cloud_to_rain
Definition: ERF_KesslerUtils.H:17
amrex::Real dq_vapor_to_cloud
Definition: ERF_KesslerUtils.H:15
MoistureType moisture_type
Definition: ERF_DataStruct.H:1299