Skip to content

Commit

Permalink
MueLu: Use helper functions
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Glusa <[email protected]>
  • Loading branch information
cgcgcg committed Jan 24, 2025
1 parent e5fba41 commit 3170137
Show file tree
Hide file tree
Showing 53 changed files with 147 additions and 356 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ MueLuTpetraQ2Q1PreconditionerFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>:
for (int i = 0; i < valA.size(); i++) valB[i] = Teuchos::ScalarTraits<SC>::magnitude(valA[i]);

RCP<Matrix> B = rcp(new CrsMatrixWrap(A.getRowMap(), A.getColMap(), 0));
RCP<CrsMatrix> Bcrs = rcp_dynamic_cast<CrsMatrixWrap>(B)->getCrsMatrix();
RCP<CrsMatrix> Bcrs = toCrsMatrix(B);
Bcrs->setAllValues(iaB, jaB, valB);
Bcrs->expertStaticFillComplete(A.getDomainMap(), A.getRangeMap());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ShiftedLaplacianOperator<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
}

RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > tpA =
Utilities<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Op2NonConstTpetraCrs(A);
toTpetra(A);
return tpA->getDomainMap();
}

Expand All @@ -63,7 +63,7 @@ ShiftedLaplacianOperator<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
return Xpetra::toTpetraNonZero(tpbA->getRangeMap());

RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > tpA =
Utilities<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Op2NonConstTpetraCrs(A);
toTpetra(A);
return tpA->getRangeMap();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
void ShiftedLaplacian<Scalar, LocalOrdinal, GlobalOrdinal, Node>::setProblemMatrix(RCP<Matrix>& 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_);
Expand Down
2 changes: 1 addition & 1 deletion packages/muelu/example/advanced/blockcrs/BlockCrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ int main_(Teuchos::CommandLineProcessor &clp, Xpetra::UnderlyingLib lib, int arg
std::string matrixType = galeriParameters.GetMatrixType();
RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > Axp;
MueLuExamples::generate_user_matrix_and_nullspace<Scalar, LocalOrdinal, GlobalOrdinal, Node>(matrixType, lib, galeriList, comm, Axp, nullspace);
Acrs = Xpetra::Helpers<SC, LO, GO, NO>::Op2NonConstTpetraCrs(Axp);
Acrs = toTpetra(Axp);
}
// Block this bad boy
Ablock = Tpetra::convertToBlockCrsMatrix<SC, LO, GO, NO>(*Acrs, blocksize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ int main(int argc, char* argv[]) {
RCP<ADRXpetraProblem> Pr = ADR::Xpetra::BuildProblem<scalar_type, local_ordinal_type, global_ordinal_type, Map, CrsMatrixWrap, MultiVector>(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList());
RCP<Matrix> xpetraA = Pr->BuildMatrix();

RCP<crs_matrix_type> A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA);
RCP<crs_matrix_type> A = toTpetra(xpetraA);
RCP<const driver_map_type> map = MueLuUtilities::Map2TpetraMap(*xpetraMap);

// ===================================================
Expand Down Expand Up @@ -228,7 +228,7 @@ int main(int argc, char* argv[]) {
// ===================================

RCP<muelu_tpetra_operator_type> M;
M = MueLu::CreateTpetraPreconditioner((RCP<operator_type>)A, mueluParams, Utilities::MV2NonConstTpetraMV(coordinates));
M = MueLu::CreateTpetraPreconditioner((RCP<operator_type>)A, mueluParams, toTpetra(coordinates));

RCP<multivector_type> X_muelu = rcp(new multivector_type(map, 1));
RCP<multivector_type> B = rcp(new multivector_type(map, 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ int main(int argc, char *argv[]) {
RCP<ADRXpetraProblem> Pr = ADR::Xpetra::BuildProblem<scalar_type, local_ordinal_type, global_ordinal_type, Map, CrsMatrixWrap, MultiVector>(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList());
RCP<Matrix> xpetraA = Pr->BuildMatrix();

RCP<crs_matrix_type> A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA);
RCP<crs_matrix_type> A = MueLutoTpetra(xpetraA);
RCP<const driver_map_type> map = MueLuUtilities::Map2TpetraMap(*xpetraMap);

// Construct a multigrid preconditioner
RCP<muelu_tpetra_operator_type> M = MueLu::CreateTpetraPreconditioner((RCP<operator_type>)A, mueluParams, Utilities::MV2NonConstTpetraMV(coordinates));
RCP<muelu_tpetra_operator_type> M = MueLu::CreateTpetraPreconditioner((RCP<operator_type>)A, mueluParams, toTpetra(coordinates));

RCP<multivector_type> X = rcp(new multivector_type(map, 1));
RCP<multivector_type> B = rcp(new multivector_type(map, 1));
Expand Down
4 changes: 2 additions & 2 deletions packages/muelu/research/max/AdditiveMG/Repartition_ADR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ int main(int argc, char *argv[]) {
RCP<ADRXpetraProblem> Pr = ADR::Xpetra::BuildProblem<scalar_type, local_ordinal_type, global_ordinal_type, Map, CrsMatrixWrap, MultiVector>(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList());
RCP<Matrix> xpetraA = Pr->BuildMatrix();

RCP<crs_matrix_type> A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA);
RCP<crs_matrix_type> A = toTpetra(xpetraA);
RCP<const driver_map_type> map = MueLuUtilities::Map2TpetraMap(*xpetraMap);

//
// Construct a multigrid preconditioner
//

RCP<muelu_tpetra_operator_type> M = MueLu::CreateTpetraPreconditioner((RCP<operator_type>)A, mueluParams, Utilities::MV2NonConstTpetraMV(coordinates));
RCP<muelu_tpetra_operator_type> M = MueLu::CreateTpetraPreconditioner((RCP<operator_type>)A, mueluParams, toTpetra(coordinates));

RCP<multivector_type> X = rcp(new multivector_type(map, 1));
RCP<multivector_type> B = rcp(new multivector_type(map, 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ coarse_file_sublist.set("R", "{1}");*/
if (L->IsAvailable("R"))
restr = L->template Get<RCP<Xpetra::Matrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type>>>("R");

RCP<crs_matrix_type> tpetra_prolong = MueLuUtilities::Op2NonConstTpetraCrs(prolong);
RCP<crs_matrix_type> tpetra_restr = MueLuUtilities::Op2NonConstTpetraCrs(restr);
RCP<crs_matrix_type> tpetra_prolong = toTpetra(prolong);
RCP<crs_matrix_type> tpetra_restr = toTpetra(restr);

int mypid = GlobalComm_->getRank();
GlobalComm_->barrier();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ int main(int argc, char* argv[]) {
RCP<ADRXpetraProblem> Pr = ADR::Xpetra::BuildProblem<scalar_type, local_ordinal_type, global_ordinal_type, Map, CrsMatrixWrap, MultiVector>(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList());
RCP<Matrix> xpetraA = Pr->BuildMatrix();

RCP<crs_matrix_type> A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA);
RCP<crs_matrix_type> A = toTpetra(xpetraA);
RCP<const driver_map_type> map = MueLuUtilities::Map2TpetraMap(*xpetraMap);

// ===================================================
Expand Down Expand Up @@ -256,8 +256,8 @@ int main(int argc, char* argv[]) {
if (L->IsAvailable("R"))
restr = L->template Get<RCP<Xpetra::Matrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type>>>("R");

RCP<crs_matrix_type> tpetra_prolong = MueLuUtilities::Op2NonConstTpetraCrs(prolong);
RCP<crs_matrix_type> tpetra_restr = MueLuUtilities::Op2NonConstTpetraCrs(restr);
RCP<crs_matrix_type> tpetra_prolong = toTpetra(prolong);
RCP<crs_matrix_type> tpetra_restr = toTpetra(restr);

#include <Teuchos_TimeMonitor.hpp>
RCP<Teuchos::Time> PbarSetUp = Teuchos::TimeMonitor::getNewCounter("Pbar: SetUp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ int main(int argc, char* argv[]) {
RCP<ADRXpetraProblem> Pr = ADR::Xpetra::BuildProblem<scalar_type, local_ordinal_type, global_ordinal_type, Map, CrsMatrixWrap, MultiVector>(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList());
RCP<Matrix> xpetraA = Pr->BuildMatrix();

RCP<crs_matrix_type> A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA);
RCP<crs_matrix_type> A = toTpetra(xpetraA);
RCP<const driver_map_type> map = MueLuUtilities::Map2TpetraMap(*xpetraMap);

// ===================================================
Expand Down Expand Up @@ -244,8 +244,8 @@ int main(int argc, char* argv[]) {
if (L->IsAvailable("R"))
restr = L->template Get<RCP<Xpetra::Matrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type>>>("R");

RCP<crs_matrix_type> tpetra_prolong = MueLuUtilities::Op2NonConstTpetraCrs(prolong);
RCP<crs_matrix_type> tpetra_restr = MueLuUtilities::Op2NonConstTpetraCrs(restr);
RCP<crs_matrix_type> tpetra_prolong = toTpetra(prolong);
RCP<crs_matrix_type> tpetra_restr = toTpetra(restr);

Tpetra::MatrixMarket::Writer<crs_matrix_type>::writeSparseFile("P.mtx", tpetra_prolong); // Auxiliary prints introduced to generate pictures

Expand Down
6 changes: 3 additions & 3 deletions packages/muelu/research/max/AdditiveMG/tentative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ int main(int argc, char* argv[]) {
RCP<ADRXpetraProblem> Pr = ADR::Xpetra::BuildProblem<scalar_type, local_ordinal_type, global_ordinal_type, Map, CrsMatrixWrap, MultiVector>(matrixParameters.GetMatrixType(), xpetraMap, matrixParameters.GetParameterList());
RCP<Matrix> xpetraA = Pr->BuildMatrix();

RCP<crs_matrix_type> A = MueLuUtilities::Op2NonConstTpetraCrs(xpetraA);
RCP<crs_matrix_type> A = toTpetra(xpetraA);
RCP<const driver_map_type> map = MueLuUtilities::Map2TpetraMap(*xpetraMap);

// ===================================================
Expand Down Expand Up @@ -252,8 +252,8 @@ int main(int argc, char* argv[]) {
if (L->IsAvailable("R"))
restr = L->template Get<RCP<Xpetra::Matrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type>>>("R");

RCP<crs_matrix_type> tpetra_prolong = MueLuUtilities::Op2NonConstTpetraCrs(prolong);
RCP<crs_matrix_type> tpetra_restr = MueLuUtilities::Op2NonConstTpetraCrs(restr);
RCP<crs_matrix_type> tpetra_prolong = toTpetra(prolong);
RCP<crs_matrix_type> tpetra_restr = toTpetra(restr);

#include <Teuchos_TimeMonitor.hpp>
RCP<Teuchos::Time> PbarSetUp = Teuchos::TimeMonitor::getNewCounter("Pbar: SetUp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

// Ifpack2
#include "Ifpack2_OverlappingRowMatrix_def.hpp"
#include "Xpetra_TpetraMultiVector_decl.hpp"

// MueLu
#include <MueLu_Utilities.hpp>
Expand Down Expand Up @@ -621,7 +622,7 @@ class MatrixSplitting : public Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>
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<Matrix> region_matrix = regionMatrixData_[region_idx];

RCP<tpetra_crs_matrix> tpetraGlobalMatrix = MueLu::Utilities<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Op2NonConstTpetraCrs(compositeMatrixData_);
RCP<tpetra_crs_matrix> tpetraGlobalMatrix = toTpetra(compositeMatrixData_);
Ifpack2::OverlappingRowMatrix<tpetra_row_matrix> enlargedMatrix(tpetraGlobalMatrix, 2);

region_matrix->resumeFill();
Expand Down
4 changes: 2 additions & 2 deletions packages/muelu/research/q2q1/MueLu_Q2Q1uPFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ void Q2Q1uPFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::BuildP(Level& fin

// FIXME: remove magic number 30
RCP<Matrix> amalgA = MatrixFactory::Build(nodeMap, nodeMap, 30);
RCP<CrsMatrix> amalgA_crs = rcp_dynamic_cast<CrsMatrixWrap>(amalgA)->getCrsMatrix();
RCP<CrsMatrix> amalgA_crs = toCrsMatrix(amalgA);

// FIXME: this should be written similar to CoalesceDropFactory Merge
for (LO row = 0; row < as<LO>(AForPat->getRowMap()->getLocalNumElements()); row += NDim) {
Expand Down Expand Up @@ -1665,7 +1665,7 @@ void Q2Q1uPFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
RCP<const Map> coarseMap = MapFactory::Build(rowMap->lib(), Cptlist.size(), rowMap->getIndexBase() + offset, rowMap->getComm());

P = rcp(new CrsMatrixWrap(rowMap, coarseMap, 0));
RCP<CrsMatrix> Pcrs = rcp_dynamic_cast<CrsMatrixWrap>(P)->getCrsMatrix();
RCP<CrsMatrix> Pcrs = toCrsMatrix(P);

ArrayRCP<size_t> iaP;
ArrayRCP<LO> jaP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ MakeCompositeDirectSolver(RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal
RCP<TimeMonitor> tm = rcp(new TimeMonitor(*TimeMonitor::getNewTimer("MakeCompositeDirectSolver: 1 - Setup")));

// convert matrix to Tpetra
RCP<Tpetra_CrsMatrix> tMat = Utilities::Op2NonConstTpetraCrs(compOp);
RCP<Tpetra_CrsMatrix> tMat = toTpetra(compOp);

// Amesos2-specific key phrase that denote smoother type
std::string amesos2SolverName = "KLU2";
Expand Down
10 changes: 5 additions & 5 deletions packages/muelu/research/regionMG/src/SetupRegionMatrix_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ void MakeRegionMatrices(const RCP<Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, Gl
regionMats = rcp(new CrsMatrixWrap(revisedRowMap, revisedColMap, 9));

// Extract current region CrsMatrix
RCP<CrsMatrix> regionCrsMat = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(regionMats)->getCrsMatrix();
RCP<CrsMatrix> regionCrsMat = toCrsMatrix(regionMats);

// Extract current quasi-region CrsMatrix
RCP<CrsMatrix> quasiRegionCrsMat = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(quasiRegionMats)->getCrsMatrix();
RCP<CrsMatrix> quasiRegionCrsMat = toCrsMatrix(quasiRegionMats);

// Pull out the data from the quasi-region CrsMatrix
ArrayRCP<const size_t> rowptrQuasiRegion;
Expand Down Expand Up @@ -295,7 +295,7 @@ void MakeRegionMatrices(const RCP<Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, Gl
regDiag->update(-SC_ONE, *regCorrection, SC_ONE, *regNspViolation, SC_ONE);

// Extract current region matrix in as CrsMatrix
RCP<CrsMatrix> regionCrsMat = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(regionMats)->getCrsMatrix();
RCP<CrsMatrix> regionCrsMat = toCrsMatrix(regionMats);
regionCrsMat->replaceDiag(*regDiag);

tm = Teuchos::null;
Expand Down Expand Up @@ -348,10 +348,10 @@ void regionalToComposite(const RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOr
regMat->getCrsGraph()->getLocalMaxNumRowEntries()));

// Extract current quasi-region CrsMatrix
RCP<CrsMatrix> quasiRegionCrsMat = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(quasiRegMat)->getCrsMatrix();
RCP<CrsMatrix> quasiRegionCrsMat = toCrsMatrix(quasiRegMat);

// Extract current region CrsMatrix
RCP<CrsMatrix> regionCrsMat = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(regMat)->getCrsMatrix();
RCP<CrsMatrix> regionCrsMat = toCrsMatrix(regMat);

// Pull out the data from the region CrsMatrix
Teuchos::ArrayRCP<const size_t> rowptrRegion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
using Tpetra_Vector = Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>;

// *fos << "Attempting to use Amesos2 to solve the coarse grid problem" << std::endl;
RCP<Tpetra_MultiVector> tX = Utilities::MV2NonConstTpetraMV2(*compX);
RCP<const Tpetra_MultiVector> tB = Utilities::MV2TpetraMV(compRhs);
RCP<Tpetra_Vector> tX = toTpetra(compX);
RCP<const Tpetra_Vector> tB = toTpetra(compRhs);

/* Solve!
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ std::tuple<GlobalOrdinal, typename MueLu::LWGraph_kokkos<LocalOrdinal, GlobalOrd

// TODO: We could merge pass 1 and 2.

auto crsA = rcp_dynamic_cast<CrsMatrixWrap>(A, true)->getCrsMatrix();
auto crsA = toCrsMatrix(A);
auto lclA = crsA->getLocalMatrixDevice();
auto range = range_type(0, lclA.numRows());

Expand Down Expand Up @@ -902,7 +902,7 @@ std::tuple<GlobalOrdinal, typename MueLu::LWGraph_kokkos<LocalOrdinal, GlobalOrd

// TODO: We could merge pass 1 and 2.

auto crsA = rcp_dynamic_cast<CrsMatrixWrap>(A, true)->getCrsMatrix();
auto crsA = toCrsMatrix(A);
auto lclA = crsA->getLocalMatrixDevice();
auto range = range_type(0, numNodes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ void UnsmooshFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(Level &fi
Teuchos::ArrayRCP<const size_t> amalgRowPtr(amalgP->getLocalNumRows());
Teuchos::ArrayRCP<const LocalOrdinal> amalgCols(amalgP->getLocalNumEntries());
Teuchos::ArrayRCP<const Scalar> amalgVals(amalgP->getLocalNumEntries());
Teuchos::RCP<CrsMatrixWrap> amalgPwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(amalgP);
Teuchos::RCP<CrsMatrix> amalgPcrs = amalgPwrap->getCrsMatrix();
Teuchos::RCP<CrsMatrix> amalgPcrs = toCrsMatrix(amalgP);
amalgPcrs->getAllValues(amalgRowPtr, amalgCols, amalgVals);

// calculate number of dof rows for new prolongator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ void VariableDofLaplacianFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Bui

// start variable dof amalgamation

Teuchos::RCP<CrsMatrixWrap> Awrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(A);
Teuchos::RCP<CrsMatrix> Acrs = Awrap->getCrsMatrix();
Teuchos::RCP<CrsMatrix> Acrs = toCrsMatrix(A);
// Acrs->describe(*fancy, Teuchos::VERB_EXTREME);

size_t nNonZeros = 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/muelu/src/Misc/MueLu_LowPrecisionFactory_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void LowPrecisionFactory<double, LocalOrdinal, GlobalOrdinal, Node>::Build(Level
RCP<Matrix> A = Get<RCP<Matrix> >(currentLevel, matrixKey);

if ((A->getRowMap()->lib() == Xpetra::UseTpetra) && std::is_same<Scalar, double>::value) {
auto tpA = rcp_dynamic_cast<TpetraCrsMatrix>(rcp_dynamic_cast<CrsMatrixWrap>(A)->getCrsMatrix(), true)->getTpetra_CrsMatrix();
auto tpA = toTpetra(A);
auto tpLowA = tpA->template convert<HalfScalar>();
auto tpLowOpA = rcp(new Tpetra::CrsMatrixMultiplyOp<Scalar, HalfScalar, LocalOrdinal, GlobalOrdinal, Node>(tpLowA));
auto xpTpLowOpA = rcp(new TpetraOperator(tpLowOpA));
Expand Down Expand Up @@ -136,7 +136,7 @@ void LowPrecisionFactory<std::complex<double>, LocalOrdinal, GlobalOrdinal, Node
RCP<Matrix> A = Get<RCP<Matrix> >(currentLevel, matrixKey);

if ((A->getRowMap()->lib() == Xpetra::UseTpetra) && std::is_same<Scalar, std::complex<double> >::value) {
auto tpA = rcp_dynamic_cast<TpetraCrsMatrix>(rcp_dynamic_cast<CrsMatrixWrap>(A)->getCrsMatrix(), true)->getTpetra_CrsMatrix();
auto tpA = toTpetra(A);
auto tpLowA = tpA->template convert<HalfScalar>();
auto tpLowOpA = rcp(new Tpetra::CrsMatrixMultiplyOp<Scalar, HalfScalar, LocalOrdinal, GlobalOrdinal, Node>(tpLowA));
auto xpTpLowOpA = rcp(new TpetraOperator(tpLowOpA));
Expand Down
12 changes: 6 additions & 6 deletions packages/muelu/src/Smoothers/MueLu_Amesos2Smoother_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void Amesos2Smoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Setup(Level& cu
}

RCP<Matrix> newA = rcp(new CrsMatrixWrap(rowMap, colMap, 0));
RCP<CrsMatrix> newAcrs = rcp_dynamic_cast<CrsMatrixWrap>(newA)->getCrsMatrix();
RCP<CrsMatrix> newAcrs = toCrsMatrix(newA);
newAcrs->setAllValues(newRowPointers, newColIndices, newValues);
newAcrs->expertStaticFillComplete(A->getDomainMap(), A->getRangeMap(),
importer, A->getCrsGraph()->getExporter());
Expand All @@ -287,7 +287,7 @@ void Amesos2Smoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Setup(Level& cu
factorA = A;
}

RCP<Tpetra_CrsMatrix> tA = Utilities::Op2NonConstTpetraCrs(factorA);
RCP<const Tpetra_CrsMatrix> tA = toTpetra(factorA);

prec_ = Amesos2::create<Tpetra_CrsMatrix, Tpetra_MultiVector>(type_, tA);
TEUCHOS_TEST_FOR_EXCEPTION(prec_ == Teuchos::null, Exceptions::RuntimeError, "Amesos2::create returns Teuchos::null");
Expand All @@ -311,8 +311,8 @@ void Amesos2Smoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Apply(MultiVect

RCP<Tpetra_MultiVector> tX, tB;
if (!useTransformation_) {
tX = Utilities::MV2NonConstTpetraMV2(X);
tB = Utilities::MV2NonConstTpetraMV2(const_cast<MultiVector&>(B));
tX = toTpetra(Teuchos::rcpFromRef(X));
tB = toTpetra(Teuchos::rcpFromRef(const_cast<MultiVector&>(B)));
} else {
// Copy data of the original vectors into the transformed ones
size_t numVectors = X.getNumVectors();
Expand All @@ -328,8 +328,8 @@ void Amesos2Smoother<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Apply(MultiVect
B_data[i] = Bdata[i];
}

tX = Utilities::MV2NonConstTpetraMV2(*X_);
tB = Utilities::MV2NonConstTpetraMV2(*B_);
tX = toTpetra(X_);
tB = toTpetra(B_);
}

prec_->setX(tX);
Expand Down
Loading

0 comments on commit 3170137

Please sign in to comment.