// @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 #include #include #include #include // Xpetra #include #include #include #include #include #include #include #include #include #include // MueLu #include #include #include #include #include #include #include #include #include using Teuchos::RCP; using Teuchos::rcp; // Copy & paste from MueLu_TestHelpers.cpp namespace MueLuTests { // static members initialization of the class TestHelpers::Parameters Xpetra::Parameters TestHelpers::Parameters::xpetraParameters = Xpetra::Parameters(Teuchos::UnitTestRepository::getCLP()); } // namespace MueLuTests template typename Teuchos::ScalarTraits::magnitudeType CheckCommutingProperty(MueLu::Level& nodeLevel_coarse, MueLu::Level& edgeLevel_fine, MueLu::Level& edgeLevel_coarse) { #include RCP Pn = nodeLevel_coarse.Get >("P"); RCP Pe = edgeLevel_coarse.Get >("P"); RCP D0_f = edgeLevel_fine.Get >("D0"); RCP D0_c = edgeLevel_coarse.Get >("D0"); using XMM = Xpetra::MatrixMatrix; using MT = typename Teuchos::ScalarTraits::magnitudeType; SC one = Teuchos::ScalarTraits::one(); SC zero = Teuchos::ScalarTraits::zero(); RCP dummy; RCP out0 = Teuchos::getFancyOStream(rcp(new Teuchos::oblackholestream())); RCP left = XMM::Multiply(*Pe, false, *D0_c, false, dummy, *out0); RCP right = XMM::Multiply(*D0_f, false, *Pn, false, dummy, *out0); // We need a non-FC matrix for the add, sadly RCP sum_c = CrsMatrixFactory::Build(left->getRowMap(), left->getLocalMaxNumRowEntries() + right->getLocalMaxNumRowEntries()); RCP summation = rcp(new CrsMatrixWrap(sum_c)); XMM::TwoMatrixAdd(*left, false, one, *summation, zero); XMM::TwoMatrixAdd(*right, false, -one, *summation, one); MT norm = summation->getFrobeniusNorm(); return norm; } template void read_matrix(Xpetra::UnderlyingLib& lib, RCP >& comm, RCP >& SM_Matrix, RCP >& D0_Matrix, RCP >& Kn_Matrix, RCP::magnitudeType, LocalOrdinal, GlobalOrdinal, Node> >& coords) { #include RCP out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout)); std::string S_file, M1_file, D0_file; if (!Teuchos::ScalarTraits::isComplex) { S_file = "S.mat"; D0_file = "D0.mat"; M1_file = "M1.mat"; } else { S_file = "S_complex.mat"; D0_file = "D0_complex.mat"; M1_file = "M1_complex.mat"; } std::string coords_file = "coords.mat"; // maps for nodal and edge matrices RCP node_map; RCP edge_map; // gradient matrix try { std::string base = D0_file.substr(0, D0_file.find_last_of('/') + 1); std::string D0_filename = D0_file.substr(D0_file.find_last_of('/') + 1, std::string::npos); std::string edgeMap_file = base + "rowmap_" + D0_filename; std::string nodeMap_file = base + "domainmap_" + D0_filename; std::string colMap_file = base + "colmap_" + D0_filename; node_map = Xpetra::IO::ReadMap(nodeMap_file, lib, comm); edge_map = Xpetra::IO::ReadMap(edgeMap_file, lib, comm); RCP colMap; if (comm->getSize() > 1) colMap = Xpetra::IO::ReadMap(colMap_file, lib, comm); D0_Matrix = Xpetra::IO::Read(D0_file, edge_map, colMap, node_map, edge_map); } catch (const std::exception&) { // *out << "Skipping D0 maps, because: " << e.what() << std::endl; D0_Matrix = Xpetra::IO::Read(D0_file, lib, comm); node_map = D0_Matrix->getDomainMap(); edge_map = D0_Matrix->getRangeMap(); } // build stiffness plus mass matrix (SM_Matrix) // edge stiffness matrix RCP S_Matrix = Xpetra::IO::Read(S_file, edge_map); RCP M1_Matrix = Xpetra::IO::Read(M1_file, edge_map); Scalar one = Teuchos::ScalarTraits::one(); Xpetra::MatrixMatrix::TwoMatrixAdd(*S_Matrix, false, one, *M1_Matrix, false, one, SM_Matrix, *out); SM_Matrix->fillComplete(); // coordinates coords = Xpetra::IO::magnitudeType, LO, GO, NO>::ReadMultiVector(coords_file, node_map); // Generate Kn matrix { RCP temp = Xpetra::MatrixFactory::Build(SM_Matrix->getRangeMap()); Xpetra::MatrixMatrix::Multiply(*SM_Matrix, false, *D0_Matrix, false, *temp, true, true); Kn_Matrix = Xpetra::MatrixFactory::Build(D0_Matrix->getDomainMap()); Xpetra::MatrixMatrix::Multiply(*D0_Matrix, true, *temp, false, *Kn_Matrix, true, true); } } namespace MueLuTests { TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(ReitzingerPFactory, Setup2Level_Unsmoothed, Scalar, LocalOrdinal, GlobalOrdinal, Node) { #include MUELU_TESTING_SET_OSTREAM; MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); RCP > comm = TestHelpers::Parameters::getDefaultComm(); Xpetra::UnderlyingLib lib = MueLuTests::TestHelpers::Parameters::getLib(); RCP SM_Matrix, D0_Matrix, Kn_Matrix; RCP::magnitudeType, LO, GO, NO> > coords; read_matrix(lib, comm, SM_Matrix, D0_Matrix, Kn_Matrix, coords); int NumLevels = 2; // This guy works by generating a nodal hierarchy, copying the relevant data to the edge hierarchy // and then generating the edge hierarchy Hierarchy NodeH, EdgeH; // NodeH.EnableGraphDumping("node_graph_0",0); // EdgeH.EnableGraphDumping("edge_graph_0",0); NodeH.SetMaxCoarseSize(10); // Generate Node Hierarchy out << "*** Setting Up Node Hierarchy *** " << std::endl; { RCP Finest = NodeH.GetLevel(); Finest->setDefaultVerbLevel(Teuchos::VERB_HIGH); Finest->Set("A", Kn_Matrix); // Level 0 FactoryManager M0; // how to build aggregates and smoother of the first level M0.SetKokkosRefactor(false); // Level 1 (Plain aggregation) FactoryManager M1; M1.SetKokkosRefactor(false); Teuchos::ParameterList tp_list; tp_list.set("tentative: constant column sums", false); tp_list.set("tentative: calculate qr", false); RCP PnodalFact = rcp(new TentativePFactory()); PnodalFact->SetParameterList(tp_list); M1.SetFactory("P", PnodalFact); M1.SetFactory("CoarseSolver", Teuchos::null); bool r; r = NodeH.Setup(0, Teuchos::null, rcpFromRef(M0), rcpFromRef(M1)); TEST_EQUALITY(r, false); r = NodeH.Setup(1, rcpFromRef(M0), rcpFromRef(M1), Teuchos::null); TEST_EQUALITY(r, true); RCP l0 = NodeH.GetLevel(0); RCP l1 = NodeH.GetLevel(1); } out << "*** Copy Node->Edge Data *** " << std::endl; // Copy Data to Edge Hierarchy for (int i = 0; i < NumLevels; i++) { EdgeH.AddNewLevel(); RCP NodeL = NodeH.GetLevel(i); RCP EdgeL = EdgeH.GetLevel(i); EdgeL->Set("NodeAggMatrix", NodeL->Get >("A")); EdgeL->Set("NodeMatrix", NodeL->Get >("A")); if (i != 0) { EdgeL->Set("Pnodal", NodeL->Get >("P")); RCP P = NodeL->Get >("P"); // Xpetra::IO::Write("Pn.mat",*P); } if (i == 0) { EdgeL->Set("A", SM_Matrix); EdgeL->Set("D0", D0_Matrix); } } // Generate the Edge Hierarchy out << "*** Setting Up Edge Hierarchy *** " << std::endl; { FactoryManager M0; // how to build aggregates and smoother of the first level M0.SetKokkosRefactor(false); // Level 1 (Plain aggregation) FactoryManager M1; M1.SetKokkosRefactor(false); RCP PedgeFact = rcp(new ReitzingerPFactory()); M1.SetFactory("P", PedgeFact); M1.SetFactory("CoarseSolver", Teuchos::null); // Do the setup bool r; r = EdgeH.Setup(0, Teuchos::null, rcpFromRef(M0), rcpFromRef(M1)); TEST_EQUALITY(r, false); r = EdgeH.Setup(1, rcpFromRef(M0), rcpFromRef(M1), Teuchos::null); TEST_EQUALITY(r, true); } RCP l0 = EdgeH.GetLevel(0); RCP l1 = EdgeH.GetLevel(1); RCP node_l1 = NodeH.GetLevel(1); TEST_EQUALITY(l0->IsAvailable("A", MueLu::NoFactory::get()), true); TEST_EQUALITY(l1->IsAvailable("A", MueLu::NoFactory::get()), true); TEST_EQUALITY(l1->IsAvailable("P", MueLu::NoFactory::get()), true); // Check the commuting property using MT = typename Teuchos::ScalarTraits::magnitudeType; Teuchos::Array norm(1), norm0(1); norm0[0] = Teuchos::ScalarTraits::zero(); norm[0] = CheckCommutingProperty(*node_l1, *l0, *l1); TEST_COMPARE_FLOATING_ARRAYS(norm, norm0, Teuchos::ScalarTraits::eps() * 100) } TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(ReitzingerPFactory, Setup2Level_AlphaSmoothed, Scalar, LocalOrdinal, GlobalOrdinal, Node) { #include MUELU_TESTING_SET_OSTREAM; MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); RCP > comm = TestHelpers::Parameters::getDefaultComm(); Xpetra::UnderlyingLib lib = MueLuTests::TestHelpers::Parameters::getLib(); RCP SM_Matrix, D0_Matrix, Kn_Matrix; RCP::magnitudeType, LO, GO, NO> > coords; read_matrix(lib, comm, SM_Matrix, D0_Matrix, Kn_Matrix, coords); int NumLevels = 2; // This guy works by generating a nodal hierarchy, copying the relevant data to the edge hierarchy // and then generating the edge hierarchy Hierarchy NodeH, EdgeH; NodeH.SetMaxCoarseSize(10); // NodeH.EnableGraphDumping("node_graph_0",0); // EdgeH.EnableGraphDumping("edge_graph_0",0); // Generate Node Hierarchy out << "*** Setting Up Node Hierarchy *** " << std::endl; { RCP Finest = NodeH.GetLevel(); Finest->setDefaultVerbLevel(Teuchos::VERB_HIGH); Finest->Set("A", Kn_Matrix); // Level 0 FactoryManager M0; // how to build aggregates and smoother of the first level M0.SetKokkosRefactor(false); // Level 1 (Plain aggregation) FactoryManager M1; M1.SetKokkosRefactor(false); Teuchos::ParameterList tp_list; tp_list.set("tentative: constant column sums", false); tp_list.set("tentative: calculate qr", false); RCP PnodalFact = rcp(new TentativePFactory()); PnodalFact->SetParameterList(tp_list); M1.SetFactory("P", PnodalFact); M1.SetFactory("CoarseSolver", Teuchos::null); bool r; r = NodeH.Setup(0, Teuchos::null, rcpFromRef(M0), rcpFromRef(M1)); TEST_EQUALITY(r, false); r = NodeH.Setup(1, rcpFromRef(M0), rcpFromRef(M1), Teuchos::null); TEST_EQUALITY(r, true); RCP l0 = NodeH.GetLevel(0); RCP l1 = NodeH.GetLevel(1); } out << "*** Copy Node->Edge Data *** " << std::endl; // Copy Data to Edge Hierarchy for (int i = 0; i < NumLevels; i++) { EdgeH.AddNewLevel(); RCP NodeL = NodeH.GetLevel(i); RCP EdgeL = EdgeH.GetLevel(i); EdgeL->Set("NodeAggMatrix", NodeL->Get >("A")); EdgeL->Set("NodeMatrix", NodeL->Get >("A")); if (i != 0) { EdgeL->Set("Pnodal", NodeL->Get >("P")); RCP P = NodeL->Get >("P"); // Xpetra::IO::Write("Pn.mat",*P); } if (i == 0) { EdgeL->Set("A", SM_Matrix); EdgeL->Set("D0", D0_Matrix); } } // Generate the Edge Hierarchy out << "*** Setting Up Edge Hierarchy *** " << std::endl; { FactoryManager M0; // how to build aggregates and smoother of the first level M0.SetKokkosRefactor(false); // Level 1 (Smoothed Reitzinger) FactoryManager M1; M1.SetKokkosRefactor(false); RCP PedgeFact = rcp(new ReitzingerPFactory()); RCP PFact = rcp(new SaPFactory()); PFact->SetFactory("P", PedgeFact); M1.SetFactory("Ptent", PedgeFact); M1.SetFactory("P", PFact); M1.SetFactory("CoarseSolver", Teuchos::null); // Do the setup bool r; r = EdgeH.Setup(0, Teuchos::null, rcpFromRef(M0), rcpFromRef(M1)); TEST_EQUALITY(r, false); r = EdgeH.Setup(1, rcpFromRef(M0), rcpFromRef(M1), Teuchos::null); TEST_EQUALITY(r, true); } RCP l0 = EdgeH.GetLevel(0); RCP l1 = EdgeH.GetLevel(1); { RCP Pe = l1->Get >("P"); // Xpetra::IO::Write("Pe.mat",*Pe); } TEST_EQUALITY(l0->IsAvailable("A", MueLu::NoFactory::get()), true); TEST_EQUALITY(l1->IsAvailable("A", MueLu::NoFactory::get()), true); TEST_EQUALITY(l1->IsAvailable("P", MueLu::NoFactory::get()), true); } TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(ReitzingerPFactory, Setup3Level_AlphaSmoothed, Scalar, LocalOrdinal, GlobalOrdinal, Node) { #include MUELU_TESTING_SET_OSTREAM; MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); RCP > comm = TestHelpers::Parameters::getDefaultComm(); Xpetra::UnderlyingLib lib = MueLuTests::TestHelpers::Parameters::getLib(); RCP SM_Matrix, D0_Matrix, Kn_Matrix; RCP::magnitudeType, LO, GO, NO> > coords; read_matrix(lib, comm, SM_Matrix, D0_Matrix, Kn_Matrix, coords); int NumLevels = 3; // This guy works by generating a nodal hierarchy, copying the relevant data to the edge hierarchy // and then generating the edge hierarchy Hierarchy NodeH, EdgeH; NodeH.SetMaxCoarseSize(1); EdgeH.SetMaxCoarseSize(1); // NodeH.EnableGraphDumping("node_graph_0",0); // EdgeH.EnableGraphDumping("edge_graph_0",0); // Generate Node Hierarchy out << "*** Setting Up Node Hierarchy *** " << std::endl; { RCP Finest = NodeH.GetLevel(); Finest->setDefaultVerbLevel(Teuchos::VERB_HIGH); Finest->Set("A", Kn_Matrix); Finest->Set("Coordinates", coords); // Level 0 FactoryManager M0; // how to build aggregates and smoother of the first level M0.SetKokkosRefactor(false); // Level 1 (Plain aggregation) FactoryManager M1; { M1.SetKokkosRefactor(false); Teuchos::ParameterList tp_list; tp_list.set("tentative: constant column sums", false); tp_list.set("tentative: calculate qr", false); RCP PnodalFact = rcp(new TentativePFactory()); PnodalFact->SetParameterList(tp_list); M1.SetFactory("P", PnodalFact); M1.SetFactory("Ptent", PnodalFact); // You actually need this } // Level 2 (Plain aggregation) FactoryManager M2; { M2.SetKokkosRefactor(false); Teuchos::ParameterList tp_list; tp_list.set("tentative: constant column sums", false); tp_list.set("tentative: calculate qr", false); RCP PnodalFact = rcp(new TentativePFactory()); PnodalFact->SetParameterList(tp_list); M2.SetFactory("P", PnodalFact); M2.SetFactory("CoarseSolver", Teuchos::null); } bool r; r = NodeH.Setup(0, Teuchos::null, rcpFromRef(M0), rcpFromRef(M1)); TEST_EQUALITY(r, false); r = NodeH.Setup(1, rcpFromRef(M0), rcpFromRef(M1), rcpFromRef(M2)); TEST_EQUALITY(r, false); r = NodeH.Setup(2, rcpFromRef(M1), rcpFromRef(M2), Teuchos::null); TEST_EQUALITY(r, true); RCP l0 = NodeH.GetLevel(0); RCP l1 = NodeH.GetLevel(1); RCP l2 = NodeH.GetLevel(2); } out << "*** Copy Node->Edge Data *** " << std::endl; // Copy Data to Edge Hierarchy for (int i = 0; i < NumLevels; i++) { EdgeH.AddNewLevel(); RCP NodeL = NodeH.GetLevel(i); RCP EdgeL = EdgeH.GetLevel(i); EdgeL->Set("NodeAggMatrix", NodeL->Get >("A")); EdgeL->Set("NodeMatrix", NodeL->Get >("A")); if (i != 0) { EdgeL->Set("Pnodal", NodeL->Get >("P")); RCP P = NodeL->Get >("P"); // Xpetra::IO::Write("Pn.mat",*P); } if (i == 0) { EdgeL->Set("A", SM_Matrix); EdgeL->Set("D0", D0_Matrix); } } // Generate the Edge Hierarchy out << "*** Setting Up Edge Hierarchy *** " << std::endl; { FactoryManager M0; // how to build aggregates and smoother of the first level M0.SetKokkosRefactor(false); // Level 1 (Smoothed Reitzinger) FactoryManager M1; { M1.SetKokkosRefactor(false); RCP PedgeFact1 = rcp(new ReitzingerPFactory()); RCP PFact = rcp(new SaPFactory()); PFact->SetFactory("P", PedgeFact1); M1.SetFactory("Ptent", PedgeFact1); M1.SetFactory("D0", PedgeFact1); M1.SetFactory("P", PFact); } // Level 2 (just like level 1) FactoryManager M2; { M2.SetKokkosRefactor(false); RCP PedgeFact2 = rcp(new ReitzingerPFactory()); RCP PFact = rcp(new SaPFactory()); PFact->SetFactory("P", PedgeFact2); M2.SetFactory("Ptent", PedgeFact2); M2.SetFactory("D0", PedgeFact2); M2.SetFactory("P", PFact); M2.SetFactory("CoarseSolver", Teuchos::null); } // Do the setup bool r; r = EdgeH.Setup(0, Teuchos::null, rcpFromRef(M0), rcpFromRef(M1)); TEST_EQUALITY(r, false); r = EdgeH.Setup(1, rcpFromRef(M0), rcpFromRef(M1), rcpFromRef(M2)); TEST_EQUALITY(r, false); r = EdgeH.Setup(2, rcpFromRef(M1), rcpFromRef(M2), Teuchos::null); TEST_EQUALITY(r, true); } RCP node_l1 = NodeH.GetLevel(1); RCP node_l2 = NodeH.GetLevel(2); RCP l0 = EdgeH.GetLevel(0); RCP l1 = EdgeH.GetLevel(1); RCP l2 = EdgeH.GetLevel(2); TEST_EQUALITY(l0->IsAvailable("A", MueLu::NoFactory::get()), true); TEST_EQUALITY(l1->IsAvailable("A", MueLu::NoFactory::get()), true); TEST_EQUALITY(l1->IsAvailable("P", MueLu::NoFactory::get()), true); TEST_EQUALITY(l2->IsAvailable("A", MueLu::NoFactory::get()), true); TEST_EQUALITY(l2->IsAvailable("P", MueLu::NoFactory::get()), true); } TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(ReitzingerPFactory, Setup3Level_Unsmoothed, Scalar, LocalOrdinal, GlobalOrdinal, Node) { #include MUELU_TESTING_SET_OSTREAM; MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); RCP > comm = TestHelpers::Parameters::getDefaultComm(); Xpetra::UnderlyingLib lib = MueLuTests::TestHelpers::Parameters::getLib(); RCP SM_Matrix, D0_Matrix, Kn_Matrix; RCP::magnitudeType, LO, GO, NO> > coords; read_matrix(lib, comm, SM_Matrix, D0_Matrix, Kn_Matrix, coords); int NumLevels = 3; // This guy works by generating a nodal hierarchy, copying the relevant data to the edge hierarchy // and then generating the edge hierarchy Hierarchy NodeH, EdgeH; NodeH.SetMaxCoarseSize(1); EdgeH.SetMaxCoarseSize(1); // NodeH.EnableGraphDumping("node_graph_0",0); // EdgeH.EnableGraphDumping("edge_graph_0",0); // Generate Node Hierarchy out << "*** Setting Up Node Hierarchy *** " << std::endl; { RCP Finest = NodeH.GetLevel(); Finest->setDefaultVerbLevel(Teuchos::VERB_HIGH); Finest->Set("A", Kn_Matrix); Finest->Set("Coordinates", coords); // Level 0 FactoryManager M0; // how to build aggregates and smoother of the first level M0.SetKokkosRefactor(false); // Level 1 (Plain aggregation) FactoryManager M1; { M1.SetKokkosRefactor(false); Teuchos::ParameterList tp_list; tp_list.set("tentative: constant column sums", false); tp_list.set("tentative: calculate qr", false); RCP PnodalFact = rcp(new TentativePFactory()); PnodalFact->SetParameterList(tp_list); M1.SetFactory("P", PnodalFact); M1.SetFactory("Ptent", PnodalFact); // You actually need this } // Level 2 (Plain aggregation) FactoryManager M2; { M2.SetKokkosRefactor(false); Teuchos::ParameterList tp_list; tp_list.set("tentative: constant column sums", false); tp_list.set("tentative: calculate qr", false); RCP PnodalFact = rcp(new TentativePFactory()); PnodalFact->SetParameterList(tp_list); M2.SetFactory("P", PnodalFact); M2.SetFactory("CoarseSolver", Teuchos::null); } bool r; r = NodeH.Setup(0, Teuchos::null, rcpFromRef(M0), rcpFromRef(M1)); TEST_EQUALITY(r, false); r = NodeH.Setup(1, rcpFromRef(M0), rcpFromRef(M1), rcpFromRef(M2)); TEST_EQUALITY(r, false); r = NodeH.Setup(2, rcpFromRef(M1), rcpFromRef(M2), Teuchos::null); TEST_EQUALITY(r, true); RCP l0 = NodeH.GetLevel(0); RCP l1 = NodeH.GetLevel(1); RCP l2 = NodeH.GetLevel(2); } out << "*** Copy Node->Edge Data *** " << std::endl; // Copy Data to Edge Hierarchy for (int i = 0; i < NumLevels; i++) { EdgeH.AddNewLevel(); RCP NodeL = NodeH.GetLevel(i); RCP EdgeL = EdgeH.GetLevel(i); EdgeL->Set("NodeAggMatrix", NodeL->Get >("A")); EdgeL->Set("NodeMatrix", NodeL->Get >("A")); if (i != 0) { EdgeL->Set("Pnodal", NodeL->Get >("P")); RCP P = NodeL->Get >("P"); // Xpetra::IO::Write("Pn.mat",*P); } if (i == 0) { EdgeL->Set("A", SM_Matrix); EdgeL->Set("D0", D0_Matrix); } } // Generate the Edge Hierarchy out << "*** Setting Up Edge Hierarchy *** " << std::endl; { FactoryManager M0; // how to build aggregates and smoother of the first level M0.SetKokkosRefactor(false); // Level 1 (Plain aggregation) FactoryManager M1; { M1.SetKokkosRefactor(false); RCP PFact = rcp(new ReitzingerPFactory()); M1.SetFactory("Ptent", PFact); M1.SetFactory("D0", PFact); M1.SetFactory("P", PFact); } // Level 2 (just like level 1) FactoryManager M2; { M2.SetKokkosRefactor(false); RCP PFact = rcp(new ReitzingerPFactory()); M2.SetFactory("Ptent", PFact); M2.SetFactory("D0", PFact); M2.SetFactory("P", PFact); M2.SetFactory("CoarseSolver", Teuchos::null); } // Do the setup bool r; r = EdgeH.Setup(0, Teuchos::null, rcpFromRef(M0), rcpFromRef(M1)); TEST_EQUALITY(r, false); r = EdgeH.Setup(1, rcpFromRef(M0), rcpFromRef(M1), rcpFromRef(M2)); TEST_EQUALITY(r, false); r = EdgeH.Setup(2, rcpFromRef(M1), rcpFromRef(M2), Teuchos::null); TEST_EQUALITY(r, true); } RCP node_l1 = NodeH.GetLevel(1); RCP node_l2 = NodeH.GetLevel(2); RCP l0 = EdgeH.GetLevel(0); RCP l1 = EdgeH.GetLevel(1); RCP l2 = EdgeH.GetLevel(2); // l0->print(std::cout,MueLu::Debug); // l1->print(std::cout,MueLu::Debug); // l2->print(std::cout,MueLu::Debug); TEST_EQUALITY(l0->IsAvailable("A", MueLu::NoFactory::get()), true); TEST_EQUALITY(l1->IsAvailable("A", MueLu::NoFactory::get()), true); TEST_EQUALITY(l1->IsAvailable("P", MueLu::NoFactory::get()), true); TEST_EQUALITY(l2->IsAvailable("A", MueLu::NoFactory::get()), true); TEST_EQUALITY(l2->IsAvailable("P", MueLu::NoFactory::get()), true); // Check the commuting property using MT = typename Teuchos::ScalarTraits::magnitudeType; Teuchos::Array norm(1), norm0(1); norm0[0] = Teuchos::ScalarTraits::zero(); norm[0] = CheckCommutingProperty(*node_l1, *l0, *l1); TEST_COMPARE_FLOATING_ARRAYS(norm, norm0, Teuchos::ScalarTraits::eps() * 100); norm[0] = CheckCommutingProperty(*node_l2, *l1, *l2); TEST_COMPARE_FLOATING_ARRAYS(norm, norm0, Teuchos::ScalarTraits::eps() * 100); } #define MUELU_ETI_GROUP(Scalar, LO, GO, Node) \ TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(ReitzingerPFactory, Setup2Level_Unsmoothed, Scalar, LO, GO, Node) \ TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(ReitzingerPFactory, Setup2Level_AlphaSmoothed, Scalar, LO, GO, Node) \ TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(ReitzingerPFactory, Setup3Level_Unsmoothed, Scalar, LO, GO, Node) \ TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(ReitzingerPFactory, Setup3Level_AlphaSmoothed, Scalar, LO, GO, Node) #include } // namespace MueLuTests int main(int argc, char* argv[]) { Teuchos::GlobalMPISession mpiSession(&argc, &argv); #ifdef HAVE_MUELU_KOKKOS Kokkos::initialize(argc, argv); #endif bool success = false; bool verbose = true; int ierr = -1; try { // Note: the command line parameter --linAlgebra= is take into account. // Xpetra parameters are added to the Teuchos::CommandLineProcessor of Teuchos::UnitTestRepository in MueLu_TestHelpers.cpp #ifdef ParallelDebug RCP > comm = Teuchos::DefaultComm::getComm(); int mypid = comm->getRank(); if (mypid == 0) std::cout << "Host and Process Ids for tasks" << std::endl; for (int i = 0; i < comm->getSize(); i++) { if (i == mypid) { char buf[80]; char hostname[80]; gethostname(hostname, sizeof(hostname)); int pid = getpid(); sprintf(buf, "Host: %s\tMPI rank: %d,\tPID: %d\n\tattach %d\n\tcontinue\n", hostname, mypid, pid, pid); printf("%s\n", buf); fflush(stdout); sleep(1); } } if (mypid == 0) { printf("** Enter a character to continue > "); fflush(stdout); char go = ' '; scanf("%c", &go); } comm->barrier(); #endif ierr = Teuchos::UnitTestRepository::runUnitTestsFromMain(argc, argv); success = true; } TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success); #ifdef HAVE_MUELU_KOKKOS Kokkos::finalize(); #endif return (success ? ierr : EXIT_FAILURE); }