Skip to content

Commit

Permalink
add heating source term to erf (erf-model#1395)
Browse files Browse the repository at this point in the history
  • Loading branch information
xyuan authored Jan 24, 2024
1 parent 9ea9813 commit 6a0ba3b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ private:

#if defined(ERF_USE_RRTMGP)
Radiation rad;
amrex::Vector<amrex::MultiFab> qheating_rates; // radiation heating rate source terms
#endif

// Fillpatcher classes for coarse-fine boundaries
Expand Down
6 changes: 6 additions & 0 deletions Source/ERF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ ERF::ERF ()
// NOTE: size micro before readparams (chooses the model at all levels)
micro.ReSize(nlevs_max);
qmoist.resize(nlevs_max);
#if defined(ERF_USE_RRTMGP)
qheating_rates.resize(nlevs_max);
#endif

ReadParameters();
const std::string& pv1 = "plot_vars_1"; setPlotVariables(pv1,plot_var_names_1);
Expand Down Expand Up @@ -1488,6 +1491,9 @@ ERF::ERF (const amrex::RealBox& rb, int max_level_in,
// NOTE: size micro before readparams (chooses the model at all levels)
micro.ReSize(nlevs_max);
qmoist.resize(nlevs_max);
#if defined(ERF_USE_RRTMGP)
qheating_rates.resize(nlevs_max);
#endif

ReadParameters();
const std::string& pv1 = "plot_vars_1"; setPlotVariables(pv1,plot_var_names_1);
Expand Down
18 changes: 18 additions & 0 deletions Source/TimeIntegration/ERF_slow_rhs_pre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ void erf_slow_rhs_pre (int level, int finest_level,
MultiFab& Omega,
const MultiFab& source,
const MultiFab& buoyancy,
#ifdef ERF_USE_RRTMGP
const MultiFab& qheating_rates,
#endif
MultiFab* Tau11, MultiFab* Tau22, MultiFab* Tau33,
MultiFab* Tau12, MultiFab* Tau13, MultiFab* Tau21,
MultiFab* Tau23, MultiFab* Tau31, MultiFab* Tau32,
Expand Down Expand Up @@ -699,6 +702,21 @@ void erf_slow_rhs_pre (int level, int finest_level,
cell_rhs(i,j,k,RhoTheta_comp) += src_arr(i,j,k,RhoTheta_comp);
});
}

#ifdef ERF_USE_RRTMGP
auto const& qheating_arr = qheating_rates.const_array(mfi);
if (l_use_terrain && l_moving_terrain) {
amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
cell_rhs(i,j,k,RhoTheta_comp) += (qheating_arr(i,j,k,0) + qheating_arr(i,j,k,1)) / detJ_arr(i,j,k);
});
} else {
amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
cell_rhs(i,j,k,RhoTheta_comp) += qheating_arr(i,j,k,0) + qheating_arr(i,j,k,1);
});
}
#endif
}

// Add Rayleigh damping
Expand Down
3 changes: 3 additions & 0 deletions Source/TimeIntegration/TI_headers.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ void erf_slow_rhs_pre (int level, int finest_level, int nrk,
amrex::MultiFab& Omega,
const amrex::MultiFab& source,
const amrex::MultiFab& buoyancy,
#if defined(ERF_USE_RRTMGP)
const amrex::MultiFab& qheating_rates,
#endif
amrex::MultiFab* Tau11,
amrex::MultiFab* Tau22,
amrex::MultiFab* Tau33,
Expand Down
12 changes: 10 additions & 2 deletions Source/TimeIntegration/TI_slow_rhs_fun.H
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@

erf_slow_rhs_pre(level, finest_level, nrk, slow_dt, S_rhs, S_data, S_prim, S_scratch,
xvel_new, yvel_new, zvel_new,
z_t_rk[level], Omega, source, buoyancy, Tau11, Tau22, Tau33, Tau12,
z_t_rk[level], Omega, source, buoyancy,
#if defined(ERF_USE_RRTMGP)
qheating_rates[level],
#endif
Tau11, Tau22, Tau33, Tau12,
Tau13, Tau21, Tau23, Tau31, Tau32, SmnSmn, eddyDiffs,
Hfx3, Diss,
fine_geom, solverChoice, m_most, domain_bcs_type_d, domain_bcs_type,
Expand Down Expand Up @@ -185,7 +189,11 @@

erf_slow_rhs_pre(level, finest_level, nrk, slow_dt, S_rhs, S_data, S_prim, S_scratch,
xvel_new, yvel_new, zvel_new,
z_t_rk[level], Omega, source, buoyancy, Tau11, Tau22, Tau33, Tau12,
z_t_rk[level], Omega, source, buoyancy,
#if defined(ERF_USE_RRTMGP)
qheating_rates[level],
#endif
Tau11, Tau22, Tau33, Tau12,
Tau13, Tau21, Tau23, Tau31, Tau32, SmnSmn, eddyDiffs,
Hfx3, Diss,
fine_geom, solverChoice, m_most, domain_bcs_type_d, domain_bcs_type,
Expand Down

0 comments on commit 6a0ba3b

Please sign in to comment.