Function for computing the coefficients for the tridiagonal solver used in the fast integrator (the acoustic substepping).
47 const GpuArray<Real, AMREX_SPACEDIM>
dxInv = geom.InvCellSizeArray();
50 const Box &domain = geom.Domain();
52 MultiFab coeff_A_mf(fast_coeffs, amrex::make_alias, 0, 1);
53 MultiFab coeff_B_mf(fast_coeffs, amrex::make_alias, 1, 1);
54 MultiFab coeff_C_mf(fast_coeffs, amrex::make_alias, 2, 1);
55 MultiFab coeff_P_mf(fast_coeffs, amrex::make_alias, 3, 1);
56 MultiFab coeff_Q_mf(fast_coeffs, amrex::make_alias, 4, 1);
61 const Array<Real,AMREX_SPACEDIM> grav{
zero,
zero, -gravity};
62 const GpuArray<Real,AMREX_SPACEDIM> grav_gpu{grav[0], grav[1], grav[2]};
68 #pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
74 Box bx = mfi.tilebox();
75 Box tbz = surroundingNodes(bx,2);
77 const Array4<const Real> & stage_cons = S_stage_data[
IntVars::cons].const_array(mfi);
78 const Array4<const Real> & prim = S_stage_prim.const_array(mfi);
80 const Array4<const Real>& detJ = (mesh_type != MeshType::ConstantDz) ?
81 detJ_cc->const_array(mfi) : Array4<const Real>{};
83 const Array4<const Real>& pi_stage_ca = pi_stage.const_array(mfi);
85 FArrayBox gam_fab; gam_fab.resize(surroundingNodes(bx,2),1,The_Async_Arena());
87 auto const& coeffA_a = coeff_A_mf.array(mfi);
88 auto const& coeffB_a = coeff_B_mf.array(mfi);
89 auto const& coeffC_a = coeff_C_mf.array(mfi);
90 auto const& coeffP_a = coeff_P_mf.array(mfi);
91 auto const& coeffQ_a = coeff_Q_mf.array(mfi);
92 auto const& gam_a = gam_fab.array();
98 Box bx_shrunk_in_k = bx;
99 int klo = tbz.smallEnd(2);
100 int khi = tbz.bigEnd(2);
101 bx_shrunk_in_k.setSmall(2,klo+1);
102 bx_shrunk_in_k.setBig(2,
khi-1);
110 if (mesh_type != MeshType::ConstantDz)
112 ParallelFor(bx_shrunk_in_k, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
114 Real pi_c =
myhalf * (pi_stage_ca(i,j,k-1) + pi_stage_ca(i,j,k));
116 Real detJ_on_kface =
myhalf * (detJ(i,j,k) + detJ(i,j,k-1));
117 Real inv_detJ_on_kface =
one / detJ_on_kface;
124 Real Thm_grad = dzi * inv_detJ_on_kface * ( Thm_hi - Thm_lo );
134 if (l_use_moisture) {
137 coeff_P /= (
one +
q);
138 coeff_Q /= (
one +
q);
144 coeffP_a(i,j,k) = coeff_P;
145 coeffQ_a(i,j,k) = coeff_Q;
152 Real D = beta_2 * beta_2 * dzi *
static_cast<Real>(dtau * dtau);
153 coeffA_a(i,j,k) = D * (
one/detJ(i,j,k-1)) * ( halfg - coeff_Q * theta_t_lo );
154 coeffC_a(i,j,k) = D * (
one/detJ(i,j,k )) * (-halfg + coeff_P * theta_t_hi );
156 coeffB_a(i,j,k) =
one + D * ( (coeff_Q/detJ(i,j,k-1) - coeff_P/detJ(i,j,k)) * theta_t_mid
157 + halfg * (
one/detJ(i,j,k) -
one/detJ(i,j,k-1)) );
162 ParallelFor(bx_shrunk_in_k, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k)
164 Real pi_c =
myhalf * (pi_stage_ca(i,j,k-1) + pi_stage_ca(i,j,k));
171 Real Thm_grad = dzi * ( Thm_hi - Thm_lo );
181 if (l_use_moisture) {
184 coeff_P /= (
one +
q);
185 coeff_Q /= (
one +
q);
191 coeffP_a(i,j,k) = coeff_P;
192 coeffQ_a(i,j,k) = coeff_Q;
199 Real D = beta_2 * beta_2 * dzi *
static_cast<Real>(dtau * dtau);
200 coeffA_a(i,j,k) = D * ( halfg - coeff_Q * theta_t_lo );
201 coeffC_a(i,j,k) = D * (-halfg + coeff_P * theta_t_hi );
203 coeffB_a(i,j,k) =
one + D * (coeff_Q - coeff_P) * theta_t_mid;
207 amrex::Box b2d = tbz;
210 auto const lo = amrex::lbound(bx);
211 auto const hi = amrex::ubound(bx);
213 auto const domhi = amrex::ubound(domain);
216 BL_PROFILE(
"make_coeffs_b2d_loop");
218 ParallelFor(b2d, [=] AMREX_GPU_DEVICE (
int i,
int j,
int) {
221 coeffA_a(i,j,lo.z) =
zero;
222 coeffB_a(i,j,lo.z) =
one;
223 coeffC_a(i,j,lo.z) =
zero;
226 coeffA_a(i,j,hi.z+1) =
zero;
227 coeffB_a(i,j,hi.z+1) =
one;
228 coeffC_a(i,j,hi.z+1) =
zero;
232 if ( (hi.z == domhi.z) &&
235 coeffA_a(i,j,hi.z+1) = -
one;
239 gam_a(i,j,lo.z) = coeffC_a(i,j,lo.z) / coeffB_a(i,j,lo.z);
240 for (
int k = lo.z+1; k <= hi.z+1; k++) {
241 coeffB_a(i,j,k) =
one / ( coeffB_a(i,j,k) - coeffA_a(i,j,k)*gam_a(i,j,k-1) );
242 gam_a(i,j,k) = coeffC_a(i,j,k) * coeffB_a(i,j,k);
247 for (
int j = lo.y; j <= hi.y; ++j) {
249 for (
int i = lo.x; i <= hi.x; ++i) {
250 coeffA_a(i,j,lo.z) =
zero;
251 coeffB_a(i,j,lo.z) =
one;
252 coeffC_a(i,j,lo.z) =
zero;
253 gam_a(i,j,lo.z) = coeffC_a(i,j,lo.z) / coeffB_a(i,j,lo.z);
256 for (
int j = lo.y; j <= hi.y; ++j) {
258 for (
int i = lo.x; i <= hi.x; ++i) {
261 coeffA_a(i,j,hi.z+1) =
zero;
262 coeffB_a(i,j,hi.z+1) =
one;
263 coeffC_a(i,j,hi.z+1) =
zero;
267 if ( (hi.z == domhi.z) &&
270 coeffA_a(i,j,hi.z+1) = -
one;
274 for (
int k = lo.z+1; k <= hi.z+1; ++k) {
275 for (
int j = lo.y; j <= hi.y; ++j) {
277 for (
int i = lo.x; i <= hi.x; ++i) {
278 coeffB_a(i,j,k) =
one / ( coeffB_a(i,j,k) - coeffA_a(i,j,k)*gam_a(i,j,k-1) );
279 gam_a(i,j,k) = coeffC_a(i,j,k) * coeffB_a(i,j,k);
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 RvoRd
Definition: ERF_Constants.H:56
constexpr amrex::Real R_d
Definition: ERF_Constants.H:47
constexpr amrex::Real Gamma
Definition: ERF_Constants.H:62
#define PrimQ1_comp
Definition: ERF_IndexDefines.H:61
#define PrimQ2_comp
Definition: ERF_IndexDefines.H:62
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:40
#define PrimTheta_comp
Definition: ERF_IndexDefines.H:58
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:17
const int khi
Definition: ERF_InitCustomPert_Bubble.H:21
void make_fast_coeffs(int, MultiFab &fast_coeffs, Vector< MultiFab > &S_stage_data, const MultiFab &S_stage_prim, const MultiFab &pi_stage, const amrex::Geometry geom, bool l_use_moisture, MeshType mesh_type, Real gravity, Real c_p, std::unique_ptr< MultiFab > &detJ_cc, const double dtau, Real beta_s, amrex::GpuArray< ERF_BC, AMREX_SPACEDIM *2 > &phys_bc_type)
Definition: ERF_MakeFastCoeffs.cpp:27
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
@ cons
Definition: ERF_IndexDefines.H:232
@ q
Definition: ERF_WSM6.H:184