From 2a5a7fb41e577d6126ecdc322053cde2611aaaa8 Mon Sep 17 00:00:00 2001 From: Philipp Grete Date: Thu, 8 Aug 2024 20:25:32 +0200 Subject: [PATCH] Bump Parthenon and update interfaces --- external/parthenon | 2 +- src/hydro/hydro.cpp | 6 +++--- src/hydro/hydro_driver.cpp | 24 +++++++++++------------- src/pgen/linear_wave.cpp | 13 ++++++------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/external/parthenon b/external/parthenon index a619994..8feea2c 160000 --- a/external/parthenon +++ b/external/parthenon @@ -1 +1 @@ -Subproject commit a61999403a09a2946bd6ae40b5140169833b844a +Subproject commit 8feea2c9cc48789adc1de5d48b36305e18c352da diff --git a/src/hydro/hydro.cpp b/src/hydro/hydro.cpp index 9aa9d51..e36e67e 100644 --- a/src/hydro/hydro.cpp +++ b/src/hydro/hydro.cpp @@ -248,8 +248,8 @@ TaskStatus CalculateFluxes(std::shared_ptr> &md) { int il, iu, jl, ju, kl, ku; jl = jb.s, ju = jb.e, kl = kb.s, ku = kb.e; // TODO(pgrete): are these looop limits are likely too large for 2nd order - if (pmb->block_size.nx2 > 1) { - if (pmb->block_size.nx3 == 1) // 2D + if (pmb->block_size.nx(X2DIR) > 1) { + if (pmb->block_size.nx(X3DIR) == 1) // 2D jl = jb.s - 1, ju = jb.e + 1, kl = kb.s, ku = kb.e; else // 3D jl = jb.s - 1, ju = jb.e + 1, kl = kb.s - 1, ku = kb.e + 1; @@ -299,7 +299,7 @@ TaskStatus CalculateFluxes(std::shared_ptr> &md) { parthenon::ScratchPad2D::shmem_size(num_scratch_vars, nx1) * 3; // set the loop limits il = ib.s - 1, iu = ib.e + 1, kl = kb.s, ku = kb.e; - if (pmb->block_size.nx3 == 1) // 2D + if (pmb->block_size.nx(X3DIR) == 1) // 2D kl = kb.s, ku = kb.e; else // 3D kl = kb.s - 1, ku = kb.e + 1; diff --git a/src/hydro/hydro_driver.cpp b/src/hydro/hydro_driver.cpp index 28f2d1b..8c76fa8 100644 --- a/src/hydro/hydro_driver.cpp +++ b/src/hydro/hydro_driver.cpp @@ -77,19 +77,16 @@ TaskCollection HydroDriver::MakeTaskCollection(BlockList_t &blocks, int stage) { auto &tl = single_tasklist_per_pack_region[i]; auto &mu0 = pmesh->mesh_data.GetOrAdd("base", i); const auto any = parthenon::BoundaryType::any; - tl.AddTask(none, parthenon::cell_centered_bvars::StartReceiveBoundBufs, mu0); - tl.AddTask(none, parthenon::cell_centered_bvars::StartReceiveFluxCorrections, mu0); + tl.AddTask(none, parthenon::StartReceiveBoundBufs, mu0); + tl.AddTask(none, parthenon::StartReceiveFluxCorrections, mu0); // Calculate fluxes (will be stored in the x1, x2, x3 flux arrays of each var) auto calc_flux = tl.AddTask(none, CalculateFluxes, mu0); // Correct for fluxes across levels (to maintain conservative nature of update) - auto send_flx = tl.AddTask( - calc_flux, parthenon::cell_centered_bvars::LoadAndSendFluxCorrections, mu0); - auto recv_flx = tl.AddTask( - calc_flux, parthenon::cell_centered_bvars::ReceiveFluxCorrections, mu0); - auto set_flx = - tl.AddTask(recv_flx, parthenon::cell_centered_bvars::SetFluxCorrections, mu0); + auto send_flx = tl.AddTask(calc_flux, parthenon::LoadAndSendFluxCorrections, mu0); + auto recv_flx = tl.AddTask(calc_flux, parthenon::ReceiveFluxCorrections, mu0); + auto set_flx = tl.AddTask(recv_flx, parthenon::SetFluxCorrections, mu0); auto &mu1 = pmesh->mesh_data.GetOrAdd("u1", i); // Compute the divergence of fluxes of conserved variables @@ -101,8 +98,7 @@ TaskCollection HydroDriver::MakeTaskCollection(BlockList_t &blocks, int stage) { // Update ghost cells (local and non local) // Note that Parthenon also support to add those tasks manually for more fine-grained // control. - parthenon::cell_centered_bvars::AddBoundaryExchangeTasks(update, tl, mu0, - pmesh->multilevel); + parthenon::AddBoundaryExchangeTasks(update, tl, mu0, pmesh->multilevel); } TaskRegion &async_region_3 = tc.AddRegion(num_task_lists_executed_independently); @@ -110,9 +106,11 @@ TaskCollection HydroDriver::MakeTaskCollection(BlockList_t &blocks, int stage) { auto &tl = async_region_3[i]; auto &u0 = blocks[i]->meshblock_data.Get("base"); auto prolongBound = none; - if (pmesh->multilevel) { - prolongBound = tl.AddTask(none, parthenon::ProlongateBoundaries, u0); - } + // Currently taken care of by AddBoundaryExchangeTasks above. + // Needs to be reintroduced once we reintroduce split (local/nonlocal) communication. + // if (pmesh->multilevel) { + // prolongBound = tl.AddTask(none, parthenon::ProlongateBoundaries, u0); + // } // set physical boundaries auto set_bc = tl.AddTask(prolongBound, parthenon::ApplyBoundaryConditions, u0); diff --git a/src/pgen/linear_wave.cpp b/src/pgen/linear_wave.cpp index ac98c06..13c081e 100644 --- a/src/pgen/linear_wave.cpp +++ b/src/pgen/linear_wave.cpp @@ -19,11 +19,9 @@ #include // fopen(), fprintf(), freopen() #include // endl #include // stringstream -#include // runtime_error #include // c_str() // Parthenon headers -#include "mesh/mesh.hpp" #include #include @@ -32,6 +30,7 @@ namespace linear_wave { using namespace parthenon::driver::prelude; +using namespace parthenon::package::prelude; // TODO(pgrete) temp fix to address removal in Parthenon. Update when merging with MHD constexpr int NWAVE = 5; @@ -275,9 +274,9 @@ void UserWorkAfterLoop(Mesh *mesh, ParameterInput *pin, parthenon::SimTime &tm) if (parthenon::Globals::my_rank == 0) { // normalize errors by number of cells const auto mesh_size = mesh->mesh_size; - const auto vol = (mesh_size.x1max - mesh_size.x1min) * - (mesh_size.x2max - mesh_size.x2min) * - (mesh_size.x3max - mesh_size.x3min); + const auto vol = (mesh_size.xmax(X1DIR) - mesh_size.xmin(X1DIR)) * + (mesh_size.xmax(X2DIR) - mesh_size.xmin(X2DIR)) * + (mesh_size.xmax(X3DIR) - mesh_size.xmin(X3DIR)); for (int i = 0; i < (NHYDRO + NFIELD); ++i) l1_err[i] = l1_err[i] / vol; // compute rms error @@ -315,8 +314,8 @@ void UserWorkAfterLoop(Mesh *mesh, ParameterInput *pin, parthenon::SimTime &tm) } // write errors - std::fprintf(pfile, "%d %d", mesh_size.nx1, mesh_size.nx2); - std::fprintf(pfile, " %d %d", mesh_size.nx3, tm.ncycle); + std::fprintf(pfile, "%d %d", mesh_size.nx(X1DIR), mesh_size.nx(X2DIR)); + std::fprintf(pfile, " %d %d", mesh_size.nx(X3DIR), tm.ncycle); std::fprintf(pfile, " %e %e", rms_err, l1_err[IDN]); std::fprintf(pfile, " %e %e %e", l1_err[IM1], l1_err[IM2], l1_err[IM3]); std::fprintf(pfile, " %e", l1_err[IEN]);