30 Real
rho_0 = Real(1.29);
45 Real coef = dtn *
m_geom.InvCellSize(2);
47 auto domain =
m_geom.Domain();
48 int k_lo = domain.smallEnd(2);
49 int k_hi = domain.bigEnd(2);
62 auto ba =
tabs->boxArray();
63 auto dm =
tabs->DistributionMap();
64 auto ngrow =
tabs->nGrowVect();
67 fz.define(convert(ba, IntVect(0,0,1)), dm, 3, ngrow);
86 auto const& ma_rho =
rho->const_arrays();
87 auto const& ma_tabs =
tabs->const_arrays();
88 auto const& ma_qpr =
qpr->const_arrays();
89 auto const& ma_qps =
qps->const_arrays();
90 auto const& ma_qpg =
qpg->const_arrays();
97 ?
m_detJ_cc->const_arrays() : MultiArray4<const Real>{};
98 const Real dz_ref =
m_geom.CellSize(2);
99 GpuTuple<Real> max = ParReduce(TypeList<ReduceOpMax>{},
102 [=] AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k) noexcept
107 ma_qpr[box_no], ma_qps[box_no],
109 i, j, k, k_lo, k_hi);
112 const Real detJ_size = (ma_dJ)
114 ma_dJ[box_no](i,j,receiver_k))
119 dtn, dz_ref, detJ_size) };
121 Real max_courant = get<0>(max);
125 ParallelDescriptor::ReduceRealMax(max_courant);
130 coef /= Real(n_substep);
131 dtn /= Real(n_substep);
134 for (
int nsub(0); nsub<n_substep; ++nsub)
142 for (MFIter mfi(*
qp,
TileNoZ()); mfi.isValid(); ++mfi) {
143 auto qpr_array =
qpr->array(mfi);
144 auto qps_array =
qps->array(mfi);
145 auto qpg_array =
qpg->array(mfi);
146 auto qp_array =
qp->array(mfi);
147 auto rho_array =
rho->const_array(mfi);
148 auto tabs_array =
tabs->const_array(mfi);
149 auto fz_array = fz.array(mfi);
151 auto rain_accum_array =
rain_accum->array(mfi);
152 auto snow_accum_array =
snow_accum->array(mfi);
157 : Array4<const Real>{};
159 const Real inv_dt =
one /
dt;
161 const auto dJ_array = (
m_detJ_cc) ?
m_detJ_cc->const_array(mfi) : Array4<const Real>{};
163 const auto& tbx = mfi.tilebox();
164 const auto& tbz = mfi.tilebox(IntVect(0,0,1),IntVect(0));
167 ParallelFor(tbz, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
171 qpr_array, qps_array, qpg_array,
172 i, j, k, k_lo, k_hi);
175 vrain, vsnow, vgrau);
181 const Real detJ_donor = (dJ_array) ? dJ_array(i,j,donor_k) :
one;
190 rho_array(i,j,donor_k),
191 qpr_array(i,j,donor_k),
195 rho_array(i,j,donor_k),
196 qps_array(i,j,donor_k),
200 rho_array(i,j,donor_k),
201 qpg_array(i,j,donor_k),
207 if (inflow_array && inflow_array(i,j,k,inflow_flag) > Real(0.5)) {
208 fz_array(i,j,k,0) = inflow_array(i,j,k,0) * inv_dt;
209 fz_array(i,j,k,1) = inflow_array(i,j,k,1) * inv_dt;
210 fz_array(i,j,k,2) = inflow_array(i,j,k,2) * inv_dt;
213 sed_array(i,j,k,0) += fz_array(i,j,k,0) * dtn;
214 sed_array(i,j,k,1) += fz_array(i,j,k,1) * dtn;
215 sed_array(i,j,k,2) += fz_array(i,j,k,2) * dtn;
220 {fz_array(i,j,k,0), fz_array(i,j,k,1), fz_array(i,j,k,2)},
222 rain_accum_array(i,j,k) = rain_accum_array(i,j,k) + surface_accum.
rain;
223 snow_accum_array(i,j,k) = snow_accum_array(i,j,k) + surface_accum.
snow;
224 graupel_accum_array(i,j,k) = graupel_accum_array(i,j,k) + surface_accum.
graupel;
226 precip_accum_array(i,j,k) += (fz_array(i,j,k,0) + fz_array(i,j,k,1) + fz_array(i,j,k,2))
227 * dtn /
rhor * Real(1000.0);
232 ParallelFor(tbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
235 Real dJinv = (dJ_array) ?
one/dJ_array(i,j,k) :
one;
241 rho_array(i,j,k), dJinv, coef);
243 rho_array(i,j,k), dJinv, coef);
245 rho_array(i,j,k), dJinv, coef);
247 qpr_array(i,j,k) = std::max(Real(0.0), qpr_array(i,j,k) + dqpr);
248 qps_array(i,j,k) = std::max(Real(0.0), qps_array(i,j,k) + dqps);
249 qpg_array(i,j,k) = std::max(Real(0.0), qpg_array(i,j,k) + dqpg);
250 qp_array(i,j,k) = qpr_array(i,j,k) + qps_array(i,j,k) + qpg_array(i,j,k);
Real rho_0
Definition: ERF_InitCustomPert_ABL.H:18
constexpr amrex::Real csnow
Definition: ERF_MicrophysicsConstants.H:70
constexpr amrex::Real nzerog
Definition: ERF_MicrophysicsConstants.H:95
constexpr amrex::Real cgrau
Definition: ERF_MicrophysicsConstants.H:71
constexpr amrex::Real a_grau
Definition: ERF_MicrophysicsConstants.H:66
constexpr amrex::Real nzeror
Definition: ERF_MicrophysicsConstants.H:93
constexpr amrex::Real a_rain
Definition: ERF_MicrophysicsConstants.H:62
constexpr amrex::Real nzeros
Definition: ERF_MicrophysicsConstants.H:94
constexpr amrex::Real a_snow
Definition: ERF_MicrophysicsConstants.H:64
constexpr amrex::Real crain
Definition: ERF_MicrophysicsConstants.H:69
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE SAMPrecipFluxComponents sam_precip_component_fluxes_from_face_state(const SAMPrecipComponentFaceState &face_state, const amrex::Real &vrain, const amrex::Real &vsnow, const amrex::Real &vgrau) noexcept
Definition: ERF_SAMUtils.H:1145
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE SAMSurfaceAccumulation sam_surface_accumulation_from_component_fluxes(const SAMPrecipFluxComponents &component_fluxes, const amrex::Real &dtn) noexcept
Definition: ERF_SAMUtils.H:1215
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real sam_precip_component_max_fall_speed(const SAMPrecipComponentFaceState &face_state, const amrex::Real &vrain, const amrex::Real &vsnow, const amrex::Real &vgrau, const amrex::Real &rho_0) noexcept
Definition: ERF_SAMUtils.H:999
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE SAMPrecipComponentFaceState sam_precip_component_face_state(const amrex::Array4< const amrex::Real > &rho_array, const amrex::Array4< const amrex::Real > &tabs_array, const amrex::Array4< const amrex::Real > &qpr_array, const amrex::Array4< const amrex::Real > &qps_array, const amrex::Array4< const amrex::Real > &qpg_array, const int &i, const int &j, const int &k, const int &k_lo, const int &k_hi) noexcept
Definition: ERF_SAMUtils.H:1062
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE SAMPrecipFluxComponents sam_precip_flux_components_density_corrected(const SAMPrecipFluxComponents &precip_fluxes, const amrex::Real &rho_0, const amrex::Real &rho_avg) noexcept
Definition: ERF_SAMUtils.H:1172
@ qp
Definition: ERF_Kessler.H:34
@ rain_accum
Definition: ERF_Kessler.H:36
@ graupel_accum
Definition: ERF_Morrison.H:55
@ qpg
Definition: ERF_Morrison.H:44
@ qps
Definition: ERF_Morrison.H:43
@ qpr
Definition: ERF_Morrison.H:42
@ snow_accum
Definition: ERF_Morrison.H:54
Definition: ERF_SAMUtils.H:127
amrex::Real rho_avg
Definition: ERF_SAMUtils.H:128
Definition: ERF_SAMUtils.H:148
amrex::Real snow
Definition: ERF_SAMUtils.H:150
amrex::Real rain
Definition: ERF_SAMUtils.H:149
amrex::Real graupel
Definition: ERF_SAMUtils.H:151
Definition: ERF_SAMUtils.H:142
amrex::Real rain
Definition: ERF_SAMUtils.H:143
amrex::Real snow
Definition: ERF_SAMUtils.H:144
amrex::Real graupel
Definition: ERF_SAMUtils.H:145