diff --git a/example/poisson_gmg/poisson_driver.cpp b/example/poisson_gmg/poisson_driver.cpp index f2ea76fe22fd..49eefe1164c4 100644 --- a/example/poisson_gmg/poisson_driver.cpp +++ b/example/poisson_gmg/poisson_driver.cpp @@ -75,14 +75,16 @@ TaskCollection PoissonDriver::MakeTaskCollection(BlockList_t &blocks) { auto &md_rhs = pmesh->mesh_data.Add("rhs", md, {u::name()}); // Move the rhs variable into the rhs stage for stage based solver - auto copy_rhs = tl.AddTask(none, TF(solvers::utils::CopyDataBetweenFields), md); + auto copy_rhs = + tl.AddTask(none, TF(solvers::utils::between_fields::CopyData), md); copy_rhs = tl.AddTask(copy_rhs, TF(solvers::utils::CopyData>), md, md_rhs); // Possibly set rhs <- A.u_exact for a given u_exact so that the exact solution is // known when we solve A.u = rhs if (use_exact_rhs) { - auto copy_exact = tl.AddTask(copy_rhs, TF(solvers::utils::CopyDataBetweenFields), md); + auto copy_exact = tl.AddTask( + copy_rhs, TF(solvers::utils::between_fields::CopyData), md); copy_exact = tl.AddTask( copy_exact, TF(solvers::utils::CopyData>), md, md_u); auto comm = AddBoundaryExchangeTasks(copy_exact, tl, md_u, true); @@ -103,8 +105,9 @@ TaskCollection PoissonDriver::MakeTaskCollection(BlockList_t &blocks) { auto copy_back = tl.AddTask( solve, TF(solvers::utils::CopyData>), md_u, md); auto diff = tl.AddTask( - copy_back, TF(solvers::utils::AddFieldsAndStore), md, 1.0, -1.0); - auto get_err = solvers::utils::DotProduct(diff, tl, &err, md); + copy_back, TF(solvers::utils::between_fields::AddFieldsAndStore), + md, 1.0, -1.0); + auto get_err = solvers::utils::between_fields::DotProduct(diff, tl, &err, md); tl.AddTask( get_err, [](PoissonDriver *driver, int partition) { diff --git a/src/solvers/solver_utils.hpp b/src/solvers/solver_utils.hpp index 21cb36c24ccf..23372650d781 100644 --- a/src/solvers/solver_utils.hpp +++ b/src/solvers/solver_utils.hpp @@ -148,8 +148,10 @@ struct Stencil { }; namespace utils { + +namespace between_fields { template -TaskStatus CopyDataBetweenFields(const std::shared_ptr> &md) { +TaskStatus CopyData(const std::shared_ptr> &md) { using TE = parthenon::TopologicalElement; TE te = TE::CC; IndexRange ib = md->GetBoundsI(IndexDomain::entire, te); @@ -177,6 +179,7 @@ TaskStatus CopyDataBetweenFields(const std::shared_ptr> &md) { }); return TaskStatus::complete; } +} // namespace between_fields template TaskStatus CopyData(const std::shared_ptr> &md_in, @@ -245,6 +248,10 @@ TaskStatus SetToZero(const std::shared_ptr> &md) { return TaskStatus::complete; } +// Utilities functions in the between_fields namespace work on separate fields specified +// by types. Other utility functions work on the same list of fields across separate +// MeshData containers. +namespace between_fields { template TaskStatus AddFieldsAndStoreInteriorSelect(const std::shared_ptr> &md, Real wa = 1.0, Real wb = 1.0, @@ -292,6 +299,7 @@ TaskStatus AddFieldsAndStore(const std::shared_ptr> &md, Real wa return AddFieldsAndStoreInteriorSelect( md, wa, wb, false); } +} // namespace between_fields template TaskStatus AddFieldsAndStoreInteriorSelect(const std::shared_ptr> &md_a, @@ -347,6 +355,7 @@ TaskStatus AddFieldsAndStore(const std::shared_ptr> &md_a, wa, wb, false); } +namespace between_fields { template TaskStatus ADividedByB(const std::shared_ptr> &md) { IndexRange ib = md->GetBoundsI(IndexDomain::interior); @@ -367,6 +376,7 @@ TaskStatus ADividedByB(const std::shared_ptr> &md) { }); return TaskStatus::complete; } +} // namespace between_fields template TaskStatus ADividedByB(const std::shared_ptr> &md_a, @@ -391,6 +401,7 @@ TaskStatus ADividedByB(const std::shared_ptr> &md_a, return TaskStatus::complete; } +namespace between_fields { template TaskStatus DotProductLocal(const std::shared_ptr> &md, AllReduce *adotb) { @@ -439,6 +450,7 @@ TaskID DotProduct(TaskID dependency_in, TaskList &tl, AllReduce *adotb, start_global_adotb, &AllReduce::CheckReduce, adotb); return finish_global_adotb; } +} // namespace between_fields template TaskStatus GlobalMinLocal(const std::shared_ptr> &md,