46 #ifndef MUELU_UTILITIES_KOKKOS_DECL_HPP 47 #define MUELU_UTILITIES_KOKKOS_DECL_HPP 50 #if defined(HAVE_MUELU_KOKKOS_REFACTOR) 54 #include "Teuchos_ScalarTraits.hpp" 55 #include "Teuchos_ParameterList.hpp" 57 #include "Xpetra_BlockedCrsMatrix_fwd.hpp" 58 #include "Xpetra_CrsMatrix_fwd.hpp" 59 #include "Xpetra_CrsMatrixWrap_fwd.hpp" 60 #include "Xpetra_ExportFactory.hpp" 61 #include "Xpetra_ImportFactory_fwd.hpp" 62 #include "Xpetra_MapFactory_fwd.hpp" 63 #include "Xpetra_Map_fwd.hpp" 64 #include "Xpetra_MatrixFactory_fwd.hpp" 65 #include "Xpetra_Matrix_fwd.hpp" 66 #include "Xpetra_MultiVectorFactory_fwd.hpp" 67 #include "Xpetra_MultiVector_fwd.hpp" 68 #include "Xpetra_Operator_fwd.hpp" 69 #include "Xpetra_VectorFactory_fwd.hpp" 70 #include "Xpetra_Vector_fwd.hpp" 72 #include "Xpetra_IO.hpp" 74 #include "Kokkos_ArithTraits.hpp" 76 #ifdef HAVE_MUELU_EPETRA 77 #include "Epetra_MultiVector.h" 78 #include "Epetra_CrsMatrix.h" 79 #include "Xpetra_EpetraCrsMatrix_fwd.hpp" 80 #include "Xpetra_EpetraMultiVector_fwd.hpp" 84 #include "MueLu_Utilities.hpp" 85 #include "MueLu_UtilitiesBase.hpp" 87 #ifdef HAVE_MUELU_TPETRA 88 #include "Tpetra_CrsMatrix.hpp" 89 #include "Tpetra_Map.hpp" 90 #include "Tpetra_MultiVector.hpp" 91 #include "Xpetra_TpetraCrsMatrix_fwd.hpp" 92 #include "Xpetra_TpetraMultiVector_fwd.hpp" 110 #undef MUELU_UTILITIES_KOKKOS_SHORT 114 using TST = Teuchos::ScalarTraits<SC>;
115 using Magnitude =
typename TST::magnitudeType;
116 using RealValuedMultiVector = Xpetra::MultiVector<Magnitude,LO,GO,NO>;
118 #ifdef HAVE_MUELU_EPETRA 121 static RCP<const Epetra_MultiVector> MV2EpetraMV(RCP<MultiVector>
const vec) {
return Utilities::MV2EpetraMV(vec); }
137 #ifdef HAVE_MUELU_TPETRA 140 static RCP<const Tpetra::MultiVector<SC,LO,GO,NO> > MV2TpetraMV(RCP<MultiVector>
const vec) {
return Utilities::MV2TpetraMV(vec); }
144 static const Tpetra::MultiVector<SC,LO,GO,NO>& MV2TpetraMV(
const MultiVector& vec) {
return Utilities::MV2TpetraMV(vec); }
147 static RCP<const Tpetra::CrsMatrix<SC,LO,GO,NO> > Op2TpetraCrs(RCP<const Matrix> Op) {
return Utilities::Op2TpetraCrs(Op); }
150 static const Tpetra::CrsMatrix<SC,LO,GO,NO>& Op2TpetraCrs(
const Matrix& Op) {
return Utilities::Op2TpetraCrs(Op); }
153 static RCP<const Tpetra::RowMatrix<SC,LO,GO,NO> > Op2TpetraRow(RCP<const Matrix> Op) {
return Utilities::Op2TpetraRow(Op); }
156 static const RCP<const Tpetra::Map<LO, GO, NO> > Map2TpetraMap(
const Map& map) {
return Utilities::Map2TpetraMap(map); }
159 static RCP<Xpetra::Matrix<SC,LO,GO,NO> > Crs2Op(RCP<CrsMatrix> Op) {
return Utilities::Crs2Op(Op); }
167 static Teuchos::ArrayRCP<SC> GetMatrixDiagonal(
const Matrix& A);
175 static RCP<Vector> GetMatrixDiagonalInverse(
const Matrix& A, Magnitude tol = TST::eps()*100);
186 static RCP<Vector> GetMatrixOverlappedDiagonal(
const Matrix& A);
201 static Teuchos::Array<Magnitude> ResidualNorm(
const Operator& Op,
const MultiVector& X,
const MultiVector& RHS) {
205 static RCP<MultiVector> Residual(
const Operator& Op,
const MultiVector& X,
const MultiVector& RHS) {
209 static void PauseForDebugger();
226 static SC PowerMethod(
const Matrix& A,
bool scaleByDiag =
true,
227 LO niters = 10, Magnitude tolerance = 1e-2,
bool verbose =
false,
unsigned int seed = 123) {
231 static void MyOldScaleMatrix(Matrix& Op,
const Teuchos::ArrayRCP<const SC>& scalingVector,
bool doInverse =
true,
232 bool doFillComplete =
true,
bool doOptimizeStorage =
true);
234 static void MyOldScaleMatrix_Tpetra(Matrix& Op,
const Teuchos::ArrayRCP<SC>& scalingVector,
235 bool doFillComplete,
bool doOptimizeStorage);
237 static void MyOldScaleMatrix_Epetra(Matrix& Op,
const Teuchos::ArrayRCP<SC>& scalingVector,
238 bool doFillComplete,
bool doOptimizeStorage);
240 static RCP<Teuchos::FancyOStream> MakeFancy(std::ostream& os) {
return Utilities::MakeFancy(os); }
270 static RCP<MultiVector> RealValuedToScalarMultiVector(RCP<RealValuedMultiVector> X);
288 static RCP<Matrix> Transpose(Matrix& Op,
bool optimizeTranspose =
false,
const std::string & label = std::string()) {
292 static RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,
LocalOrdinal,
GlobalOrdinal,
Node> > ExtractCoordinatesFromParameterList(ParameterList& paramList) {
300 static RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> >
ReverseCuthillMcKee(
const Matrix &Op);
305 static RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> >
CuthillMcKee(
const Matrix &Op);
321 template <
class Node>
322 class Utilities_kokkos<double,int,int,
Node> :
public UtilitiesBase<double,int,int,Node> {
327 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType Magnitude;
328 typedef Xpetra::MultiVector<Magnitude,LocalOrdinal,GlobalOrdinal,Node> RealValuedMultiVector;
331 #undef MUELU_UTILITIES_KOKKOS_SHORT 336 #ifdef HAVE_MUELU_EPETRA 339 static RCP<const Epetra_MultiVector> MV2EpetraMV(RCP<MultiVector>
const vec) {
return Utilities::MV2EpetraMV(vec); }
355 #ifdef HAVE_MUELU_TPETRA 358 static RCP<const Tpetra::MultiVector<SC,LO,GO,NO> > MV2TpetraMV(RCP<MultiVector>
const vec) {
return Utilities::MV2TpetraMV(vec); }
362 static const Tpetra::MultiVector<SC,LO,GO,NO>& MV2TpetraMV(
const MultiVector& vec) {
return Utilities::MV2TpetraMV(vec); }
365 static RCP<const Tpetra::CrsMatrix<SC,LO,GO,NO> > Op2TpetraCrs(RCP<const Matrix> Op) {
return Utilities::Op2TpetraCrs(Op); }
368 static const Tpetra::CrsMatrix<SC,LO,GO,NO>& Op2TpetraCrs(
const Matrix& Op) {
return Utilities::Op2TpetraCrs(Op); }
371 static RCP<const Tpetra::RowMatrix<SC,LO,GO,NO> > Op2TpetraRow(RCP<const Matrix> Op) {
return Utilities::Op2TpetraRow(Op); }
374 static const RCP<const Tpetra::Map<LO, GO, NO> > Map2TpetraMap(
const Map& map) {
return Utilities::Map2TpetraMap(map); }
376 static RCP<Xpetra::Matrix<SC,LO,GO,NO> > Crs2Op(RCP<CrsMatrix> Op) {
return Utilities::Crs2Op(Op); }
378 static ArrayRCP<SC> GetMatrixDiagonal(
const Matrix& A) {
381 static RCP<Vector> GetMatrixDiagonalInverse(
const Matrix& A, Magnitude tol = Teuchos::ScalarTraits<SC>::eps()*100) {
384 static ArrayRCP<SC> GetLumpedMatrixDiagonal(
const Matrix& A) {
387 static RCP<Vector> GetLumpedMatrixDiagonal(RCP<const Matrix > A) {
390 static RCP<Vector> GetMatrixOverlappedDiagonal(
const Matrix& A) {
393 static RCP<Vector> GetInverse(RCP<const Vector> v, Magnitude tol = Teuchos::ScalarTraits<SC>::eps()*100, SC tolReplacement = Teuchos::ScalarTraits<SC>::zero()) {
396 static Teuchos::Array<Magnitude> ResidualNorm(
const Operator& Op,
const MultiVector& X,
const MultiVector& RHS) {
399 static RCP<MultiVector> Residual(
const Operator& Op,
const MultiVector& X,
const MultiVector& RHS) {
402 static void PauseForDebugger() {
405 static RCP<Teuchos::FancyOStream> MakeFancy(std::ostream& os) {
423 static RCP<MultiVector> RealValuedToScalarMultiVector(RCP<RealValuedMultiVector> X);
425 static Scalar PowerMethod(
const Matrix& A,
bool scaleByDiag =
true, LO niters = 10, Magnitude tolerance = 1e-2,
bool verbose =
false,
unsigned int seed = 123) {
429 static void MyOldScaleMatrix(Matrix& Op,
const Teuchos::ArrayRCP<const SC>& scalingVector,
bool doInverse =
true,
430 bool doFillComplete =
true,
bool doOptimizeStorage =
true) {
431 SC one = Teuchos::ScalarTraits<SC>::one();
432 Teuchos::ArrayRCP<SC> sv(scalingVector.size());
434 for (
int i = 0; i < scalingVector.size(); ++i)
435 sv[i] = one / scalingVector[i];
437 for (
int i = 0; i < scalingVector.size(); ++i)
438 sv[i] = scalingVector[i];
441 switch (Op.getRowMap()->lib()) {
442 case Xpetra::UseTpetra:
443 MyOldScaleMatrix_Tpetra(Op, sv, doFillComplete, doOptimizeStorage);
446 case Xpetra::UseEpetra:
447 MyOldScaleMatrix_Epetra(Op, sv, doFillComplete, doOptimizeStorage);
451 throw Exceptions::RuntimeError(
"Only Epetra and Tpetra matrices can be scaled.");
452 #ifndef __NVCC__ //prevent nvcc warning 459 static void MyOldScaleMatrix_Tpetra(Matrix& Op,
const Teuchos::ArrayRCP<Scalar>& scalingVector,
460 bool doFillComplete,
bool doOptimizeStorage) {
461 #ifdef HAVE_MUELU_TPETRA 462 #ifdef HAVE_MUELU_TPETRA_INST_INT_INT 464 Tpetra::CrsMatrix<SC,LO,GO,NO>& tpOp = Op2NonConstTpetraCrs(Op);
466 const RCP<const Tpetra::Map<LO,GO,NO> > rowMap = tpOp.getRowMap();
467 const RCP<const Tpetra::Map<LO,GO,NO> > domainMap = tpOp.getDomainMap();
468 const RCP<const Tpetra::Map<LO,GO,NO> > rangeMap = tpOp.getRangeMap();
470 size_t maxRowSize = tpOp.getNodeMaxNumRowEntries();
471 if (maxRowSize == Teuchos::as<size_t>(-1))
474 std::vector<SC> scaledVals(maxRowSize);
475 if (tpOp.isFillComplete())
478 if (Op.isLocallyIndexed() ==
true) {
479 Teuchos::ArrayView<const LO> cols;
480 Teuchos::ArrayView<const SC> vals;
482 for (
size_t i = 0; i < rowMap->getNodeNumElements(); ++i) {
483 tpOp.getLocalRowView(i, cols, vals);
484 size_t nnz = tpOp.getNumEntriesInLocalRow(i);
485 if (nnz > maxRowSize) {
487 scaledVals.resize(maxRowSize);
489 for (
size_t j = 0; j < nnz; ++j)
490 scaledVals[j] = vals[j]*scalingVector[i];
493 Teuchos::ArrayView<const SC> valview(&scaledVals[0], nnz);
494 tpOp.replaceLocalValues(i, cols, valview);
499 Teuchos::ArrayView<const GO> cols;
500 Teuchos::ArrayView<const SC> vals;
502 for (
size_t i = 0; i < rowMap->getNodeNumElements(); ++i) {
503 GO gid = rowMap->getGlobalElement(i);
504 tpOp.getGlobalRowView(gid, cols, vals);
505 size_t nnz = tpOp.getNumEntriesInGlobalRow(gid);
506 if (nnz > maxRowSize) {
508 scaledVals.resize(maxRowSize);
511 for (
size_t j = 0; j < nnz; ++j)
512 scaledVals[j] = vals[j]*scalingVector[i];
515 Teuchos::ArrayView<const SC> valview(&scaledVals[0], nnz);
516 tpOp.replaceGlobalValues(gid, cols, valview);
521 if (doFillComplete) {
522 if (domainMap == Teuchos::null || rangeMap == Teuchos::null)
523 throw Exceptions::RuntimeError(
"In Utilities::Scaling: cannot fillComplete because the domain and/or range map hasn't been defined");
525 RCP<Teuchos::ParameterList> params = rcp(
new Teuchos::ParameterList());
526 params->set(
"Optimize Storage", doOptimizeStorage);
527 params->set(
"No Nonlocal Changes",
true);
528 Op.fillComplete(Op.getDomainMap(), Op.getRangeMap(), params);
531 throw Exceptions::RuntimeError(
"Only Tpetra::CrsMatrix types can be scaled (Err.1)");
534 throw Exceptions::RuntimeError(
"Matrix scaling is not possible because Tpetra has not been compiled with support for LO=GO=int.");
537 throw Exceptions::RuntimeError(
"Matrix scaling is not possible because Tpetra has not been enabled.");
541 static void MyOldScaleMatrix_Epetra(Matrix& Op,
const Teuchos::ArrayRCP<Scalar>& scalingVector,
bool doFillComplete,
bool doOptimizeStorage) {
542 #ifdef HAVE_MUELU_EPETRA 554 for (
int j = 0; j < nnz; ++j)
555 vals[j] *= scalingVector[i];
559 throw Exceptions::RuntimeError(
"Only Epetra_CrsMatrix types can be scaled");
562 throw Exceptions::RuntimeError(
"Matrix scaling is not possible because Epetra has not been enabled.");
563 #endif // HAVE_MUELU_EPETRA 571 static RCP<Matrix> Transpose(Matrix& Op,
bool =
false,
const std::string & label = std::string(),
const Teuchos::RCP<Teuchos::ParameterList> ¶ms=Teuchos::null) {
572 switch (Op.getRowMap()->lib()) {
573 case Xpetra::UseTpetra:
575 #ifdef HAVE_MUELU_TPETRA 576 #ifdef HAVE_MUELU_TPETRA_INST_INT_INT 581 RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > A;
582 Tpetra::RowMatrixTransposer<SC,LO,GO,NO> transposer(rcpFromRef(tpetraOp),label);
584 using Teuchos::ParameterList;
586 RCP<ParameterList> transposeParams = params.is_null () ?
587 rcp (
new ParameterList) :
588 rcp (new ParameterList (*params));
589 transposeParams->set (
"sort",
false);
590 A = transposer.createTranspose(transposeParams);
593 RCP<Xpetra::TpetraCrsMatrix<SC,LO,GO,NO> > AA = rcp(
new Xpetra::TpetraCrsMatrix<SC,LO,GO,NO>(A));
594 RCP<CrsMatrix> AAA = rcp_implicit_cast<CrsMatrix>(AA);
595 RCP<CrsMatrixWrap> AAAA = rcp(
new CrsMatrixWrap(AAA));
599 catch (std::exception& e) {
600 std::cout <<
"threw exception '" << e.what() <<
"'" << std::endl;
601 throw Exceptions::RuntimeError(
"Utilities::Transpose failed, perhaps because matrix is not a Crs matrix");
604 throw Exceptions::RuntimeError(
"Utilities::Transpose: Tpetra is not compiled with LO=GO=int. Add TPETRA_INST_INT_INT:BOOL=ON to your configuration!");
607 throw Exceptions::RuntimeError(
"Utilities::Transpose: Tpetra is not compiled!");
609 #ifndef __NVCC__ //prevent nvcc warning 613 case Xpetra::UseEpetra:
615 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_EPETRAEXT) 616 Teuchos::TimeMonitor tm(*Teuchos::TimeMonitor::getNewTimer(
"ZZ Entire Transpose"));
623 RCP<Epetra_CrsMatrix> rcpA(A);
624 RCP<Xpetra::EpetraCrsMatrixT<GO,NO> > AA = rcp(
new Xpetra::EpetraCrsMatrixT<GO,NO> (rcpA));
625 RCP<CrsMatrix> AAA = rcp_implicit_cast<CrsMatrix>(AA);
626 RCP<CrsMatrixWrap> AAAA = rcp(
new CrsMatrixWrap(AAA));
627 AAAA->fillComplete(Op.getRangeMap(), Op.getDomainMap());
631 throw Exceptions::RuntimeError(
"Epetra (Err. 2)");
633 #ifndef __NVCC__ //prevent nvcc warning 638 throw Exceptions::RuntimeError(
"Only Epetra and Tpetra matrices can be transposed.");
639 #ifndef __NVCC__ //prevent nvcc warning 644 #ifndef __NVCC__ //prevent nvcc warning 645 return Teuchos::null;
651 static RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,LO,GO,NO> > ExtractCoordinatesFromParameterList(ParameterList& paramList) {
652 RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,LO,GO,NO> > coordinates = Teuchos::null;
655 if(paramList.isParameter (
"Coordinates") ==
false)
658 #if defined(HAVE_MUELU_TPETRA) 659 #if ( defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT)) || \ 660 (!defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT)) 665 #if !defined(HAVE_TPETRA_EXPLICIT_INSTANTIATION) || defined(HAVE_TPETRA_INST_FLOAT) 666 typedef Tpetra::MultiVector<float, LO,GO,NO> tfMV;
667 RCP<tfMV> floatCoords = Teuchos::null;
673 typedef Tpetra::MultiVector<SC,LO,GO,NO> tdMV;
674 RCP<tdMV> doubleCoords = Teuchos::null;
675 if (paramList.isType<RCP<tdMV> >(
"Coordinates")) {
677 doubleCoords = paramList.get<RCP<tdMV> >(
"Coordinates");
678 paramList.remove(
"Coordinates");
680 #if !defined(HAVE_TPETRA_EXPLICIT_INSTANTIATION) || defined(HAVE_TPETRA_INST_FLOAT) 681 else if (paramList.isType<RCP<tfMV> >(
"Coordinates")) {
683 floatCoords = paramList.get<RCP<tfMV> >(
"Coordinates");
684 paramList.remove(
"Coordinates");
685 doubleCoords = rcp(
new tdMV(floatCoords->getMap(), floatCoords->getNumVectors()));
690 if(doubleCoords != Teuchos::null) {
691 coordinates = Teuchos::rcp(
new Xpetra::TpetraMultiVector<SC,LO,GO,NO>(doubleCoords));
692 TEUCHOS_TEST_FOR_EXCEPT(doubleCoords->getNumVectors() != coordinates->getNumVectors());
694 #endif // Tpetra instantiated on GO=int and EpetraNode 695 #endif // endif HAVE_TPETRA 697 #if defined(HAVE_MUELU_EPETRA) 698 RCP<Epetra_MultiVector> doubleEpCoords;
699 if (paramList.isType<RCP<Epetra_MultiVector> >(
"Coordinates")) {
700 doubleEpCoords = paramList.get<RCP<Epetra_MultiVector> >(
"Coordinates");
701 paramList.remove(
"Coordinates");
702 RCP<Xpetra::EpetraMultiVectorT<GO,NO> > epCoordinates = Teuchos::rcp(
new Xpetra::EpetraMultiVectorT<GO,NO>(doubleEpCoords));
703 coordinates = rcp_dynamic_cast<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,LO,GO,NO> >(epCoordinates);
704 TEUCHOS_TEST_FOR_EXCEPT(doubleEpCoords->NumVectors() != Teuchos::as<int>(coordinates->getNumVectors()));
707 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(coordinates));
714 static RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> >
ReverseCuthillMcKee(
const Matrix &Op);
719 static RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> >
CuthillMcKee(
const Matrix &Op);
728 template <
class View,
unsigned AppendValue >
733 template <
class MT,
unsigned T >
734 struct CombineMemoryTraits {
738 template <
unsigned U,
unsigned T>
739 struct CombineMemoryTraits<
Kokkos::MemoryTraits<U>, T> {
740 typedef Kokkos::MemoryTraits<U|T> type;
743 template <
class DataType,
unsigned T,
class... Pack >
744 struct AppendTrait<
Kokkos::
View< DataType, Pack... >, T> {
751 #define MUELU_UTILITIES_KOKKOS_SHORT 753 #endif // #if defined(HAVE_MUELU_KOKKOS_REFACTOR) 755 #endif // MUELU_UTILITIES_KOKKOS_DECL_HPP const Epetra_Map & RowMap() const
static void SetRandomSeed(const Teuchos::Comm< int > &comm)
static const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > Map2TpetraMap(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map)
MueLu::DefaultLocalOrdinal LocalOrdinal
KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
static RCP< const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2TpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > const vec)
Helper utility to pull out the underlying Tpetra objects from an Xpetra object.
static RCP< const Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2TpetraCrs(RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
static const Epetra_Map & Map2EpetraMap(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map)
Teuchos::RCP< Xpetra::Vector< LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node > > ReverseCuthillMcKee(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op)
static RCP< Epetra_CrsMatrix > Op2NonConstEpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
static Scalar PowerMethod(const Matrix &A, bool scaleByDiag=true, LocalOrdinal niters=10, Magnitude tolerance=1e-2, bool verbose=false, unsigned int seed=123)
Simple transpose for Tpetra::CrsMatrix types.
static RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::magnitudeType, LocalOrdinal, GlobalOrdinal, Node > > ExtractCoordinatesFromParameterList(ParameterList ¶mList)
static RCP< const Epetra_MultiVector > MV2EpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > const vec)
Helper utility to pull out the underlying Epetra objects from an Xpetra object.
void ZeroDirichletCols(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &A, const Kokkos::View< const bool *, typename Node::device_type > &dirichletCols, Scalar replaceWith)
static Teuchos::RCP< Vector > GetInverse(Teuchos::RCP< const Vector > v, Magnitude tol=Teuchos::ScalarTraits< Scalar >::eps() *100, Scalar tolReplacement=Teuchos::ScalarTraits< Scalar >::zero())
Return vector containing inverse of input vector.
void ZeroDirichletRows(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &A, const Kokkos::View< const bool *, typename Node::device_type > &dirichletRows, Scalar replaceWith)
Teuchos::RCP< Xpetra::Vector< LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node > > CuthillMcKee(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op)
Namespace for MueLu classes and methods.
void ApplyOAZToMatrixRows(Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &A, const Kokkos::View< const bool *, typename Node::device_type > &dirichletRows)
int ExtractMyRowView(int MyRow, int &NumEntries, double *&Values, int *&Indices) const
static RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2NonConstTpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > vec)
static void PauseForDebugger()
static RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Residual(const Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &RHS)
Kokkos::View< bool *, typename NO::device_type > DetectDirichletRows(const Xpetra::Matrix< SC, LO, GO, NO > &A, const typename Teuchos::ScalarTraits< SC >::magnitudeType &tol, const bool count_twos_as_dirichlet)
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
static RCP< Epetra_MultiVector > MV2NonConstEpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > vec)
static RCP< Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
int NumMyElements() const
static RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2NonConstTpetraMV2(Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec)
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Transpose(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, bool optimizeTranspose=false, const std::string &label=std::string(), const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
static RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2TpetraRow(RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
static Teuchos::ArrayRCP< Scalar > GetLumpedMatrixDiagonal(const Matrix &A)
Extract Matrix Diagonal of lumped matrix.
void deep_copy(const DynRankView< DT, DP... > &dst, typename ViewTraits< DT, DP... >::const_value_type &value, typename std::enable_if< std::is_same< typename ViewTraits< DT, DP... >::specialize, void >::value >::type *=nullptr)
static Teuchos::Array< Magnitude > ResidualNorm(const Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const MultiVector &X, const MultiVector &RHS)
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Crs2Op(RCP< Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
static RCP< const Epetra_CrsMatrix > Op2EpetraCrs(RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
static RCP< MultiVector > Residual(const Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const MultiVector &X, const MultiVector &RHS)
static Teuchos::Array< Magnitude > ResidualNorm(const Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &RHS)
static RCP< Vector > GetMatrixDiagonalInverse(const Matrix &A, Magnitude tol=Teuchos::ScalarTraits< Scalar >::eps() *100)
Extract Matrix Diagonal.
static RCP< Teuchos::FancyOStream > MakeFancy(std::ostream &os)
static RCP< Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraRow(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op)
static RCP< Vector > GetMatrixOverlappedDiagonal(const Matrix &A)
Extract Overlapped Matrix Diagonal.
Kokkos::View< bool *, typename NO::device_type > DetectDirichletCols(const Xpetra::Matrix< SC, LO, GO, NO > &A, const Kokkos::View< const bool *, typename NO::device_type > &dirichletRows)
static RCP< Teuchos::FancyOStream > MakeFancy(std::ostream &os)
static Scalar PowerMethod(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, bool scaleByDiag=true, LocalOrdinal niters=10, Magnitude tolerance=1e-2, bool verbose=false, unsigned int seed=123)
static void SetRandomSeed(const Teuchos::Comm< int > &comm)
Set seed for random number generator.
static Teuchos::ArrayRCP< Scalar > GetMatrixDiagonal(const Matrix &A)
Extract Matrix Diagonal.