Skip to content

Commit

Permalink
Bump Parthenon and update interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrete committed Aug 8, 2024
1 parent f9e230f commit 2a5a7fb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion external/parthenon
6 changes: 3 additions & 3 deletions src/hydro/hydro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ TaskStatus CalculateFluxes(std::shared_ptr<MeshData<Real>> &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;
Expand Down Expand Up @@ -299,7 +299,7 @@ TaskStatus CalculateFluxes(std::shared_ptr<MeshData<Real>> &md) {
parthenon::ScratchPad2D<Real>::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;
Expand Down
24 changes: 11 additions & 13 deletions src/hydro/hydro_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>, mu0);
tl.AddTask(none, parthenon::cell_centered_bvars::StartReceiveFluxCorrections, mu0);
tl.AddTask(none, parthenon::StartReceiveBoundBufs<any>, 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
Expand All @@ -101,18 +98,19 @@ 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);
for (int i = 0; i < blocks.size(); i++) {
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);
Expand Down
13 changes: 6 additions & 7 deletions src/pgen/linear_wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
#include <cstdio> // fopen(), fprintf(), freopen()
#include <iostream> // endl
#include <sstream> // stringstream
#include <stdexcept> // runtime_error
#include <string> // c_str()

// Parthenon headers
#include "mesh/mesh.hpp"
#include <parthenon/driver.hpp>
#include <parthenon/package.hpp>

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 2a5a7fb

Please sign in to comment.