diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e8555710754..5217f6110f7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### Removed (removing behavior/API/varaibles/...) ### Incompatibilities (i.e. breaking changes) +- [[PR 974]](https://github.com/parthenon-hpc-lab/parthenon/pull/974) Change GetParentPointer to always return T* ## Release 23.11 diff --git a/example/poisson/poisson_package.cpp b/example/poisson/poisson_package.cpp index 24d60613981f..7037c42b2061 100644 --- a/example/poisson/poisson_package.cpp +++ b/example/poisson/poisson_package.cpp @@ -1,5 +1,5 @@ //======================================================================================== -// (C) (or copyright) 2021-2022. Triad National Security, LLC. All rights reserved. +// (C) (or copyright) 2021-2023. Triad National Security, LLC. All rights reserved. // // This program was produced under U.S. Government contract 89233218CNA000001 for Los // Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC @@ -142,6 +142,7 @@ TaskStatus SetMatrixElements(T *u) { } auto &GetCoords(std::shared_ptr &pmb) { return pmb->coords; } +auto &GetCoords(MeshBlock *pmb) { return pmb->coords; } auto &GetCoords(Mesh *pm) { return pm->block_list[0]->coords; } template diff --git a/src/amr_criteria/refinement_package.cpp b/src/amr_criteria/refinement_package.cpp index 285d01c71c21..a1f4c4eb560b 100644 --- a/src/amr_criteria/refinement_package.cpp +++ b/src/amr_criteria/refinement_package.cpp @@ -1,5 +1,5 @@ //======================================================================================== -// (C) (or copyright) 2020. Triad National Security, LLC. All rights reserved. +// (C) (or copyright) 2020-2023. Triad National Security, LLC. All rights reserved. // // This program was produced under U.S. Government contract 89233218CNA000001 for Los // Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC @@ -59,7 +59,7 @@ AmrTag CheckAllRefinement(MeshBlockData *rc) { // 2) the code must maintain proper nesting, which sometimes means a block that is // tagged as "derefine" must be left alone (or possibly refined?) because of // neighboring blocks. Similarly for "do nothing" - std::shared_ptr pmb = rc->GetBlockPointer(); + MeshBlock *pmb = rc->GetBlockPointer(); // delta_level holds the max over all criteria. default to derefining. AmrTag delta_level = AmrTag::derefine; for (auto &pkg : pmb->packages.AllPackages()) { diff --git a/src/bvals/boundary_conditions.cpp b/src/bvals/boundary_conditions.cpp index bac842d8614b..b148820fbe35 100644 --- a/src/bvals/boundary_conditions.cpp +++ b/src/bvals/boundary_conditions.cpp @@ -35,7 +35,7 @@ TaskStatus ApplyBoundaryConditionsOnCoarseOrFine(std::shared_ptr pmb = rc->GetBlockPointer(); + MeshBlock *pmb = rc->GetBlockPointer(); Mesh *pmesh = pmb->pmy_mesh; const int ndim = pmesh->ndim; diff --git a/src/bvals/boundary_conditions_generic.hpp b/src/bvals/boundary_conditions_generic.hpp index b7300e6298d2..9b8ad4d510cc 100644 --- a/src/bvals/boundary_conditions_generic.hpp +++ b/src/bvals/boundary_conditions_generic.hpp @@ -1,5 +1,5 @@ //======================================================================================== -// (C) (or copyright) 2020-2022. Triad National Security, LLC. All rights reserved. +// (C) (or copyright) 2020-2023. Triad National Security, LLC. All rights reserved. // // This program was produced under U.S. Government contract 89233218CNA000001 for Los // Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC @@ -63,7 +63,7 @@ void GenericBC(std::shared_ptr> &rc, bool coarse, if (lend < lstart) return; auto nb = IndexRange{lstart, lend}; - std::shared_ptr pmb = rc->GetBlockPointer(); + MeshBlock *pmb = rc->GetBlockPointer(); const auto &bounds = coarse ? pmb->c_cellbounds : pmb->cellbounds; const auto &range = X1 ? bounds.GetBoundsI(IndexDomain::interior, el) diff --git a/src/bvals/comms/bnd_info.cpp b/src/bvals/comms/bnd_info.cpp index fa4545705524..ce71b0f98953 100644 --- a/src/bvals/comms/bnd_info.cpp +++ b/src/bvals/comms/bnd_info.cpp @@ -77,8 +77,7 @@ void ProResCache_t::RegisterRegionHost(int region, ProResInfo pri, Variable pmb, +SpatiallyMaskedIndexer6D CalcIndices(const NeighborBlock &nb, MeshBlock *pmb, TopologicalElement el, IndexRangeType ir_type, bool prores, std::array tensor_shape) { const auto &ni = nb.ni; @@ -202,7 +201,7 @@ SpatiallyMaskedIndexer6D CalcIndices(const NeighborBlock &nb, {s[2], e[2]}, {s[1], e[1]}, {s[0], e[0]}); } -int GetBufferSize(std::shared_ptr pmb, const NeighborBlock &nb, +int GetBufferSize(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v) { // This does not do a careful job of calculating the buffer size, in many // cases there will be some extra storage that is not required, but there @@ -221,7 +220,7 @@ int GetBufferSize(std::shared_ptr pmb, const NeighborBlock &nb, v->GetDim(4) * topo_comp; } -BndInfo BndInfo::GetSendBndInfo(std::shared_ptr pmb, const NeighborBlock &nb, +BndInfo BndInfo::GetSendBndInfo(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v, CommBuffer::owner_t> *buf) { BndInfo out; @@ -254,7 +253,7 @@ BndInfo BndInfo::GetSendBndInfo(std::shared_ptr pmb, const NeighborBl return out; } -BndInfo BndInfo::GetSetBndInfo(std::shared_ptr pmb, const NeighborBlock &nb, +BndInfo BndInfo::GetSetBndInfo(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v, CommBuffer::owner_t> *buf) { BndInfo out; @@ -294,8 +293,7 @@ BndInfo BndInfo::GetSetBndInfo(std::shared_ptr pmb, const NeighborBlo return out; } -ProResInfo ProResInfo::GetInteriorRestrict(std::shared_ptr pmb, - const NeighborBlock & /*nb*/, +ProResInfo ProResInfo::GetInteriorRestrict(MeshBlock *pmb, const NeighborBlock & /*nb*/, std::shared_ptr> v) { ProResInfo out; @@ -326,8 +324,7 @@ ProResInfo ProResInfo::GetInteriorRestrict(std::shared_ptr pmb, return out; } -ProResInfo ProResInfo::GetInteriorProlongate(std::shared_ptr pmb, - const NeighborBlock & /*nb*/, +ProResInfo ProResInfo::GetInteriorProlongate(MeshBlock *pmb, const NeighborBlock & /*nb*/, std::shared_ptr> v) { ProResInfo out; @@ -357,7 +354,7 @@ ProResInfo ProResInfo::GetInteriorProlongate(std::shared_ptr pmb, return out; } -ProResInfo ProResInfo::GetSend(std::shared_ptr pmb, const NeighborBlock &nb, +ProResInfo ProResInfo::GetSend(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v) { ProResInfo out; @@ -388,7 +385,7 @@ ProResInfo ProResInfo::GetSend(std::shared_ptr pmb, const NeighborBlo return out; } -ProResInfo ProResInfo::GetSet(std::shared_ptr pmb, const NeighborBlock &nb, +ProResInfo ProResInfo::GetSet(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v) { ProResInfo out; out.allocated = v->IsAllocated(); @@ -447,7 +444,7 @@ ProResInfo ProResInfo::GetSet(std::shared_ptr pmb, const NeighborBloc return out; } -BndInfo BndInfo::GetSendCCFluxCor(std::shared_ptr pmb, const NeighborBlock &nb, +BndInfo BndInfo::GetSendCCFluxCor(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v, CommBuffer::owner_t> *buf) { BndInfo out; @@ -504,7 +501,7 @@ BndInfo BndInfo::GetSendCCFluxCor(std::shared_ptr pmb, const Neighbor return out; } -BndInfo BndInfo::GetSetCCFluxCor(std::shared_ptr pmb, const NeighborBlock &nb, +BndInfo BndInfo::GetSetCCFluxCor(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v, CommBuffer::owner_t> *buf) { BndInfo out; diff --git a/src/bvals/comms/bnd_info.hpp b/src/bvals/comms/bnd_info.hpp index 4fcc9ed3f706..4cc03b0c13a9 100644 --- a/src/bvals/comms/bnd_info.hpp +++ b/src/bvals/comms/bnd_info.hpp @@ -57,16 +57,16 @@ struct BndInfo { // These are are used to generate the BndInfo struct for various // kinds of boundary types and operations. - static BndInfo GetSendBndInfo(std::shared_ptr pmb, const NeighborBlock &nb, + static BndInfo GetSendBndInfo(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v, CommBuffer::owner_t> *buf); - static BndInfo GetSetBndInfo(std::shared_ptr pmb, const NeighborBlock &nb, + static BndInfo GetSetBndInfo(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v, CommBuffer::owner_t> *buf); - static BndInfo GetSendCCFluxCor(std::shared_ptr pmb, const NeighborBlock &nb, + static BndInfo GetSendCCFluxCor(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v, CommBuffer::owner_t> *buf); - static BndInfo GetSetCCFluxCor(std::shared_ptr pmb, const NeighborBlock &nb, + static BndInfo GetSetCCFluxCor(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v, CommBuffer::owner_t> *buf); }; @@ -89,23 +89,21 @@ struct ProResInfo { // These are are used to generate the BndInfo struct for various // kinds of boundary types and operations. - static ProResInfo GetNull(std::shared_ptr pmb, const NeighborBlock &nb, + static ProResInfo GetNull(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v) { return ProResInfo(); } - static ProResInfo GetSend(std::shared_ptr pmb, const NeighborBlock &nb, + static ProResInfo GetSend(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v); - static ProResInfo GetSet(std::shared_ptr pmb, const NeighborBlock &nb, + static ProResInfo GetSet(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v); - static ProResInfo GetInteriorProlongate(std::shared_ptr pmb, - const NeighborBlock &nb, + static ProResInfo GetInteriorProlongate(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v); - static ProResInfo GetInteriorRestrict(std::shared_ptr pmb, - const NeighborBlock &nb, + static ProResInfo GetInteriorRestrict(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v); }; -int GetBufferSize(std::shared_ptr pmb, const NeighborBlock &nb, +int GetBufferSize(MeshBlock *pmb, const NeighborBlock &nb, std::shared_ptr> v); using BndInfoArr_t = ParArray1D; diff --git a/src/bvals/comms/boundary_communication.cpp b/src/bvals/comms/boundary_communication.cpp index 351ab6873a5a..1257638c110b 100644 --- a/src/bvals/comms/boundary_communication.cpp +++ b/src/bvals/comms/boundary_communication.cpp @@ -210,7 +210,7 @@ TaskStatus ReceiveBoundBufs(std::shared_ptr> &md) { int ibound = 0; if (Globals::sparse_config.enabled) { ForEachBoundary( - md, [&](sp_mb_t pmb, sp_mbd_t rc, nb_t &nb, const sp_cv_t v) { + md, [&](auto pmb, sp_mbd_t rc, nb_t &nb, const sp_cv_t v) { const std::size_t ibuf = cache.idx_vec[ibound]; auto &buf = *cache.buf_vec[ibuf]; diff --git a/src/bvals/comms/build_boundary_buffers.cpp b/src/bvals/comms/build_boundary_buffers.cpp index a76d86dadb94..9058877cac23 100644 --- a/src/bvals/comms/build_boundary_buffers.cpp +++ b/src/bvals/comms/build_boundary_buffers.cpp @@ -44,70 +44,69 @@ template void BuildBoundaryBufferSubset(std::shared_ptr> &md, Mesh::comm_buf_map_t &buf_map) { Mesh *pmesh = md->GetMeshPointer(); - ForEachBoundary( - md, [&](sp_mb_t pmb, sp_mbd_t /*rc*/, nb_t &nb, const sp_cv_t v) { - // Calculate the required size of the buffer for this boundary - int buf_size = GetBufferSize(pmb, nb, v); - - // Add a buffer pool if one does not exist for this size - if (pmesh->pool_map.count(buf_size) == 0) { - pmesh->pool_map.emplace(std::make_pair( - buf_size, buf_pool_t([buf_size](buf_pool_t *pool) { - using buf_t = buf_pool_t::base_t; - // TODO(LFR): Make nbuf a user settable parameter - const int nbuf = 200; - buf_t chunk("pool buffer", buf_size * nbuf); - for (int i = 1; i < nbuf; ++i) { - pool->AddFreeObjectToPool( - buf_t(chunk, std::make_pair(i * buf_size, (i + 1) * buf_size))); - } - return buf_t(chunk, std::make_pair(0, buf_size)); - }))); - } - - const int receiver_rank = nb.snb.rank; - const int sender_rank = Globals::my_rank; - - int tag = 0; + ForEachBoundary(md, [&](auto pmb, sp_mbd_t /*rc*/, nb_t &nb, const sp_cv_t v) { + // Calculate the required size of the buffer for this boundary + int buf_size = GetBufferSize(pmb, nb, v); + + // Add a buffer pool if one does not exist for this size + if (pmesh->pool_map.count(buf_size) == 0) { + pmesh->pool_map.emplace(std::make_pair( + buf_size, buf_pool_t([buf_size](buf_pool_t *pool) { + using buf_t = buf_pool_t::base_t; + // TODO(LFR): Make nbuf a user settable parameter + const int nbuf = 200; + buf_t chunk("pool buffer", buf_size * nbuf); + for (int i = 1; i < nbuf; ++i) { + pool->AddFreeObjectToPool( + buf_t(chunk, std::make_pair(i * buf_size, (i + 1) * buf_size))); + } + return buf_t(chunk, std::make_pair(0, buf_size)); + }))); + } + + const int receiver_rank = nb.snb.rank; + const int sender_rank = Globals::my_rank; + + int tag = 0; #ifdef MPI_PARALLEL - // Get a bi-directional mpi tag for this pair of blocks - tag = pmesh->tag_map.GetTag(pmb, nb); - auto comm_label = v->label(); - if constexpr (BTYPE == BoundaryType::flxcor_send || - BTYPE == BoundaryType::flxcor_recv) - comm_label += "_flcor"; - mpi_comm_t comm = pmesh->GetMPIComm(comm_label); + // Get a bi-directional mpi tag for this pair of blocks + tag = pmesh->tag_map.GetTag(pmb, nb); + auto comm_label = v->label(); + if constexpr (BTYPE == BoundaryType::flxcor_send || + BTYPE == BoundaryType::flxcor_recv) + comm_label += "_flcor"; + mpi_comm_t comm = pmesh->GetMPIComm(comm_label); #else // Setting to zero is fine here since this doesn't actually get used when everything // is on the same rank mpi_comm_t comm = 0; #endif - bool use_sparse_buffers = v->IsSet(Metadata::Sparse); - auto get_resource_method = [pmesh, buf_size]() { - return buf_pool_t::owner_t(pmesh->pool_map.at(buf_size).Get()); - }; - - // Build send buffer (unless this is a receiving flux boundary) - if constexpr (IsSender(BTYPE)) { - auto s_key = SendKey(pmb, nb, v); - if (buf_map.count(s_key) == 0) - buf_map[s_key] = CommBuffer::owner_t>( - tag, sender_rank, receiver_rank, comm, get_resource_method, - use_sparse_buffers); - } - - // Also build the non-local receive buffers here - if constexpr (IsReceiver(BTYPE)) { - if (sender_rank != receiver_rank) { - auto r_key = ReceiveKey(pmb, nb, v); - if (buf_map.count(r_key) == 0) - buf_map[r_key] = CommBuffer::owner_t>( - tag, receiver_rank, sender_rank, comm, get_resource_method, - use_sparse_buffers); - } - } - }); + bool use_sparse_buffers = v->IsSet(Metadata::Sparse); + auto get_resource_method = [pmesh, buf_size]() { + return buf_pool_t::owner_t(pmesh->pool_map.at(buf_size).Get()); + }; + + // Build send buffer (unless this is a receiving flux boundary) + if constexpr (IsSender(BTYPE)) { + auto s_key = SendKey(pmb, nb, v); + if (buf_map.count(s_key) == 0) + buf_map[s_key] = CommBuffer::owner_t>( + tag, sender_rank, receiver_rank, comm, get_resource_method, + use_sparse_buffers); + } + + // Also build the non-local receive buffers here + if constexpr (IsReceiver(BTYPE)) { + if (sender_rank != receiver_rank) { + auto r_key = ReceiveKey(pmb, nb, v); + if (buf_map.count(r_key) == 0) + buf_map[r_key] = CommBuffer::owner_t>( + tag, receiver_rank, sender_rank, comm, get_resource_method, + use_sparse_buffers); + } + } + }); } } // namespace diff --git a/src/bvals/comms/bvals_utils.hpp b/src/bvals/comms/bvals_utils.hpp index d2161ab80f9c..8683027e1c4f 100644 --- a/src/bvals/comms/bvals_utils.hpp +++ b/src/bvals/comms/bvals_utils.hpp @@ -3,7 +3,7 @@ // Copyright(C) 2022 The Parthenon collaboration // Licensed under the 3-clause BSD License, see LICENSE file for details //======================================================================================== -// (C) (or copyright) 2022. Triad National Security, LLC. All rights reserved. +// (C) (or copyright) 2022-2023. Triad National Security, LLC. All rights reserved. // // This program was produced under U.S. Government contract 89233218CNA000001 for Los // Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC @@ -36,7 +36,7 @@ namespace parthenon { inline std::tuple -SendKey(const std::shared_ptr &pmb, const NeighborBlock &nb, +SendKey(const MeshBlock *pmb, const NeighborBlock &nb, const std::shared_ptr> &pcv) { const int sender_id = pmb->gid; const int receiver_id = nb.snb.gid; @@ -45,7 +45,7 @@ SendKey(const std::shared_ptr &pmb, const NeighborBlock &nb, } inline std::tuple -ReceiveKey(const std::shared_ptr &pmb, const NeighborBlock &nb, +ReceiveKey(const MeshBlock *pmb, const NeighborBlock &nb, const std::shared_ptr> &pcv) { const int receiver_id = pmb->gid; const int sender_id = nb.snb.gid; @@ -78,17 +78,16 @@ void InitializeBufferCache(std::shared_ptr> &md, COMM_MAP *comm_m std::vector> key_order; int boundary_idx = 0; - ForEachBoundary( - md, [&](sp_mb_t pmb, sp_mbd_t rc, nb_t &nb, const sp_cv_t v) { - auto key = KeyFunc(pmb, nb, v); - PARTHENON_DEBUG_REQUIRE(comm_map->count(key) > 0, - "Boundary communicator does not exist"); - // Create a unique index by combining receiver gid (second element of the key - // tuple) and geometric element index (fourth element of the key tuple) - int recvr_idx = 27 * std::get<1>(key) + std::get<3>(key); - key_order.push_back({recvr_idx, boundary_idx, key}); - ++boundary_idx; - }); + ForEachBoundary(md, [&](auto pmb, sp_mbd_t rc, nb_t &nb, const sp_cv_t v) { + auto key = KeyFunc(pmb, nb, v); + PARTHENON_DEBUG_REQUIRE(comm_map->count(key) > 0, + "Boundary communicator does not exist"); + // Create a unique index by combining receiver gid (second element of the key + // tuple) and geometric element index (fourth element of the key tuple) + int recvr_idx = 27 * std::get<1>(key) + std::get<3>(key); + key_order.push_back({recvr_idx, boundary_idx, key}); + ++boundary_idx; + }); // If desired, sort the keys and boundary indices by receiver_idx // std::sort(key_order.begin(), key_order.end(), @@ -127,8 +126,7 @@ inline auto CheckSendBufferCacheForRebuild(std::shared_ptr> md) { bool rebuild = false; bool other_communication_unfinished = false; int nbound = 0; - ForEachBoundary(md, [&](sp_mb_t pmb, sp_mbd_t rc, nb_t &nb, - const sp_cv_t v) { + ForEachBoundary(md, [&](auto pmb, sp_mbd_t rc, nb_t &nb, const sp_cv_t v) { const std::size_t ibuf = cache.idx_vec[nbound]; auto &buf = *(cache.buf_vec[ibuf]); @@ -160,8 +158,7 @@ inline auto CheckReceiveBufferCacheForRebuild(std::shared_ptr> md bool rebuild = false; int nbound = 0; - ForEachBoundary(md, [&](sp_mb_t pmb, sp_mbd_t rc, nb_t &nb, - const sp_cv_t v) { + ForEachBoundary(md, [&](auto pmb, sp_mbd_t rc, nb_t &nb, const sp_cv_t v) { const std::size_t ibuf = cache.idx_vec[nbound]; auto &buf = *cache.buf_vec[ibuf]; if (ibuf < cache.bnd_info_h.size()) { @@ -185,13 +182,12 @@ inline auto CheckReceiveBufferCacheForRebuild(std::shared_ptr> md return std::make_tuple(rebuild, nbound); } -using F_BND_INFO = std::function pmb, const NeighborBlock &nb, - std::shared_ptr> v, CommBuffer::owner_t> *buf)>; +using F_BND_INFO = std::function> v, + CommBuffer::owner_t> *buf)>; -using F_PRORES_INFO = - std::function pmb, const NeighborBlock &nb, - std::shared_ptr> v)>; +using F_PRORES_INFO = std::function> v)>; template inline void RebuildBufferCache(std::shared_ptr> md, int nbound, @@ -215,23 +211,22 @@ inline void RebuildBufferCache(std::shared_ptr> md, int nbound, } int ibound = 0; - ForEachBoundary( - md, [&](sp_mb_t pmb, sp_mbd_t rc, nb_t &nb, const sp_cv_t v) { - // bnd_info - const std::size_t ibuf = cache.idx_vec[ibound]; - cache.bnd_info_h(ibuf) = BndInfoCreator(pmb, nb, v, cache.buf_vec[ibuf]); - - // subsets ordering is same as in cache.bnd_info - // RefinementFunctions_t owns all relevant functionality, so - // only one ParArray2D needed. - if constexpr (!((BOUND_TYPE == BoundaryType::flxcor_send) || - (BOUND_TYPE == BoundaryType::flxcor_recv))) { - cache.prores_cache.RegisterRegionHost(ibuf, ProResInfoCreator(pmb, nb, v), - v.get(), pkg); - } - - ++ibound; - }); + ForEachBoundary(md, [&](auto pmb, sp_mbd_t rc, nb_t &nb, const sp_cv_t v) { + // bnd_info + const std::size_t ibuf = cache.idx_vec[ibound]; + cache.bnd_info_h(ibuf) = BndInfoCreator(pmb, nb, v, cache.buf_vec[ibuf]); + + // subsets ordering is same as in cache.bnd_info + // RefinementFunctions_t owns all relevant functionality, so + // only one ParArray2D needed. + if constexpr (!((BOUND_TYPE == BoundaryType::flxcor_send) || + (BOUND_TYPE == BoundaryType::flxcor_recv))) { + cache.prores_cache.RegisterRegionHost(ibuf, ProResInfoCreator(pmb, nb, v), v.get(), + pkg); + } + + ++ibound; + }); Kokkos::deep_copy(cache.bnd_info, cache.bnd_info_h); if constexpr (!((BOUND_TYPE == BoundaryType::flxcor_send) || (BOUND_TYPE == BoundaryType::flxcor_recv))) { diff --git a/src/bvals/comms/tag_map.cpp b/src/bvals/comms/tag_map.cpp index 4b82ea4bd5ff..da562c29a2f9 100644 --- a/src/bvals/comms/tag_map.cpp +++ b/src/bvals/comms/tag_map.cpp @@ -25,7 +25,7 @@ namespace parthenon { using namespace loops; using namespace loops::shorthands; -TagMap::rank_pair_t TagMap::MakeChannelPair(const std::shared_ptr &pmb, +TagMap::rank_pair_t TagMap::MakeChannelPair(const MeshBlock *pmb, const NeighborBlock &nb) { const int location_idx_me = (1 + nb.ni.ox1) + 3 * (1 + nb.ni.ox2 + 3 * (1 + nb.ni.ox3)); const int location_idx_nb = (1 - nb.ni.ox1) + 3 * (1 - nb.ni.ox2 + 3 * (1 - nb.ni.ox3)); @@ -35,7 +35,7 @@ TagMap::rank_pair_t TagMap::MakeChannelPair(const std::shared_ptr &pm } template void TagMap::AddMeshDataToMap(std::shared_ptr> &md) { - ForEachBoundary(md, [&](sp_mb_t pmb, sp_mbd_t rc, nb_t &nb, const sp_cv_t v) { + ForEachBoundary(md, [&](auto pmb, sp_mbd_t rc, nb_t &nb, const sp_cv_t v) { const int other_rank = nb.snb.rank; if (map_.count(other_rank) < 1) map_[other_rank] = rank_pair_map_t(); auto &pair_map = map_[other_rank]; @@ -67,7 +67,7 @@ void TagMap::ResolveMap() { } } -int TagMap::GetTag(const std::shared_ptr &pmb, const NeighborBlock &nb) { +int TagMap::GetTag(const MeshBlock *pmb, const NeighborBlock &nb) { const int other_rank = nb.snb.rank; auto &pair_map = map_[other_rank]; return pair_map[MakeChannelPair(pmb, nb)]; diff --git a/src/bvals/comms/tag_map.hpp b/src/bvals/comms/tag_map.hpp index 8ecfb23d0fea..0c3bebb86e84 100644 --- a/src/bvals/comms/tag_map.hpp +++ b/src/bvals/comms/tag_map.hpp @@ -90,8 +90,7 @@ class TagMap { // firsts NeighborBlock information) return an ordered pair of BlockGeometricElementIds // corresponding to the two blocks geometric elements that coincide. This serves as a // unique key defining the two-way communication channel between these elements - rank_pair_t MakeChannelPair(const std::shared_ptr &pmb, - const NeighborBlock &nb); + rank_pair_t MakeChannelPair(const MeshBlock *pmb, const NeighborBlock &nb); public: void clear() { map_.clear(); } @@ -108,7 +107,7 @@ class TagMap { // After the map has been resolved, get the tag for a particular MeshBlock NeighborBlock // pair - int GetTag(const std::shared_ptr &pmb, const NeighborBlock &nb); + int GetTag(const MeshBlock *pmb, const NeighborBlock &nb); }; } // namespace parthenon diff --git a/src/interface/meshblock_data.hpp b/src/interface/meshblock_data.hpp index 18fd041ee77c..caf3be9c9d3c 100644 --- a/src/interface/meshblock_data.hpp +++ b/src/interface/meshblock_data.hpp @@ -67,14 +67,14 @@ class MeshBlockData { MeshBlockData(const MeshBlockData &src, const std::vector &flags, const std::vector &sparse_ids = {}); - /// Returns shared pointer to a block - std::shared_ptr GetBlockPointer() const { + std::shared_ptr GetBlockSharedPointer() const { if (pmy_block.expired()) { PARTHENON_THROW("Invalid pointer to MeshBlock!"); } return pmy_block.lock(); } - auto GetParentPointer() const { return GetBlockPointer(); } + MeshBlock *GetBlockPointer() const { return GetBlockSharedPointer().get(); } + MeshBlock *GetParentPointer() const { return GetBlockPointer(); } void SetAllowedDt(const Real dt) const { GetBlockPointer()->SetAllowedDt(dt); } Mesh *GetMeshPointer() const { return GetBlockPointer()->pmy_mesh; } @@ -97,10 +97,10 @@ class MeshBlockData { SetBlockPointer(other.get()); } void SetBlockPointer(const MeshBlockData &other) { - pmy_block = other.GetBlockPointer(); + pmy_block = other.GetBlockSharedPointer(); } void SetBlockPointer(const MeshBlockData *other) { - pmy_block = other->GetBlockPointer(); + pmy_block = other->GetBlockSharedPointer(); } void Initialize(const std::shared_ptr resolved_packages, diff --git a/src/interface/update.cpp b/src/interface/update.cpp index e4da9849f8d2..ea13f83b1790 100644 --- a/src/interface/update.cpp +++ b/src/interface/update.cpp @@ -35,7 +35,7 @@ namespace Update { template <> TaskStatus FluxDivergence(MeshBlockData *in, MeshBlockData *dudt_cont) { - std::shared_ptr pmb = in->GetBlockPointer(); + MeshBlock *pmb = in->GetBlockPointer(); const IndexDomain interior = IndexDomain::interior; const IndexRange ib = in->GetBoundsI(interior); @@ -87,7 +87,7 @@ template <> TaskStatus UpdateWithFluxDivergence(MeshBlockData *u0_data, MeshBlockData *u1_data, const Real gam0, const Real gam1, const Real beta_dt) { - std::shared_ptr pmb = u0_data->GetBlockPointer(); + MeshBlock *pmb = u0_data->GetBlockPointer(); const IndexDomain interior = IndexDomain::interior; const IndexRange ib = u0_data->GetBoundsI(interior); diff --git a/src/mesh/amr_loadbalance.cpp b/src/mesh/amr_loadbalance.cpp index 1bebea12216a..3db82c4fef65 100644 --- a/src/mesh/amr_loadbalance.cpp +++ b/src/mesh/amr_loadbalance.cpp @@ -751,7 +751,7 @@ void Mesh::RedistributeAndRefineMeshBlocks(ParameterInput *pin, ApplicationInput auto pmb = FindMeshBlock(on); for (auto &var : pmb->vars_cc_) { restriction_cache.RegisterRegionHost( - irestrict++, ProResInfo::GetInteriorRestrict(pmb, NeighborBlock(), var), + irestrict++, ProResInfo::GetInteriorRestrict(pmb.get(), NeighborBlock(), var), var.get(), resolved_packages.get()); } } @@ -917,8 +917,9 @@ void Mesh::RedistributeAndRefineMeshBlocks(ParameterInput *pin, ApplicationInput auto pmb = FindMeshBlock(nn); for (auto &var : pmb->vars_cc_) { prolongation_cache.RegisterRegionHost( - iprolong++, ProResInfo::GetInteriorProlongate(pmb, NeighborBlock(), var), - var.get(), resolved_packages.get()); + iprolong++, + ProResInfo::GetInteriorProlongate(pmb.get(), NeighborBlock(), var), var.get(), + resolved_packages.get()); } } }