diff --git a/Source/TimeIntegration/ERF_Advance.cpp b/Source/TimeIntegration/ERF_Advance.cpp index 197edaddd..6f99b3a0b 100644 --- a/Source/TimeIntegration/ERF_Advance.cpp +++ b/Source/TimeIntegration/ERF_Advance.cpp @@ -35,6 +35,35 @@ ERF::Advance (int lev, Real time, Real dt_lev, int iteration, int /*ncycle*/) MultiFab& V_new = vars_new[lev][Vars::yvel]; MultiFab& W_new = vars_new[lev][Vars::zvel]; + // We need to set these because otherwise in the first call to erf_advance we may + // read uninitialized data on ghost values in setting the bc's on the velocities + U_new.setVal(1.e34,U_new.nGrowVect()); + V_new.setVal(1.e34,V_new.nGrowVect()); + W_new.setVal(1.e34,W_new.nGrowVect()); + + // + // NOTE: the momenta here are not fillpatched (they are only used as scratch space) + // If lev == 0 we have already FillPatched this in ERF::TimeStep + // +// if (lev == 0) { +// FillPatch(lev, time, {&S_old, &U_old, &V_old, &W_old}); +// } else { + if (lev > 0) { + FillPatch(lev, time, {&S_old, &U_old, &V_old, &W_old}, + {&S_old, &rU_old[lev], &rV_old[lev], &rW_old[lev]}, + base_state[lev], base_state[lev]); + } + + // + // So we must convert the fillpatched to momenta, including the ghost values + // + VelocityToMomentum(U_old, rU_old[lev].nGrowVect(), + V_old, rV_old[lev].nGrowVect(), + W_old, rW_old[lev].nGrowVect(), + S_old, rU_old[lev], rV_old[lev], rW_old[lev], + Geom(lev).Domain(), + domain_bcs_type); + // TODO: Can test on multiple levels later // Update the inflow perturbation update time and amplitude if (lev == 0) { @@ -86,33 +115,6 @@ ERF::Advance (int lev, Real time, Real dt_lev, int iteration, int /*ncycle*/) } } - // We need to set these because otherwise in the first call to erf_advance we may - // read uninitialized data on ghost values in setting the bc's on the velocities - U_new.setVal(1.e34,U_new.nGrowVect()); - V_new.setVal(1.e34,V_new.nGrowVect()); - W_new.setVal(1.e34,W_new.nGrowVect()); - - // - // NOTE: the momenta here are not fillpatched (they are only used as scratch space) - // - if (lev == 0) { - FillPatch(lev, time, {&S_old, &U_old, &V_old, &W_old}); - } else { - FillPatch(lev, time, {&S_old, &U_old, &V_old, &W_old}, - {&S_old, &rU_old[lev], &rV_old[lev], &rW_old[lev]}, - base_state[lev], base_state[lev]); - } - - // - // So we must convert the fillpatched to momenta, including the ghost values - // - VelocityToMomentum(U_old, rU_old[lev].nGrowVect(), - V_old, rV_old[lev].nGrowVect(), - W_old, rW_old[lev].nGrowVect(), - S_old, rU_old[lev], rV_old[lev], rW_old[lev], - Geom(lev).Domain(), - domain_bcs_type); - #if defined(ERF_USE_WINDFARM) if (solverChoice.windfarm_type != WindFarmType::None) { advance_windfarm(Geom(lev), dt_lev, S_old, diff --git a/Source/TimeIntegration/ERF_TimeStep.cpp b/Source/TimeIntegration/ERF_TimeStep.cpp index 3460582fd..e512a9a2b 100644 --- a/Source/TimeIntegration/ERF_TimeStep.cpp +++ b/Source/TimeIntegration/ERF_TimeStep.cpp @@ -15,6 +15,26 @@ using namespace amrex; void ERF::timeStep (int lev, Real time, int /*iteration*/) { + // + // We need to FillPatch the coarse level before assessing whether to regrid + // We have not done the swap yet so we fill the "new" which will become the "old" + // + MultiFab& S_new = vars_new[lev][Vars::cons]; + MultiFab& U_new = vars_new[lev][Vars::xvel]; + MultiFab& V_new = vars_new[lev][Vars::yvel]; + MultiFab& W_new = vars_new[lev][Vars::zvel]; + + // + // NOTE: the momenta here are not fillpatched (they are only used as scratch space) + // + if (lev == 0) { + FillPatch(lev, time, {&S_new, &U_new, &V_new, &W_new}); + } else if (lev < finest_level) { + FillPatch(lev, time, {&S_new, &U_new, &V_new, &W_new}, + {&S_new, &rU_new[lev], &rV_new[lev], &rW_new[lev]}, + base_state[lev], base_state[lev]); + } + if (regrid_int > 0) // We may need to regrid { // help keep track of whether a level was already regridded