// @HEADER // ***************************************************************************** // MueLu: A package for multigrid based preconditioning // // Copyright 2012 NTESS and the MueLu contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #include #include #include #include "MueLu_TestHelpers_kokkos.hpp" #include #include "MueLu_Level.hpp" #include #include "MueLu_Aggregates.hpp" #include "MueLu_AmalgamationFactory.hpp" #include "MueLu_CoalesceDropFactory_kokkos.hpp" namespace MueLuTests { TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(AmalgamationInfo_kokkos, Constructor, Scalar, LocalOrdinal, GlobalOrdinal, Node) { #include MUELU_TESTING_SET_OSTREAM; MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); out << "version: " << MueLu::Version() << std::endl; LO fullblocksize = 1; // block dim for fixed size blocks GO offset = 0; // global offset of dof gids LO blockid = -1; // block id in strided map LO nStridedOffset = 0; // DOF offset for strided block id "blockid" (default = 0) LO stridedblocksize = fullblocksize; // size of strided block id "blockid" (default = fullblocksize, only if blockid!=-1 stridedblocksize <= fullblocksize) const GO nx = 199; using test_factory = TestHelpers_kokkos::TestFactory; RCP A = TestHelpers_kokkos::TestFactory::Build1DPoisson(nx); RCP amalgamationData; RCP > theRowTranslation = rcp(new Array); RCP > theColTranslation = rcp(new Array); RCP amalgamationInfo_kokkos = rcp(new AmalgamationInfo(theRowTranslation, theColTranslation, A->getRowMap(), A->getColMap(), A->getColMap(), fullblocksize, offset, blockid, nStridedOffset, stridedblocksize)); TEST_INEQUALITY(amalgamationInfo_kokkos, Teuchos::null); TEST_EQUALITY(amalgamationInfo_kokkos->description(), "AmalgamationInfo"); LO fullBlockSizeExpected; LO blockIDExpected; LO stridingOffsetExpected; LO stridedBlockSizeExpected; GO indexBaseExpected; amalgamationInfo_kokkos->GetStridingInformation(fullBlockSizeExpected, blockIDExpected, stridingOffsetExpected, stridedBlockSizeExpected, indexBaseExpected); TEST_EQUALITY(fullBlockSizeExpected == fullblocksize, true); TEST_EQUALITY(blockIDExpected == blockid, true); TEST_EQUALITY(stridingOffsetExpected == nStridedOffset, true); TEST_EQUALITY(stridedBlockSizeExpected == stridedblocksize, true); TEST_EQUALITY(indexBaseExpected == A->getColMap()->getIndexBase(), true); TEST_EQUALITY(amalgamationInfo_kokkos->getNodeRowMap() == A->getRowMap(), true); TEST_EQUALITY(amalgamationInfo_kokkos->getNodeColMap() == A->getColMap(), true); TEST_EQUALITY(amalgamationInfo_kokkos->getRowTranslation() == theRowTranslation, true); TEST_EQUALITY(amalgamationInfo_kokkos->getColTranslation() == theColTranslation, true); TEST_EQUALITY(amalgamationInfo_kokkos->GlobalOffset() == offset, true); } // Constructor TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(AmalgamationInfo_kokkos, UnamalgateAggregate, Scalar, LocalOrdinal, GlobalOrdinal, Node) { #include MUELU_TESTING_SET_OSTREAM; MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); out << "version: " << MueLu::Version() << std::endl; LO fullblocksize = 1; // block dim for fixed size blocks GO offset = 0; // global offset of dof gids LO blockid = -1; // block id in strided map LO nStridedOffset = 0; // DOF offset for strided block id "blockid" (default = 0) LO stridedblocksize = fullblocksize; // size of strided block id "blockid" (default = fullblocksize, only if blockid!=-1 stridedblocksize <= fullblocksize) const GO nx = 199; using test_factory = TestHelpers_kokkos::TestFactory; RCP A = TestHelpers_kokkos::TestFactory::Build1DPoisson(nx); RCP amalgamationData; RCP > theRowTranslation = rcp(new Array); RCP > theColTranslation = rcp(new Array); RCP amalgamationInfo_kokkos = rcp(new AmalgamationInfo(theRowTranslation, theColTranslation, A->getRowMap(), A->getColMap(), A->getColMap(), fullblocksize, offset, blockid, nStridedOffset, stridedblocksize)); RCP amalgFact = rcp(new AmalgamationFactory()); RCP dropFact = rcp(new CoalesceDropFactory_kokkos()); dropFact->SetFactory("UnAmalgamationInfo", amalgFact); RCP graph; Level level; TestHelpers_kokkos::TestFactory::createSingleLevelHierarchy(level); level.Set("A", A); level.Request("Graph", dropFact.get()); level.Request(*dropFact); dropFact->Build(level); graph = level.Get >("Graph", dropFact.get()); RCP aggregates = rcp(new Aggregates(*graph)); GO numAggs = aggregates->GetNumAggregates(); ArrayRCP aggSizes = Teuchos::ArrayRCP(numAggs); ArrayRCP aggStart; ArrayRCP aggToRowMap; amalgamationInfo_kokkos->UnamalgamateAggregates(*aggregates, aggStart, aggToRowMap); } // UnamalgateAggregate #define MUELU_ETI_GROUP(Scalar, LO, GO, Node) \ TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(AmalgamationInfo_kokkos, Constructor, Scalar, LO, GO, Node) \ TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(AmalgamationInfo_kokkos, UnamalgateAggregate, Scalar, LO, GO, Node) #include } // namespace MueLuTests