Skip to content

Commit

Permalink
move and comment GetLevelsAndLogicalLocationsFlat
Browse files Browse the repository at this point in the history
  • Loading branch information
lroberts36 committed Apr 15, 2024
1 parent 188ed2a commit 46239a8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
20 changes: 20 additions & 0 deletions src/mesh/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,4 +1347,24 @@ void Mesh::SetupMPIComms() {
#endif
}

// Return list of locations and levels for the legacy tree
// TODO(LFR): It doesn't make sense to offset the level by the
// legacy tree root level since the location indices are defined
// for loc.level(). It seems this level offset is required for
// the output to agree with the legacy output though.
std::pair<std::vector<std::int64_t>, std::vector<std::int64_t>>
Mesh::GetLevelsAndLogicalLocationsFlat() const noexcept {
std::vector<std::int64_t> levels, logicalLocations;
levels.reserve(nbtotal);
logicalLocations.reserve(nbtotal * 3);
for (auto loc : loclist) {
loc = forest.GetLegacyTreeLocation(loc);
levels.push_back(loc.level() - GetLegacyTreeRootLevel());
logicalLocations.push_back(loc.lx1());
logicalLocations.push_back(loc.lx2());
logicalLocations.push_back(loc.lx3());
}
return std::make_pair(levels, logicalLocations);
}

} // namespace parthenon
16 changes: 2 additions & 14 deletions src/mesh/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,8 @@ class Mesh {
std::vector<int> GetNbList() const noexcept { return nblist; }
std::vector<LogicalLocation> GetLocList() const noexcept { return loclist; }

// TODO(JMM): Put in implementation file?
auto GetLevelsAndLogicalLocationsFlat() const noexcept {
std::vector<std::int64_t> levels, logicalLocations;
levels.reserve(nbtotal);
logicalLocations.reserve(nbtotal * 3);
for (auto loc : loclist) {
loc = forest.GetLegacyTreeLocation(loc);
levels.push_back(loc.level());
logicalLocations.push_back(loc.lx1());
logicalLocations.push_back(loc.lx2());
logicalLocations.push_back(loc.lx3());
}
return std::make_pair(levels, logicalLocations);
}
std::pair<std::vector<std::int64_t>, std::vector<std::int64_t>>
GetLevelsAndLogicalLocationsFlat() const noexcept;

void OutputMeshStructure(const int dim, const bool dump_mesh_structure = true);

Expand Down

0 comments on commit 46239a8

Please sign in to comment.