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);
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));
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 if (solverChoice.terrain_type == TerrainType::EB)
144 const Array4<const Real>& vfrac_u = (get_eb(level).get_u_const_factory())->getVolFrac().const_array(mfi);
145 const Array4<const Real>& vfrac_v = (get_eb(level).get_v_const_factory())->getVolFrac().const_array(mfi);
146 const Array4<const Real>& vfrac_w = (get_eb(level).get_w_const_factory())->getVolFrac().const_array(mfi);
149 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
150 if (vfrac_u(i,j,k) >
zero) {
158 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
159 if (vfrac_v(i,j,k) >
zero) {
167 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
168 if (vfrac_w(i,j,k) >
zero) {
179 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
183 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
187 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
195 if (solverChoice.terrain_type == TerrainType::EB)
197 BL_PROFILE(
"no_substep_fun_redistribute");
202 for (
int i = 1; i <= AMREX_SPACEDIM; ++i) {
203 dUdt[i].define(F_slow[i].boxArray(), F_slow[i].DistributionMap(), F_slow[i].nComp(), F_slow[i].nGrow(), MFInfo());
205 for (
int i = 0; i <= AMREX_SPACEDIM; ++i) {
206 dUdt[i].setVal(0, 0, ncomp_fast[i], dUdt[i].nGrow());
207 MultiFab::Copy(dUdt[i], F_slow[i], 0, 0, F_slow[i].nComp(), 0);
208 dUdt[i].setDomainBndry(bogus_large_value_d, 0, ncomp_fast[i], fine_geom);
209 dUdt[i].FillBoundary(fine_geom.periodicity());
212 BCRec
const* bc_ptr_d = domain_bcs_type_d.data();
215 MultiFab S_pert_cons(ba, dm, S_old[
IntVars::cons].nComp(), ngv_pert, MFInfo(), EBFactory(level));
216 MultiFab rt0(ba, dm, 1, ngv_pert, MFInfo(), EBFactory(level));
219 MultiFab::Copy(S_pert_cons, S_old[
IntVars::cons],0,0,S_pert_cons.nComp(), ngv_pert);
228 MultiFab::Subtract(S_pert_cons, rt0 , 0,1,1,ngv_pert);
232 S_pert_cons, EBFactory(level), bc_ptr_d, slow_dt);
244 for ( MFIter mfi(S_sum[
IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi)
246 const Box bx = mfi.tilebox();
247 Box tbx = mfi.nodaltilebox(0);
248 Box tby = mfi.nodaltilebox(1);
249 Box tbz = mfi.nodaltilebox(2);
251 Vector<Array4<Real> > ssum_h(n_data);
252 Vector<Array4<Real> > sold_h(n_data);
253 Vector<Array4<Real> > fslow_h(n_data);
255 for (
int i = 0; i < n_data; ++i) {
256 ssum_h[i] = S_sum[i].array(mfi);
257 sold_h[i] = S_old[i].array(mfi);
258 fslow_h[i] = F_slow[i].array(mfi);
261 Gpu::AsyncVector<Array4<Real> > sold_d(n_data);
262 Gpu::AsyncVector<Array4<Real> > ssum_d(n_data);
263 Gpu::AsyncVector<Array4<Real> > fslow_d(n_data);
265 Gpu::copy(Gpu::hostToDevice, sold_h.begin(), sold_h.end(), sold_d.begin());
266 Gpu::copy(Gpu::hostToDevice, ssum_h.begin(), ssum_h.end(), ssum_d.begin());
267 Gpu::copy(Gpu::hostToDevice, fslow_h.begin(), fslow_h.end(), fslow_d.begin());
269 Array4<Real>* sold = sold_d.dataPtr();
270 Array4<Real>* ssum = ssum_d.dataPtr();
271 Array4<Real>* fslow = fslow_d.dataPtr();
274 const Array4<const Real>& vfrac_c = (get_eb(level).get_const_factory())->getVolFrac().const_array(mfi);
279 if (vfrac_c(i,j,k) >
zero) {
285 const Array4<const Real>& vfrac_u = (get_eb(level).get_u_const_factory())->getVolFrac().const_array(mfi);
286 const Array4<const Real>& vfrac_v = (get_eb(level).get_v_const_factory())->getVolFrac().const_array(mfi);
287 const Array4<const Real>& vfrac_w = (get_eb(level).get_w_const_factory())->getVolFrac().const_array(mfi);
290 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
291 if (vfrac_u(i,j,k) >
zero) {
296 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
297 if (vfrac_v(i,j,k) >
zero) {
302 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
303 if (vfrac_w(i,j,k) >
zero) {
316 fast_only=
true, vel_and_mom_synced=
false);
318 if (solverChoice.anelastic[level]) {
319 bool have_tb = (thin_xforce[0] || thin_yforce[0] || thin_zforce[0]);
321 project_velocity_tb(level, slow_dt, S_sum);
323 project_momenta(level, time_for_fp, slow_dt, S_sum);
constexpr amrex::Real bogus_large_value
Definition: ERF_Constants.H:26
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
@ v_y
Definition: ERF_DataStruct.H:29
@ u_x
Definition: ERF_DataStruct.H:28
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:39
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:17
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
auto no_substep_fun
Definition: ERF_TI_no_substep_fun.H:4
auto apply_bcs
Definition: ERF_TI_utils.H:34
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:258
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:328
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:845
@ th0_comp
Definition: ERF_IndexDefines.H:79
@ r0_comp
Definition: ERF_IndexDefines.H:76
@ NumTypes
Definition: ERF_IndexDefines.H:236
@ ymom
Definition: ERF_IndexDefines.H:234
@ cons
Definition: ERF_IndexDefines.H:232
@ zmom
Definition: ERF_IndexDefines.H:235
@ xmom
Definition: ERF_IndexDefines.H:233
@ nn
Definition: ERF_WDM6.H:31