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())
31 for ( MFIter mfi(S_sum[
IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi)
33 const Box bx = mfi.tilebox();
34 Box tbx = mfi.nodaltilebox(0);
35 Box tby = mfi.nodaltilebox(1);
36 Box tbz = mfi.nodaltilebox(2);
38 Vector<Array4<Real> > ssum_h(n_data);
39 Vector<Array4<Real> > sold_h(n_data);
40 Vector<Array4<Real> > fslow_h(n_data);
42 for (
int i = 0; i < n_data; ++i) {
43 ssum_h[i] = S_sum[i].array(mfi);
44 sold_h[i] = S_old[i].array(mfi);
45 fslow_h[i] = F_slow[i].array(mfi);
48 Gpu::AsyncVector<Array4<Real> > sold_d(n_data);
49 Gpu::AsyncVector<Array4<Real> > ssum_d(n_data);
50 Gpu::AsyncVector<Array4<Real> > fslow_d(n_data);
52 Gpu::copy(Gpu::hostToDevice, sold_h.begin(), sold_h.end(), sold_d.begin());
53 Gpu::copy(Gpu::hostToDevice, ssum_h.begin(), ssum_h.end(), ssum_d.begin());
54 Gpu::copy(Gpu::hostToDevice, fslow_h.begin(), fslow_h.end(), fslow_d.begin());
56 Array4<Real>* sold = sold_d.dataPtr();
57 Array4<Real>* ssum = ssum_d.dataPtr();
58 Array4<Real>* fslow = fslow_d.dataPtr();
61 if ( solverChoice.terrain_type == TerrainType::MovingFittedMesh )
63 const Array4<const Real>& dJ_old = detJ_cc[level]->const_array(mfi);
64 const Array4<const Real>& dJ_new = detJ_cc_new[level]->const_array(mfi);
65 const Array4<const Real>& dJ_stg = detJ_cc_src[level]->const_array(mfi);
67 const Array4<const Real>& z_nd_old = z_phys_nd[level]->const_array(mfi);
68 const Array4<const Real>& z_nd_new = z_phys_nd_new[level]->const_array(mfi);
70 const Array4<const Real>& mf_u = mapfac[level][
MapFacType::u_x]->const_array(mfi);
71 const Array4<const Real>& mf_v = mapfac[level][
MapFacType::v_y]->const_array(mfi);
73 const Array4<Real >& z_t_arr = z_t_rk[level]->array(mfi);
77 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int nn) {
86 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
92 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
99 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
106 mf_u, mf_v, z_nd_new,
dxInv);
108 Real dJ_old_kface =
myhalf * (dJ_old(i,j,k) + dJ_old(i,j,k-1));
109 Real dJ_new_kface =
myhalf * (dJ_new(i,j,k) + dJ_new(i,j,k-1));
116 const Array4<const Real>& dJ_old = detJ_cc[level]->const_array(mfi);
118 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k,
int nn) {
120 if (dJ_old(i,j,k) >
zero) {
129 if (solverChoice.terrain_type == TerrainType::EB)
131 const Array4<const Real>& vfrac_u = (get_eb(level).get_u_const_factory())->getVolFrac().const_array(mfi);
132 const Array4<const Real>& vfrac_v = (get_eb(level).get_v_const_factory())->getVolFrac().const_array(mfi);
133 const Array4<const Real>& vfrac_w = (get_eb(level).get_w_const_factory())->getVolFrac().const_array(mfi);
136 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
137 if (vfrac_u(i,j,k) >
zero) {
145 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
146 if (vfrac_v(i,j,k) >
zero) {
154 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
155 if (vfrac_w(i,j,k) >
zero) {
166 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
170 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
174 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
182 if (solverChoice.terrain_type == TerrainType::EB)
184 BL_PROFILE(
"no_substep_fun_redistribute");
189 for (
int i = 1; i <= AMREX_SPACEDIM; ++i) {
190 dUdt[i].define(F_slow[i].boxArray(), F_slow[i].DistributionMap(), F_slow[i].nComp(), F_slow[i].nGrow(), MFInfo());
192 for (
int i = 0; i <= AMREX_SPACEDIM; ++i) {
193 dUdt[i].setVal(0, 0, ncomp_fast[i], dUdt[i].nGrow());
194 MultiFab::Copy(dUdt[i], F_slow[i], 0, 0, F_slow[i].nComp(), 0);
195 dUdt[i].setDomainBndry(bogus_large_value_d, 0, ncomp_fast[i], fine_geom);
196 dUdt[i].FillBoundary(fine_geom.periodicity());
199 BCRec
const* bc_ptr_d = domain_bcs_type_d.data();
202 MultiFab S_pert_cons(ba, dm, S_old[
IntVars::cons].nComp(), ngv_pert, MFInfo(), EBFactory(level));
203 MultiFab rt0(ba, dm, 1, ngv_pert, MFInfo(), EBFactory(level));
206 MultiFab::Copy(S_pert_cons, S_old[
IntVars::cons],0,0,S_pert_cons.nComp(), ngv_pert);
215 MultiFab::Subtract(S_pert_cons, rt0 , 0,1,1,ngv_pert);
219 S_pert_cons, EBFactory(level), bc_ptr_d, slow_dt);
231 for ( MFIter mfi(S_sum[
IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi)
233 const Box bx = mfi.tilebox();
234 Box tbx = mfi.nodaltilebox(0);
235 Box tby = mfi.nodaltilebox(1);
236 Box tbz = mfi.nodaltilebox(2);
238 Vector<Array4<Real> > ssum_h(n_data);
239 Vector<Array4<Real> > sold_h(n_data);
240 Vector<Array4<Real> > fslow_h(n_data);
242 for (
int i = 0; i < n_data; ++i) {
243 ssum_h[i] = S_sum[i].array(mfi);
244 sold_h[i] = S_old[i].array(mfi);
245 fslow_h[i] = F_slow[i].array(mfi);
248 Gpu::AsyncVector<Array4<Real> > sold_d(n_data);
249 Gpu::AsyncVector<Array4<Real> > ssum_d(n_data);
250 Gpu::AsyncVector<Array4<Real> > fslow_d(n_data);
252 Gpu::copy(Gpu::hostToDevice, sold_h.begin(), sold_h.end(), sold_d.begin());
253 Gpu::copy(Gpu::hostToDevice, ssum_h.begin(), ssum_h.end(), ssum_d.begin());
254 Gpu::copy(Gpu::hostToDevice, fslow_h.begin(), fslow_h.end(), fslow_d.begin());
256 Array4<Real>* sold = sold_d.dataPtr();
257 Array4<Real>* ssum = ssum_d.dataPtr();
258 Array4<Real>* fslow = fslow_d.dataPtr();
261 const Array4<const Real>& vfrac_c = (get_eb(level).get_const_factory())->getVolFrac().const_array(mfi);
266 if (vfrac_c(i,j,k) >
zero) {
272 const Array4<const Real>& vfrac_u = (get_eb(level).get_u_const_factory())->getVolFrac().const_array(mfi);
273 const Array4<const Real>& vfrac_v = (get_eb(level).get_v_const_factory())->getVolFrac().const_array(mfi);
274 const Array4<const Real>& vfrac_w = (get_eb(level).get_w_const_factory())->getVolFrac().const_array(mfi);
277 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
278 if (vfrac_u(i,j,k) >
zero) {
283 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
284 if (vfrac_v(i,j,k) >
zero) {
289 [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept {
290 if (vfrac_w(i,j,k) >
zero) {
303 fast_only=
true, vel_and_mom_synced=
false);
305 if (solverChoice.anelastic[level]) {
306 bool have_tb = (thin_xforce[0] || thin_yforce[0] || thin_zforce[0]);
308 project_velocity_tb(level, slow_dt, S_sum);
310 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:25
@ u_x
Definition: ERF_DataStruct.H:24
void redistribute_term(int ncomp, const Geometry &geom, MultiFab &result, MultiFab &result_tmp, MultiFab const &state, EBFArrayBoxFactory const &ebfact, BCRec const *bc, double local_dt_d)
Definition: ERF_EBRedistribute.cpp:13
#define Rho_comp
Definition: ERF_IndexDefines.H:36
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:17
ParallelFor(grown_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:104
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:144
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:464
@ th0_comp
Definition: ERF_IndexDefines.H:76
@ r0_comp
Definition: ERF_IndexDefines.H:73
@ NumTypes
Definition: ERF_IndexDefines.H:197
@ ymom
Definition: ERF_IndexDefines.H:195
@ cons
Definition: ERF_IndexDefines.H:193
@ zmom
Definition: ERF_IndexDefines.H:196
@ xmom
Definition: ERF_IndexDefines.H:194