diff --git a/Source/driver/Castro_advance_ctu.cpp b/Source/driver/Castro_advance_ctu.cpp index 7659f445a2..01d2e7a1d3 100644 --- a/Source/driver/Castro_advance_ctu.cpp +++ b/Source/driver/Castro_advance_ctu.cpp @@ -31,19 +31,6 @@ Castro::do_advance_ctu (Real time, Real dt) MultiFab& S_new = get_new_data(State_Type); - MultiFab& old_source = get_old_data(Source_Type); - MultiFab& new_source = get_new_data(Source_Type); - -#ifdef MHD - MultiFab& Bx_old = get_old_data(Mag_Type_x); - MultiFab& By_old = get_old_data(Mag_Type_y); - MultiFab& Bz_old = get_old_data(Mag_Type_z); - - MultiFab& Bx_new = get_new_data(Mag_Type_x); - MultiFab& By_new = get_new_data(Mag_Type_y); - MultiFab& Bz_new = get_new_data(Mag_Type_z); -#endif - // Perform initialization steps. status = initialize_do_advance(time, dt); @@ -77,11 +64,7 @@ Castro::do_advance_ctu (Real time, Real dt) construct_old_gravity(prev_time); #endif - do_old_sources( -#ifdef MHD - Bx_old, By_old, Bz_old, -#endif - old_source, Sborder, S_new, prev_time, dt); + do_old_sources(prev_time, dt); #ifdef SIMPLIFIED_SDC #ifdef REACTIONS @@ -116,11 +99,7 @@ Castro::do_advance_ctu (Real time, Real dt) construct_new_gravity(cur_time); #endif - do_new_sources( -#ifdef MHD - Bx_new, By_new, Bz_new, -#endif - new_source, Sborder, S_new, cur_time, dt); + do_new_sources(cur_time, dt); // If the state has ghost zones, sync them up now since the hydro // source and new-time sources only work on the valid zones. diff --git a/Source/sources/Castro_sources.H b/Source/sources/Castro_sources.H index b4ac46288c..1e765bcb01 100644 --- a/Source/sources/Castro_sources.H +++ b/Source/sources/Castro_sources.H @@ -47,6 +47,16 @@ amrex::Real time, amrex::Real dt, bool apply_to_state = true); +/// +/// Construct source terms at old time (convenience wrapper for CTU advance) +/// +/// @param time the current simulation time +/// @param dt the timestep to advance (e.g., go from time to +/// time + dt) +/// + void do_old_sources (amrex::Real time, amrex::Real dt); + + /// /// Construct the old-time source /// @@ -83,6 +93,16 @@ amrex::Real time, amrex::Real dt, bool apply_to_state = true); +/// +/// Construct new time sources (convenience wrapper for CTU advance) +/// +/// @param time the current simulation time +/// @param dt the timestep to advance (e.g., go from time to +/// time + dt) +/// + void do_new_sources (amrex::Real time, amrex::Real dt); + + /// /// Construct the new-time sources. /// diff --git a/Source/sources/Castro_sources.cpp b/Source/sources/Castro_sources.cpp index 86bc343d1e..bcdb1884b2 100644 --- a/Source/sources/Castro_sources.cpp +++ b/Source/sources/Castro_sources.cpp @@ -172,7 +172,26 @@ Castro::do_old_sources( }); #endif } +} + +void +Castro::do_old_sources (Real time, Real dt) +{ + MultiFab& S_new = get_new_data(State_Type); + + MultiFab& old_source = get_old_data(Source_Type); +#ifdef MHD + MultiFab& Bx_old = get_old_data(Mag_Type_x); + MultiFab& By_old = get_old_data(Mag_Type_y); + MultiFab& Bz_old = get_old_data(Mag_Type_z); +#endif + + do_old_sources( +#ifdef MHD + Bx_old, By_old, Bz_old, +#endif + old_source, Sborder, S_new, time, dt); } void @@ -235,6 +254,26 @@ Castro::do_new_sources( } +void +Castro::do_new_sources (Real time, Real dt) +{ + MultiFab& S_new = get_new_data(State_Type); + + MultiFab& new_source = get_new_data(Source_Type); + +#ifdef MHD + MultiFab& Bx_new = get_new_data(Mag_Type_x); + MultiFab& By_new = get_new_data(Mag_Type_y); + MultiFab& Bz_new = get_new_data(Mag_Type_z); +#endif + + do_new_sources( +#ifdef MHD + Bx_new, By_new, Bz_new, +#endif + new_source, Sborder, S_new, time, dt); +} + void Castro::construct_old_source(int src, MultiFab& source, MultiFab& state_in, Real time, Real dt) {