| 10 | using namespace amrex; |
| 11 | |
| 12 | void |
| 13 | Castro::construct_old_gravity (Real time) |
| 14 | { |
| 15 | BL_PROFILE("Castro::construct_old_gravity()"); |
| 16 | |
| 17 | const Real strt_time = ParallelDescriptor::second(); |
| 18 | |
| 19 | MultiFab& grav_old = get_old_data(Gravity_Type); |
| 20 | MultiFab& phi_old = get_old_data(PhiGrav_Type); |
| 21 | |
| 22 | // Always set phi to zero initially since some gravity modes |
| 23 | // don't use it and we want to have valid data. |
| 24 | |
| 25 | if (gravity->get_gravity_type() != "PoissonGrav") { |
| 26 | phi_old.setVal(0.0); |
| 27 | } |
| 28 | |
| 29 | if (!do_grav) { |
| 30 | |
| 31 | grav_old.setVal(0.0); |
| 32 | |
| 33 | return; |
| 34 | |
| 35 | } |
| 36 | |
| 37 | // Do level solve at beginning of time step in order to compute the |
| 38 | // difference between the multilevel and the single level solutions. |
| 39 | // Note that we don't need to do this solve for single-level runs, |
| 40 | // since the solution at the end of the last timestep won't have changed. |
| 41 | // Similarly, we can skip this if we aren't subcycling on this level |
| 42 | // or all levels above this level, since the new-time composite solve |
| 43 | // at the new time in the last step will still be valid. |
| 44 | |
| 45 | bool do_old_solve = true; |
| 46 | |
| 47 | if (parent->subcyclingMode() == "None" || parent->finestLevel() == 0) { |
| 48 | do_old_solve = false; |
| 49 | } |
| 50 | |
| 51 | if (gravity->get_gravity_type() == "PoissonGrav" && do_old_solve) |
| 52 | { |
| 53 | // Create a copy of the current (composite) data on this level. |
| 54 | |
| 55 | MultiFab comp_phi; |
| 56 | Vector<std::unique_ptr<MultiFab> > comp_gphi(AMREX_SPACEDIM); |
| 57 | |
| 58 | if (gravity->DoCompositeCorrection() && level < parent->finestLevel() && level <= gravity->get_max_solve_level()) { |
| 59 | |
| 60 | comp_phi.define(phi_old.boxArray(), phi_old.DistributionMap(), phi_old.nComp(), phi_old.nGrow()); |
| 61 | MultiFab::Copy(comp_phi, phi_old, 0, 0, phi_old.nComp(), phi_old.nGrow()); |
| 62 | |
| 63 | for (int n = 0; n < AMREX_SPACEDIM; ++n) { |
| 64 | comp_gphi[n] = std::make_unique<MultiFab>(getEdgeBoxArray(n), dmap, 1, 0); |
| 65 | MultiFab::Copy(*comp_gphi[n], *gravity->get_grad_phi_prev(level)[n], 0, 0, 1, 0); |
| 66 | } |
| 67 | |
| 68 | } |
| 69 |
nothing calls this directly
no test coverage detected