// @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 // Galeri #include #include #include //#include #include #include #include #include #include #include namespace MueLuTests { TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(UncoupledAggregationFactory, Constructor, Scalar, LocalOrdinal, GlobalOrdinal, Node) { #include out << "version: " << MueLu::Version() << std::endl; RCP aggFact = rcp(new UncoupledAggregationFactory()); TEST_EQUALITY(aggFact != Teuchos::null, true); TEST_THROW(aggFact->SetOrdering("unknown_ordering"), Teuchos::Exceptions::InvalidParameterValue); aggFact->SetOrdering("natural"); TEST_EQUALITY(aggFact->GetOrdering() == "natural", true); aggFact->SetOrdering("graph"); TEST_EQUALITY(aggFact->GetOrdering() == "graph", true); aggFact->SetOrdering("random"); TEST_EQUALITY(aggFact->GetOrdering() == "random", true); aggFact->SetMaxNeighAlreadySelected(100); TEST_EQUALITY(aggFact->GetMaxNeighAlreadySelected() == 100, true); aggFact->SetMinNodesPerAggregate(10); TEST_EQUALITY(aggFact->GetMinNodesPerAggregate() == 10, true); auto validParamList = aggFact->GetValidParameterList(); TEST_EQUALITY(validParamList != Teuchos::null, true); } // Constructor TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(UncoupledAggregationFactory, Build, Scalar, LocalOrdinal, GlobalOrdinal, Node) { #include MUELU_TESTING_SET_OSTREAM; MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); out << "version: " << MueLu::Version() << std::endl; RCP > comm = TestHelpers_kokkos::Parameters::getDefaultComm(); // Make a Matrix with multiple degrees of freedom per node GlobalOrdinal nx = 20, ny = 20; // Describes the initial layout of matrix rows across processors. Teuchos::ParameterList galeriList; galeriList.set("nx", nx); galeriList.set("ny", ny); const GO nxx = 200; using test_factory = TestHelpers_kokkos::TestFactory; Teuchos::CommandLineProcessor clp(false); Galeri::Xpetra::Parameters matrixParameters(clp, 8748); // manage parameters of the test case Xpetra::Parameters xpetraParameters(clp); // manage parameters of xpetra RCP A = TestHelpers_kokkos::TestFactory::Build1DPoisson(nxx); RCP map = MapFactory::Build(xpetraParameters.GetLib(), matrixParameters.GetNumGlobalElements(), 0, comm); map = Xpetra::MapFactory::Build(map, 2); // expand map for 2 DOFs per node A->SetFixedBlockSize(2); Level aLevel; TestHelpers_kokkos::TestFactory::createSingleLevelHierarchy(aLevel); aLevel.Request("A"); aLevel.Set("A", A); RCP amalgFact = rcp(new AmalgamationFactory()); RCP dropFact = rcp(new CoalesceDropFactory_kokkos()); dropFact->SetFactory("UnAmalgamationInfo", amalgFact); RCP aggFact = rcp(new UncoupledAggregationFactory()); aggFact->SetFactory("Graph", dropFact); aLevel.Request(*aggFact); aggFact->Build(aLevel); } // Build TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(UncoupledAggregationFactory, Build_MIS2_Coarsen, Scalar, LocalOrdinal, GlobalOrdinal, Node) { #include MUELU_TESTING_SET_OSTREAM; MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); out << "version: " << MueLu::Version() << std::endl; RCP > comm = TestHelpers_kokkos::Parameters::getDefaultComm(); // Make a Matrix with multiple degrees of freedom per node GlobalOrdinal nx = 20, ny = 20; // Describes the initial layout of matrix rows across processors. Teuchos::ParameterList galeriList; galeriList.set("nx", nx); galeriList.set("ny", ny); const GO nxx = 200; using test_factory = TestHelpers_kokkos::TestFactory; Teuchos::CommandLineProcessor clp(false); Galeri::Xpetra::Parameters matrixParameters(clp, 8748); // manage parameters of the test case Xpetra::Parameters xpetraParameters(clp); // manage parameters of xpetra RCP A = TestHelpers_kokkos::TestFactory::Build1DPoisson(nxx); RCP map = MapFactory::Build(xpetraParameters.GetLib(), matrixParameters.GetNumGlobalElements(), 0, comm); map = Xpetra::MapFactory::Build(map, 2); // expand map for 2 DOFs per node A->SetFixedBlockSize(2); Level aLevel; TestHelpers_kokkos::TestFactory::createSingleLevelHierarchy(aLevel); aLevel.Request("A"); aLevel.Set("A", A); RCP amalgFact = rcp(new AmalgamationFactory()); RCP dropFact = rcp(new CoalesceDropFactory_kokkos()); dropFact->SetFactory("UnAmalgamationInfo", amalgFact); RCP aggFact = rcp(new UncoupledAggregationFactory()); aggFact->SetFactory("Graph", dropFact); aggFact->SetParameter("aggregation: coloring algorithm", Teuchos::ParameterEntry(std::string("mis2 coarsening"))); aLevel.Request(*aggFact); aggFact->Build(aLevel); } // Build_MIS2_Coarsen TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(UncoupledAggregationFactory, Build_MIS2_Aggregate, Scalar, LocalOrdinal, GlobalOrdinal, Node) { #include MUELU_TESTING_SET_OSTREAM; MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); out << "version: " << MueLu::Version() << std::endl; RCP > comm = TestHelpers_kokkos::Parameters::getDefaultComm(); // Make a Matrix with multiple degrees of freedom per node GlobalOrdinal nx = 20, ny = 20; // Describes the initial layout of matrix rows across processors. Teuchos::ParameterList galeriList; galeriList.set("nx", nx); galeriList.set("ny", ny); const GO nxx = 200; using test_factory = TestHelpers_kokkos::TestFactory; Teuchos::CommandLineProcessor clp(false); Galeri::Xpetra::Parameters matrixParameters(clp, 8748); // manage parameters of the test case Xpetra::Parameters xpetraParameters(clp); // manage parameters of xpetra RCP A = TestHelpers_kokkos::TestFactory::Build1DPoisson(nxx); RCP map = MapFactory::Build(xpetraParameters.GetLib(), matrixParameters.GetNumGlobalElements(), 0, comm); map = Xpetra::MapFactory::Build(map, 2); // expand map for 2 DOFs per node A->SetFixedBlockSize(2); Level aLevel; TestHelpers_kokkos::TestFactory::createSingleLevelHierarchy(aLevel); aLevel.Request("A"); aLevel.Set("A", A); RCP amalgFact = rcp(new AmalgamationFactory()); RCP dropFact = rcp(new CoalesceDropFactory_kokkos()); dropFact->SetFactory("UnAmalgamationInfo", amalgFact); RCP aggFact = rcp(new UncoupledAggregationFactory()); aggFact->SetFactory("Graph", dropFact); aggFact->SetParameter("aggregation: coloring algorithm", Teuchos::ParameterEntry(std::string("mis2 aggregation"))); aLevel.Request(*aggFact); aggFact->Build(aLevel); } // Build_MIS2_Aggregate #define MUELU_ETI_GROUP(Scalar, LO, GO, Node) \ TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(UncoupledAggregationFactory, Constructor, Scalar, LO, GO, Node) \ TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(UncoupledAggregationFactory, Build, Scalar, LO, GO, Node) \ TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(UncoupledAggregationFactory, Build_MIS2_Coarsen, Scalar, LO, GO, Node) \ TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(UncoupledAggregationFactory, Build_MIS2_Aggregate, Scalar, LO, GO, Node) #include } // namespace MueLuTests