Skip to content

Commit

Permalink
Merge Pull Request #13362 from cgcgcg/Trilinos/mueluFixShuffle
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: b'MueLu: Silence warnings'
PR Author: cgcgcg
  • Loading branch information
trilinos-autotester authored Aug 19, 2024
2 parents ec9e57a + 282b669 commit ada2829
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/muelu/src/Misc/MueLu_FilteredAFactory_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ namespace MueLu {
template <class T>
void sort_and_unique(T& array) {
std::sort(array.begin(), array.end());
std::unique(array.begin(), array.end());
auto last = std::unique(array.begin(), array.end());
array.erase(last, array.end());
}

template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
Expand Down
6 changes: 3 additions & 3 deletions packages/muelu/test/unit_tests/Repartition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,13 +942,13 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(Repartition, CoordinateMap, Scalar, LocalOrdin

// build a map that is a "randomly" permuted version of the correct
// coordinate map. This map will be used to build the "bad" coordinates.
RCP<const Map> coordMap = coordinates->getMap();
std::srand(Teuchos::as<unsigned int>(comm->getRank() * 31415));
RCP<const Map> coordMap = coordinates->getMap();
Teuchos::ArrayView<const GlobalOrdinal> correctLocalElts = coordMap->getLocalElementList();
std::vector<GlobalOrdinal> eltsToShuffle;
for (size_t i = 0; i < Teuchos::as<size_t>(correctLocalElts.size()); ++i)
eltsToShuffle.push_back(correctLocalElts[i]);
std::random_shuffle(eltsToShuffle.begin(), eltsToShuffle.end(), [](GlobalOrdinal i) { return std::rand() % i; });
std::mt19937 g(Teuchos::as<unsigned int>(comm->getRank() * 31415));
std::shuffle(eltsToShuffle.begin(), eltsToShuffle.end(), g);
Teuchos::Array<GlobalOrdinal> eltList(eltsToShuffle);
RCP<const Map> badMap = MapFactory::Build(TestHelpers::Parameters::getLib(), coordMap->getGlobalNumElements(), eltList(), coordMap->getIndexBase(), comm);

Expand Down

0 comments on commit ada2829

Please sign in to comment.