Rebalance density and potential temperature columns to satisfy hydrostatic equilibrium.
29 #ifdef AMREX_USE_FLOAT
37 int k_dom_lo = geom.Domain().smallEnd(2);
39 for (MFIter mfi(
rho,
TileNoZ()); mfi.isValid(); ++mfi) {
40 Box bx = mfi.tilebox();
41 int klo = bx.smallEnd(2);
42 int khi = bx.bigEnd(2);
63 "rebalance_columns with use_sfc requires boxes that "
64 "reach the bottom of the domain: the integration is "
65 "seeded from p_0 at the surface. Set erf.max_grid_size_z "
66 "large enough that the grids are not decomposed in z.");
70 const Array4< Real>& th_arr =
theta.array(mfi);
71 const Array4<const Real>&
qv_arr =
qv.const_array(mfi);
72 const Array4<const Real>& qt_arr =
qt.const_array(mfi);
74 const Array4<const Real>& z_arr = z_phys->const_array(mfi);
76 ParallelFor(bx, [=,RdoCp_d=
RdoCp] AMREX_GPU_DEVICE (
int i,
int j,
int ) noexcept
80 Real rho_tot_hi, rho_tot_lo;
92 z_hi =
Real(0.125) * (z_arr(i,j,klo ) + z_arr(i+1,j,klo ) + z_arr(i,j+1,klo ) + z_arr(i+1,j+1,klo )
93 +z_arr(i,j,klo+1) + z_arr(i+1,j,klo+1) + z_arr(i,j+1,klo+1) + z_arr(i+1,j+1,klo+1));
97 qt_lo = qt_arr(i,j,klo);
99 Th_lo = th_arr(i,j,klo);
102 rho_tot_lo = R_lo * (
one + qt_lo);
103 C = -P_lo +
myhalf*rho_tot_lo*grav*
dz;
106 qt_hi = qt_arr(i,j,klo);
108 Th_hi = th_arr(i,j,klo);
112 rho_tot_hi = R_hi * (
one + qt_hi);
113 F = P_hi +
myhalf*rho_tot_hi*grav*
dz + C;
117 grav, C, Th_hi, T_hi,
119 P_hi, R_hi, F, maintain_Th);
123 if (!maintain_Th) { th_arr(i,j,klo) =
getThgivenTandP(T_hi, P_hi, RdoCp_d); }
129 z_lo =
Real(0.125) * (z_arr(i,j,klo ) + z_arr(i+1,j,klo ) + z_arr(i,j+1,klo ) + z_arr(i+1,j+1,klo )
130 +z_arr(i,j,klo+1) + z_arr(i+1,j,klo+1) + z_arr(i,j+1,klo+1) + z_arr(i+1,j+1,klo+1));
135 for (
int k(klo+1); k<=
khi; ++k)
137 z_hi =
Real(0.125) * (z_arr(i,j,k ) + z_arr(i+1,j,k ) + z_arr(i,j+1,k ) + z_arr(i+1,j+1,k )
138 +z_arr(i,j,k+1) + z_arr(i+1,j,k+1) + z_arr(i,j+1,k+1) + z_arr(i+1,j+1,k+1));
142 qt_lo = qt_arr(i,j,k-1);
144 Th_lo = th_arr(i,j,k-1);
146 rho_tot_lo = R_lo * (
one + qt_lo);
147 C = -P_lo +
myhalf*rho_tot_lo*grav*
dz;
150 qt_hi = qt_arr(i,j,k);
152 Th_hi = th_arr(i,j,k);
155 rho_tot_hi = R_hi * (
one + qt_hi);
156 F = P_hi +
myhalf*rho_tot_hi*grav*
dz + C;
160 grav, C, Th_hi, T_hi,
162 P_hi, R_hi, F, maintain_Th);
166 if (!maintain_Th) { th_arr(i,j,k) =
getThgivenTandP(T_hi, P_hi, RdoCp_d); }
constexpr amrex::Real one
Definition: ERF_Constants.H:9
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
constexpr amrex::Real p_0
Definition: ERF_Constants.H:61
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:64
constexpr amrex::Real RdoCp
Definition: ERF_Constants.H:54
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhogivenThetaPress(const amrex::Real th, const amrex::Real p, const amrex::Real rdOcp, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:96
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getThgivenTandP(const amrex::Real T, const amrex::Real P, const amrex::Real rdOcp)
Definition: ERF_EOS.H:18
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh(const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:81
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenPandTh(const amrex::Real P, const amrex::Real th, const amrex::Real rdOcp)
Definition: ERF_EOS.H:32
const int khi
Definition: ERF_InitCustomPert_Bubble.H:21
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_cloud_chamber_config.active, "Cloud Chamber: initializer reached without a parsed configuration")
auto qv_arr
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:210
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);})
amrex::Real Real
Definition: ERF_ShocInterface.H:19
AMREX_FORCE_INLINE amrex::IntVect TileNoZ()
Definition: ERF_TileNoZ.H:11
auto rho_arr
Definition: ERF_UpdateWSubsidence_SineMassFlux.H:3
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void Newton_Raphson_hse(const Real &m_tol, const Real &RdoCp, const Real &dz, const Real &g, const Real &C, const Real &Th, const Real &T, const Real &qt, const Real &qv, Real &P, Real &rd, Real &F, const bool &maintain_Th)
Definition: ERF_HSEUtils.H:44
@ theta
Definition: ERF_SLM.H:20
@ rho
Definition: ERF_Kessler.H:24
@ qt
Definition: ERF_Kessler.H:29
@ qv
Definition: ERF_Kessler.H:30
@ dz
Definition: ERF_AdvanceWDM6.cpp:270