5 Vector<MultiFab>& S_old,
6 Vector<MultiFab>& F_slow,
7 const Real time_for_fp,
const Real slow_dt,
10 BL_PROFILE(
"no_substep_fun");
11 amrex::ignore_unused(nrk);
14 const auto& dxInv = fine_geom.InvCellSizeArray();
16 const amrex::GpuArray<int, IntVars::NumTypes> scomp_fast = {0,0,0,0};
17 const amrex::GpuArray<int, IntVars::NumTypes> ncomp_fast = {2,1,1,1};
19 if (verbose) amrex::Print() <<
" No-substepping time integration at level " << level
20 << std::setprecision(timeprecision)
21 <<
" to " << time_for_fp
22 <<
" with dt = " << slow_dt << std::endl;
26 #pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
29 for ( MFIter mfi(S_sum[
IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi)
31 const Box bx = mfi.tilebox();
32 Box tbx = mfi.nodaltilebox(0);
33 Box tby = mfi.nodaltilebox(1);
34 Box tbz = mfi.nodaltilebox(2);
36 Vector<Array4<Real> > ssum_h(n_data);
37 Vector<Array4<Real> > sold_h(n_data);
38 Vector<Array4<Real> > fslow_h(n_data);
40 for (
int i = 0; i < n_data; ++i) {
41 ssum_h[i] = S_sum[i].array(mfi);
42 sold_h[i] = S_old[i].array(mfi);
43 fslow_h[i] = F_slow[i].array(mfi);
46 Gpu::AsyncVector<Array4<Real> > sold_d(n_data);
47 Gpu::AsyncVector<Array4<Real> > ssum_d(n_data);
48 Gpu::AsyncVector<Array4<Real> > fslow_d(n_data);
50 Gpu::copy(Gpu::hostToDevice, sold_h.begin(), sold_h.end(), sold_d.begin());
51 Gpu::copy(Gpu::hostToDevice, ssum_h.begin(), ssum_h.end(), ssum_d.begin());
52 Gpu::copy(Gpu::hostToDevice, fslow_h.begin(), fslow_h.end(), fslow_d.begin());
54 Array4<Real>* sold = sold_d.dataPtr();
55 Array4<Real>* ssum = ssum_d.dataPtr();
56 Array4<Real>* fslow = fslow_d.dataPtr();
59 if ( solverChoice.terrain_type == TerrainType::MovingFittedMesh )
61 const Array4<const Real>& dJ_old = detJ_cc[level]->const_array(mfi);
62 const Array4<const Real>& dJ_new = detJ_cc_new[level]->const_array(mfi);
63 const Array4<const Real>& dJ_stg = detJ_cc_src[level]->const_array(mfi);
65 const Array4<const Real>& z_nd_old = z_phys_nd[level]->const_array(mfi);
66 const Array4<const Real>& z_nd_new = z_phys_nd_new[level]->const_array(mfi);
68 const Array4<const Real>& mf_u = mapfac[level][
MapFacType::u_x]->const_array(mfi);
69 const Array4<const Real>& mf_v = mapfac[level][
MapFacType::v_y]->const_array(mfi);
71 const Array4<Real >& z_t_arr = z_t_rk[level]->array(mfi);
75 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int nn) {
84 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
90 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
97 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
104 mf_u, mf_v, z_nd_new,dxInv);
106 Real dJ_old_kface = 0.5 * (dJ_old(i,j,k) + dJ_old(i,j,k-1));
107 Real dJ_new_kface = 0.5 * (dJ_new(i,j,k) + dJ_new(i,j,k-1));
114 const Array4<const Real>& dJ_old = detJ_cc[level]->const_array(mfi);
116 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int nn) {
118 if (dJ_old(i,j,k) > 0.0) {
127 if (solverChoice.terrain_type == TerrainType::EB)
129 const Array4<const Real>& vfrac_u = (get_eb(level).get_u_const_factory())->getVolFrac().const_array(mfi);
130 const Array4<const Real>& vfrac_v = (get_eb(level).get_v_const_factory())->getVolFrac().const_array(mfi);
131 const Array4<const Real>& vfrac_w = (get_eb(level).get_w_const_factory())->getVolFrac().const_array(mfi);
133 ParallelFor(tbx, tby, tbz,
134 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
135 if (vfrac_u(i,j,k) > 0.0) {
143 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
144 if (vfrac_v(i,j,k) > 0.0) {
152 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
153 if (vfrac_w(i,j,k) > 0.0) {
163 ParallelFor(tbx, tby, tbz,
164 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
168 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
172 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
180 if (solverChoice.terrain_type == TerrainType::EB)
182 BL_PROFILE(
"no_substep_fun_redistribute");
187 for (
int i = 1; i <= AMREX_SPACEDIM; ++i) {
188 dUdt[i].define(F_slow[i].boxArray(), F_slow[i].DistributionMap(), F_slow[i].nComp(), F_slow[i].nGrow(), MFInfo());
190 for (
int i = 0; i <= AMREX_SPACEDIM; ++i) {
191 dUdt[i].setVal(0.0, 0, ncomp_fast[i], dUdt[i].nGrow());
192 MultiFab::Copy(dUdt[i], F_slow[i], 0, 0, F_slow[i].nComp(), 0);
193 dUdt[i].setDomainBndry(1.234e10, 0, ncomp_fast[i], fine_geom);
194 dUdt[i].FillBoundary(fine_geom.periodicity());
197 BCRec
const* bc_ptr_d = domain_bcs_type_d.data();
200 MultiFab S_pert_cons(ba, dm, S_old[
IntVars::cons].nComp(), ngv_pert, MFInfo(), EBFactory(level));
201 MultiFab rt0(ba, dm, 1, ngv_pert, MFInfo(), EBFactory(level));
204 MultiFab::Copy(S_pert_cons, S_old[
IntVars::cons],0,0,S_pert_cons.nComp(), ngv_pert);
213 MultiFab::Subtract(S_pert_cons, rt0 , 0,1,1,ngv_pert);
217 S_pert_cons, EBFactory(level), bc_ptr_d, slow_dt);
229 for ( MFIter mfi(S_sum[
IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi)
231 const Box bx = mfi.tilebox();
232 Box tbx = mfi.nodaltilebox(0);
233 Box tby = mfi.nodaltilebox(1);
234 Box tbz = mfi.nodaltilebox(2);
236 Vector<Array4<Real> > ssum_h(n_data);
237 Vector<Array4<Real> > sold_h(n_data);
238 Vector<Array4<Real> > fslow_h(n_data);
240 for (
int i = 0; i < n_data; ++i) {
241 ssum_h[i] = S_sum[i].array(mfi);
242 sold_h[i] = S_old[i].array(mfi);
243 fslow_h[i] = F_slow[i].array(mfi);
246 Gpu::AsyncVector<Array4<Real> > sold_d(n_data);
247 Gpu::AsyncVector<Array4<Real> > ssum_d(n_data);
248 Gpu::AsyncVector<Array4<Real> > fslow_d(n_data);
250 Gpu::copy(Gpu::hostToDevice, sold_h.begin(), sold_h.end(), sold_d.begin());
251 Gpu::copy(Gpu::hostToDevice, ssum_h.begin(), ssum_h.end(), ssum_d.begin());
252 Gpu::copy(Gpu::hostToDevice, fslow_h.begin(), fslow_h.end(), fslow_d.begin());
254 Array4<Real>* sold = sold_d.dataPtr();
255 Array4<Real>* ssum = ssum_d.dataPtr();
256 Array4<Real>* fslow = fslow_d.dataPtr();
259 const Array4<const Real>& vfrac_c = (get_eb(level).get_const_factory())->getVolFrac().const_array(mfi);
261 ParallelFor(bx, ncomp_fast[
IntVars::cons], [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int nn)
264 if (vfrac_c(i,j,k) > 0.0) {
270 const Array4<const Real>& vfrac_u = (get_eb(level).get_u_const_factory())->getVolFrac().const_array(mfi);
271 const Array4<const Real>& vfrac_v = (get_eb(level).get_v_const_factory())->getVolFrac().const_array(mfi);
272 const Array4<const Real>& vfrac_w = (get_eb(level).get_w_const_factory())->getVolFrac().const_array(mfi);
274 ParallelFor(tbx, tby, tbz,
275 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
276 if (vfrac_u(i,j,k) > 0.0) {
281 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
282 if (vfrac_v(i,j,k) > 0.0) {
287 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
288 if (vfrac_w(i,j,k) > 0.0) {
301 fast_only=
true, vel_and_mom_synced=
false);
303 if (solverChoice.anelastic[level]) {
304 bool have_tb = (thin_xforce[0] || thin_yforce[0] || thin_zforce[0]);
306 project_velocity_tb(level, slow_dt, S_sum);
308 project_momenta(level, slow_dt, S_sum);
@ v_y
Definition: ERF_DataStruct.H:24
@ u_x
Definition: ERF_DataStruct.H:23
void redistribute_term(int ncomp, const Geometry &geom, MultiFab &result, MultiFab &result_tmp, MultiFab const &state, EBFArrayBoxFactory const &ebfact, BCRec const *bc, Real const local_dt)
Definition: ERF_EBRedistribute.cpp:13
#define Rho_comp
Definition: ERF_IndexDefines.H:36
amrex::Real Real
Definition: ERF_ShocInterface.H:19
auto no_substep_fun
Definition: ERF_TI_no_substep_fun.H:4
auto apply_bcs
Definition: ERF_TI_utils.H:73
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:102
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:142
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_u, const amrex::Array4< const amrex::Real > &mf_v, const amrex::Array4< const amrex::Real > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv)
Definition: ERF_TerrainMetrics.H:462
@ th0_comp
Definition: ERF_IndexDefines.H:66
@ r0_comp
Definition: ERF_IndexDefines.H:63
@ NumTypes
Definition: ERF_IndexDefines.H:162
@ ymom
Definition: ERF_IndexDefines.H:160
@ cons
Definition: ERF_IndexDefines.H:158
@ zmom
Definition: ERF_IndexDefines.H:161
@ xmom
Definition: ERF_IndexDefines.H:159