| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// MueLu: A package for multigrid based preconditioning |
| 4 |
// |
| 5 |
// Copyright 2012 NTESS and the MueLu contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#include "Teuchos_UnitTestHarness.hpp" |
| 11 |
|
| 12 |
#include "MueLu_TestHelpers_kokkos.hpp" |
| 13 |
#include "MueLu_Version.hpp" |
| 14 |
|
| 15 |
#include <Xpetra_MultiVectorFactory.hpp> |
| 16 |
|
| 17 |
#include "MueLu_Aggregates.hpp" |
| 18 |
#include "MueLu_CoarseMapFactory.hpp" |
| 19 |
|
| 20 |
namespace MueLuTests { |
| 21 |
|
| 22 |
TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(CoarseMap_kokkos, StandardCase, Scalar, LocalOrdinal, GlobalOrdinal, Node) { |
| 23 |
#include "MueLu_UseShortNames.hpp" |
| 24 |
MUELU_TESTING_SET_OSTREAM; |
| 25 |
MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, NO); |
| 26 |
out << "version: " << MueLu::Version() << std::endl; |
| 27 |
|
| 28 |
Level fineLevel; |
| 29 |
TestHelpers_kokkos::TestFactory<SC, LO, GO, NO>::createSingleLevelHierarchy(fineLevel); |
| 30 |
|
| 31 |
RCP<Matrix> A = TestHelpers_kokkos::TestFactory<SC, LO, GO, NO>::Build1DPoisson(15); |
| 32 |
fineLevel.Set("A", A); |
| 33 |
|
| 34 |
// build dummy aggregate structure |
| 35 |
RCP<Aggregates> aggs = Teuchos::rcp(new Aggregates(A->getRowMap())); |
| 36 |
aggs->SetNumAggregates(10); // set (local!) number of aggregates |
| 37 |
fineLevel.Set("Aggregates", aggs); |
| 38 |
|
| 39 |
// build dummy nullspace vector |
| 40 |
RCP<MultiVector> nsp = MultiVectorFactory::Build(A->getRowMap(), 1); |
| 41 |
nsp->putScalar(1.0); |
| 42 |
fineLevel.Set("Nullspace", nsp); |
| 43 |
|
| 44 |
RCP<CoarseMapFactory> coarseMapFactory = Teuchos::rcp(new CoarseMapFactory()); |
| 45 |
coarseMapFactory->SetFactory("Aggregates", MueLu::NoFactory::getRCP()); |
| 46 |
coarseMapFactory->SetFactory("Nullspace", MueLu::NoFactory::getRCP()); |
| 47 |
|
| 48 |
fineLevel.Request("CoarseMap", coarseMapFactory.get()); |
| 49 |
coarseMapFactory->Build(fineLevel); |
| 50 |
|
| 51 |
auto myCoarseMap = fineLevel.Get<Teuchos::RCP<const Map> >("CoarseMap", coarseMapFactory.get()); |
| 52 |
|
| 53 |
TEST_EQUALITY(myCoarseMap->getMinAllGlobalIndex() == 0, true); |
| 54 |
TEST_EQUALITY(myCoarseMap->getMaxLocalIndex() == 9, true); |
| 55 |
} |
| 56 |
|
| 57 |
#define MUELU_ETI_GROUP(SC, LO, GO, NO) \ |
| 58 |
TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(CoarseMap_kokkos, StandardCase, SC, LO, GO, NO) |
| 59 |
|
| 60 |
#include <MueLu_ETI_4arg.hpp> |
| 61 |
|
| 62 |
} // namespace MueLuTests |