5 Vector<MultiFab>& S_old,
6 Vector<MultiFab>& F_slow,
7 const double time_for_fp,
const double slow_dt_d,
10 BL_PROFILE(
"no_substep_fun");
11 amrex::ignore_unused(nrk);
14 amrex::Real slow_dt =
static_cast<Real
>(slow_dt_d);
16 const auto&
dxInv = fine_geom.InvCellSizeArray();
18 const amrex::GpuArray<int, IntVars::NumTypes> scomp_fast = {0,0,0,0};
19 const amrex::GpuArray<int, IntVars::NumTypes> ncomp_fast = {2,1,1,1};
21 if (verbose) amrex::Print() <<
" No-substepping time integration at level " << level
22 << std::setprecision(timeprecision)
23 <<
" to " << time_for_fp
24 <<
" with dt = " << slow_dt << std::endl;
28 #pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
41 const bool do_tiling = (solverChoice.terrain_type == TerrainType::MovingFittedMesh)
42 ?
false : TilingIfNotGPU();
44 for ( MFIter mfi(S_sum[
IntVars::cons],do_tiling); mfi.isValid(); ++mfi)
46 const Box bx = mfi.tilebox();
47 Box tbx = mfi.nodaltilebox(0);
48 Box tby = mfi.nodaltilebox(1);
49 Box tbz = mfi.nodaltilebox(2);
51 Vector<Array4<Real> > ssum_h(n_data);
52 Vector<Array4<Real> > sold_h(n_data);
53 Vector<Array4<Real> > fslow_h(n_data);
55 for (
int i = 0; i < n_data; ++i) {
56 ssum_h[i] = S_sum[i].array(mfi);
57 sold_h[i] = S_old[i].array(mfi);
58 fslow_h[i] = F_slow[i].array(mfi);
61 Gpu::AsyncVector<Array4<Real> > sold_d(n_data);
62 Gpu::AsyncVector<Array4<Real> > ssum_d(n_data);
63 Gpu::AsyncVector<Array4<Real> > fslow_d(n_data);
65 Gpu::copy(Gpu::hostToDevice, sold_h.begin(), sold_h.end(), sold_d.begin());
66 Gpu::copy(Gpu::hostToDevice, ssum_h.begin(), ssum_h.end(), ssum_d.begin());
67 Gpu::copy(Gpu::hostToDevice, fslow_h.begin(), fslow_h.end(), fslow_d.begin());
69 Array4<Real>* sold = sold_d.dataPtr();
70 Array4<Real>* ssum = ssum_d.dataPtr();
71 Array4<Real>* fslow = fslow_d.dataPtr();
74 if ( solverChoice.terrain_type == TerrainType::MovingFittedMesh )
76 const Array4<const Real>& dJ_old = detJ_cc[level]->const_array(mfi);
77 const Array4<const Real>& dJ_new = detJ_cc_new[level]->const_array(mfi);
78 const Array4<const Real>& dJ_stg = detJ_cc_src[level]->const_array(mfi);
80 const Array4<const Real>& z_nd_old = z_phys_nd[level]->const_array(mfi);
81 const Array4<const Real>& z_nd_new = z_phys_nd_new[level]->const_array(mfi);
83 const Array4<const Real>& mf_u = mapfac[level][
MapFacType::u_x]->const_array(mfi);
84 const Array4<const Real>& mf_v = mapfac[level][
MapFacType::v_y]->const_array(mfi);
86 const Array4<Real >& z_t_arr = z_t_rk[level]->array(mfi);
90 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int nn) {
99 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
105 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
112 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
119 mf_u, mf_v, z_nd_new,
dxInv);
121 Real dJ_old_kface =
myhalf * (dJ_old(i,j,k) + dJ_old(i,j,k-1));
122 Real dJ_new_kface =
myhalf * (dJ_new(i,j,k) + dJ_new(i,j,k-1));
128 }
else if (solverChoice.terrain_type != TerrainType::EB) {
129 const Array4<const Real>& dJ_old = detJ_cc[level]->const_array(mfi);
131 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int nn) {
133 if (dJ_old(i,j,k) >
zero) {
142 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
146 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
150 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
159 if (solverChoice.terrain_type == TerrainType::EB)
161 BL_PROFILE(
"no_substep_fun_redistribute");
166 for (
int i = 1; i <= AMREX_SPACEDIM; ++i) {
167 dUdt[i].define(F_slow[i].boxArray(), F_slow[i].DistributionMap(), F_slow[i].nComp(), F_slow[i].nGrow(), MFInfo());
169 for (
int i = 0; i <= AMREX_SPACEDIM; ++i) {
172 MultiFab::Copy(dUdt[i], F_slow[i], 0, 0, F_slow[i].nComp(), F_slow[i].nGrow());
174 dUdt[i].setDomainBndry(bogus_large_value_d, 0, ncomp_fast[i], fine_geom);
177 BCRec
const* bc_ptr_d = domain_bcs_type_d.data();
180 MultiFab S_pert_cons(ba, dm, S_old[
IntVars::cons].nComp(), ngv_pert, MFInfo(), EBFactory(level));
181 MultiFab rt0(ba, dm, 1, ngv_pert, MFInfo(), EBFactory(level));
184 MultiFab::Copy(S_pert_cons, S_old[
IntVars::cons],0,0,S_pert_cons.nComp(), ngv_pert);
193 MultiFab::Subtract(S_pert_cons, rt0 , 0,1,1,ngv_pert);
197 S_pert_cons, EBFactory(level), bc_ptr_d, slow_dt);
210 #pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
212 for ( MFIter mfi(S_sum[
IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi)
214 const Box bx = mfi.tilebox();
215 Box tbx = mfi.nodaltilebox(0);
216 Box tby = mfi.nodaltilebox(1);
217 Box tbz = mfi.nodaltilebox(2);
219 const Array4<Real >& ssum_c = S_sum[
IntVars::cons].array(mfi);
220 const Array4<Real >& ssum_u = S_sum[
IntVars::xmom].array(mfi);
221 const Array4<Real >& ssum_v = S_sum[
IntVars::ymom].array(mfi);
222 const Array4<Real >& ssum_w = S_sum[
IntVars::zmom].array(mfi);
223 const Array4<const Real>& sold_c = S_old[
IntVars::cons].const_array(mfi);
224 const Array4<const Real>& sold_u = S_old[
IntVars::xmom].const_array(mfi);
225 const Array4<const Real>& sold_v = S_old[
IntVars::ymom].const_array(mfi);
226 const Array4<const Real>& sold_w = S_old[
IntVars::zmom].const_array(mfi);
227 const Array4<const Real>& fslow_c = F_slow[
IntVars::cons].const_array(mfi);
228 const Array4<const Real>& fslow_u = F_slow[
IntVars::xmom].const_array(mfi);
229 const Array4<const Real>& fslow_v = F_slow[
IntVars::ymom].const_array(mfi);
230 const Array4<const Real>& fslow_w = F_slow[
IntVars::zmom].const_array(mfi);
232 const Array4<const Real>& vfrac_c = (get_eb(level).get_const_factory())->getVolFrac().const_array(mfi);
233 const Array4<const Real>& vfrac_u = (get_eb(level).get_u_const_factory())->getVolFrac().const_array(mfi);
234 const Array4<const Real>& vfrac_v = (get_eb(level).get_v_const_factory())->getVolFrac().const_array(mfi);
235 const Array4<const Real>& vfrac_w = (get_eb(level).get_w_const_factory())->getVolFrac().const_array(mfi);
240 ssum_c(i,j,k,n) = (vfrac_c(i,j,k) >
zero) ? sold_c(i,j,k,n) + slow_dt * fslow_c(i,j,k,n)
245 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
246 ssum_u(i,j,k) = (vfrac_u(i,j,k) >
zero) ? sold_u(i,j,k) + slow_dt * fslow_u(i,j,k)
249 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
250 ssum_v(i,j,k) = (vfrac_v(i,j,k) >
zero) ? sold_v(i,j,k) + slow_dt * fslow_v(i,j,k)
253 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
254 ssum_w(i,j,k) = (vfrac_w(i,j,k) >
zero) ? sold_w(i,j,k) + slow_dt * fslow_w(i,j,k)
265 if (solverChoice.rayleigh_slow_implicit_w(level))
267 const Real dampcoef = solverChoice.dampingChoice.rayleigh_dampcoef;
268 const Real* sinesq_stag = d_sinesq_stag_at_lev;
270 const int klo = fine_geom.Domain().smallEnd(2);
271 const int khi = fine_geom.Domain().bigEnd(2);
272 const bool is_eb = (solverChoice.terrain_type == TerrainType::EB);
274 #pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
276 for (MFIter mfi(S_sum[
IntVars::zmom],TilingIfNotGPU()); mfi.isValid(); ++mfi)
278 const Box tbz = mfi.tilebox();
279 const Array4<Real >& rho_w = S_sum[
IntVars::zmom].array(mfi);
281 const Array4<const Real> vfrac = is_eb ?
282 (get_eb(level).get_w_const_factory())->getVolFrac().const_array(mfi) : Array4<const Real>{};
283 ParallelFor(tbz, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
285 if (k <= klo || k >
khi) {
return; }
286 if (is_eb && vfrac(i,j,k) <=
zero) {
return; }
287 const Real a = slow_dt * dampcoef * sinesq_stag[k];
289 rho_w(i,j,k) = (rho_w(i,j,k) + a * rho_on_w_face *
wbar[k]) / (
one + a);
297 fast_only=
true, vel_and_mom_synced=
false);
299 if (solverChoice.compressibility_type[level] != CompressibilityType::FullyCompressible) {
300 bool have_tb = (thin_xforce[level] || thin_yforce[level] || thin_zforce[level]);
302 project_velocity_tb(level, slow_dt, S_sum);
304 project_momenta(level, time_for_fp, slow_dt, S_sum,
true);
constexpr amrex::Real bogus_large_value
Definition: ERF_Constants.H:19
@ wbar
Definition: ERF_DataStruct.H:235
@ v_y
Definition: ERF_DataStruct.H:41
@ u_x
Definition: ERF_DataStruct.H:40
void redistribute_term(int ncomp, const Geometry &geom, MultiFab &result, MultiFab &result_tmp, MultiFab const &state, EBFactType const &ebfact, BCRec const *bc, double local_dt_d, int const igrid)
Apply EB state redistribution to result_tmp and write the redistributed result.
Definition: ERF_EBRedistribute.cpp:21
#define Rho_comp
Definition: ERF_IndexDefines.H:61
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:16
const int khi
Definition: ERF_InitCustomPert_Bubble.H:25
const int klo
Definition: ERF_InitCustomPert_KE.H:9
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);})
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
auto no_substep_fun
Definition: ERF_TI_no_substep_fun.H:4
auto apply_bcs
Definition: ERF_TI_utils.H:46
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real WFromOmega(int &i, int &j, int &k, amrex::Real omega, const amrex::Array4< const amrex::Real > &u_arr, const amrex::Array4< const amrex::Real > &v_arr, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vy, const amrex::Array4< const amrex::Real > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv)
Definition: ERF_TerrainMetrics.H:867
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:281
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtJface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:351
@ th0_comp
Definition: ERF_IndexDefines.H:112
@ r0_comp
Definition: ERF_IndexDefines.H:109
@ NumTypes
Definition: ERF_IndexDefines.H:253
@ ymom
Definition: ERF_IndexDefines.H:251
@ cons
Definition: ERF_IndexDefines.H:249
@ zmom
Definition: ERF_IndexDefines.H:252
@ xmom
Definition: ERF_IndexDefines.H:250
@ nn
Definition: ERF_WDM6.H:33
@ cons
Definition: ERF_IndexDefines.H:231