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 RCP<Vector> GetMatrixDiagonal(
const Matrix& A);
175 static RCP<Vector> GetMatrixDiagonalInverse(
const Matrix& A, Magnitude tol = TST::eps()*100,
const bool doLumped =
false);
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) {
224 static SC PowerMethod(
const Matrix& A,
bool scaleByDiag =
true,
225 LO niters = 10, Magnitude tolerance = 1e-2,
bool verbose =
false,
unsigned int seed = 123) {
229 static SC PowerMethod(
const Matrix& A,
const Teuchos::RCP<Vector> &invDiag,
230 LO niters = 10, Magnitude tolerance = 1e-2,
bool verbose =
false,
unsigned int seed = 123) {
234 static void MyOldScaleMatrix(Matrix& Op,
const Teuchos::ArrayRCP<const SC>& scalingVector,
bool doInverse =
true,
235 bool doFillComplete =
true,
bool doOptimizeStorage =
true);
237 static void MyOldScaleMatrix_Tpetra(Matrix& Op,
const Teuchos::ArrayRCP<SC>& scalingVector,
238 bool doFillComplete,
bool doOptimizeStorage);
240 static void MyOldScaleMatrix_Epetra(Matrix& Op,
const Teuchos::ArrayRCP<SC>& scalingVector,
241 bool doFillComplete,
bool doOptimizeStorage);
243 static RCP<Teuchos::FancyOStream> MakeFancy(std::ostream& os) {
return Utilities::MakeFancy(os); }
261 static void FindNonZeros(
const typename Xpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::dual_view_type::t_dev_const_um vals,
298 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType rowSumTol,
301 static RCP<MultiVector> RealValuedToScalarMultiVector(RCP<RealValuedMultiVector> X);
319 static RCP<Matrix> Transpose(Matrix& Op,
bool optimizeTranspose =
false,
const std::string & label = std::string()) {
323 static RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,
LocalOrdinal,
GlobalOrdinal,
Node> > ExtractCoordinatesFromParameterList(ParameterList& paramList) {
330 static RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> >
CuthillMcKee(
const Matrix &Op);
334 static RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> >
ReverseCuthillMcKee(
const Matrix &Op);
350 template <
class Node>
351 class Utilities_kokkos<double,int,int,
Node> :
public UtilitiesBase<double,int,int,Node> {
356 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType Magnitude;
357 typedef Xpetra::MultiVector<Magnitude,LocalOrdinal,GlobalOrdinal,Node> RealValuedMultiVector;
360 #undef MUELU_UTILITIES_KOKKOS_SHORT 365 #ifdef HAVE_MUELU_EPETRA 368 static RCP<const Epetra_MultiVector> MV2EpetraMV(RCP<MultiVector>
const vec) {
return Utilities::MV2EpetraMV(vec); }
384 #ifdef HAVE_MUELU_TPETRA 387 static RCP<const Tpetra::MultiVector<SC,LO,GO,NO> > MV2TpetraMV(RCP<MultiVector>
const vec) {
return Utilities::MV2TpetraMV(vec); }
391 static const Tpetra::MultiVector<SC,LO,GO,NO>& MV2TpetraMV(
const MultiVector& vec) {
return Utilities::MV2TpetraMV(vec); }
394 static RCP<const Tpetra::CrsMatrix<SC,LO,GO,NO> > Op2TpetraCrs(RCP<const Matrix> Op) {
return Utilities::Op2TpetraCrs(Op); }
397 static const Tpetra::CrsMatrix<SC,LO,GO,NO>& Op2TpetraCrs(
const Matrix& Op) {
return Utilities::Op2TpetraCrs(Op); }
400 static RCP<const Tpetra::RowMatrix<SC,LO,GO,NO> > Op2TpetraRow(RCP<const Matrix> Op) {
return Utilities::Op2TpetraRow(Op); }
403 static const RCP<const Tpetra::Map<LO, GO, NO> > Map2TpetraMap(
const Map& map) {
return Utilities::Map2TpetraMap(map); }
405 static RCP<Xpetra::Matrix<SC,LO,GO,NO> > Crs2Op(RCP<CrsMatrix> Op) {
return Utilities::Crs2Op(Op); }
407 static RCP<Vector> GetMatrixDiagonal(
const Matrix& A) {
408 const auto rowMap = A.getRowMap();
409 auto diag = Xpetra::VectorFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node>::Build(rowMap,
true);
411 A.getLocalDiagCopy(*diag);
415 static RCP<Vector> GetMatrixDiagonalInverse(
const Matrix& A, Magnitude tol = Teuchos::ScalarTraits<SC>::eps()*100,
const bool doLumped=
false) {
418 static RCP<Vector> GetLumpedMatrixDiagonal(Matrix
const &A,
const bool doReciprocal=
false, Magnitude tol = Teuchos::ScalarTraits<Scalar>::eps()*100,
Scalar tolReplacement = Teuchos::ScalarTraits<Scalar>::zero(),
const bool replaceSingleEntryRowWithZero =
false) {
421 static RCP<Vector> GetMatrixOverlappedDiagonal(
const Matrix& A) {
424 static RCP<Vector> GetInverse(RCP<const Vector> v, Magnitude tol = Teuchos::ScalarTraits<SC>::eps()*100, SC tolReplacement = Teuchos::ScalarTraits<SC>::zero()) {
427 static Teuchos::Array<Magnitude> ResidualNorm(
const Operator& Op,
const MultiVector& X,
const MultiVector& RHS) {
430 static RCP<MultiVector> Residual(
const Operator& Op,
const MultiVector& X,
const MultiVector& RHS) {
433 static RCP<Teuchos::FancyOStream> MakeFancy(std::ostream& os) {
445 static void FindNonZeros(
const typename Xpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::dual_view_type::t_dev_const_um vals,
460 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType rowSumTol,
463 static RCP<MultiVector> RealValuedToScalarMultiVector(RCP<RealValuedMultiVector> X);
465 static Scalar PowerMethod(
const Matrix& A,
bool scaleByDiag =
true, LO niters = 10, Magnitude tolerance = 1e-2,
bool verbose =
false,
unsigned int seed = 123) {
469 static Scalar PowerMethod(
const Matrix& A,
const Teuchos::RCP<Vector> &invDiag, LO niters = 10, Magnitude tolerance = 1e-2,
bool verbose =
false,
unsigned int seed = 123) {
473 static void MyOldScaleMatrix(Matrix& Op,
const Teuchos::ArrayRCP<const SC>& scalingVector,
bool doInverse =
true,
474 bool doFillComplete =
true,
bool doOptimizeStorage =
true) {
475 SC one = Teuchos::ScalarTraits<SC>::one();
476 Teuchos::ArrayRCP<SC> sv(scalingVector.size());
478 for (
int i = 0; i < scalingVector.size(); ++i)
479 sv[i] = one / scalingVector[i];
481 for (
int i = 0; i < scalingVector.size(); ++i)
482 sv[i] = scalingVector[i];
485 switch (Op.getRowMap()->lib()) {
486 case Xpetra::UseTpetra:
487 MyOldScaleMatrix_Tpetra(Op, sv, doFillComplete, doOptimizeStorage);
490 case Xpetra::UseEpetra:
491 MyOldScaleMatrix_Epetra(Op, sv, doFillComplete, doOptimizeStorage);
495 throw Exceptions::RuntimeError(
"Only Epetra and Tpetra matrices can be scaled.");
496 #ifndef __NVCC__ //prevent nvcc warning 503 static void MyOldScaleMatrix_Tpetra(Matrix& Op,
const Teuchos::ArrayRCP<Scalar>& scalingVector,
504 bool doFillComplete,
bool doOptimizeStorage) {
505 #ifdef HAVE_MUELU_TPETRA 506 #ifdef HAVE_MUELU_TPETRA_INST_INT_INT 508 Tpetra::CrsMatrix<SC,LO,GO,NO>& tpOp = Op2NonConstTpetraCrs(Op);
510 const RCP<const Tpetra::Map<LO,GO,NO> > rowMap = tpOp.getRowMap();
511 const RCP<const Tpetra::Map<LO,GO,NO> > domainMap = tpOp.getDomainMap();
512 const RCP<const Tpetra::Map<LO,GO,NO> > rangeMap = tpOp.getRangeMap();
514 size_t maxRowSize = tpOp.getNodeMaxNumRowEntries();
515 if (maxRowSize == Teuchos::as<size_t>(-1))
518 std::vector<SC> scaledVals(maxRowSize);
519 if (tpOp.isFillComplete())
522 if (Op.isLocallyIndexed() ==
true) {
523 typename Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::local_inds_host_view_type cols;
524 typename Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::values_host_view_type vals;
526 for (
size_t i = 0; i < rowMap->getNodeNumElements(); ++i) {
527 tpOp.getLocalRowView(i, cols, vals);
528 size_t nnz = tpOp.getNumEntriesInLocalRow(i);
529 if (nnz > maxRowSize) {
531 scaledVals.resize(maxRowSize);
533 for (
size_t j = 0; j < nnz; ++j)
534 scaledVals[j] = vals[j]*scalingVector[i];
537 Teuchos::ArrayView<const LocalOrdinal> cols_view(cols.data(), nnz);
538 Teuchos::ArrayView<const SC> valview(&scaledVals[0], nnz);
539 tpOp.replaceLocalValues(i, cols_view, valview);
544 typename Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::global_inds_host_view_type cols;
545 typename Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::values_host_view_type vals;
547 for (
size_t i = 0; i < rowMap->getNodeNumElements(); ++i) {
548 GO gid = rowMap->getGlobalElement(i);
549 tpOp.getGlobalRowView(gid, cols, vals);
550 size_t nnz = tpOp.getNumEntriesInGlobalRow(gid);
551 if (nnz > maxRowSize) {
553 scaledVals.resize(maxRowSize);
556 for (
size_t j = 0; j < nnz; ++j)
557 scaledVals[j] = vals[j]*scalingVector[i];
560 Teuchos::ArrayView<const GlobalOrdinal> cols_view(cols.data(), nnz);
561 Teuchos::ArrayView<const SC> valview(&scaledVals[0], nnz);
562 tpOp.replaceGlobalValues(gid, cols_view, valview);
567 if (doFillComplete) {
568 if (domainMap == Teuchos::null || rangeMap == Teuchos::null)
569 throw Exceptions::RuntimeError(
"In Utilities::Scaling: cannot fillComplete because the domain and/or range map hasn't been defined");
571 RCP<Teuchos::ParameterList> params = rcp(
new Teuchos::ParameterList());
572 params->set(
"Optimize Storage", doOptimizeStorage);
573 params->set(
"No Nonlocal Changes",
true);
574 Op.fillComplete(Op.getDomainMap(), Op.getRangeMap(), params);
577 throw Exceptions::RuntimeError(
"Only Tpetra::CrsMatrix types can be scaled (Err.1)");
580 throw Exceptions::RuntimeError(
"Matrix scaling is not possible because Tpetra has not been compiled with support for LO=GO=int.");
583 throw Exceptions::RuntimeError(
"Matrix scaling is not possible because Tpetra has not been enabled.");
587 static void MyOldScaleMatrix_Epetra(Matrix& Op,
const Teuchos::ArrayRCP<Scalar>& scalingVector,
bool doFillComplete,
bool doOptimizeStorage) {
588 #ifdef HAVE_MUELU_EPETRA 600 for (
int j = 0; j < nnz; ++j)
601 vals[j] *= scalingVector[i];
605 throw Exceptions::RuntimeError(
"Only Epetra_CrsMatrix types can be scaled");
608 throw Exceptions::RuntimeError(
"Matrix scaling is not possible because Epetra has not been enabled.");
609 #endif // HAVE_MUELU_EPETRA 617 static RCP<Matrix> Transpose(Matrix& Op,
bool =
false,
const std::string & label = std::string(),
const Teuchos::RCP<Teuchos::ParameterList> ¶ms=Teuchos::null) {
618 switch (Op.getRowMap()->lib()) {
619 case Xpetra::UseTpetra:
621 #ifdef HAVE_MUELU_TPETRA 622 #ifdef HAVE_MUELU_TPETRA_INST_INT_INT 627 RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > A;
628 Tpetra::RowMatrixTransposer<SC,LO,GO,NO> transposer(rcpFromRef(tpetraOp),label);
630 using Teuchos::ParameterList;
632 RCP<ParameterList> transposeParams = params.is_null () ?
633 rcp (
new ParameterList) :
634 rcp (new ParameterList (*params));
635 transposeParams->set (
"sort",
false);
636 A = transposer.createTranspose(transposeParams);
639 RCP<Xpetra::TpetraCrsMatrix<SC,LO,GO,NO> > AA = rcp(
new Xpetra::TpetraCrsMatrix<SC,LO,GO,NO>(A));
640 RCP<CrsMatrix> AAA = rcp_implicit_cast<CrsMatrix>(AA);
641 RCP<CrsMatrixWrap> AAAA = rcp(
new CrsMatrixWrap(AAA));
645 catch (std::exception& e) {
646 std::cout <<
"threw exception '" << e.what() <<
"'" << std::endl;
647 throw Exceptions::RuntimeError(
"Utilities::Transpose failed, perhaps because matrix is not a Crs matrix");
650 throw Exceptions::RuntimeError(
"Utilities::Transpose: Tpetra is not compiled with LO=GO=int. Add TPETRA_INST_INT_INT:BOOL=ON to your configuration!");
653 throw Exceptions::RuntimeError(
"Utilities::Transpose: Tpetra is not compiled!");
655 #ifndef __NVCC__ //prevent nvcc warning 659 case Xpetra::UseEpetra:
661 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_EPETRAEXT) 662 Teuchos::TimeMonitor tm(*Teuchos::TimeMonitor::getNewTimer(
"ZZ Entire Transpose"));
669 RCP<Epetra_CrsMatrix> rcpA(A);
670 RCP<Xpetra::EpetraCrsMatrixT<GO,NO> > AA = rcp(
new Xpetra::EpetraCrsMatrixT<GO,NO> (rcpA));
671 RCP<CrsMatrix> AAA = rcp_implicit_cast<CrsMatrix>(AA);
672 RCP<CrsMatrixWrap> AAAA = rcp(
new CrsMatrixWrap(AAA));
673 AAAA->fillComplete(Op.getRangeMap(), Op.getDomainMap());
677 throw Exceptions::RuntimeError(
"Epetra (Err. 2)");
679 #ifndef __NVCC__ //prevent nvcc warning 684 throw Exceptions::RuntimeError(
"Only Epetra and Tpetra matrices can be transposed.");
685 #ifndef __NVCC__ //prevent nvcc warning 690 #ifndef __NVCC__ //prevent nvcc warning 691 return Teuchos::null;
697 static RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,LO,GO,NO> > ExtractCoordinatesFromParameterList(ParameterList& paramList) {
698 RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,LO,GO,NO> > coordinates = Teuchos::null;
701 if(paramList.isParameter (
"Coordinates") ==
false)
704 #if defined(HAVE_MUELU_TPETRA) 705 #if ( defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT)) || \ 706 (!defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT)) 711 #if !defined(HAVE_TPETRA_EXPLICIT_INSTANTIATION) || defined(HAVE_TPETRA_INST_FLOAT) 712 typedef Tpetra::MultiVector<float, LO,GO,NO> tfMV;
713 RCP<tfMV> floatCoords = Teuchos::null;
719 typedef Tpetra::MultiVector<SC,LO,GO,NO> tdMV;
720 RCP<tdMV> doubleCoords = Teuchos::null;
721 if (paramList.isType<RCP<tdMV> >(
"Coordinates")) {
723 doubleCoords = paramList.get<RCP<tdMV> >(
"Coordinates");
724 paramList.remove(
"Coordinates");
726 #if !defined(HAVE_TPETRA_EXPLICIT_INSTANTIATION) || defined(HAVE_TPETRA_INST_FLOAT) 727 else if (paramList.isType<RCP<tfMV> >(
"Coordinates")) {
729 floatCoords = paramList.get<RCP<tfMV> >(
"Coordinates");
730 paramList.remove(
"Coordinates");
731 doubleCoords = rcp(
new tdMV(floatCoords->getMap(), floatCoords->getNumVectors()));
736 if(doubleCoords != Teuchos::null) {
737 coordinates = Teuchos::rcp(
new Xpetra::TpetraMultiVector<SC,LO,GO,NO>(doubleCoords));
738 TEUCHOS_TEST_FOR_EXCEPT(doubleCoords->getNumVectors() != coordinates->getNumVectors());
740 #endif // Tpetra instantiated on GO=int and EpetraNode 741 #endif // endif HAVE_TPETRA 743 #if defined(HAVE_MUELU_EPETRA) 744 RCP<Epetra_MultiVector> doubleEpCoords;
745 if (paramList.isType<RCP<Epetra_MultiVector> >(
"Coordinates")) {
746 doubleEpCoords = paramList.get<RCP<Epetra_MultiVector> >(
"Coordinates");
747 paramList.remove(
"Coordinates");
748 RCP<Xpetra::EpetraMultiVectorT<GO,NO> > epCoordinates = Teuchos::rcp(
new Xpetra::EpetraMultiVectorT<GO,NO>(doubleEpCoords));
749 coordinates = rcp_dynamic_cast<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,LO,GO,NO> >(epCoordinates);
750 TEUCHOS_TEST_FOR_EXCEPT(doubleEpCoords->NumVectors() != Teuchos::as<int>(coordinates->getNumVectors()));
753 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(coordinates));
760 static RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> >
ReverseCuthillMcKee(
const Matrix &Op);
765 static RCP<Xpetra::Vector<LocalOrdinal,LocalOrdinal,GlobalOrdinal,Node> >
CuthillMcKee(
const Matrix &Op);
774 template <
class View,
unsigned AppendValue >
779 template <
class MT,
unsigned T >
780 struct CombineMemoryTraits {
784 template <
unsigned U,
unsigned T>
785 struct CombineMemoryTraits<
Kokkos::MemoryTraits<U>, T> {
786 typedef Kokkos::MemoryTraits<U|T> type;
789 template <
class DataType,
unsigned T,
class... Pack >
790 struct AppendTrait<
Kokkos::
View< DataType, Pack... >, T> {
797 #define MUELU_UTILITIES_KOKKOS_SHORT 799 #endif // #if defined(HAVE_MUELU_KOKKOS_REFACTOR) 801 #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)
Power method.
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)
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)
void DetectDirichletColsAndDomains(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Kokkos::View< bool *, typename Node::device_type > &dirichletRows, Kokkos::View< bool *, typename Node::device_type > dirichletCols, Kokkos::View< bool *, typename Node::device_type > dirichletDomain)
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)
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)
int NumMyElements() const
static Teuchos::RCP< Vector > GetLumpedMatrixDiagonal(Matrix const &A, const bool doReciprocal=false, Magnitude tol=Teuchos::ScalarTraits< Scalar >::eps() *100, Scalar valReplacement=Teuchos::ScalarTraits< Scalar >::zero(), const bool replaceSingleEntryRowWithZero=false)
Extract Matrix Diagonal of lumped matrix.
static Teuchos::RCP< Vector > GetInverse(Teuchos::RCP< const Vector > v, Magnitude tol=Teuchos::ScalarTraits< Scalar >::eps() *100, Scalar valReplacement=Teuchos::ScalarTraits< Scalar >::zero())
Return vector containing inverse of input vector.
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 RCP< Vector > GetMatrixDiagonalInverse(const Matrix &A, Magnitude tol=Teuchos::ScalarTraits< Scalar >::eps() *100, Scalar valReplacement=Teuchos::ScalarTraits< Scalar >::zero())
Extract Matrix Diagonal.
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)
void FindNonZeros(const typename Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::dual_view_type::t_dev_const_um vals, Kokkos::View< bool *, typename Node::device_type > nonzeros)
void ApplyRowSumCriterion(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const typename Teuchos::ScalarTraits< Scalar >::magnitudeType rowSumTol, Kokkos::View< bool *, typename Node::device_type > &dirichletRows)
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.