From 338c1763af8a706971fef5ff78e2aa483011fe97 Mon Sep 17 00:00:00 2001 From: Jonah Maxwell Miller Date: Wed, 6 Dec 2023 19:37:23 -0700 Subject: [PATCH 1/8] first pack converted --- src/fluid/fluid.cpp | 82 +++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 47 deletions(-) diff --git a/src/fluid/fluid.cpp b/src/fluid/fluid.cpp index f870c6fa..bca3bce5 100644 --- a/src/fluid/fluid.cpp +++ b/src/fluid/fluid.cpp @@ -28,6 +28,7 @@ #include "tmunu.hpp" #include +#include #include #include #include @@ -350,43 +351,30 @@ TaskStatus PrimitiveToConservedRegion(MeshBlockData *rc, const IndexRange namespace p = fluid_prim; namespace c = fluid_cons; namespace impl = internal_variables; + using parthenon::MakePackDescriptor; + auto *pmb = rc->GetParentPointer(); + auto &resolved_pkgs = pmb->resolved_packages; - const std::vector vars( - {p::density::name(), c::density::name(), p::velocity::name(), c::momentum::name(), - p::energy::name(), c::energy::name(), p::bfield::name(), c::bfield::name(), - p::ye::name(), c::ye::name(), p::pressure::name(), p::gamma1::name(), - impl::cell_signal_speed::name()}); + static auto desc = + MakePackDescriptor(resolved_pkgs.get()); + auto v = desc.GetPack(rc); - PackIndexMap imap; - auto v = rc->PackVariables(vars, imap); - - const int prho = imap[p::density::name()].first; - const int crho = imap[c::density::name()].first; - const int pvel_lo = imap[p::velocity::name()].first; - const int pvel_hi = imap[p::velocity::name()].second; - const int cmom_lo = imap[c::momentum::name()].first; - const int cmom_hi = imap[c::momentum::name()].second; - const int peng = imap[p::energy::name()].first; - const int ceng = imap[c::energy::name()].first; - const int prs = imap[p::pressure::name()].first; - const int gm1 = imap[p::gamma1::name()].first; - const int pb_lo = imap[p::bfield::name()].first; - const int pb_hi = imap[p::bfield::name()].second; - const int cb_lo = imap[c::bfield::name()].first; - const int cb_hi = imap[c::bfield::name()].second; - const int pye = imap[p::ye::name()].second; // -1 if not present - const int cye = imap[c::ye::name()].second; - const int sig_lo = imap[impl::cell_signal_speed::name()].first; - const int sig_hi = imap[impl::cell_signal_speed::name()].second; + // We need these to check whether or not these variables are present + // in the pack. They are -1 if not present. + const int pb_hi = v.GetUpperBoundHost(0, p::bfield()); + const int pye = v.GetUpperBoundHost(0, p::ye()); auto geom = Geometry::GetCoordinateSystem(rc); - auto coords = pmb->coords; + const int nblocks = v.GetNBlocks(); parthenon::par_for( - DEFAULT_LOOP_PATTERN, "PrimToCons", DevExecSpace(), 0, v.GetDim(5) - 1, kb.s, kb.e, + DEFAULT_LOOP_PATTERN, "PrimToCons", DevExecSpace(), 0, nblocks - 1, kb.s, kb.e, jb.s, jb.e, ib.s, ib.e, KOKKOS_LAMBDA(const int b, const int k, const int j, const int i) { + auto &coords = v.GetCoordinates(b); Real gcov4[4][4]; geom.SpacetimeMetric(CellLocation::Cent, k, j, i, gcov4); Real gcon[3][3]; @@ -397,43 +385,43 @@ TaskStatus PrimitiveToConservedRegion(MeshBlockData *rc, const IndexRange geom.ContravariantShift(CellLocation::Cent, k, j, i, shift); Real S[3]; - const Real vel[] = {v(b, pvel_lo, k, j, i), v(b, pvel_lo + 1, k, j, i), - v(b, pvel_hi, k, j, i)}; + const Real vel[] = {v(b, p::velocity(0), k, j, i), v(b, p::velocity(1), k, j, i), + v(b, p::velocity(2), k, j, i)}; Real bcons[3]; Real bp[3] = {0.0, 0.0, 0.0}; if (pb_hi > 0) { - bp[0] = v(b, pb_lo, k, j, i); - bp[1] = v(b, pb_lo + 1, k, j, i); - bp[2] = v(b, pb_hi, k, j, i); + for (int d = 0; d < 3; ++d) { + bp[d] = v(b, p::bfield(d), k, j, i); + } } Real ye_cons; Real ye_prim = 0.0; if (pye > 0) { - ye_prim = v(b, pye, k, j, i); + ye_prim = v(b, p::ye(), k, j, i); } Real sig[3]; - prim2con::p2c(v(b, prho, k, j, i), vel, bp, v(b, peng, k, j, i), ye_prim, - v(b, prs, k, j, i), v(b, gm1, k, j, i), gcov4, gcon, shift, lapse, - gdet, v(b, crho, k, j, i), S, bcons, v(b, ceng, k, j, i), ye_cons, - sig); + prim2con::p2c(v(b, p::density(), k, j, i), vel, bp, v(b, p::energy(), k, j, i), + ye_prim, v(b, p::pressure(), k, j, i), v(b, p::gamma1(), k, j, i), + gcov4, gcon, shift, lapse, gdet, v(b, c::density(), k, j, i), S, + bcons, v(b, c::energy(), k, j, i), ye_cons, sig); - v(b, cmom_lo, k, j, i) = S[0]; - v(b, cmom_lo + 1, k, j, i) = S[1]; - v(b, cmom_hi, k, j, i) = S[2]; + for (int d = 0; d < 3; ++d) { + v(b, c::momentum(d), k, j, i) = S[d]; + } if (pb_hi > 0) { - v(b, cb_lo, k, j, i) = bcons[0]; - v(b, cb_lo + 1, k, j, i) = bcons[1]; - v(b, cb_hi, k, j, i) = bcons[2]; + for (int d = 0; d < 3; ++d) { + v(b, c::bfield(d), k, j, i) = bcons[d]; + } } if (pye > 0) { - v(b, cye, k, j, i) = ye_cons; + v(b, c::ye(), k, j, i) = ye_cons; } - for (int m = sig_lo; m <= sig_hi; m++) { - v(b, m, k, j, i) = sig[m - sig_lo]; + for (int d = 0; d < 3; d++) { + v(b, impl::cell_signal_speed(d), k, j, i) = sig[d]; } }); From 94d03c7eea4b52f99704d94e341339ecf7d67f80 Mon Sep 17 00:00:00 2001 From: Jonah Maxwell Miller Date: Thu, 7 Dec 2023 09:57:50 -0700 Subject: [PATCH 2/8] ported over source terms and tmunu to sparse packs --- src/fluid/fluid.cpp | 58 ++++++++++++++++----------------- src/fluid/tmunu.hpp | 40 +++++++++++++---------- src/phoebus_utils/variables.hpp | 10 ++++++ 3 files changed, 61 insertions(+), 47 deletions(-) diff --git a/src/fluid/fluid.cpp b/src/fluid/fluid.cpp index bca3bce5..b92c781b 100644 --- a/src/fluid/fluid.cpp +++ b/src/fluid/fluid.cpp @@ -536,6 +536,10 @@ TaskStatus CalculateFluidSourceTerms(MeshBlockData *rc, MeshBlockData *rc_src) { constexpr int ND = Geometry::NDFULL; constexpr int NS = Geometry::NDSPACE; + using phoebus::MakePackDescriptor; + namespace c = fluid_cons; + namespace diag = diagnostic_variables; + Mesh *pmesh = rc->GetMeshPointer(); auto &fluid = pmesh->packages.Get("fluid"); if (!fluid->Param("active") || fluid->Param("zero_sources")) @@ -545,37 +549,35 @@ TaskStatus CalculateFluidSourceTerms(MeshBlockData *rc, IndexRange jb = rc->GetBoundsJ(IndexDomain::interior); IndexRange kb = rc->GetBoundsK(IndexDomain::interior); - std::vector vars( - {fluid_cons::momentum::name(), fluid_cons::energy::name()}); + static auto desc = MakePackDescriptorPackVariables(vars, imap); - const int cmom_lo = imap[fluid_cons::momentum::name()].first; - const int cmom_hi = imap[fluid_cons::momentum::name()].second; - const int ceng = imap[fluid_cons::energy::name()].first; - const int idiag = imap[diagnostic_variables::src_terms::name()].first; - + >(rc); + auto src = desc.GetPack(rc_src); auto tmunu = BuildStressEnergyTensor(rc); auto geom = Geometry::GetCoordinateSystem(rc); + const int nblocks = src.GetNBlocks(); parthenon::par_for( - DEFAULT_LOOP_PATTERN, "TmunuSourceTerms", DevExecSpace(), kb.s, kb.e, jb.s, jb.e, - ib.s, ib.e, KOKKOS_LAMBDA(const int k, const int j, const int i) { + DEFAULT_LOOP_PATTERN, "TmunuSourceTerms", DevExecSpace(), 0, nblocks - 1, kb.s, + kb.e, jb.s, jb.e, ib.s, ib.e, + KOKKOS_LAMBDA(const int b, const int k, const int j, const int i) { Real Tmunu[ND][ND], dg[ND][ND][ND], gam[ND][ND][ND]; - tmunu(Tmunu, k, j, i); - Real gdet = geom.DetG(CellLocation::Cent, k, j, i); + tmunu(Tmunu, b, k, j, i); + Real gdet = geom.DetG(CellLocation::Cent, b, k, j, i); - geom.MetricDerivative(CellLocation::Cent, k, j, i, dg); + geom.MetricDerivative(CellLocation::Cent, b, k, j, i, dg); Geometry::Utils::SetConnectionCoeffFromMetricDerivs(dg, gam); + // momentum source terms SPACELOOP(l) { Real src_mom = 0.0; SPACETIMELOOP2(m, n) { src_mom += Tmunu[m][n] * (dg[n][l + 1][m] - gam[l + 1][n][m]); } - src(cmom_lo + l, k, j, i) = gdet * src_mom; + src(b, c::momentum(l), k, j, i) = gdet * src_mom; } // energy source term @@ -583,10 +585,10 @@ TaskStatus CalculateFluidSourceTerms(MeshBlockData *rc, Real TGam = 0.0; #if USE_VALENCIA // TODO(jcd): maybe use the lapse and shift here instead of gcon - const Real alpha = geom.Lapse(CellLocation::Cent, k, j, i); + const Real alpha = geom.Lapse(CellLocation::Cent, b, k, j, i); const Real inv_alpha2 = robust::ratio(1, alpha * alpha); Real shift[NS]; - geom.ContravariantShift(CellLocation::Cent, k, j, i, shift); + geom.ContravariantShift(CellLocation::Cent, b, k, j, i, shift); Real gcon0[4] = {-inv_alpha2, inv_alpha2 * shift[0], inv_alpha2 * shift[1], inv_alpha2 * shift[2]}; for (int m = 0; m < ND; m++) { @@ -601,25 +603,23 @@ TaskStatus CalculateFluidSourceTerms(MeshBlockData *rc, Real Ta = 0.0; Real da[ND]; // Real *da = &gam[1][0][0]; - geom.GradLnAlpha(CellLocation::Cent, k, j, i, da); + geom.GradLnAlpha(CellLocation::Cent, b, k, j, i, da); for (int m = 0; m < ND; m++) { Ta += Tmunu[m][0] * da[m]; } - src(ceng, k, j, i) = gdet * alpha * (Ta - TGam); + src(b, c::energy(), k, j, i) = gdet * alpha * (Ta - TGam); #else - SPACETIMELOOP2(mu, nu) { - TGam += Tmunu[mu][nu] * gam[nu][0][mu]; - } - src(ceng, k, j, i) = gdet * TGam; + SPACETIMELOOP2(mu, nu) { TGam += Tmunu[mu][nu] * gam[nu][0][mu]; } + src(b, c::energy(), k, j, i) = gdet * TGam; #endif // USE_VALENCIA } #if SET_FLUX_SRC_DIAGS - src(idiag, k, j, i) = 0.0; - src(idiag + 1, k, j, i) = src(cmom_lo, k, j, i); - src(idiag + 2, k, j, i) = src(cmom_lo + 1, k, j, i); - src(idiag + 3, k, j, i) = src(cmom_lo + 2, k, j, i); - src(idiag + 4, k, j, i) = src(ceng, k, j, i); + src(diag::src_terms(0), b, k, j, i) = 0.0; + src(diag::src_terms(1), b, k, j, i) = src(c::momentum(0), k, j, i); + src(diag::src_terms(2), b, k, j, i) = src(c::momentum(1), k, j, i); + src(diag::src_terms(3), b, k, j, i) = src(c::momentum(2), k, j, i); + src(diag::src_terms(4), b, k, j, i) = src(c::energy(), k, j, i); #endif }); diff --git a/src/fluid/tmunu.hpp b/src/fluid/tmunu.hpp index fdbac2f5..8e5ffa8a 100644 --- a/src/fluid/tmunu.hpp +++ b/src/fluid/tmunu.hpp @@ -19,6 +19,9 @@ #include #include +#include +#include + #include "geometry/geometry.hpp" #include "phoebus_utils/cell_locations.hpp" #include "phoebus_utils/relativity_utils.hpp" @@ -26,12 +29,10 @@ #include "phoebus_utils/variables.hpp" namespace fluid { +using namespace parthenon::package::prelude; -const std::vector TMUNU_VARS = { - fluid_prim::density::name(), fluid_prim::velocity::name(), fluid_prim::energy::name(), - fluid_prim::pressure::name(), fluid_prim::bfield::name()}; // Indices are upstairs -template +template class StressEnergyTensorCon { public: // TODO(JMM): Should these be moved out of Geometry? @@ -42,15 +43,18 @@ class StressEnergyTensorCon { template StressEnergyTensorCon(Data *rc) { - PackIndexMap imap; - pack_ = rc->PackVariables(TMUNU_VARS, imap); + namespace p = fluid_prim; + using phoebus::MakePackDescriptor; + static auto desc = + MakePackDescriptor( + rc); + pack_ = desc.GetPack(rc); system_ = Geometry::GetCoordinateSystem(rc); - - ir_ = imap[fluid_prim::density::name()].first; - iv_ = imap[fluid_prim::velocity::name()].first; - iu_ = imap[fluid_prim::energy::name()].first; - ip_ = imap[fluid_prim::pressure::name()].first; - ib_ = imap[fluid_prim::bfield::name()].first; + ir_ = pack_.GetLowerBoundHost(0, p::density()); + iv_ = pack_.GetLowerBoundHost(0, p::velocity()); + iu_ = pack_.GetLowerBoundHost(0, p::energy()); + ip_ = pack_.GetLowerBoundHost(0, p::pressure()); + ib_ = pack_.GetLowerBoundHost(0, p::bfield()); } // TODO(JMM): Assumes cell centers. If that needs to change, this @@ -80,7 +84,7 @@ class StressEnergyTensorCon { } KOKKOS_FORCEINLINE_FUNCTION Real GetVar_(int v, const int k, const int j, const int i) const { - return pack_(v, k, j, i); + return pack_(0, v, k, j, i); } template @@ -125,15 +129,15 @@ class StressEnergyTensorCon { bsq = Bsq * iW * iW + Bdotv * Bdotv; } - Pack pack_; + parthenon::SparsePack + pack_; CoordinateSystem system_; int ir_, iv_, iu_, ip_, ib_; }; -using TmunuMesh = - StressEnergyTensorCon>>; -using TmunuMeshBlock = - StressEnergyTensorCon>; +using TmunuMesh = StressEnergyTensorCon; +using TmunuMeshBlock = StressEnergyTensorCon; TmunuMesh BuildStressEnergyTensor(MeshData *rc); TmunuMeshBlock BuildStressEnergyTensor(MeshBlockData *rc); diff --git a/src/phoebus_utils/variables.hpp b/src/phoebus_utils/variables.hpp index d4a31547..d510af9e 100644 --- a/src/phoebus_utils/variables.hpp +++ b/src/phoebus_utils/variables.hpp @@ -14,6 +14,7 @@ #ifndef PHOEBUS_UTILS_VARIABLES_HPP_ #define PHOEBUS_UTILS_VARIABLES_HPP_ +#include #include #define VARIABLE(ns, varname) \ @@ -123,4 +124,13 @@ VARIABLE_CUSTOM(r_divf, r.flux_divergence); VARIABLE_CUSTOM(r_src_terms, r.src_terms); } // namespace diagnostic_variables +namespace phoebus { +template +auto MakePackDescriptor(Data *rc) { + parthenon::Mesh *pm = rc->GetMeshPointer(); + parthenon::StateDescriptor *resolved_pkgs = pm->resolved_packages.get(); + return parthenon::MakePackDescriptor(resolved_pkgs); +} +} // namespace phoebus + #endif // PHOEBUS_UTILS_VARIABLES_HPP_ From 5ae6e5ff912e1176ae87375a5b19cf5e50231c1b Mon Sep 17 00:00:00 2001 From: Jonah Maxwell Miller Date: Thu, 7 Dec 2023 10:20:47 -0700 Subject: [PATCH 3/8] typos --- src/fluid/fluid.cpp | 4 ++-- src/fluid/fluid.hpp | 4 ++-- src/phoebus_driver.cpp | 20 +++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/fluid/fluid.cpp b/src/fluid/fluid.cpp index b92c781b..56d61687 100644 --- a/src/fluid/fluid.cpp +++ b/src/fluid/fluid.cpp @@ -532,8 +532,8 @@ TaskStatus ConservedToPrimitiveClassic(T *rc, const IndexRange &ib, const IndexR return TaskStatus::complete; } -TaskStatus CalculateFluidSourceTerms(MeshBlockData *rc, - MeshBlockData *rc_src) { +TaskStatus CalculateFluidSourceTerms(MeshData *rc, + MeshData *rc_src) { constexpr int ND = Geometry::NDFULL; constexpr int NS = Geometry::NDSPACE; using phoebus::MakePackDescriptor; diff --git a/src/fluid/fluid.hpp b/src/fluid/fluid.hpp index 3eb63583..b2ac00b4 100644 --- a/src/fluid/fluid.hpp +++ b/src/fluid/fluid.hpp @@ -43,8 +43,8 @@ TaskStatus ConservedToPrimitiveClassic(T *rc, const IndexRange &ib, const IndexR template TaskStatus ConservedToPrimitiveVanDerHolst(T *rc, const IndexRange &ib, const IndexRange &jb, const IndexRange &kb); -TaskStatus CalculateFluidSourceTerms(MeshBlockData *rc, - MeshBlockData *rc_src); +TaskStatus CalculateFluidSourceTerms(MeshData *rc, + MeshData *rc_src); TaskStatus CalculateFluxes(MeshBlockData *rc); TaskStatus FluxCT(MeshBlockData *rc); TaskStatus CalculateDivB(MeshBlockData *rc); diff --git a/src/phoebus_driver.cpp b/src/phoebus_driver.cpp index 8299f5b4..86289bc4 100644 --- a/src/phoebus_driver.cpp +++ b/src/phoebus_driver.cpp @@ -253,14 +253,25 @@ TaskCollection PhoebusDriver::RungeKuttaStage(const int stage) { TaskRegion &sync_region_1 = tc.AddRegion(num_partitions); for (int ib = 0; ib < num_partitions; ++ib) { auto &base = pmesh->mesh_data.GetOrAdd("base", ib); + // pull out the container we'll use to get fluxes and/or compute RHSs auto &sc0 = pmesh->mesh_data.GetOrAdd(stage_name[stage - 1], ib); + // pull out a container we'll use to store dU/dt. + // This is just -flux_divergence in this example auto &sc1 = pmesh->mesh_data.GetOrAdd(stage_name[stage], ib); + // pull out a container for the geometric source terms + auto &gsrc = pmesh->mesh_data.GetOrAdd("geometric source terms", ib); auto &tl = sync_region_1[ib]; tl.AddTask(none, parthenon::StartReceiveBoundBufs, sc1); if (pmesh->multilevel) { tl.AddTask(none, parthenon::StartReceiveFluxCorrections, sc0); } + TaskID geom_src(0); + if (fluid_active) { + auto hydro_geom_src = + tl.AddTask(none, fluid::CalculateFluidSourceTerms, sc0.get(), gsrc.get()); + geom_src = geom_src | hydro_geom_src; + } } TaskRegion &async_region_1 = tc.AddRegion(num_independent_task_lists); @@ -268,15 +279,9 @@ TaskCollection PhoebusDriver::RungeKuttaStage(const int stage) { auto pmb = blocks[ib].get(); auto &tl = async_region_1[ib]; - // pull out the container we'll use to get fluxes and/or compute RHSs auto &sc0 = pmb->meshblock_data.Get(stage_name[stage - 1]); - // pull out a container we'll use to store dU/dt. - // This is just -flux_divergence in this example auto &dudt = pmb->meshblock_data.Get("dUdt"); - // pull out the container that will hold the updated state - // effectively, sc1 = sc0 + dudt*dt auto &sc1 = pmb->meshblock_data.Get(stage_name[stage]); - // pull out a container for the geometric source terms auto &gsrc = pmb->meshblock_data.Get("geometric source terms"); TaskID geom_src(0); @@ -285,10 +290,7 @@ TaskCollection PhoebusDriver::RungeKuttaStage(const int stage) { if (fluid_active) { auto hydro_flux = tl.AddTask(none, fluid::CalculateFluxes, sc0.get()); auto hydro_flux_ct = tl.AddTask(hydro_flux, fluid::FluxCT, sc0.get()); - auto hydro_geom_src = - tl.AddTask(none, fluid::CalculateFluidSourceTerms, sc0.get(), gsrc.get()); sndrcv_flux_depend = sndrcv_flux_depend | hydro_flux_ct; - geom_src = geom_src | hydro_geom_src; } if (rad_moments_active) { From 14f71dd79a814464b9715cdc13eebb574ff36df9 Mon Sep 17 00:00:00 2001 From: Jonah Maxwell Miller Date: Fri, 8 Dec 2023 11:19:48 -0700 Subject: [PATCH 4/8] output coords data when available --- inputs/linear_modes.pin | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/inputs/linear_modes.pin b/inputs/linear_modes.pin index d7e942ef..49745a77 100644 --- a/inputs/linear_modes.pin +++ b/inputs/linear_modes.pin @@ -23,6 +23,8 @@ variables = p.density, & p.energy, & p.bfield, & pressure, & + g.n.coord, & + g.c.coord, & cs file_type = hdf5 # Tabular data dump @@ -63,9 +65,9 @@ num_threads = 1 # maximum number of OMP threads #bc_vars = primitive -# -# nx1 = 128 -# nx2 = 128 + +nx1 = 64 +nx2 = 64 # nx3 = 1 From c5e795ba46cff06eddc347d1a2cc063434af7e05 Mon Sep 17 00:00:00 2001 From: Jonah Maxwell Miller Date: Fri, 8 Dec 2023 11:20:09 -0700 Subject: [PATCH 5/8] clean up python scripts a little --- scripts/python/linmode.py | 2 +- scripts/python/movie1d.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/python/linmode.py b/scripts/python/linmode.py index 7c465d5c..67cdb2a0 100755 --- a/scripts/python/linmode.py +++ b/scripts/python/linmode.py @@ -282,7 +282,7 @@ def get_mode(x, y, t, var): dump = phdf.phdf(dumps[-1]) tf_soln = mode["tf"] t = dump.Time - if (np.fabs(t - tf_soln) / tf_soln) > 0.05: + if not args.use_initial and (np.fabs(t - tf_soln) / tf_soln) > 0.05: print("Mismatch in expected solution times!") print(" Code: ", t) print(" Soln: ", tf_soln) diff --git a/scripts/python/movie1d.py b/scripts/python/movie1d.py index 4b112a63..fa4347cc 100644 --- a/scripts/python/movie1d.py +++ b/scripts/python/movie1d.py @@ -30,7 +30,10 @@ def addPath(): def read(filename, nGhost=0): """ Read the parthenon hdf file """ - from phdf import phdf + try: + from parthenon_tools.phdf import phdf + except ModuleNotFoundError: + from phdf import phdf f = phdf(filename) return f From 832f156142df93892a6ebc33b306922264219fcf Mon Sep 17 00:00:00 2001 From: Jonah Maxwell Miller Date: Fri, 8 Dec 2023 11:20:38 -0700 Subject: [PATCH 6/8] fix bug with too many signal speeds --- src/fluid/fluid.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fluid/fluid.cpp b/src/fluid/fluid.cpp index 56d61687..b39a11e5 100644 --- a/src/fluid/fluid.cpp +++ b/src/fluid/fluid.cpp @@ -353,8 +353,9 @@ TaskStatus PrimitiveToConservedRegion(MeshBlockData *rc, const IndexRange namespace impl = internal_variables; using parthenon::MakePackDescriptor; - auto *pmb = rc->GetParentPointer(); - auto &resolved_pkgs = pmb->resolved_packages; + Mesh *pmesh = rc->GetMeshPointer(); + auto &resolved_pkgs = pmesh->resolved_packages; + const int ndim = pmesh->ndim; static auto desc = MakePackDescriptor *rc, const IndexRange v(b, c::ye(), k, j, i) = ye_cons; } - for (int d = 0; d < 3; d++) { + for (int d = 0; d < ndim; d++) { v(b, impl::cell_signal_speed(d), k, j, i) = sig[d]; } }); From cf51ce036d788e3bcd9d766d37cd9605f5b0339d Mon Sep 17 00:00:00 2001 From: Jonah Miller Date: Thu, 14 Dec 2023 11:22:05 -0700 Subject: [PATCH 7/8] update to using pack::contains and format --- external/parthenon | 2 +- src/fluid/fluid.cpp | 15 +++++++-------- src/fluid/fluid.hpp | 3 +-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/external/parthenon b/external/parthenon index a540d397..0072037f 160000 --- a/external/parthenon +++ b/external/parthenon @@ -1 +1 @@ -Subproject commit a540d39766022b9fccc2f48cc9263efc8717d663 +Subproject commit 0072037fcadb208059152ce1502d1edc1f3c9ba0 diff --git a/src/fluid/fluid.cpp b/src/fluid/fluid.cpp index b39a11e5..82aa5826 100644 --- a/src/fluid/fluid.cpp +++ b/src/fluid/fluid.cpp @@ -365,8 +365,8 @@ TaskStatus PrimitiveToConservedRegion(MeshBlockData *rc, const IndexRange // We need these to check whether or not these variables are present // in the pack. They are -1 if not present. - const int pb_hi = v.GetUpperBoundHost(0, p::bfield()); - const int pye = v.GetUpperBoundHost(0, p::ye()); + const int contains_b = v.ContainsHost(0, p::bfield()); + const int contains_ye = v.ContainsHost(0, p::ye()); auto geom = Geometry::GetCoordinateSystem(rc); const int nblocks = v.GetNBlocks(); @@ -390,14 +390,14 @@ TaskStatus PrimitiveToConservedRegion(MeshBlockData *rc, const IndexRange v(b, p::velocity(2), k, j, i)}; Real bcons[3]; Real bp[3] = {0.0, 0.0, 0.0}; - if (pb_hi > 0) { + if (contains_b) { for (int d = 0; d < 3; ++d) { bp[d] = v(b, p::bfield(d), k, j, i); } } Real ye_cons; Real ye_prim = 0.0; - if (pye > 0) { + if (contains_ye) { ye_prim = v(b, p::ye(), k, j, i); } @@ -411,13 +411,13 @@ TaskStatus PrimitiveToConservedRegion(MeshBlockData *rc, const IndexRange v(b, c::momentum(d), k, j, i) = S[d]; } - if (pb_hi > 0) { + if (contains_b) { for (int d = 0; d < 3; ++d) { v(b, c::bfield(d), k, j, i) = bcons[d]; } } - if (pye > 0) { + if (contains_ye) { v(b, c::ye(), k, j, i) = ye_cons; } @@ -533,8 +533,7 @@ TaskStatus ConservedToPrimitiveClassic(T *rc, const IndexRange &ib, const IndexR return TaskStatus::complete; } -TaskStatus CalculateFluidSourceTerms(MeshData *rc, - MeshData *rc_src) { +TaskStatus CalculateFluidSourceTerms(MeshData *rc, MeshData *rc_src) { constexpr int ND = Geometry::NDFULL; constexpr int NS = Geometry::NDSPACE; using phoebus::MakePackDescriptor; diff --git a/src/fluid/fluid.hpp b/src/fluid/fluid.hpp index b2ac00b4..fa206f8e 100644 --- a/src/fluid/fluid.hpp +++ b/src/fluid/fluid.hpp @@ -43,8 +43,7 @@ TaskStatus ConservedToPrimitiveClassic(T *rc, const IndexRange &ib, const IndexR template TaskStatus ConservedToPrimitiveVanDerHolst(T *rc, const IndexRange &ib, const IndexRange &jb, const IndexRange &kb); -TaskStatus CalculateFluidSourceTerms(MeshData *rc, - MeshData *rc_src); +TaskStatus CalculateFluidSourceTerms(MeshData *rc, MeshData *rc_src); TaskStatus CalculateFluxes(MeshBlockData *rc); TaskStatus FluxCT(MeshBlockData *rc); TaskStatus CalculateDivB(MeshBlockData *rc); From 7574c385e93f1d42839295d53e2db379f2e6324e Mon Sep 17 00:00:00 2001 From: Jonah Miller Date: Thu, 14 Dec 2023 13:02:42 -0700 Subject: [PATCH 8/8] Update phoebus_driver.cpp --- src/phoebus_driver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/phoebus_driver.cpp b/src/phoebus_driver.cpp index 86289bc4..38ceb8f3 100644 --- a/src/phoebus_driver.cpp +++ b/src/phoebus_driver.cpp @@ -274,6 +274,7 @@ TaskCollection PhoebusDriver::RungeKuttaStage(const int stage) { } } + // Goal: make async regions go away TaskRegion &async_region_1 = tc.AddRegion(num_independent_task_lists); for (int ib = 0; ib < num_independent_task_lists; ib++) { auto pmb = blocks[ib].get();