Skip to content

Commit

Permalink
Fix an ordering issue in the KHARMA driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Prather committed Oct 27, 2023
1 parent 5879ca0 commit b980561
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions kharma/driver/kharma_step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,29 +153,29 @@ TaskCollection KHARMADriver::MakeDefaultTaskCollection(BlockList_t &blocks, int
const KReconstruction::Type& recon = driver_pkg.Get<KReconstruction::Type>("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<std::string>{"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<MeshData<Real>>, md_sub_step_init.get(), md_flux_src.get());
auto t_flux_div = tl.AddTask(t_flux_bounds, Update::FluxDivergence<MeshData<Real>>, 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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b980561

Please sign in to comment.