MueLu  Version of the Day
MueLu_Utilities_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef MUELU_UTILITIES_DECL_HPP
47 #define MUELU_UTILITIES_DECL_HPP
48 
49 #include <unistd.h> //necessary for "sleep" function in debugging methods
50 #include <string>
51 
52 #include "MueLu_ConfigDefs.hpp"
53 
54 #include <Teuchos_ScalarTraits.hpp>
55 #include <Teuchos_ParameterList.hpp>
56 
57 #include <Xpetra_BlockedCrsMatrix_fwd.hpp>
58 #include <Xpetra_CrsMatrix_fwd.hpp>
59 #include <Xpetra_CrsMatrixWrap_fwd.hpp>
60 #include <Xpetra_ImportFactory_fwd.hpp>
61 #include <Xpetra_Map_fwd.hpp>
62 #include <Xpetra_MapFactory_fwd.hpp>
63 #include <Xpetra_Matrix_fwd.hpp>
64 #include <Xpetra_MatrixFactory_fwd.hpp>
65 #include <Xpetra_MultiVector_fwd.hpp>
66 #include <Xpetra_MultiVectorFactory_fwd.hpp>
67 #include <Xpetra_Operator_fwd.hpp>
68 #include <Xpetra_Vector_fwd.hpp>
69 #include <Xpetra_VectorFactory_fwd.hpp>
70 #include <Xpetra_ExportFactory.hpp>
71 
72 #ifdef HAVE_MUELU_EPETRA
73 #include <Xpetra_EpetraCrsMatrix_fwd.hpp>
74 
75 // needed because of inlined function
76 //TODO: remove inline function?
77 #include <Xpetra_EpetraCrsMatrix.hpp>
78 #include <Xpetra_CrsMatrixWrap.hpp>
79 
80 #endif
81 
82 #include "MueLu_Exceptions.hpp"
83 
84 #ifdef HAVE_MUELU_EPETRAEXT
85 class Epetra_CrsMatrix;
86 class Epetra_MultiVector;
87 class Epetra_Vector;
88 #endif
89 
90 #ifdef HAVE_MUELU_TPETRA
91 #include <Tpetra_CrsMatrix.hpp>
92 #include <Tpetra_Map.hpp>
93 #include <Tpetra_MultiVector.hpp>
94 #include <Xpetra_TpetraCrsMatrix_fwd.hpp>
95 #include <Xpetra_TpetraMultiVector_fwd.hpp>
96 #endif
97 
98 
99 namespace MueLu {
100 // MPI helpers
101 #define MueLu_sumAll(rcpComm, in, out) \
102  Teuchos::reduceAll(*rcpComm, Teuchos::REDUCE_SUM, in, Teuchos::outArg(out))
103 #define MueLu_minAll(rcpComm, in, out) \
104  Teuchos::reduceAll(*rcpComm, Teuchos::REDUCE_MIN, in, Teuchos::outArg(out))
105 #define MueLu_maxAll(rcpComm, in, out) \
106  Teuchos::reduceAll(*rcpComm, Teuchos::REDUCE_MAX, in, Teuchos::outArg(out))
107 
108 #ifdef HAVE_MUELU_EPETRA
109  //defined after Utils class
110  template<typename SC,typename LO,typename GO,typename NO>
111  RCP<Xpetra::CrsMatrixWrap<SC,LO,GO,NO> >
112  Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap(RCP<Epetra_CrsMatrix> &epAB);
113 
114  template<typename SC,typename LO,typename GO,typename NO>
115  RCP<Xpetra::Matrix<SC, LO, GO, NO> >
116  EpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Epetra_CrsMatrix>& A);
117 
118  template<typename SC,typename LO,typename GO,typename NO>
119  RCP<Xpetra::MultiVector<SC, LO, GO, NO> >
120  EpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP<Epetra_MultiVector>& V);
121 #endif
122 
123 #ifdef HAVE_MUELU_TPETRA
124  template<typename SC,typename LO,typename GO,typename NO>
125  RCP<Xpetra::Matrix<SC, LO, GO, NO> >
126  TpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Tpetra::CrsMatrix<SC, LO, GO, NO> >& Atpetra);
127 
128 
129  template<typename SC,typename LO,typename GO,typename NO>
130  RCP<Xpetra::MultiVector<SC, LO, GO, NO> >
131  TpetraCrs_To_XpetraMultiVector(const Teuchos::RCP<Tpetra::MultiVector<SC, LO, GO, NO> >& Vtpetra);
132 #endif
133 
141  template <class Scalar,
142  class LocalOrdinal = int,
143  class GlobalOrdinal = LocalOrdinal,
144  class Node = KokkosClassic::DefaultNode::DefaultNodeType>
145  class Utils {
146 #undef MUELU_UTILITIES_SHORT
147 #include "MueLu_UseShortNames.hpp"
148 
149  public:
150  typedef typename Teuchos::ScalarTraits<SC>::magnitudeType Magnitude;
151 
152 #ifdef HAVE_MUELU_EPETRA
153  // @{
155  static RCP<const Epetra_MultiVector> MV2EpetraMV(RCP<MultiVector> const Vec);
156  static RCP< Epetra_MultiVector> MV2NonConstEpetraMV(RCP<MultiVector> Vec);
157 
158  static const Epetra_MultiVector& MV2EpetraMV(const MultiVector& Vec);
159  static Epetra_MultiVector& MV2NonConstEpetraMV(MultiVector& Vec);
160 
161  static RCP<const Epetra_CrsMatrix> Op2EpetraCrs(RCP<const Matrix> Op);
162  static RCP< Epetra_CrsMatrix> Op2NonConstEpetraCrs(RCP<Matrix> Op);
163 
164  static const Epetra_CrsMatrix& Op2EpetraCrs(const Matrix& Op);
165  static Epetra_CrsMatrix& Op2NonConstEpetraCrs(Matrix& Op);
166 
167  static const Epetra_Map& Map2EpetraMap(const Map& map);
168  // @}
169 #endif
170 
171 #ifdef HAVE_MUELU_TPETRA
172  // @{
174  static RCP<const Tpetra::MultiVector<SC,LO,GO,NO> > MV2TpetraMV(RCP<MultiVector> const Vec);
175  static RCP< Tpetra::MultiVector<SC,LO,GO,NO> > MV2NonConstTpetraMV(RCP<MultiVector> Vec);
176  static RCP< Tpetra::MultiVector<SC,LO,GO,NO> > MV2NonConstTpetraMV2(MultiVector& Vec);
177 
178  static const Tpetra::MultiVector<SC,LO,GO,NO>& MV2TpetraMV(const MultiVector& Vec);
179  static Tpetra::MultiVector<SC,LO,GO,NO>& MV2NonConstTpetraMV(MultiVector& Vec);
180 
181  static RCP<const Tpetra::CrsMatrix<SC,LO,GO,NO> > Op2TpetraCrs(RCP<const Matrix> Op);
182  static RCP< Tpetra::CrsMatrix<SC,LO,GO,NO> > Op2NonConstTpetraCrs(RCP<Matrix> Op);
183 
184  static const Tpetra::CrsMatrix<SC,LO,GO,NO>& Op2TpetraCrs(const Matrix& Op);
185  static Tpetra::CrsMatrix<SC,LO,GO,NO>& Op2NonConstTpetraCrs(Matrix& Op);
186 
187  static RCP<const Tpetra::RowMatrix<SC,LO,GO,NO> > Op2TpetraRow(RCP<const Matrix> Op);
188  static RCP< Tpetra::RowMatrix<SC,LO,GO,NO> > Op2NonConstTpetraRow(RCP<Matrix> Op);
189 
190 
191  static const RCP<const Tpetra::Map<LO, GO, NO> > Map2TpetraMap(const Map& map);
192 #endif
193 
194  static RCP<Xpetra::Matrix<SC,LO,GO,NO> > Crs2Op(RCP<CrsMatrix> Op);
195 
196 
197 
198 
205  static Teuchos::ArrayRCP<SC> GetMatrixDiagonal(const Matrix& A);
206 
213  static RCP<Vector> GetMatrixDiagonalInverse(const Matrix& A, Magnitude tol = Teuchos::ScalarTraits<SC>::eps()*100);
214 
215 
216 
223  static Teuchos::ArrayRCP<SC> GetLumpedMatrixDiagonal(const Matrix& A);
224 
232  static RCP<Vector> GetMatrixOverlappedDiagonal(const Matrix& A);
233 
243  static void ScaleMatrix(Matrix& Op, const Teuchos::ArrayRCP<SC>& scalingVector, bool doInverse = true);
244 
245 
246  // TODO: should NOT return an Array. Definition must be changed to:
247  // - ArrayRCP<> ResidualNorm(Matrix const &Op, MultiVector const &X, MultiVector const &RHS)
248  // or
249  // - void ResidualNorm(Matrix const &Op, MultiVector const &X, MultiVector const &RHS, Array &)
250  static Teuchos::Array<Magnitude> ResidualNorm(const Operator& Op, const MultiVector& X, const MultiVector& RHS);
251 
252  static RCP<MultiVector> Residual(const Operator& Op, const MultiVector& X, const MultiVector& RHS);
253 
254  // NOTE:
255  // A better place for the Read/Write function is probably Xpetra
256 
258 
259 
260  static void Write(const std::string& fileName, const Map& M);
261 
263  static void Write(const std::string& fileName, const MultiVector& Vec);
264 
266  static void Write(const std::string& fileName, const Matrix& Op);
267 
269  static Teuchos::RCP<Matrix> Read(const std::string& fileName, Xpetra::UnderlyingLib lib, const RCP<const Teuchos::Comm<int> >& comm, bool binary = false);
270 
275  static Teuchos::RCP<Matrix> Read(const std::string& filename,
276  const RCP<const Map> rowMap,
277  RCP<const Map> colMap = Teuchos::null,
278  const RCP<const Map> domainMap = Teuchos::null,
279  const RCP<const Map> rangeMap = Teuchos::null,
280  const bool callFillComplete = true,
281  const bool binary = false,
282  const bool tolerant = false,
283  const bool debug = false);
285 
286  static void PauseForDebugger();
287 
303  static Scalar PowerMethod(const Matrix& A, bool scaleByDiag = true,
304  LO niters = 10, Magnitude tolerance = 1e-2, bool verbose = false, unsigned int seed = 123);
305 
306  static void MyOldScaleMatrix(Matrix& Op, const Teuchos::ArrayRCP<const SC>& scalingVector, bool doInverse = true,
307  bool doFillComplete = true, bool doOptimizeStorage = true);
308 
309  static void MyOldScaleMatrix_Tpetra(Matrix& Op, const Teuchos::ArrayRCP<SC>& scalingVector,
310  bool doFillComplete, bool doOptimizeStorage);
311 
312  static RCP<Teuchos::FancyOStream> MakeFancy(std::ostream& os);
313 
318  static typename Teuchos::ScalarTraits<Scalar>::magnitudeType Distance2(const MultiVector& v, LocalOrdinal i0, LocalOrdinal i1);
319 
327  static Teuchos::ArrayRCP<const bool> DetectDirichletRows(const Matrix& A, const Magnitude& tol = Teuchos::ScalarTraits<SC>::zero());
328 
338  static void SetRandomSeed(const Teuchos::Comm<int> &comm);
339 
340  static void findDirichletRows(Teuchos::RCP<Matrix> A,
341  std::vector<LO>& dirichletRows);
342  static void findDirichletCols(Teuchos::RCP<Matrix> A,
343  std::vector<LO>& dirichletRows,
344  std::vector<LO>& dirichletCols);
345  static void Apply_BCsToMatrixRows(Teuchos::RCP<Matrix>& A,
346  std::vector<LO>& dirichletRows);
347  static void Apply_BCsToMatrixCols(Teuchos::RCP<Matrix>& A,
348  std::vector<LO>& dirichletCols);
349  static void Remove_Zeroed_Rows(Teuchos::RCP<Matrix>& A, double tol=1.0e-14);
350 
351  }; // class Utils
352 
357  long ExtractNonSerializableData(const Teuchos::ParameterList& inList, Teuchos::ParameterList& serialList, Teuchos::ParameterList& nonSerialList);
358 
359 
363  void TokenizeStringAndStripWhiteSpace(const std::string & stream, std::vector<std::string> & tokenList, const char* token = ",");
364 
367  bool IsParamMuemexVariable(const std::string& name);
368 
369 #ifdef HAVE_MUELU_EPETRA
370  //This non-member templated function exists so that the matrix-matrix multiply will compile if Epetra, Tpetra, and ML are enabled.
371  template<class SC,class LO,class GO,class NO>
372  RCP<Xpetra::CrsMatrixWrap<SC,LO,GO,NO> >
374  {
375  TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap cannot be used with Scalar != double, LocalOrdinal != int, GlobalOrdinal != int");
376  return Teuchos::null;
377  }
378 
379  typedef KokkosClassic::DefaultNode::DefaultNodeType KDNT;
380 
381  //specialization for the case of ScalarType=double and LocalOrdinal=GlobalOrdinal=int
382  template<>
383  inline RCP<Xpetra::CrsMatrixWrap<double,int,int,KDNT> > Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap<double,int,int,KDNT > (RCP<Epetra_CrsMatrix> &epAB) {
384  RCP<Xpetra::EpetraCrsMatrix> tmpC1 = rcp(new Xpetra::EpetraCrsMatrix(epAB));
385  RCP<Xpetra::CrsMatrix<double,int,int,KDNT> > tmpC2 = rcp_implicit_cast<Xpetra::CrsMatrix<double,int,int,KDNT> >(tmpC1);
386  RCP<Xpetra::CrsMatrixWrap<double,int,int,KDNT> > tmpC3 = rcp(new Xpetra::CrsMatrixWrap<double,int,int,KDNT>(tmpC2));
387  return tmpC3;
388  }
389 
394  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
395  RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
396  EpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Epetra_CrsMatrix>& A) {
397  typedef Xpetra::EpetraCrsMatrix XECrsMatrix;
398  typedef Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> XCrsMatrix;
399  typedef Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node> XCrsMatrixWrap;
400 
401  RCP<XCrsMatrix> Atmp = rcp(new XECrsMatrix(A));
402  return rcp(new XCrsMatrixWrap(Atmp));
403  }
404 
409  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
410  RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
411  EpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP<Epetra_MultiVector>& V) {
412  return rcp(new Xpetra::EpetraMultiVector(V));
413  }
414 #endif
415 
416 #ifdef HAVE_MUELU_TPETRA
417 
421  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
422  RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
423  TpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& Atpetra) {
424  typedef Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> XTCrsMatrix;
425  typedef Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> XCrsMatrix;
426  typedef Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node> XCrsMatrixWrap;
427 
428  RCP<XCrsMatrix> Atmp = rcp(new XTCrsMatrix(Atpetra));
429  return rcp(new XCrsMatrixWrap(Atmp));
430  }
431 
436  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
437  RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
438  TpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& Vtpetra) {
439  return rcp(new Xpetra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Vtpetra));
440  }
441 #endif
442 
444  template<class T>
445  std::string toString(const T& what) {
446  std::ostringstream buf;
447  buf << what;
448  return buf.str();
449  }
450 
457  template <class Scalar,
458  class LocalOrdinal = int,
459  class GlobalOrdinal = LocalOrdinal,
460  class Node = KokkosClassic::DefaultNode::DefaultNodeType>
461  class Utils2 {
462 
463 #include "MueLu_UseShortNames.hpp"
464 
465  public:
466 
472  static RCP<Matrix> Transpose(Matrix& Op, bool optimizeTranspose = false,const std::string & label = std::string());
473 
475  static void MyOldScaleMatrix_Epetra(Matrix& Op, const Teuchos::ArrayRCP<SC>& scalingVector, bool doFillComplete, bool doOptimizeStorage);
476 
477  static RCP<MultiVector> ReadMultiVector (const std::string& fileName, const RCP<const Map>& map);
478  static RCP<const Map> ReadMap (const std::string& fileName, Xpetra::UnderlyingLib lib, const RCP<const Teuchos::Comm<int> >& comm);
479  }; // class Utils2
480 
481  // specialization Utils2 for SC=double, LO=GO=int
482  template<>
483  class Utils2<double,int,int> {
484  typedef double SC;
485  typedef int LO;
486  typedef int GO;
487  typedef KokkosClassic::DefaultNode::DefaultNodeType NO;
488  typedef Xpetra::Map<int,int,NO> Map;
489  typedef Xpetra::Matrix<double,int,int,NO> Matrix;
490  typedef Xpetra::MultiVector<double,int,int,NO> MultiVector;
491 
492  public:
493 
494  static RCP<Matrix> Transpose (Matrix& Op, bool optimizeTranspose = false,const std::string & label = std::string());
495  static void MyOldScaleMatrix_Epetra (Matrix& Op, const Teuchos::ArrayRCP<SC>& scalingVector, bool doFillComplete, bool doOptimizeStorage);
496  static RCP<MultiVector> ReadMultiVector (const std::string& fileName, const RCP<const Map>& map);
497  static RCP<const Map> ReadMap (const std::string& fileName, Xpetra::UnderlyingLib lib, const RCP<const Teuchos::Comm<int> >& comm);
498 
499  };
500 
501 
502 #ifdef HAVE_MUELU_EPETRA
503 
507  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
508  RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
509  EpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Epetra_CrsMatrix>& A);
510 
515  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
516  RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
517  EpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP<Epetra_MultiVector>& V);
518 #endif
519 
520 #ifdef HAVE_MUELU_TPETRA
521 
525  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
526  RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
527  TpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& Atpetra);
528 
533  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
534  RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
535  TpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& Vtpetra);
536 #endif
537 
538 } //namespace MueLu
539 
540 #define MUELU_UTILITIES_SHORT
541 #endif // MUELU_UTILITIES_DECL_HPP
static void SetRandomSeed(const Teuchos::Comm< int > &comm)
Set seed for random number generator.
static void Remove_Zeroed_Rows(Teuchos::RCP< Matrix > &A, double tol=1.0e-14)
static RCP< Epetra_MultiVector > MV2NonConstEpetraMV(RCP< MultiVector > Vec)
static void Write(const std::string &fileName, const Map &M)
Read/Write methods.
RCP< Xpetra::Matrix< SC, LO, GO, NO > > EpetraCrs_To_XpetraMatrix(const Teuchos::RCP< Epetra_CrsMatrix > &A)
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
RCP< Xpetra::MultiVector< SC, LO, GO, NO > > TpetraCrs_To_XpetraMultiVector(const Teuchos::RCP< Tpetra::MultiVector< SC, LO, GO, NO > > &Vtpetra)
static const Epetra_Map & Map2EpetraMap(const Map &map)
static Teuchos::ArrayRCP< SC > GetLumpedMatrixDiagonal(const Matrix &A)
Extract Matrix Diagonal of lumped matrix.
static void findDirichletCols(Teuchos::RCP< Matrix > A, std::vector< LO > &dirichletRows, std::vector< LO > &dirichletCols)
static RCP< const Tpetra::MultiVector< SC, LO, GO, NO > > MV2TpetraMV(RCP< MultiVector > const Vec)
Helper utility to pull out the underlying Tpetra objects from an Xpetra object.
static Teuchos::Array< Magnitude > ResidualNorm(const Operator &Op, const MultiVector &X, const MultiVector &RHS)
Teuchos::ScalarTraits< SC >::magnitudeType Magnitude
KokkosClassic::DefaultNode::DefaultNodeType NO
static const RCP< const Tpetra::Map< LO, GO, NO > > Map2TpetraMap(const Map &map)
Namespace for MueLu classes and methods.
bool IsParamMuemexVariable(const std::string &name)
static RCP< Tpetra::MultiVector< SC, LO, GO, NO > > MV2NonConstTpetraMV(RCP< MultiVector > Vec)
static RCP< Xpetra::Matrix< SC, LO, GO, NO > > Crs2Op(RCP< CrsMatrix > Op)
static void PauseForDebugger()
static RCP< Tpetra::MultiVector< SC, LO, GO, NO > > MV2NonConstTpetraMV2(MultiVector &Vec)
static RCP< Vector > GetMatrixOverlappedDiagonal(const Matrix &A)
Extract Overlapped Matrix Diagonal.
static RCP< const Epetra_MultiVector > MV2EpetraMV(RCP< MultiVector > const Vec)
Helper utility to pull out the underlying Epetra objects from an Xpetra object.
static RCP< const Tpetra::RowMatrix< SC, LO, GO, NO > > Op2TpetraRow(RCP< const Matrix > Op)
static Teuchos::RCP< Matrix > Read(const std::string &fileName, Xpetra::UnderlyingLib lib, const RCP< const Teuchos::Comm< int > > &comm, bool binary=false)
Read matrix from file in Matrix Market or binary format.
static void Apply_BCsToMatrixRows(Teuchos::RCP< Matrix > &A, std::vector< LO > &dirichletRows)
static RCP< const Epetra_CrsMatrix > Op2EpetraCrs(RCP< const Matrix > Op)
RCP< Xpetra::CrsMatrixWrap< double, int, int, KDNT > > Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap< double, int, int, KDNT >(RCP< Epetra_CrsMatrix > &epAB)
static RCP< const Tpetra::CrsMatrix< SC, LO, GO, NO > > Op2TpetraCrs(RCP< const Matrix > Op)
static void ScaleMatrix(Matrix &Op, const Teuchos::ArrayRCP< SC > &scalingVector, bool doInverse=true)
Left scale matrix by an arbitrary vector.
static RCP< Teuchos::FancyOStream > MakeFancy(std::ostream &os)
static void MyOldScaleMatrix(Matrix &Op, const Teuchos::ArrayRCP< const SC > &scalingVector, bool doInverse=true, bool doFillComplete=true, bool doOptimizeStorage=true)
static void MyOldScaleMatrix_Tpetra(Matrix &Op, const Teuchos::ArrayRCP< SC > &scalingVector, bool doFillComplete, bool doOptimizeStorage)
RCP< Xpetra::CrsMatrixWrap< SC, LO, GO, NO > > Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap(RCP< Epetra_CrsMatrix > &epAB)
static RCP< Tpetra::CrsMatrix< SC, LO, GO, NO > > Op2NonConstTpetraCrs(RCP< Matrix > Op)
Xpetra::MultiVector< double, int, int, NO > MultiVector
Xpetra::Matrix< double, int, int, NO > Matrix
RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > TpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &Vtpetra)
static RCP< Tpetra::RowMatrix< SC, LO, GO, NO > > Op2NonConstTpetraRow(RCP< Matrix > Op)
static Teuchos::ScalarTraits< Scalar >::magnitudeType Distance2(const MultiVector &v, LocalOrdinal i0, LocalOrdinal i1)
Squared distance between two rows in a multivector.
static Teuchos::ArrayRCP< SC > GetMatrixDiagonal(const Matrix &A)
Extract Matrix Diagonal.
RCP< Xpetra::Matrix< SC, LO, GO, NO > > TpetraCrs_To_XpetraMatrix(const Teuchos::RCP< Tpetra::CrsMatrix< SC, LO, GO, NO > > &Atpetra)
MueLu utility class.
static Teuchos::ArrayRCP< const bool > DetectDirichletRows(const Matrix &A, const Magnitude &tol=Teuchos::ScalarTraits< SC >::zero())
Detect Dirichlet rows.
static Scalar PowerMethod(const Matrix &A, bool scaleByDiag=true, LO niters=10, Magnitude tolerance=1e-2, bool verbose=false, unsigned int seed=123)
Simple transpose for Tpetra::CrsMatrix types.
Exception throws to report errors in the internal logical of the program.
static RCP< Epetra_CrsMatrix > Op2NonConstEpetraCrs(RCP< Matrix > Op)
void TokenizeStringAndStripWhiteSpace(const std::string &stream, std::vector< std::string > &tokenList, const char *delimChars)
RCP< Xpetra::MultiVector< SC, LO, GO, NO > > EpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP< Epetra_MultiVector > &V)
KokkosClassic::DefaultNode::DefaultNodeType KDNT
static RCP< Vector > GetMatrixDiagonalInverse(const Matrix &A, Magnitude tol=Teuchos::ScalarTraits< SC >::eps()*100)
Extract Matrix Diagonal.
static RCP< MultiVector > Residual(const Operator &Op, const MultiVector &X, const MultiVector &RHS)
static void Apply_BCsToMatrixCols(Teuchos::RCP< Matrix > &A, std::vector< LO > &dirichletCols)
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)
static void findDirichletRows(Teuchos::RCP< Matrix > A, std::vector< LO > &dirichletRows)