From 31701370f5db0c22755b2c984c59d94cf08bdcaf Mon Sep 17 00:00:00 2001 From: Christian Glusa Date: Fri, 24 Jan 2025 11:29:09 -0700 Subject: [PATCH] MueLu: Use helper functions Signed-off-by: Christian Glusa --- ...eLuTpetraQ2Q1PreconditionerFactory_def.hpp | 2 +- .../MueLu_ShiftedLaplacianOperator_def.hpp | 4 +- .../tpetra/MueLu_ShiftedLaplacian_def.hpp | 2 +- .../example/advanced/blockcrs/BlockCrs.cpp | 2 +- .../max/AdditiveMG/MultiplicativeBricks.cpp | 4 +- .../max/AdditiveMG/MultiplicativeStride.cpp | 4 +- .../max/AdditiveMG/Repartition_ADR.cpp | 4 +- .../max/AdditiveMG/Smooth_Prolongation.cpp | 4 +- .../max/AdditiveMG/SmoothedAdditiveBricks.cpp | 6 +- .../max/AdditiveMG/SmoothedAdditiveStride.cpp | 6 +- .../research/max/AdditiveMG/tentative.cpp | 6 +- .../Xpetra_MatrixSplitting.hpp | 3 +- .../research/q2q1/MueLu_Q2Q1uPFactory.hpp | 4 +- .../regionMG/src/SetupRegionHierarchy_def.hpp | 2 +- .../regionMG/src/SetupRegionMatrix_def.hpp | 10 +- .../regionMG/src/SolveRegionHierarchy_def.hpp | 6 +- .../MueLu_CoalesceDropFactory_kokkos_def.hpp | 4 +- .../MueLu_UnsmooshFactory_def.hpp | 3 +- .../MueLu_VariableDofLaplacianFactory_def.hpp | 3 +- .../Misc/MueLu_LowPrecisionFactory_def.hpp | 4 +- .../Smoothers/MueLu_Amesos2Smoother_def.hpp | 12 +- .../src/Smoothers/MueLu_BelosSmoother_def.hpp | 12 +- .../Smoothers/MueLu_Ifpack2Smoother_def.hpp | 8 +- .../Smoothers/MueLu_ProjectorSmoother_def.hpp | 2 +- .../MueLu_StratimikosSmoother_def.hpp | 2 +- .../BlackBox/MueLu_BlackBoxPFactory_def.hpp | 2 +- .../Classical/MueLu_ClassicalPFactory_def.hpp | 2 +- .../MueLu_GeneralGeometricPFactory_def.hpp | 2 +- ...eLu_GeometricInterpolationPFactory_def.hpp | 6 +- ...metricInterpolationPFactory_kokkos_def.hpp | 4 +- .../MueLu_IntrepidPCoarsenFactory_def.hpp | 4 +- .../MueLu_SemiCoarsenPFactory_def.hpp | 4 +- .../MueLu_SemiCoarsenPFactory_kokkos_def.hpp | 2 +- .../MueLu_TentativePFactory_def.hpp | 2 +- .../muelu/src/Utils/MueLu_Utilities_decl.hpp | 121 +----------------- .../muelu/src/Utils/MueLu_Utilities_def.hpp | 93 +------------- .../muelu/test/interface/CreateOperator.cpp | 2 +- packages/muelu/test/maxwell/Maxwell3D.cpp | 4 +- .../test/perf_tests_kokkos/Redirection.cpp | 2 +- packages/muelu/test/scaling/Driver.cpp | 2 +- packages/muelu/test/scaling/DriverCore.hpp | 4 +- .../muelu/test/scaling/ImportPerformance.cpp | 4 +- .../muelu/test/scaling/JacobiKernelDriver.cpp | 12 +- .../muelu/test/scaling/MMKernelDriver.cpp | 24 ++-- .../muelu/test/scaling/MatvecKernelDriver.cpp | 2 +- .../test/scaling/TwoMatrixMMKernelDriver.cpp | 16 +-- .../Adapters/AmgxOperatorAdapter.cpp | 4 +- .../unit_tests/Adapters/BelosAdapters.cpp | 4 +- .../Adapters/CreatePreconditioner.cpp | 36 +++--- .../Adapters/TpetraOperatorAdapter.cpp | 2 +- .../test/unit_tests/MueLu_TestHelpers_HO.hpp | 2 +- .../ParameterListInterpreter.cpp | 4 +- .../unit_tests_kokkos/Utilities_kokkos.cpp | 18 +-- 53 files changed, 147 insertions(+), 356 deletions(-) diff --git a/packages/muelu/adapters/stratimikos/Thyra_MueLuTpetraQ2Q1PreconditionerFactory_def.hpp b/packages/muelu/adapters/stratimikos/Thyra_MueLuTpetraQ2Q1PreconditionerFactory_def.hpp index 7892138358fb..b1130642b67d 100644 --- a/packages/muelu/adapters/stratimikos/Thyra_MueLuTpetraQ2Q1PreconditionerFactory_def.hpp +++ b/packages/muelu/adapters/stratimikos/Thyra_MueLuTpetraQ2Q1PreconditionerFactory_def.hpp @@ -848,7 +848,7 @@ MueLuTpetraQ2Q1PreconditionerFactory: for (int i = 0; i < valA.size(); i++) valB[i] = Teuchos::ScalarTraits::magnitude(valA[i]); RCP B = rcp(new CrsMatrixWrap(A.getRowMap(), A.getColMap(), 0)); - RCP Bcrs = rcp_dynamic_cast(B)->getCrsMatrix(); + RCP Bcrs = toCrsMatrix(B); Bcrs->setAllValues(iaB, jaB, valB); Bcrs->expertStaticFillComplete(A.getDomainMap(), A.getRangeMap()); diff --git a/packages/muelu/adapters/tpetra/MueLu_ShiftedLaplacianOperator_def.hpp b/packages/muelu/adapters/tpetra/MueLu_ShiftedLaplacianOperator_def.hpp index 43648627fae0..9052c2227d8e 100644 --- a/packages/muelu/adapters/tpetra/MueLu_ShiftedLaplacianOperator_def.hpp +++ b/packages/muelu/adapters/tpetra/MueLu_ShiftedLaplacianOperator_def.hpp @@ -42,7 +42,7 @@ ShiftedLaplacianOperator:: } RCP > tpA = - Utilities::Op2NonConstTpetraCrs(A); + toTpetra(A); return tpA->getDomainMap(); } @@ -63,7 +63,7 @@ ShiftedLaplacianOperator:: return Xpetra::toTpetraNonZero(tpbA->getRangeMap()); RCP > tpA = - Utilities::Op2NonConstTpetraCrs(A); + toTpetra(A); return tpA->getRangeMap(); } diff --git a/packages/muelu/adapters/tpetra/MueLu_ShiftedLaplacian_def.hpp b/packages/muelu/adapters/tpetra/MueLu_ShiftedLaplacian_def.hpp index d3ca3e3707f2..13de4708e535 100644 --- a/packages/muelu/adapters/tpetra/MueLu_ShiftedLaplacian_def.hpp +++ b/packages/muelu/adapters/tpetra/MueLu_ShiftedLaplacian_def.hpp @@ -101,7 +101,7 @@ template void ShiftedLaplacian::setProblemMatrix(RCP& A) { A_ = A; if (A_ != Teuchos::null) - TpetraA_ = Utilities::Op2NonConstTpetraCrs(A_); + TpetraA_ = toTpetra(A_); #ifdef HAVE_MUELU_TPETRA_INST_INT_INT if (LinearProblem_ != Teuchos::null) LinearProblem_->setOperator(TpetraA_); diff --git a/packages/muelu/example/advanced/blockcrs/BlockCrs.cpp b/packages/muelu/example/advanced/blockcrs/BlockCrs.cpp index c3a6b969a296..b44846898e33 100644 --- a/packages/muelu/example/advanced/blockcrs/BlockCrs.cpp +++ b/packages/muelu/example/advanced/blockcrs/BlockCrs.cpp @@ -281,7 +281,7 @@ int main_(Teuchos::CommandLineProcessor &clp, Xpetra::UnderlyingLib lib, int arg std::string matrixType = galeriParameters.GetMatrixType(); RCP > Axp; MueLuExamples::generate_user_matrix_and_nullspace(matrixType, lib, galeriList, comm, Axp, nullspace); - Acrs = Xpetra::Helpers::Op2NonConstTpetraCrs(Axp); + Acrs = toTpetra(Axp); } // Block this bad boy Ablock = Tpetra::convertToBlockCrsMatrix(*Acrs, blocksize); diff --git a/packages/muelu/research/max/AdditiveMG/MultiplicativeBricks.cpp b/packages/muelu/research/max/AdditiveMG/MultiplicativeBricks.cpp index fb661f734451..b8a84ef92826 100644 --- a/packages/muelu/research/max/AdditiveMG/MultiplicativeBricks.cpp +++ b/packages/muelu/research/max/AdditiveMG/MultiplicativeBricks.cpp @@ -195,7 +195,7 @@ int main(int argc, char* argv[]) { RCP Pr = ADR::Xpetra::BuildProblem(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList()); RCP xpetraA = Pr->BuildMatrix(); - RCP A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA); + RCP A = toTpetra(xpetraA); RCP map = MueLuUtilities::Map2TpetraMap(*xpetraMap); // =================================================== @@ -228,7 +228,7 @@ int main(int argc, char* argv[]) { // =================================== RCP M; - M = MueLu::CreateTpetraPreconditioner((RCP)A, mueluParams, Utilities::MV2NonConstTpetraMV(coordinates)); + M = MueLu::CreateTpetraPreconditioner((RCP)A, mueluParams, toTpetra(coordinates)); RCP X_muelu = rcp(new multivector_type(map, 1)); RCP B = rcp(new multivector_type(map, 1)); diff --git a/packages/muelu/research/max/AdditiveMG/MultiplicativeStride.cpp b/packages/muelu/research/max/AdditiveMG/MultiplicativeStride.cpp index c6282f6536b8..5e98bfae1bc8 100644 --- a/packages/muelu/research/max/AdditiveMG/MultiplicativeStride.cpp +++ b/packages/muelu/research/max/AdditiveMG/MultiplicativeStride.cpp @@ -187,11 +187,11 @@ int main(int argc, char *argv[]) { RCP Pr = ADR::Xpetra::BuildProblem(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList()); RCP xpetraA = Pr->BuildMatrix(); - RCP A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA); + RCP A = MueLutoTpetra(xpetraA); RCP map = MueLuUtilities::Map2TpetraMap(*xpetraMap); // Construct a multigrid preconditioner - RCP M = MueLu::CreateTpetraPreconditioner((RCP)A, mueluParams, Utilities::MV2NonConstTpetraMV(coordinates)); + RCP M = MueLu::CreateTpetraPreconditioner((RCP)A, mueluParams, toTpetra(coordinates)); RCP X = rcp(new multivector_type(map, 1)); RCP B = rcp(new multivector_type(map, 1)); diff --git a/packages/muelu/research/max/AdditiveMG/Repartition_ADR.cpp b/packages/muelu/research/max/AdditiveMG/Repartition_ADR.cpp index 21bb302a06de..38757de2afd7 100644 --- a/packages/muelu/research/max/AdditiveMG/Repartition_ADR.cpp +++ b/packages/muelu/research/max/AdditiveMG/Repartition_ADR.cpp @@ -197,14 +197,14 @@ int main(int argc, char *argv[]) { RCP Pr = ADR::Xpetra::BuildProblem(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList()); RCP xpetraA = Pr->BuildMatrix(); - RCP A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA); + RCP A = toTpetra(xpetraA); RCP map = MueLuUtilities::Map2TpetraMap(*xpetraMap); // // Construct a multigrid preconditioner // - RCP M = MueLu::CreateTpetraPreconditioner((RCP)A, mueluParams, Utilities::MV2NonConstTpetraMV(coordinates)); + RCP M = MueLu::CreateTpetraPreconditioner((RCP)A, mueluParams, toTpetra(coordinates)); RCP X = rcp(new multivector_type(map, 1)); RCP B = rcp(new multivector_type(map, 1)); diff --git a/packages/muelu/research/max/AdditiveMG/Smooth_Prolongation.cpp b/packages/muelu/research/max/AdditiveMG/Smooth_Prolongation.cpp index c9a339e80194..027a1d4db8c2 100644 --- a/packages/muelu/research/max/AdditiveMG/Smooth_Prolongation.cpp +++ b/packages/muelu/research/max/AdditiveMG/Smooth_Prolongation.cpp @@ -133,8 +133,8 @@ coarse_file_sublist.set("R", "{1}");*/ if (L->IsAvailable("R")) restr = L->template Get>>("R"); - RCP tpetra_prolong = MueLuUtilities::Op2NonConstTpetraCrs(prolong); - RCP tpetra_restr = MueLuUtilities::Op2NonConstTpetraCrs(restr); + RCP tpetra_prolong = toTpetra(prolong); + RCP tpetra_restr = toTpetra(restr); int mypid = GlobalComm_->getRank(); GlobalComm_->barrier(); diff --git a/packages/muelu/research/max/AdditiveMG/SmoothedAdditiveBricks.cpp b/packages/muelu/research/max/AdditiveMG/SmoothedAdditiveBricks.cpp index 3c1e7ee2f743..1ec72a82707a 100644 --- a/packages/muelu/research/max/AdditiveMG/SmoothedAdditiveBricks.cpp +++ b/packages/muelu/research/max/AdditiveMG/SmoothedAdditiveBricks.cpp @@ -201,7 +201,7 @@ int main(int argc, char* argv[]) { RCP Pr = ADR::Xpetra::BuildProblem(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList()); RCP xpetraA = Pr->BuildMatrix(); - RCP A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA); + RCP A = toTpetra(xpetraA); RCP map = MueLuUtilities::Map2TpetraMap(*xpetraMap); // =================================================== @@ -256,8 +256,8 @@ int main(int argc, char* argv[]) { if (L->IsAvailable("R")) restr = L->template Get>>("R"); - RCP tpetra_prolong = MueLuUtilities::Op2NonConstTpetraCrs(prolong); - RCP tpetra_restr = MueLuUtilities::Op2NonConstTpetraCrs(restr); + RCP tpetra_prolong = toTpetra(prolong); + RCP tpetra_restr = toTpetra(restr); #include RCP PbarSetUp = Teuchos::TimeMonitor::getNewCounter("Pbar: SetUp"); diff --git a/packages/muelu/research/max/AdditiveMG/SmoothedAdditiveStride.cpp b/packages/muelu/research/max/AdditiveMG/SmoothedAdditiveStride.cpp index 3d0af82af399..0510c6365160 100644 --- a/packages/muelu/research/max/AdditiveMG/SmoothedAdditiveStride.cpp +++ b/packages/muelu/research/max/AdditiveMG/SmoothedAdditiveStride.cpp @@ -190,7 +190,7 @@ int main(int argc, char* argv[]) { RCP Pr = ADR::Xpetra::BuildProblem(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList()); RCP xpetraA = Pr->BuildMatrix(); - RCP A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA); + RCP A = toTpetra(xpetraA); RCP map = MueLuUtilities::Map2TpetraMap(*xpetraMap); // =================================================== @@ -244,8 +244,8 @@ int main(int argc, char* argv[]) { if (L->IsAvailable("R")) restr = L->template Get>>("R"); - RCP tpetra_prolong = MueLuUtilities::Op2NonConstTpetraCrs(prolong); - RCP tpetra_restr = MueLuUtilities::Op2NonConstTpetraCrs(restr); + RCP tpetra_prolong = toTpetra(prolong); + RCP tpetra_restr = toTpetra(restr); Tpetra::MatrixMarket::Writer::writeSparseFile("P.mtx", tpetra_prolong); // Auxiliary prints introduced to generate pictures diff --git a/packages/muelu/research/max/AdditiveMG/tentative.cpp b/packages/muelu/research/max/AdditiveMG/tentative.cpp index 96e916654d05..558d3c80c9b8 100644 --- a/packages/muelu/research/max/AdditiveMG/tentative.cpp +++ b/packages/muelu/research/max/AdditiveMG/tentative.cpp @@ -200,7 +200,7 @@ int main(int argc, char* argv[]) { RCP Pr = ADR::Xpetra::BuildProblem(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList()); RCP xpetraA = Pr->BuildMatrix(); - RCP A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA); + RCP A = toTpetra(xpetraA); RCP map = MueLuUtilities::Map2TpetraMap(*xpetraMap); // =================================================== @@ -252,8 +252,8 @@ int main(int argc, char* argv[]) { if (L->IsAvailable("R")) restr = L->template Get>>("R"); - RCP tpetra_prolong = MueLuUtilities::Op2NonConstTpetraCrs(prolong); - RCP tpetra_restr = MueLuUtilities::Op2NonConstTpetraCrs(restr); + RCP tpetra_prolong = toTpetra(prolong); + RCP tpetra_restr = toTpetra(restr); #include RCP PbarSetUp = Teuchos::TimeMonitor::getNewCounter("Pbar: SetUp"); diff --git a/packages/muelu/research/max/XpetraSplitting/Xpetra_MatrixSplitting.hpp b/packages/muelu/research/max/XpetraSplitting/Xpetra_MatrixSplitting.hpp index f196d78e65f7..99c353528ac1 100644 --- a/packages/muelu/research/max/XpetraSplitting/Xpetra_MatrixSplitting.hpp +++ b/packages/muelu/research/max/XpetraSplitting/Xpetra_MatrixSplitting.hpp @@ -26,6 +26,7 @@ // Ifpack2 #include "Ifpack2_OverlappingRowMatrix_def.hpp" +#include "Xpetra_TpetraMultiVector_decl.hpp" // MueLu #include @@ -621,7 +622,7 @@ class MatrixSplitting : public Matrix TEUCHOS_TEST_FOR_EXCEPTION(num_total_regions_ != regionMatrixData_.size(), Exceptions::RuntimeError, "Number of regions does not match with the size of regionMatrixData_ structure \n"); RCP region_matrix = regionMatrixData_[region_idx]; - RCP tpetraGlobalMatrix = MueLu::Utilities::Op2NonConstTpetraCrs(compositeMatrixData_); + RCP tpetraGlobalMatrix = toTpetra(compositeMatrixData_); Ifpack2::OverlappingRowMatrix enlargedMatrix(tpetraGlobalMatrix, 2); region_matrix->resumeFill(); diff --git a/packages/muelu/research/q2q1/MueLu_Q2Q1uPFactory.hpp b/packages/muelu/research/q2q1/MueLu_Q2Q1uPFactory.hpp index 38902739880c..e24ddefe3f0b 100644 --- a/packages/muelu/research/q2q1/MueLu_Q2Q1uPFactory.hpp +++ b/packages/muelu/research/q2q1/MueLu_Q2Q1uPFactory.hpp @@ -590,7 +590,7 @@ void Q2Q1uPFactory::BuildP(Level& fin // FIXME: remove magic number 30 RCP amalgA = MatrixFactory::Build(nodeMap, nodeMap, 30); - RCP amalgA_crs = rcp_dynamic_cast(amalgA)->getCrsMatrix(); + RCP amalgA_crs = toCrsMatrix(amalgA); // FIXME: this should be written similar to CoalesceDropFactory Merge for (LO row = 0; row < as(AForPat->getRowMap()->getLocalNumElements()); row += NDim) { @@ -1665,7 +1665,7 @@ void Q2Q1uPFactory:: RCP coarseMap = MapFactory::Build(rowMap->lib(), Cptlist.size(), rowMap->getIndexBase() + offset, rowMap->getComm()); P = rcp(new CrsMatrixWrap(rowMap, coarseMap, 0)); - RCP Pcrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP Pcrs = toCrsMatrix(P); ArrayRCP iaP; ArrayRCP jaP; diff --git a/packages/muelu/research/regionMG/src/SetupRegionHierarchy_def.hpp b/packages/muelu/research/regionMG/src/SetupRegionHierarchy_def.hpp index a4ed28627bd7..4bc6ef1bbca5 100644 --- a/packages/muelu/research/regionMG/src/SetupRegionHierarchy_def.hpp +++ b/packages/muelu/research/regionMG/src/SetupRegionHierarchy_def.hpp @@ -398,7 +398,7 @@ MakeCompositeDirectSolver(RCP tm = rcp(new TimeMonitor(*TimeMonitor::getNewTimer("MakeCompositeDirectSolver: 1 - Setup"))); // convert matrix to Tpetra - RCP tMat = Utilities::Op2NonConstTpetraCrs(compOp); + RCP tMat = toTpetra(compOp); // Amesos2-specific key phrase that denote smoother type std::string amesos2SolverName = "KLU2"; diff --git a/packages/muelu/research/regionMG/src/SetupRegionMatrix_def.hpp b/packages/muelu/research/regionMG/src/SetupRegionMatrix_def.hpp index 44240be30025..b409554a767b 100644 --- a/packages/muelu/research/regionMG/src/SetupRegionMatrix_def.hpp +++ b/packages/muelu/research/regionMG/src/SetupRegionMatrix_def.hpp @@ -194,10 +194,10 @@ void MakeRegionMatrices(const RCP regionCrsMat = Teuchos::rcp_dynamic_cast(regionMats)->getCrsMatrix(); + RCP regionCrsMat = toCrsMatrix(regionMats); // Extract current quasi-region CrsMatrix - RCP quasiRegionCrsMat = Teuchos::rcp_dynamic_cast(quasiRegionMats)->getCrsMatrix(); + RCP quasiRegionCrsMat = toCrsMatrix(quasiRegionMats); // Pull out the data from the quasi-region CrsMatrix ArrayRCP rowptrQuasiRegion; @@ -295,7 +295,7 @@ void MakeRegionMatrices(const RCPupdate(-SC_ONE, *regCorrection, SC_ONE, *regNspViolation, SC_ONE); // Extract current region matrix in as CrsMatrix - RCP regionCrsMat = Teuchos::rcp_dynamic_cast(regionMats)->getCrsMatrix(); + RCP regionCrsMat = toCrsMatrix(regionMats); regionCrsMat->replaceDiag(*regDiag); tm = Teuchos::null; @@ -348,10 +348,10 @@ void regionalToComposite(const RCPgetCrsGraph()->getLocalMaxNumRowEntries())); // Extract current quasi-region CrsMatrix - RCP quasiRegionCrsMat = Teuchos::rcp_dynamic_cast(quasiRegMat)->getCrsMatrix(); + RCP quasiRegionCrsMat = toCrsMatrix(quasiRegMat); // Extract current region CrsMatrix - RCP regionCrsMat = Teuchos::rcp_dynamic_cast(regMat)->getCrsMatrix(); + RCP regionCrsMat = toCrsMatrix(regMat); // Pull out the data from the region CrsMatrix Teuchos::ArrayRCP rowptrRegion; diff --git a/packages/muelu/research/regionMG/src/SolveRegionHierarchy_def.hpp b/packages/muelu/research/regionMG/src/SolveRegionHierarchy_def.hpp index db287cf2ebc7..4b6a41ef39aa 100644 --- a/packages/muelu/research/regionMG/src/SolveRegionHierarchy_def.hpp +++ b/packages/muelu/research/regionMG/src/SolveRegionHierarchy_def.hpp @@ -192,11 +192,11 @@ void MgCycle(const int levelID, ///< ID of current level // From here on we switch to Tpetra for simplicity // we could also implement a similar Epetra branch - using Tpetra_MultiVector = Tpetra::MultiVector; + using Tpetra_Vector = Tpetra::Vector; // *fos << "Attempting to use Amesos2 to solve the coarse grid problem" << std::endl; - RCP tX = Utilities::MV2NonConstTpetraMV2(*compX); - RCP tB = Utilities::MV2TpetraMV(compRhs); + RCP tX = toTpetra(compX); + RCP tB = toTpetra(compRhs); /* Solve! * diff --git a/packages/muelu/src/Graph/MatrixTransformation/MueLu_CoalesceDropFactory_kokkos_def.hpp b/packages/muelu/src/Graph/MatrixTransformation/MueLu_CoalesceDropFactory_kokkos_def.hpp index b23f58e081f4..fb1757ec08e4 100644 --- a/packages/muelu/src/Graph/MatrixTransformation/MueLu_CoalesceDropFactory_kokkos_def.hpp +++ b/packages/muelu/src/Graph/MatrixTransformation/MueLu_CoalesceDropFactory_kokkos_def.hpp @@ -248,7 +248,7 @@ std::tuple(A, true)->getCrsMatrix(); + auto crsA = toCrsMatrix(A); auto lclA = crsA->getLocalMatrixDevice(); auto range = range_type(0, lclA.numRows()); @@ -902,7 +902,7 @@ std::tuple(A, true)->getCrsMatrix(); + auto crsA = toCrsMatrix(A); auto lclA = crsA->getLocalMatrixDevice(); auto range = range_type(0, numNodes); diff --git a/packages/muelu/src/Graph/MatrixTransformation/MueLu_UnsmooshFactory_def.hpp b/packages/muelu/src/Graph/MatrixTransformation/MueLu_UnsmooshFactory_def.hpp index 3adc1e6f038f..34ce1c0f96d7 100644 --- a/packages/muelu/src/Graph/MatrixTransformation/MueLu_UnsmooshFactory_def.hpp +++ b/packages/muelu/src/Graph/MatrixTransformation/MueLu_UnsmooshFactory_def.hpp @@ -85,8 +85,7 @@ void UnsmooshFactory::Build(Level &fi Teuchos::ArrayRCP amalgRowPtr(amalgP->getLocalNumRows()); Teuchos::ArrayRCP amalgCols(amalgP->getLocalNumEntries()); Teuchos::ArrayRCP amalgVals(amalgP->getLocalNumEntries()); - Teuchos::RCP amalgPwrap = Teuchos::rcp_dynamic_cast(amalgP); - Teuchos::RCP amalgPcrs = amalgPwrap->getCrsMatrix(); + Teuchos::RCP amalgPcrs = toCrsMatrix(amalgP); amalgPcrs->getAllValues(amalgRowPtr, amalgCols, amalgVals); // calculate number of dof rows for new prolongator diff --git a/packages/muelu/src/Graph/MatrixTransformation/MueLu_VariableDofLaplacianFactory_def.hpp b/packages/muelu/src/Graph/MatrixTransformation/MueLu_VariableDofLaplacianFactory_def.hpp index c0f7715e4d63..3951bc7e1e84 100644 --- a/packages/muelu/src/Graph/MatrixTransformation/MueLu_VariableDofLaplacianFactory_def.hpp +++ b/packages/muelu/src/Graph/MatrixTransformation/MueLu_VariableDofLaplacianFactory_def.hpp @@ -161,8 +161,7 @@ void VariableDofLaplacianFactory::Bui // start variable dof amalgamation - Teuchos::RCP Awrap = Teuchos::rcp_dynamic_cast(A); - Teuchos::RCP Acrs = Awrap->getCrsMatrix(); + Teuchos::RCP Acrs = toCrsMatrix(A); // Acrs->describe(*fancy, Teuchos::VERB_EXTREME); size_t nNonZeros = 0; diff --git a/packages/muelu/src/Misc/MueLu_LowPrecisionFactory_def.hpp b/packages/muelu/src/Misc/MueLu_LowPrecisionFactory_def.hpp index e7f48a9968ad..c5a5c194eec9 100644 --- a/packages/muelu/src/Misc/MueLu_LowPrecisionFactory_def.hpp +++ b/packages/muelu/src/Misc/MueLu_LowPrecisionFactory_def.hpp @@ -89,7 +89,7 @@ void LowPrecisionFactory::Build(Level RCP A = Get >(currentLevel, matrixKey); if ((A->getRowMap()->lib() == Xpetra::UseTpetra) && std::is_same::value) { - auto tpA = rcp_dynamic_cast(rcp_dynamic_cast(A)->getCrsMatrix(), true)->getTpetra_CrsMatrix(); + auto tpA = toTpetra(A); auto tpLowA = tpA->template convert(); auto tpLowOpA = rcp(new Tpetra::CrsMatrixMultiplyOp(tpLowA)); auto xpTpLowOpA = rcp(new TpetraOperator(tpLowOpA)); @@ -136,7 +136,7 @@ void LowPrecisionFactory, LocalOrdinal, GlobalOrdinal, Node RCP A = Get >(currentLevel, matrixKey); if ((A->getRowMap()->lib() == Xpetra::UseTpetra) && std::is_same >::value) { - auto tpA = rcp_dynamic_cast(rcp_dynamic_cast(A)->getCrsMatrix(), true)->getTpetra_CrsMatrix(); + auto tpA = toTpetra(A); auto tpLowA = tpA->template convert(); auto tpLowOpA = rcp(new Tpetra::CrsMatrixMultiplyOp(tpLowA)); auto xpTpLowOpA = rcp(new TpetraOperator(tpLowOpA)); diff --git a/packages/muelu/src/Smoothers/MueLu_Amesos2Smoother_def.hpp b/packages/muelu/src/Smoothers/MueLu_Amesos2Smoother_def.hpp index d6f0ad05c03d..7c48de5fef21 100644 --- a/packages/muelu/src/Smoothers/MueLu_Amesos2Smoother_def.hpp +++ b/packages/muelu/src/Smoothers/MueLu_Amesos2Smoother_def.hpp @@ -276,7 +276,7 @@ void Amesos2Smoother::Setup(Level& cu } RCP newA = rcp(new CrsMatrixWrap(rowMap, colMap, 0)); - RCP newAcrs = rcp_dynamic_cast(newA)->getCrsMatrix(); + RCP newAcrs = toCrsMatrix(newA); newAcrs->setAllValues(newRowPointers, newColIndices, newValues); newAcrs->expertStaticFillComplete(A->getDomainMap(), A->getRangeMap(), importer, A->getCrsGraph()->getExporter()); @@ -287,7 +287,7 @@ void Amesos2Smoother::Setup(Level& cu factorA = A; } - RCP tA = Utilities::Op2NonConstTpetraCrs(factorA); + RCP tA = toTpetra(factorA); prec_ = Amesos2::create(type_, tA); TEUCHOS_TEST_FOR_EXCEPTION(prec_ == Teuchos::null, Exceptions::RuntimeError, "Amesos2::create returns Teuchos::null"); @@ -311,8 +311,8 @@ void Amesos2Smoother::Apply(MultiVect RCP tX, tB; if (!useTransformation_) { - tX = Utilities::MV2NonConstTpetraMV2(X); - tB = Utilities::MV2NonConstTpetraMV2(const_cast(B)); + tX = toTpetra(Teuchos::rcpFromRef(X)); + tB = toTpetra(Teuchos::rcpFromRef(const_cast(B))); } else { // Copy data of the original vectors into the transformed ones size_t numVectors = X.getNumVectors(); @@ -328,8 +328,8 @@ void Amesos2Smoother::Apply(MultiVect B_data[i] = Bdata[i]; } - tX = Utilities::MV2NonConstTpetraMV2(*X_); - tB = Utilities::MV2NonConstTpetraMV2(*B_); + tX = toTpetra(X_); + tB = toTpetra(B_); } prec_->setX(tX); diff --git a/packages/muelu/src/Smoothers/MueLu_BelosSmoother_def.hpp b/packages/muelu/src/Smoothers/MueLu_BelosSmoother_def.hpp index c3a2f7a85391..d24ef63ada50 100644 --- a/packages/muelu/src/Smoothers/MueLu_BelosSmoother_def.hpp +++ b/packages/muelu/src/Smoothers/MueLu_BelosSmoother_def.hpp @@ -84,8 +84,8 @@ void BelosSmoother::SetupBelos(Level& bool useTpetra = A_->getRowMap()->lib() == Xpetra::UseTpetra; if (useTpetra) { - tBelosProblem_ = rcp(new Belos::LinearProblem()); - RCP tA = Utilities::Op2NonConstTpetraCrs(A_); + tBelosProblem_ = rcp(new Belos::LinearProblem()); + RCP tA = toTpetra(A_); tBelosProblem_->setOperator(tA); Belos::SolverFactory solverFactory; @@ -104,8 +104,8 @@ void BelosSmoother::Apply(MultiVector if (InitialGuessIsZero) { X.putScalar(0.0); - RCP > tpX = rcpFromRef(Utilities::MV2NonConstTpetraMV(X)); - RCP > tpB = rcpFromRef(Utilities::MV2TpetraMV(B)); + RCP > tpX = toTpetra(rcpFromRef(X)); + RCP > tpB = toTpetra(rcpFromRef(B)); tBelosProblem_->setInitResVec(tpB); tBelosProblem_->setProblem(tpX, tpB); @@ -116,8 +116,8 @@ void BelosSmoother::Apply(MultiVector RCP Residual = Utilities::Residual(*A_, X, B); RCP Correction = MultiVectorFactory::Build(A_->getDomainMap(), X.getNumVectors()); - RCP > tpX = rcpFromRef(Utilities::MV2NonConstTpetraMV(*Correction)); - RCP > tpB = rcpFromRef(Utilities::MV2TpetraMV(*Residual)); + RCP > tpX = toTpetra(Correction); + RCP > tpB = toTpetra(Residual); tBelosProblem_->setInitResVec(tpB); tBelosProblem_->setProblem(tpX, tpB); diff --git a/packages/muelu/src/Smoothers/MueLu_Ifpack2Smoother_def.hpp b/packages/muelu/src/Smoothers/MueLu_Ifpack2Smoother_def.hpp index e8dca02fbfff..7c655214134e 100644 --- a/packages/muelu/src/Smoothers/MueLu_Ifpack2Smoother_def.hpp +++ b/packages/muelu/src/Smoothers/MueLu_Ifpack2Smoother_def.hpp @@ -965,8 +965,8 @@ void Ifpack2Smoother::Apply(MultiVect // Apply if (InitialGuessIsZero || supportInitialGuess) { - Tpetra::MultiVector& tpX = Utilities::MV2NonConstTpetraMV(X); - const Tpetra::MultiVector& tpB = Utilities::MV2TpetraMV(B); + Tpetra::MultiVector& tpX = toTpetra(X); + const Tpetra::MultiVector& tpB = toTpetra(B); prec_->apply(tpB, tpX); } else { typedef Teuchos::ScalarTraits TST; @@ -980,8 +980,8 @@ void Ifpack2Smoother::Apply(MultiVect RCP Correction = MultiVectorFactory::Build(A_->getDomainMap(), X.getNumVectors()); - Tpetra::MultiVector& tpX = Utilities::MV2NonConstTpetraMV(*Correction); - const Tpetra::MultiVector& tpB = Utilities::MV2TpetraMV(*Residual); + Tpetra::MultiVector& tpX = toTpetra(*Correction); + const Tpetra::MultiVector& tpB = toTpetra(*Residual); prec_->apply(tpB, tpX); diff --git a/packages/muelu/src/Smoothers/MueLu_ProjectorSmoother_def.hpp b/packages/muelu/src/Smoothers/MueLu_ProjectorSmoother_def.hpp index c93f43eb6a39..c30ccfae2b39 100644 --- a/packages/muelu/src/Smoothers/MueLu_ProjectorSmoother_def.hpp +++ b/packages/muelu/src/Smoothers/MueLu_ProjectorSmoother_def.hpp @@ -70,7 +70,7 @@ void ProjectorSmoother::Setup(Level & #if defined(HAVE_XPETRA_TPETRA) #ifdef HAVE_MUELU_TPETRA_INST_INT_INT // Orthonormalize - RCP > B_ = Utilities::MV2TpetraMV(B); + RCP > B_ = toTpetra(B); // TAW: Oct 16 2015: subCopy is not part of Xpetra. One should either add it to Xpetra (with an emulator for Epetra) // or replace this call by a local loop. I'm not motivated to do this now... RCP > Borth = B_->subCopy(selectedIndices); // copy diff --git a/packages/muelu/src/Smoothers/MueLu_StratimikosSmoother_def.hpp b/packages/muelu/src/Smoothers/MueLu_StratimikosSmoother_def.hpp index fbc5a125e77e..5f7b6e1f4244 100644 --- a/packages/muelu/src/Smoothers/MueLu_StratimikosSmoother_def.hpp +++ b/packages/muelu/src/Smoothers/MueLu_StratimikosSmoother_def.hpp @@ -77,7 +77,7 @@ void StratimikosSmoother::SetupStrati if (recurMgOnFilteredA_) { RCP filteredA; ExperimentalDropVertConnections(filteredA, currentLevel); - thyraA = Xpetra::ThyraUtils::toThyra(Teuchos::rcp_dynamic_cast(filteredA)->getCrsMatrix()); + thyraA = Xpetra::ThyraUtils::toThyra(toCrsMatrix(filteredA)); } else thyraA = Xpetra::ThyraUtils::toThyra(Teuchos::rcp_dynamic_cast(A_)->getCrsMatrix()); diff --git a/packages/muelu/src/Transfers/BlackBox/MueLu_BlackBoxPFactory_def.hpp b/packages/muelu/src/Transfers/BlackBox/MueLu_BlackBoxPFactory_def.hpp index 6c0ae590c2b1..12e4280c1c0b 100644 --- a/packages/muelu/src/Transfers/BlackBox/MueLu_BlackBoxPFactory_def.hpp +++ b/packages/muelu/src/Transfers/BlackBox/MueLu_BlackBoxPFactory_def.hpp @@ -425,7 +425,7 @@ void BlackBoxPFactory::BuildP(Level& // Create the matrix itself using the above maps RCP P; P = rcp(new CrsMatrixWrap(rowMapP, colMapP, 0)); - RCP PCrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP PCrs = toCrsMatrix(P); ArrayRCP iaP; ArrayRCP jaP; diff --git a/packages/muelu/src/Transfers/Classical/MueLu_ClassicalPFactory_def.hpp b/packages/muelu/src/Transfers/Classical/MueLu_ClassicalPFactory_def.hpp index 518316b8121a..389f37e4152e 100644 --- a/packages/muelu/src/Transfers/Classical/MueLu_ClassicalPFactory_def.hpp +++ b/packages/muelu/src/Transfers/Classical/MueLu_ClassicalPFactory_def.hpp @@ -811,7 +811,7 @@ void ClassicalPFactory:: // Allocate memory & copy P = rcp(new CrsMatrixWrap(A.getRowMap(), coarseColMap, 0)); - RCP PCrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP PCrs = toCrsMatrix(P); ArrayRCP P_rowptr; ArrayRCP P_colind; ArrayRCP P_values; diff --git a/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeneralGeometricPFactory_def.hpp b/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeneralGeometricPFactory_def.hpp index 43557239d01f..2bdf0adc1c91 100644 --- a/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeneralGeometricPFactory_def.hpp +++ b/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeneralGeometricPFactory_def.hpp @@ -839,7 +839,7 @@ void GeneralGeometricPFactory:: ghostCoords->doImport(*fineCoords, *ghostImporter, Xpetra::INSERT); P = rcp(new CrsMatrixWrap(rowMapP, colMapP, 0)); - RCP PCrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP PCrs = toCrsMatrix(P); ArrayRCP iaP; ArrayRCP jaP; diff --git a/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeometricInterpolationPFactory_def.hpp b/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeometricInterpolationPFactory_def.hpp index bbd8ce60676d..dcf37d840f1e 100644 --- a/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeometricInterpolationPFactory_def.hpp +++ b/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeometricInterpolationPFactory_def.hpp @@ -282,7 +282,7 @@ void GeometricInterpolationPFactory:: // Create the prolongator matrix and its associated objects RCP dummyList = rcp(new ParameterList()); P = rcp(new CrsMatrixWrap(prolongatorGraph, dummyList)); - RCP PCrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP PCrs = toCrsMatrix(P); PCrs->setAllToScalar(1.0); PCrs->fillComplete(); @@ -319,7 +319,7 @@ void GeometricInterpolationPFactory:: RCP dummyList = rcp(new ParameterList()); P = rcp(new CrsMatrixWrap(prolongatorGraph, dummyList)); - RCP PCrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP PCrs = toCrsMatrix(P); PCrs->resumeFill(); // The Epetra matrix is considered filled at this point. { @@ -446,7 +446,7 @@ void GeometricInterpolationPFactory:: P = rcp(new CrsMatrixWrap(prolongatorGraph->getRowMap(), prolongatorGraph->getColMap(), nnzOnRows)); - RCP PCrsSqueezed = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP PCrsSqueezed = toCrsMatrix(P); PCrsSqueezed->resumeFill(); // The Epetra matrix is considered filled at this point. PCrsSqueezed->setAllValues(rowPtr, colInd, values); PCrsSqueezed->expertStaticFillComplete(prolongatorGraph->getDomainMap(), diff --git a/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeometricInterpolationPFactory_kokkos_def.hpp b/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeometricInterpolationPFactory_kokkos_def.hpp index cb6773af7870..19c678f8b457 100644 --- a/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeometricInterpolationPFactory_kokkos_def.hpp +++ b/packages/muelu/src/Transfers/GeneralGeometric/MueLu_GeometricInterpolationPFactory_kokkos_def.hpp @@ -261,7 +261,7 @@ void GeometricInterpolationPFactory_kokkos dummyList = rcp(new ParameterList()); P = rcp(new CrsMatrixWrap(prolongatorGraph, dummyList)); - RCP PCrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP PCrs = toCrsMatrix(P); PCrs->setAllToScalar(1.0); PCrs->fillComplete(); @@ -325,7 +325,7 @@ void GeometricInterpolationPFactory_kokkos dummyList = rcp(new ParameterList()); P = rcp(new CrsMatrixWrap(prolongatorGraph, dummyList)); - RCP PCrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP PCrs = toCrsMatrix(P); PCrs->resumeFill(); // The Epetra matrix is considered filled at this point. LO interpolationNodeIdx = 0, rowIdx = 0; diff --git a/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_def.hpp b/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_def.hpp index 796509b18c84..f7bcf00983ef 100644 --- a/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_def.hpp +++ b/packages/muelu/src/Transfers/PCoarsen/MueLu_IntrepidPCoarsenFactory_def.hpp @@ -570,7 +570,7 @@ void IntrepidPCoarsenFactory::Generat // Allocate P P = rcp(new CrsMatrixWrap(hi_map, lo_colMap, numFieldsHi)); // FIXLATER: Need faster fill - RCP Pcrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP Pcrs = toCrsMatrix(P); // Slow-ish fill size_t Nelem = hi_elemToNode.extent(0); @@ -635,7 +635,7 @@ void IntrepidPCoarsenFactory::Generat // Allocate P P = rcp(new CrsMatrixWrap(hi_map, lo_colMap, numFieldsHi)); // FIXLATER: Need faster fill - RCP Pcrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP Pcrs = toCrsMatrix(P); // Slow-ish fill size_t Nelem = hi_elemToNode.extent(0); diff --git a/packages/muelu/src/Transfers/SemiCoarsen/MueLu_SemiCoarsenPFactory_def.hpp b/packages/muelu/src/Transfers/SemiCoarsen/MueLu_SemiCoarsenPFactory_def.hpp index 36369a07c2f2..36a97bd781a7 100644 --- a/packages/muelu/src/Transfers/SemiCoarsen/MueLu_SemiCoarsenPFactory_def.hpp +++ b/packages/muelu/src/Transfers/SemiCoarsen/MueLu_SemiCoarsenPFactory_def.hpp @@ -906,7 +906,7 @@ LocalOrdinal SemiCoarsenPFactory:: ArrayRCP rcpColumns; ArrayRCP rcpValues; - RCP PCrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP PCrs = toCrsMatrix(P); LO nnz = Pptr[Ndofs]; PCrs->allocateAllValues(nnz, rcpRowPtr, rcpColumns, rcpValues); @@ -927,7 +927,7 @@ LocalOrdinal SemiCoarsenPFactory:: RCP RCrs; if (buildRestriction) { R = rcp(new CrsMatrixWrap(coarseMap, rowMap, 0)); - RCrs = rcp_dynamic_cast(R)->getCrsMatrix(); + RCrs = toCrsMatrix(R); nnz = Rptr[coarseMap->getLocalNumElements()]; RCrs->allocateAllValues(nnz, RrcpRowPtr, RrcpColumns, RrcpValues); diff --git a/packages/muelu/src/Transfers/SemiCoarsen/MueLu_SemiCoarsenPFactory_kokkos_def.hpp b/packages/muelu/src/Transfers/SemiCoarsen/MueLu_SemiCoarsenPFactory_kokkos_def.hpp index 338f000aa1e1..cd4430e2f0cc 100644 --- a/packages/muelu/src/Transfers/SemiCoarsen/MueLu_SemiCoarsenPFactory_kokkos_def.hpp +++ b/packages/muelu/src/Transfers/SemiCoarsen/MueLu_SemiCoarsenPFactory_kokkos_def.hpp @@ -613,7 +613,7 @@ void SemiCoarsenPFactory_kokkos< rowMap->lib(), NCLayers * itemp, NCLayers * NVertLines * DofsPerNode, 0, stridingInfo_, rowMap->getComm(), -1, 0); P = rcp(new CrsMatrixWrap(rowMap, coarseMap, 0)); - RCP PCrs = rcp_dynamic_cast(P)->getCrsMatrix(); + RCP PCrs = toCrsMatrix(P); PCrs->setAllValues(Pptr, Pcols, Pvals); PCrs->expertStaticFillComplete(coarseMap, Amat->getDomainMap()); diff --git a/packages/muelu/src/Transfers/Smoothed-Aggregation/MueLu_TentativePFactory_def.hpp b/packages/muelu/src/Transfers/Smoothed-Aggregation/MueLu_TentativePFactory_def.hpp index 220db70dc868..5969fc6a1a8d 100644 --- a/packages/muelu/src/Transfers/Smoothed-Aggregation/MueLu_TentativePFactory_def.hpp +++ b/packages/muelu/src/Transfers/Smoothed-Aggregation/MueLu_TentativePFactory_def.hpp @@ -851,7 +851,7 @@ void TentativePFactory:: // Time to construct the matrix and fill in the values Ptentative = rcp(new CrsMatrixWrap(rowMap, coarseMap, 0)); - RCP PtentCrs = rcp_dynamic_cast(Ptentative)->getCrsMatrix(); + RCP PtentCrs = toCrsMatrix(Ptentative); ArrayRCP iaPtent; ArrayRCP jaPtent; diff --git a/packages/muelu/src/Utils/MueLu_Utilities_decl.hpp b/packages/muelu/src/Utils/MueLu_Utilities_decl.hpp index 7f738cef23dc..fbb27c6cb68e 100644 --- a/packages/muelu/src/Utils/MueLu_Utilities_decl.hpp +++ b/packages/muelu/src/Utils/MueLu_Utilities_decl.hpp @@ -144,19 +144,6 @@ class Utilities : public UtilitiesBase> MV2TpetraMV(RCP> const vec); - static RCP> MV2NonConstTpetraMV(RCP> vec); - static RCP> MV2NonConstTpetraMV2(Xpetra::MultiVector& vec); - - static const Tpetra::MultiVector& MV2TpetraMV(const Xpetra::MultiVector& vec); - static Tpetra::MultiVector& MV2NonConstTpetraMV(Xpetra::MultiVector& vec); - - static RCP> Op2TpetraCrs(RCP> Op); - static RCP> Op2NonConstTpetraCrs(RCP> Op); - - static const Tpetra::CrsMatrix& Op2TpetraCrs(const Xpetra::Matrix& Op); - static Tpetra::CrsMatrix& Op2NonConstTpetraCrs(Xpetra::Matrix& Op); - static RCP> Op2TpetraBlockCrs(RCP> Op); static RCP> Op2NonConstTpetraBlockCrs(RCP> Op); @@ -302,112 +289,6 @@ class Utilities : public UtilitiesBasegetTpetra_MultiVector(); #endif } - static RCP> MV2NonConstTpetraMV(RCP vec) { -#if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ - (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) - throw Exceptions::RuntimeError("MV2NonConstTpetraMV: Tpetra has not been compiled with support for LO=GO=int."); -#else - RCP> tmpVec = rcp_dynamic_cast>(vec); - if (tmpVec == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::MultiVector to Xpetra::TpetraMultiVector failed"); - return tmpVec->getTpetra_MultiVector(); -#endif - } - static RCP> MV2NonConstTpetraMV2(MultiVector& vec) { -#if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ - (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) - throw Exceptions::RuntimeError("MV2NonConstTpetraMV2: Tpetra has not been compiled with support for LO=GO=int."); -#else - const Xpetra::TpetraMultiVector& tmpVec = dynamic_cast&>(vec); - return tmpVec.getTpetra_MultiVector(); -#endif - } - - static const Tpetra::MultiVector& MV2TpetraMV(const MultiVector& vec) { -#if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ - (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) - throw Exceptions::RuntimeError("MV2TpetraMV: Tpetra has not been compiled with support for LO=GO=int."); -#else - const Xpetra::TpetraMultiVector& tmpVec = dynamic_cast&>(vec); - return *(tmpVec.getTpetra_MultiVector()); -#endif - } - static Tpetra::MultiVector& MV2NonConstTpetraMV(MultiVector& vec) { -#if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ - (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) - throw Exceptions::RuntimeError("MV2NonConstTpetraMV: Tpetra has not been compiled with support for LO=GO=int."); -#else - const Xpetra::TpetraMultiVector& tmpVec = dynamic_cast&>(vec); - return *(tmpVec.getTpetra_MultiVector()); -#endif - } - - static RCP> Op2TpetraCrs(RCP Op) { -#if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ - (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) - throw Exceptions::RuntimeError("Op2TpetraCrs: Tpetra has not been compiled with support for LO=GO=int."); -#else - // Get the underlying Tpetra Mtx - RCP crsOp = rcp_dynamic_cast(Op); - if (crsOp == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed"); - const RCP>& tmp_ECrsMtx = rcp_dynamic_cast>(crsOp->getCrsMatrix()); - if (tmp_ECrsMtx == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed"); - return tmp_ECrsMtx->getTpetra_CrsMatrix(); -#endif - } - static RCP> Op2NonConstTpetraCrs(RCP Op) { -#if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ - (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) - throw Exceptions::RuntimeError("Op2NonConstTpetraCrs: Tpetra has not been compiled with support for LO=GO=int."); -#else - RCP crsOp = rcp_dynamic_cast(Op); - if (crsOp == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed"); - const RCP>& tmp_ECrsMtx = rcp_dynamic_cast>(crsOp->getCrsMatrix()); - if (tmp_ECrsMtx == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed"); - return tmp_ECrsMtx->getTpetra_CrsMatrixNonConst(); -#endif - }; - - static const Tpetra::CrsMatrix& Op2TpetraCrs(const Matrix& Op) { -#if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ - (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) - throw Exceptions::RuntimeError("Op2TpetraCrs: Tpetra has not been compiled with support for LO=GO=int."); -#else - try { - const CrsMatrixWrap& crsOp = dynamic_cast(Op); - try { - const Xpetra::TpetraCrsMatrix& tmp_ECrsMtx = dynamic_cast&>(*crsOp.getCrsMatrix()); - return *tmp_ECrsMtx.getTpetra_CrsMatrix(); - } catch (std::bad_cast&) { - throw Exceptions::BadCast("Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed"); - } - } catch (std::bad_cast&) { - throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed"); - } -#endif - } - static Tpetra::CrsMatrix& Op2NonConstTpetraCrs(Matrix& Op) { -#if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ - (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT)))) - throw Exceptions::RuntimeError("Op2NonConstTpetraCrs: Tpetra has not been compiled with support for LO=GO=int."); -#else - try { - CrsMatrixWrap& crsOp = dynamic_cast(Op); - try { - Xpetra::TpetraCrsMatrix& tmp_ECrsMtx = dynamic_cast&>(*crsOp.getCrsMatrix()); - return *tmp_ECrsMtx.getTpetra_CrsMatrixNonConst(); - } catch (std::bad_cast&) { - throw Exceptions::BadCast("Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed"); - } - } catch (std::bad_cast&) { - throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed"); - } -#endif - } static RCP> Op2TpetraBlockCrs(RCP Op) { #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \ @@ -591,7 +472,7 @@ class Utilities : public UtilitiesBase& tpOp = Op2NonConstTpetraCrs(Op); + Tpetra::CrsMatrix& tpOp = toTpetra(Op); const RCP> rowMap = tpOp.getRowMap(); const RCP> domainMap = tpOp.getDomainMap(); diff --git a/packages/muelu/src/Utils/MueLu_Utilities_def.hpp b/packages/muelu/src/Utils/MueLu_Utilities_def.hpp index 5548cc4595a1..5523a226426d 100644 --- a/packages/muelu/src/Utils/MueLu_Utilities_def.hpp +++ b/packages/muelu/src/Utils/MueLu_Utilities_def.hpp @@ -172,95 +172,6 @@ const Epetra_Map& Utilities::Map2Epet } #endif -template -RCP> -Utilities::MV2TpetraMV(RCP> const vec) { - RCP> tmpVec = rcp_dynamic_cast>(vec); - if (tmpVec == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::MultiVector to Xpetra::TpetraMultiVector failed"); - return tmpVec->getTpetra_MultiVector(); -} - -template -RCP> Utilities::MV2NonConstTpetraMV(RCP> vec) { - RCP> tmpVec = rcp_dynamic_cast>(vec); - if (tmpVec == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::MultiVector to Xpetra::TpetraMultiVector failed"); - return tmpVec->getTpetra_MultiVector(); -} - -template -Tpetra::MultiVector& Utilities::MV2NonConstTpetraMV(Xpetra::MultiVector& vec) { - const Xpetra::TpetraMultiVector& tmpVec = dynamic_cast&>(vec); - return *(tmpVec.getTpetra_MultiVector()); -} - -template -RCP> Utilities::MV2NonConstTpetraMV2(Xpetra::MultiVector& vec) { - const Xpetra::TpetraMultiVector& tmpVec = dynamic_cast&>(vec); - return tmpVec.getTpetra_MultiVector(); -} - -template -const Tpetra::MultiVector& -Utilities::MV2TpetraMV(const Xpetra::MultiVector& vec) { - const Xpetra::TpetraMultiVector& tmpVec = dynamic_cast&>(vec); - return *(tmpVec.getTpetra_MultiVector()); -} - -template -RCP> Utilities::Op2TpetraCrs(RCP> Op) { - // Get the underlying Tpetra Mtx - RCP> crsOp = rcp_dynamic_cast>(Op); - if (crsOp == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed"); - const RCP>& tmp_ECrsMtx = rcp_dynamic_cast>(crsOp->getCrsMatrix()); - if (tmp_ECrsMtx == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed"); - return tmp_ECrsMtx->getTpetra_CrsMatrix(); -} - -template -RCP> Utilities::Op2NonConstTpetraCrs(RCP> Op) { - RCP> crsOp = rcp_dynamic_cast>(Op); - if (crsOp == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed"); - const RCP>& tmp_ECrsMtx = rcp_dynamic_cast>(crsOp->getCrsMatrix()); - if (tmp_ECrsMtx == Teuchos::null) - throw Exceptions::BadCast("Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed"); - return tmp_ECrsMtx->getTpetra_CrsMatrixNonConst(); -} - -template -const Tpetra::CrsMatrix& Utilities::Op2TpetraCrs(const Xpetra::Matrix& Op) { - try { - const Xpetra::CrsMatrixWrap& crsOp = dynamic_cast&>(Op); - try { - const Xpetra::TpetraCrsMatrix& tmp_ECrsMtx = dynamic_cast&>(*crsOp.getCrsMatrix()); - return *tmp_ECrsMtx.getTpetra_CrsMatrix(); - } catch (std::bad_cast&) { - throw Exceptions::BadCast("Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed"); - } - } catch (std::bad_cast&) { - throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed"); - } -} - -template -Tpetra::CrsMatrix& Utilities::Op2NonConstTpetraCrs(Xpetra::Matrix& Op) { - try { - Xpetra::CrsMatrixWrap& crsOp = dynamic_cast&>(Op); - try { - Xpetra::TpetraCrsMatrix& tmp_ECrsMtx = dynamic_cast&>(*crsOp.getCrsMatrix()); - return *tmp_ECrsMtx.getTpetra_CrsMatrixNonConst(); - } catch (std::bad_cast&) { - throw Exceptions::BadCast("Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed"); - } - } catch (std::bad_cast&) { - throw Exceptions::BadCast("Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed"); - } -} - template RCP> Utilities::Op2TpetraBlockCrs(RCP> Op) { using XCrsMatrixWrap = Xpetra::CrsMatrixWrap; @@ -424,7 +335,7 @@ void Utilities::MyOldScaleMatrix_Tpet bool doFillComplete, bool doOptimizeStorage) { try { - Tpetra::CrsMatrix& tpOp = Op2NonConstTpetraCrs(Op); + Tpetra::CrsMatrix& tpOp = toTpetra(Op); const RCP> rowMap = tpOp.getRowMap(); const RCP> domainMap = tpOp.getDomainMap(); @@ -513,7 +424,7 @@ Utilities:: using Helpers = Xpetra::Helpers; /***************************************************************/ if (Helpers::isTpetraCrs(Op)) { - const Tpetra::CrsMatrix& tpetraOp = Utilities::Op2TpetraCrs(Op); + const Tpetra::CrsMatrix& tpetraOp = toTpetra(Op); RCP> A; Tpetra::RowMatrixTransposer transposer(rcpFromRef(tpetraOp), label); // more than meets the eye diff --git a/packages/muelu/test/interface/CreateOperator.cpp b/packages/muelu/test/interface/CreateOperator.cpp index 00a4eaaea530..9c07f031676f 100644 --- a/packages/muelu/test/interface/CreateOperator.cpp +++ b/packages/muelu/test/interface/CreateOperator.cpp @@ -64,7 +64,7 @@ void setup_system_list(Xpetra::UnderlyingLib& lib, Teuchos::RCP At = Xpetra::Helpers::Op2NonConstTpetraCrs(A); + RCP At = toTpetra(A); RCP > opA(At); RCP Mt = MueLu::CreateTpetraPreconditioner(opA, mueluList); diff --git a/packages/muelu/test/maxwell/Maxwell3D.cpp b/packages/muelu/test/maxwell/Maxwell3D.cpp index 6742df63872c..5b6e0c41ced4 100644 --- a/packages/muelu/test/maxwell/Maxwell3D.cpp +++ b/packages/muelu/test/maxwell/Maxwell3D.cpp @@ -408,10 +408,10 @@ bool SetupSolve(std::map inputs) { sublist->set(*key_it, Teuchos::rcp_dynamic_cast >(coords, true)->getEpetra_MultiVector()); #endif else if (value == "tD0") { - auto tD0 = Teuchos::rcp_dynamic_cast(Teuchos::rcp_dynamic_cast(D0_Matrix, true)->getCrsMatrix(), true)->getTpetra_CrsMatrix(); + auto tD0 = toTpetra(D0_Matrix); sublist->set(*key_it, tD0); } else if (value == "tCoordinates") { - sublist->set(*key_it, Teuchos::rcp_dynamic_cast(coords, true)->getTpetra_MultiVector()); + sublist->set(*key_it, toTpetra(coords)); } } } diff --git a/packages/muelu/test/perf_tests_kokkos/Redirection.cpp b/packages/muelu/test/perf_tests_kokkos/Redirection.cpp index 2e085a260db9..3d10550278d9 100644 --- a/packages/muelu/test/perf_tests_kokkos/Redirection.cpp +++ b/packages/muelu/test/perf_tests_kokkos/Redirection.cpp @@ -119,7 +119,7 @@ int main_(Teuchos::CommandLineProcessor &clp, Xpetra::UnderlyingLib &lib, int ar if (lib == Xpetra::UseTpetra) { typedef Tpetra::CrsMatrix tCrsMatrix; - RCP tA = Utilities::Op2TpetraCrs(A); + RCP tA = toTpetra(A); TEUCHOS_TEST_FOR_EXCEPTION(tA.is_null(), MueLu::Exceptions::RuntimeError, "A is not a Tpetra CrsMatrix"); diff --git a/packages/muelu/test/scaling/Driver.cpp b/packages/muelu/test/scaling/Driver.cpp index 81c45ffd5a0e..3894faa73aec 100644 --- a/packages/muelu/test/scaling/Driver.cpp +++ b/packages/muelu/test/scaling/Driver.cpp @@ -106,7 +106,7 @@ void equilibrateMatrix(Teuchos::RCP::val_type, typename Node::device_type> equil_type; - Teuchos::RCP > A = Utilities::Op2NonConstTpetraCrs(Axpetra); + Teuchos::RCP > A = toTpetra(Axpetra); if (Axpetra->getRowMap()->lib() == Xpetra::UseTpetra) { equil_type equibResult_ = computeRowAndColumnOneNorms(*A, assumeSymmetric); diff --git a/packages/muelu/test/scaling/DriverCore.hpp b/packages/muelu/test/scaling/DriverCore.hpp index 6a111bbb9103..ccc63ed8f815 100644 --- a/packages/muelu/test/scaling/DriverCore.hpp +++ b/packages/muelu/test/scaling/DriverCore.hpp @@ -144,7 +144,7 @@ void PreconditionerSetup(Teuchos::RCPSetMaxEigenvalueEstimate(-Teuchos::ScalarTraits::one()); if (useAMGX) { #if defined(HAVE_MUELU_AMGX) - RCP> Ac = Utilities::Op2NonConstTpetraCrs(A); + RCP> Ac = toTpetra(A); RCP> At = Teuchos::rcp_dynamic_cast>(Ac); RCP> Top = MueLu::CreateTpetraPreconditioner(At, mueluList); Prec = Teuchos::rcp(new Xpetra::TpetraOperator(Top)); @@ -259,7 +259,7 @@ void SystemSolve(Teuchos::RCP> Atpetra; Teuchos::RCP> Xtpetra, Btpetra; if (lib == Xpetra::UseTpetra) { - Atpetra = Utilities::Op2NonConstTpetraCrs(A); + Atpetra = toTpetra(A); Xtpetra = rcp(&Xpetra::toTpetra(*X), false); Btpetra = rcp(&Xpetra::toTpetra(*B), false); } diff --git a/packages/muelu/test/scaling/ImportPerformance.cpp b/packages/muelu/test/scaling/ImportPerformance.cpp index a501130ce2e0..ee3ae3cd088b 100644 --- a/packages/muelu/test/scaling/ImportPerformance.cpp +++ b/packages/muelu/test/scaling/ImportPerformance.cpp @@ -344,8 +344,8 @@ void TestTransfer(Teuchos::RCP crs_matrix_type; typedef Tpetra::Import import_type; - RCP Au = Utilities::Op2TpetraCrs(A); - RCP Pu = Utilities::Op2TpetraCrs(P); + RCP Au = toTpetra(A); + RCP Pu = toTpetra(P); if (Au->getComm()->getSize() == 1) return; // ================== diff --git a/packages/muelu/test/scaling/JacobiKernelDriver.cpp b/packages/muelu/test/scaling/JacobiKernelDriver.cpp index a022a185a043..da956e7c69bd 100644 --- a/packages/muelu/test/scaling/JacobiKernelDriver.cpp +++ b/packages/muelu/test/scaling/JacobiKernelDriver.cpp @@ -80,9 +80,9 @@ void Jacobi_MKL_SPMM(const Xpetra::Matrix mkl_int_type; - RCP Au = Utilities::Op2TpetraCrs(rcp(&A, false)); - RCP Bu = Utilities::Op2TpetraCrs(rcp(&B, false)); - RCP Cu = Utilities::Op2TpetraCrs(rcp(&C, false)); + RCP Au = toTpetra(rcp(&A, false)); + RCP Bu = toTpetra(rcp(&B, false)); + RCP Cu = toTpetra(rcp(&C, false)); RCP Cnc = Teuchos::rcp_const_cast(Cu); RCP Du = Xpetra::toTpetra(D); @@ -245,9 +245,9 @@ void Jacobi_Wrapper(const Xpetra::Matrix range_type; LocalOrdinal LO_INVALID = Teuchos::OrdinalTraits::invalid(); RCP Cimport; - RCP Au = Utilities::Op2TpetraCrs(rcp(&A, false)); - RCP Bu = Utilities::Op2TpetraCrs(rcp(&B, false)); - RCP Cu = Utilities::Op2TpetraCrs(rcp(&C, false)); + RCP Au = toTpetra(rcp(&A, false)); + RCP Bu = toTpetra(rcp(&B, false)); + RCP Cu = toTpetra(rcp(&C, false)); RCP Cnc = Teuchos::rcp_const_cast(Cu); RCP Du = Xpetra::toTpetra(D); diff --git a/packages/muelu/test/scaling/MMKernelDriver.cpp b/packages/muelu/test/scaling/MMKernelDriver.cpp index 737a17cfa94a..2474bb9e4cf9 100644 --- a/packages/muelu/test/scaling/MMKernelDriver.cpp +++ b/packages/muelu/test/scaling/MMKernelDriver.cpp @@ -247,9 +247,9 @@ void Multiply_ViennaCL(const Xpetra::Matrix vcl_size_t_type; - RCP Au = Utilities::Op2TpetraCrs(rcp(&A, false)); - RCP Bu = Utilities::Op2TpetraCrs(rcp(&B, false)); - RCP Cu = Utilities::Op2TpetraCrs(rcp(&C, false)); + RCP Au = toTpetra(rcp(&A, false)); + RCP Bu = toTpetra(rcp(&B, false)); + RCP Cu = toTpetra(rcp(&C, false)); RCP Cnc = Teuchos::rcp_const_cast(Cu); const KCRS &Amat = Au->getLocalMatrixDevice(); @@ -414,9 +414,9 @@ void Multiply_MKL_SPMM(const Xpetra::Matrix Au = Utilities::Op2TpetraCrs(rcp(&A, false)); - RCP Bu = Utilities::Op2TpetraCrs(rcp(&B, false)); - RCP Cu = Utilities::Op2TpetraCrs(rcp(&C, false)); + RCP Au = toTpetra(rcp(&A, false)); + RCP Bu = toTpetra(rcp(&B, false)); + RCP Cu = toTpetra(rcp(&C, false)); RCP Cnc = Teuchos::rcp_const_cast(Cu); const KCRS &Amat = Au->getLocalMatrixDevice(); @@ -598,9 +598,9 @@ void Multiply_KokkosKernels(const Xpetra::Matrix Au = Utilities::Op2TpetraCrs(rcp(&A, false)); - RCP Bu = Utilities::Op2TpetraCrs(rcp(&B, false)); - RCP Cu = Utilities::Op2TpetraCrs(rcp(&C, false)); + RCP Au = toTpetra(rcpFromRef(A)); + RCP Bu = toTpetra(rcpFromRef(B)); + RCP Cu = toTpetra(rcpFromRef(C)); RCP Cnc = Teuchos::rcp_const_cast(Cu); const KCRS &Amat = Au->getLocalMatrixDevice(); @@ -794,9 +794,9 @@ struct LTG_Tests range_type; LocalOrdinal LO_INVALID = Teuchos::OrdinalTraits::invalid(); RCP Cimport; - RCP Au = Utilities::Op2TpetraCrs(rcp(&A, false)); - RCP Bu = Utilities::Op2TpetraCrs(rcp(&B, false)); - RCP Cu = Utilities::Op2TpetraCrs(rcp(&C, false)); + RCP Au = toTpetra(rcp(&A, false)); + RCP Bu = toTpetra(rcp(&B, false)); + RCP Cu = toTpetra(rcp(&C, false)); RCP Cnc = Teuchos::rcp_const_cast(Cu); using no_init_view = Kokkos::ViewAllocateWithoutInitializing; diff --git a/packages/muelu/test/scaling/MatvecKernelDriver.cpp b/packages/muelu/test/scaling/MatvecKernelDriver.cpp index 3de6a2480dab..3d510b676f08 100644 --- a/packages/muelu/test/scaling/MatvecKernelDriver.cpp +++ b/packages/muelu/test/scaling/MatvecKernelDriver.cpp @@ -944,7 +944,7 @@ int main_(Teuchos::CommandLineProcessor& clp, Xpetra::UnderlyingLib& lib, int ar vector_type xt; vector_type yt; - At = Utilities::Op2TpetraCrs(A); + At = toTpetra(A); const crs_matrix_type& Att = *At; xt = Xpetra::toTpetra(*x); yt = Xpetra::toTpetra(*y); diff --git a/packages/muelu/test/scaling/TwoMatrixMMKernelDriver.cpp b/packages/muelu/test/scaling/TwoMatrixMMKernelDriver.cpp index 1a4b53b9a7e3..65db6b5de7e6 100644 --- a/packages/muelu/test/scaling/TwoMatrixMMKernelDriver.cpp +++ b/packages/muelu/test/scaling/TwoMatrixMMKernelDriver.cpp @@ -108,10 +108,10 @@ void MM2_MKL(const Xpetra::Matrix &A, typedef typename Kokkos::View mkl_int_type; - RCP Au = Utilities::Op2TpetraCrs(rcp(&A, false)); - RCP B1u = Utilities::Op2TpetraCrs(rcp(&B1, false)); - RCP B2u = Utilities::Op2TpetraCrs(rcp(&B2, false)); - RCP Cu = Utilities::Op2TpetraCrs(rcp(&C, false)); + RCP Au = toTpetra(rcp(&A, false)); + RCP B1u = toTpetra(rcp(&B1, false)); + RCP B2u = toTpetra(rcp(&B2, false)); + RCP Cu = toTpetra(rcp(&C, false)); RCP Cnc = Teuchos::rcp_const_cast(Cu); const KCRS &Amat = Au->getLocalMatrixDevice(); @@ -308,10 +308,10 @@ void MM2_Wrapper(const Xpetra::Matrix typedef Kokkos::RangePolicy range_type; LocalOrdinal LO_INVALID = Teuchos::OrdinalTraits::invalid(); RCP Cimport; - RCP Au = Utilities::Op2TpetraCrs(rcp(&A, false)); - RCP B1u = Utilities::Op2TpetraCrs(rcp(&B1, false)); - RCP B2u = Teuchos::rcp_const_cast(Utilities::Op2TpetraCrs(rcp(&B2, false))); - RCP Cu = Utilities::Op2TpetraCrs(rcp(&C, false)); + RCP Au = toTpetra(rcpFromRef(A)); + RCP B1u = toTpetra(rcp(&B1, false)); + RCP B2u = Teuchos::rcp_const_cast(toTpetra(rcp(&B2, false))); + RCP Cu = toTpetra(rcp(&C, false)); RCP Cnc = Teuchos::rcp_const_cast(Cu); // ********************************** diff --git a/packages/muelu/test/unit_tests/Adapters/AmgxOperatorAdapter.cpp b/packages/muelu/test/unit_tests/Adapters/AmgxOperatorAdapter.cpp index f072d8ba3d43..ebb2ac78842c 100644 --- a/packages/muelu/test/unit_tests/Adapters/AmgxOperatorAdapter.cpp +++ b/packages/muelu/test/unit_tests/Adapters/AmgxOperatorAdapter.cpp @@ -59,7 +59,7 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(AMGXOperator, Apply, Scalar, LocalOrdinal, Glo // matrix RCP Op = TestHelpers::TestFactory::Build2DPoisson(nx, -1, Xpetra::UseTpetra); - RCP > tpA = MueLu::Utilities::Op2NonConstTpetraCrs(Op); + RCP > tpA = toTpetra(Op); RCP > tOp = tpA; Teuchos::ParameterList params, dummyList; params.set("use external multigrid package", "amgx"); @@ -77,7 +77,7 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(AMGXOperator, Apply, Scalar, LocalOrdinal, Glo RHS->putScalar((double)1.0); X->putScalar((double)0.0); - aH->apply(*(MueLu::Utilities::MV2TpetraMV(RHS)), *(MueLu::Utilities::MV2NonConstTpetraMV(X))); + aH->apply(*(toTpetra(RHS)), *(toTpetra(X))); // if(comm->getSize() == 1) TEST_EQUALITY(aH->iters()==16,true); TEST_EQUALITY(aH->getStatus() == 0, true); diff --git a/packages/muelu/test/unit_tests/Adapters/BelosAdapters.cpp b/packages/muelu/test/unit_tests/Adapters/BelosAdapters.cpp index f7e78702c312..7dd79839bf17 100644 --- a/packages/muelu/test/unit_tests/Adapters/BelosAdapters.cpp +++ b/packages/muelu/test/unit_tests/Adapters/BelosAdapters.cpp @@ -230,8 +230,8 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(BelosAdapters, XpetraOp_TpetraMV, Scalar, Loca RCP belosPrec = rcp(new Belos::MueLuOp(p->GetH())); // X, B - RCP X = Utilities::MV2NonConstTpetraMV(p->GetNewX0()); - RCP B = Utilities::MV2NonConstTpetraMV(p->GetRHS()); + RCP X = toTpetra(p->GetNewX0()); + RCP B = toTpetra(p->GetRHS()); // Run Belos int numIters = MueLuTests::BelosAdaptersTest(belosOp, belosPrec, X, B, out, success); diff --git a/packages/muelu/test/unit_tests/Adapters/CreatePreconditioner.cpp b/packages/muelu/test/unit_tests/Adapters/CreatePreconditioner.cpp index bcf3b145440c..f1a2d2635fc4 100644 --- a/packages/muelu/test/unit_tests/Adapters/CreatePreconditioner.cpp +++ b/packages/muelu/test/unit_tests/Adapters/CreatePreconditioner.cpp @@ -89,12 +89,12 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(PetraOperator, CreatePreconditioner, Scalar, L RCP nullspace = Xpetra::MultiVectorFactory::Build(Op->getDomainMap(), 1); nullspace->putScalar(Teuchos::ScalarTraits::one()); - RCP tpA = MueLu::Utilities::Op2NonConstTpetraCrs(Op); + RCP tpA = toTpetra(Op); out << "========== Create Preconditioner from xmlFile ==========" << std::endl; out << "xmlFileName: " << xmlFileName << std::endl; RCP > tH = MueLu::CreateTpetraPreconditioner(RCP(tpA), xmlFileName); - tH->apply(*(Utils::MV2TpetraMV(RHS1)), *(Utils::MV2NonConstTpetraMV(X1))); + tH->apply(*(toTpetra(RHS1)), *(toTpetra(X1))); out << "after apply, ||b-A*x||_2 = " << std::setiosflags(std::ios::fixed) << std::setprecision(10) << Utils::ResidualNorm(*Op, *X1, *RHS1) << std::endl; #endif @@ -213,16 +213,16 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(PetraOperator, CreatePreconditioner_XMLOnList, RCP nullspace = Xpetra::MultiVectorFactory::Build(Op->getDomainMap(), 1); nullspace->putScalar(Teuchos::ScalarTraits::one()); - RCP > tpA = MueLu::Utilities::Op2NonConstTpetraCrs(Op); + RCP > tpA = toTpetra(Op); RCP > tH = MueLu::CreateTpetraPreconditioner(RCP(tpA), mylist); - tH->apply(*(Utils::MV2TpetraMV(RHS1)), *(Utils::MV2NonConstTpetraMV(X1))); + tH->apply(*(toTpetra(RHS1)), *(toTpetra(X1))); out << "after apply, ||b-A*x||_2 = " << std::setiosflags(std::ios::fixed) << std::setprecision(10) << Utils::ResidualNorm(*Op, *X1, *RHS1) << std::endl; mylist.set("xml parameter file", "testWithRebalance.xml"); - RCP > tpcoordinates = MueLu::Utilities::MV2NonConstTpetraMV(coordinates); - RCP > tpnullspace = Utils::MV2NonConstTpetraMV(nullspace); + RCP > tpcoordinates = toTpetra(coordinates); + RCP > tpnullspace = toTpetra(nullspace); std::string mueluXML = mylist.get("xml parameter file", ""); Teuchos::ParameterList mueluList; @@ -232,7 +232,7 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(PetraOperator, CreatePreconditioner_XMLOnList, userParamList.set > >("Nullspace", tpnullspace); tH = MueLu::CreateTpetraPreconditioner(RCP(tpA), mueluList); X1->putScalar(Teuchos::ScalarTraits::zero()); - tH->apply(*(Utils::MV2TpetraMV(RHS1)), *(Utils::MV2NonConstTpetraMV(X1))); + tH->apply(*(toTpetra(RHS1)), *(toTpetra(X1))); out << "after apply, ||b-A*x||_2 = " << std::setiosflags(std::ios::fixed) << std::setprecision(10) << Utils::ResidualNorm(*Op, *X1, *RHS1) << std::endl; #endif @@ -360,9 +360,9 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(PetraOperator, CreatePreconditioner_PDESystem, RCP X1 = MultiVectorFactory::Build(Op->getRowMap(), 1); X1->putScalar(Teuchos::ScalarTraits::zero()); - RCP > tpA = MueLu::Utilities::Op2NonConstTpetraCrs(Op); - RCP > tpcoordinates = MueLu::Utilities::MV2NonConstTpetraMV(coordinates); - RCP > tpnullspace = Utils::MV2NonConstTpetraMV(nullspace); + RCP > tpA = toTpetra(Op); + RCP > tpcoordinates = toTpetra(coordinates); + RCP > tpnullspace = toTpetra(nullspace); Teuchos::ParameterList paramList; Teuchos::updateParametersFromXmlFileAndBroadcast(xmlFileName, Teuchos::Ptr(¶mList), *tpA->getDomainMap()->getComm()); @@ -370,7 +370,7 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(PetraOperator, CreatePreconditioner_PDESystem, userParamList.set > >("Coordinates", tpcoordinates); userParamList.set > >("Nullspace", tpnullspace); RCP > tH = MueLu::CreateTpetraPreconditioner(RCP(tpA), paramList); - tH->apply(*(Utils::MV2TpetraMV(RHS1)), *(Utils::MV2NonConstTpetraMV(X1))); + tH->apply(*(toTpetra(RHS1)), *(toTpetra(X1))); out << "after apply, ||b-A*x||_2 = " << std::setiosflags(std::ios::fixed) << std::setprecision(10) << Utils::ResidualNorm(*Op, *X1, *RHS1) << std::endl; #else std::cout << "Skip PetraOperator::CreatePreconditioner_PDESystem: Tpetra is not available (with GO=int enabled)" << std::endl; @@ -480,17 +480,17 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(PetraOperator, ReusePreconditioner, Scalar, Lo RCP X1 = MultiVectorFactory::Build(Op->getRowMap(), 1); X1->putScalar(Teuchos::ScalarTraits::zero()); - RCP > tpA = MueLu::Utilities::Op2NonConstTpetraCrs(Op); + RCP > tpA = toTpetra(Op); RCP > tH = MueLu::CreateTpetraPreconditioner(RCP(tpA), xmlFileName); - tH->apply(*(Utils::MV2TpetraMV(RHS1)), *(Utils::MV2NonConstTpetraMV(X1))); + tH->apply(*(toTpetra(RHS1)), *(toTpetra(X1))); out << "after apply, ||b-A*x||_2 = " << std::setiosflags(std::ios::fixed) << std::setprecision(10) << Utils::ResidualNorm(*Op, *X1, *RHS1) << std::endl; // Reuse preconditioner MueLu::ReuseTpetraPreconditioner(tpA, *tH); X1->putScalar(Teuchos::ScalarTraits::zero()); - tH->apply(*(Utils::MV2TpetraMV(RHS1)), *(Utils::MV2NonConstTpetraMV(X1))); + tH->apply(*(toTpetra(RHS1)), *(toTpetra(X1))); out << "after apply, ||b-A*x||_2 = " << std::setiosflags(std::ios::fixed) << std::setprecision(10) << Utils::ResidualNorm(*Op, *X1, *RHS1) << std::endl; #else std::cout << "Skip PetraOperator::ReusePreconditioner: Tpetra is not available (with GO=int enabled)" << std::endl; @@ -587,21 +587,21 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(PetraOperator, ReusePreconditioner2, Scalar, L RCP X1 = MultiVectorFactory::Build(Op->getRowMap(), 1); X1->putScalar(Teuchos::ScalarTraits::zero()); - RCP > tpA = MueLu::Utilities::Op2NonConstTpetraCrs(Op); + RCP > tpA = toTpetra(Op); RCP > tH = MueLu::CreateTpetraPreconditioner(RCP(tpA), params); - tH->apply(*(Utils::MV2TpetraMV(RHS1)), *(Utils::MV2NonConstTpetraMV(X1))); + tH->apply(*(toTpetra(RHS1)), *(toTpetra(X1))); out << "after apply, ||b-A*x||_2 = " << std::setiosflags(std::ios::fixed) << std::setprecision(10) << Utils::ResidualNorm(*Op, *X1, *RHS1) << std::endl; // Reuse preconditioner matrixFile = "TestMatrices/fuego1.mm"; RCP Op2 = Xpetra::IO::Read(matrixFile, rowmap, null, null, null); - RCP > tpA2 = MueLu::Utilities::Op2NonConstTpetraCrs(Op2); + RCP > tpA2 = toTpetra(Op2); MueLu::ReuseTpetraPreconditioner(tpA2, *tH); X1->putScalar(Teuchos::ScalarTraits::zero()); - tH->apply(*(Utils::MV2TpetraMV(RHS1)), *(Utils::MV2NonConstTpetraMV(X1))); + tH->apply(*(toTpetra(RHS1)), *(toTpetra(X1))); out << "after apply, ||b-A*x||_2 = " << std::setiosflags(std::ios::fixed) << std::setprecision(10) << Utils::ResidualNorm(*Op, *X1, *RHS1) << std::endl; } else if (lib == Xpetra::UseEpetra) { #ifdef HAVE_MUELU_EPETRA diff --git a/packages/muelu/test/unit_tests/Adapters/TpetraOperatorAdapter.cpp b/packages/muelu/test/unit_tests/Adapters/TpetraOperatorAdapter.cpp index 5e86c7be2a76..c20d3c74c1e0 100644 --- a/packages/muelu/test/unit_tests/Adapters/TpetraOperatorAdapter.cpp +++ b/packages/muelu/test/unit_tests/Adapters/TpetraOperatorAdapter.cpp @@ -76,7 +76,7 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(TpetraOperator, Apply, Scalar, LocalOrdinal, G X1->putScalar((SC)0.0); - tH->apply(*(Utils::MV2TpetraMV(RHS1)), *(Utils::MV2NonConstTpetraMV(X1))); + tH->apply(*(toTpetra(RHS1)), *(toTpetra(X1))); X1->norm2(norms); out << "after apply, ||X1|| = " << std::setiosflags(std::ios::fixed) << std::setprecision(10) << norms[0] << std::endl; diff --git a/packages/muelu/test/unit_tests/MueLu_TestHelpers_HO.hpp b/packages/muelu/test/unit_tests/MueLu_TestHelpers_HO.hpp index 437749bda702..aaa9040c5aeb 100644 --- a/packages/muelu/test/unit_tests/MueLu_TestHelpers_HO.hpp +++ b/packages/muelu/test/unit_tests/MueLu_TestHelpers_HO.hpp @@ -79,7 +79,7 @@ Build1DPseudoPoissonHigherOrder(GlobalOrdinal nx, int degree, int Nproc = comm->getSize(); // Get maps - RCP Acrs = rcp_dynamic_cast(A)->getCrsMatrix(); + RCP Acrs = toCrsMatrix(A); RCP p1_colmap = Acrs->getColMap(); RCP p1_rowmap = Acrs->getRowMap(); diff --git a/packages/muelu/test/unit_tests/ParameterList/ParameterListInterpreter.cpp b/packages/muelu/test/unit_tests/ParameterList/ParameterListInterpreter.cpp index e29fe020ea25..443851733ba0 100644 --- a/packages/muelu/test/unit_tests/ParameterList/ParameterListInterpreter.cpp +++ b/packages/muelu/test/unit_tests/ParameterList/ParameterListInterpreter.cpp @@ -126,7 +126,7 @@ MT compare_matrices(RCP &Ap, RCP &Ab) { SC one = Teuchos::ScalarTraits::one(); SC zero = Teuchos::ScalarTraits::zero(); - RCP Ap_t = MueLu::Utilities::Op2TpetraCrs(Ap); + RCP Ap_t = toTpetra(Ap); auto Ab_t = MueLu::Utilities::Op2TpetraBlockCrs(Ab); RCP Ab_as_point = Tpetra::convertToCrsMatrix(*Ab_t); @@ -154,7 +154,7 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(ParameterListInterpreter, PointCrs_vs_BlockCrs { using XCRS = Xpetra::TpetraBlockCrsMatrix; - auto tA = MueLu::Utilities::Op2TpetraCrs(PointA); + auto tA = toTpetra(PointA); auto bA = Tpetra::convertToBlockCrsMatrix(*tA, 1); RCP AA = rcp(new XCRS(bA)); BlockA = rcp(new CrsMatrixWrap(rcp_implicit_cast(AA))); diff --git a/packages/muelu/test/unit_tests_kokkos/Utilities_kokkos.cpp b/packages/muelu/test/unit_tests_kokkos/Utilities_kokkos.cpp index e0461368cf51..8e69d45e29ba 100644 --- a/packages/muelu/test/unit_tests_kokkos/Utilities_kokkos.cpp +++ b/packages/muelu/test/unit_tests_kokkos/Utilities_kokkos.cpp @@ -473,19 +473,19 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(Utilities_kokkos, TransformFunctions, Scalar, TEST_EQUALITY(mv.getData(0).size(), tpetraMV.getData(0).size()); }; - auto tpetraMV = Utils::MV2TpetraMV(vector); + auto tpetraMV = toTpetra(vector); compareMV(*vector, *tpetraMV); - auto tpetraMV2 = Utils::MV2TpetraMV(*vector); + auto tpetraMV2 = toTpetra(*vector); compareMV(*vector, tpetraMV2); - auto nonConstTpetraMV = Utils::MV2NonConstTpetraMV(vector); + auto nonConstTpetraMV = toTpetra(vector); compareMV(*vector, *nonConstTpetraMV); - auto nonConstTpetraMV2 = Utils::MV2NonConstTpetraMV2(*vector); + auto nonConstTpetraMV2 = toTpetra(vector); compareMV(*vector, *nonConstTpetraMV2); - auto nonConstTpetraMV3 = Utils::MV2NonConstTpetraMV(*vector); + auto nonConstTpetraMV3 = toTpetra(*vector); compareMV(*vector, nonConstTpetraMV3); using TpetraMat = Tpetra::RowMatrix; @@ -500,16 +500,16 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(Utilities_kokkos, TransformFunctions, Scalar, TEST_EQUALITY(xpetraMat.getGlobalNumEntries(), tpetraMat.getGlobalNumEntries()); }; - auto tpetraCrsMat = Utils::Op2TpetraCrs(A); + auto tpetraCrsMat = toTpetra(A); compareMat(*A, *tpetraCrsMat); - auto nonConstTpetraCrs = Utils::Op2NonConstTpetraCrs(A); + auto nonConstTpetraCrs = toTpetra(A); compareMat(*A, *nonConstTpetraCrs); - auto tpetraCrs = Utils::Op2TpetraCrs(*A); + auto tpetraCrs = *toTpetra(A); compareMat(*A, tpetraCrs); - auto nonConstTpetraCrs2 = Utils::Op2NonConstTpetraCrs(*A); + auto nonConstTpetraCrs2 = *toTpetra(A); compareMat(*A, nonConstTpetraCrs2); auto crsMat = CrsMatrixFactory::Build(map);