From b98056163d9c727945fc96161d0fe084b662dfbd Mon Sep 17 00:00:00 2001 From: Ben Prather Date: Fri, 27 Oct 2023 12:32:07 -0600 Subject: [PATCH] Fix an ordering issue in the KHARMA driver --- kharma/driver/kharma_step.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kharma/driver/kharma_step.cpp b/kharma/driver/kharma_step.cpp index 5645958a..58c1dea2 100644 --- a/kharma/driver/kharma_step.cpp +++ b/kharma/driver/kharma_step.cpp @@ -153,29 +153,29 @@ TaskCollection KHARMADriver::MakeDefaultTaskCollection(BlockList_t &blocks, int const KReconstruction::Type& recon = driver_pkg.Get("recon"); auto t_fluxes = KHARMADriver::AddFluxCalculations(t_start_recv_flux, tl, recon, md_sub_step_init.get()); + // Any package modifications to the fluxes. e.g.: + // 1. Flux-CT calculations for B field transport + // 2. Zero fluxes through poles + // etc + auto t_fix_flux = tl.AddTask(t_fluxes, Packages::FixFlux, md_sub_step_init.get()); + // If we're in AMR, correct fluxes from neighbors - auto t_emf = t_fluxes; + auto t_flux_bounds = t_fix_flux; if (pmesh->multilevel || use_b_ct) { - tl.AddTask(t_fluxes, parthenon::LoadAndSendFluxCorrections, md_sub_step_init); - auto t_recv_flux = tl.AddTask(t_fluxes, parthenon::ReceiveFluxCorrections, md_sub_step_init); - auto t_flux_bounds = tl.AddTask(t_recv_flux, parthenon::SetFluxCorrections, md_sub_step_init); auto t_emf = t_flux_bounds; if (use_b_ct) { // Pull out a container of only EMF to synchronize auto &md_b_ct = pmesh->mesh_data.AddShallow("B_CT", std::vector{"B_CT.emf"}); // TODO this gets weird if we partition - auto t_emf_local = tl.AddTask(t_fluxes, B_CT::CalculateEMF, md_sub_step_init.get()); - auto t_emf = KHARMADriver::AddBoundarySync(t_emf_local, tl, md_b_ct); + auto t_emf_local = tl.AddTask(t_flux_bounds, B_CT::CalculateEMF, md_sub_step_init.get()); + t_emf = KHARMADriver::AddBoundarySync(t_emf_local, tl, md_b_ct); } + auto t_load_send_flux = tl.AddTask(t_emf, parthenon::LoadAndSendFluxCorrections, md_sub_step_init); + auto t_recv_flux = tl.AddTask(t_load_send_flux, parthenon::ReceiveFluxCorrections, md_sub_step_init); + t_flux_bounds = tl.AddTask(t_recv_flux, parthenon::SetFluxCorrections, md_sub_step_init); } - // Any package modifications to the fluxes. e.g.: - // 1. Flux-CT calculations for B field transport - // 2. Zero fluxes through poles - // etc - auto t_fix_flux = tl.AddTask(t_emf, Packages::FixFlux, md_sub_step_init.get()); - // Apply the fluxes to calculate a change in cell-centered values "md_flux_src" - auto t_flux_div = tl.AddTask(t_fix_flux, Update::FluxDivergence>, md_sub_step_init.get(), md_flux_src.get()); + auto t_flux_div = tl.AddTask(t_flux_bounds, Update::FluxDivergence>, md_sub_step_init.get(), md_flux_src.get()); // Add any source terms: geometric \Gamma * T, wind, damping, etc etc // Also where CT sets the change in face fields @@ -221,7 +221,7 @@ TaskCollection KHARMADriver::MakeDefaultTaskCollection(BlockList_t &blocks, int md_sub_step_init.get(), md_sub_step_final.get()); } - KHARMADriver::AddBoundarySync(t_copy_prims, tl, md_sync); + KHARMADriver::AddBoundarySync(t_copy_prims | t_update, tl, md_sync); } EndFlag();