/usr/include/trilinos/MueLu_Utilities_decl.hpp is in libtrilinos-muelu-dev 12.4.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | // @HEADER
//
// ***********************************************************************
//
// MueLu: A package for multigrid based preconditioning
// Copyright 2012 Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact
// Jonathan Hu (jhu@sandia.gov)
// Andrey Prokopenko (aprokop@sandia.gov)
// Ray Tuminaro (rstumin@sandia.gov)
//
// ***********************************************************************
//
// @HEADER
#ifndef MUELU_UTILITIES_DECL_HPP
#define MUELU_UTILITIES_DECL_HPP
#include <unistd.h> //necessary for "sleep" function in debugging methods
#include <string>
#include "MueLu_ConfigDefs.hpp"
#include <Teuchos_ScalarTraits.hpp>
#include <Teuchos_ParameterList.hpp>
#include <Xpetra_BlockedCrsMatrix_fwd.hpp>
#include <Xpetra_CrsMatrix_fwd.hpp>
#include <Xpetra_CrsMatrixWrap_fwd.hpp>
#include <Xpetra_ImportFactory_fwd.hpp>
#include <Xpetra_Map_fwd.hpp>
#include <Xpetra_MapFactory_fwd.hpp>
#include <Xpetra_Matrix_fwd.hpp>
#include <Xpetra_MatrixFactory_fwd.hpp>
#include <Xpetra_MultiVector_fwd.hpp>
#include <Xpetra_MultiVectorFactory_fwd.hpp>
#include <Xpetra_Operator_fwd.hpp>
#include <Xpetra_Vector_fwd.hpp>
#include <Xpetra_VectorFactory_fwd.hpp>
#include <Xpetra_ExportFactory.hpp>
#ifdef HAVE_MUELU_EPETRA
#include <Xpetra_EpetraCrsMatrix_fwd.hpp>
// needed because of inlined function
//TODO: remove inline function?
#include <Xpetra_EpetraCrsMatrix.hpp>
#include <Xpetra_CrsMatrixWrap.hpp>
#endif
#include "MueLu_Exceptions.hpp"
#ifdef HAVE_MUELU_EPETRAEXT
class Epetra_CrsMatrix;
class Epetra_MultiVector;
class Epetra_Vector;
#endif
#ifdef HAVE_MUELU_TPETRA
#include <Tpetra_CrsMatrix.hpp>
#include <Tpetra_Map.hpp>
#include <Tpetra_MultiVector.hpp>
#include <Xpetra_TpetraCrsMatrix_fwd.hpp>
#include <Xpetra_TpetraMultiVector_fwd.hpp>
#endif
namespace MueLu {
// MPI helpers
#define MueLu_sumAll(rcpComm, in, out) \
Teuchos::reduceAll(*rcpComm, Teuchos::REDUCE_SUM, in, Teuchos::outArg(out))
#define MueLu_minAll(rcpComm, in, out) \
Teuchos::reduceAll(*rcpComm, Teuchos::REDUCE_MIN, in, Teuchos::outArg(out))
#define MueLu_maxAll(rcpComm, in, out) \
Teuchos::reduceAll(*rcpComm, Teuchos::REDUCE_MAX, in, Teuchos::outArg(out))
#ifdef HAVE_MUELU_EPETRA
//defined after Utils class
template<typename SC,typename LO,typename GO,typename NO>
RCP<Xpetra::CrsMatrixWrap<SC,LO,GO,NO> >
Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap(RCP<Epetra_CrsMatrix> &epAB);
template<typename SC,typename LO,typename GO,typename NO>
RCP<Xpetra::Matrix<SC, LO, GO, NO> >
EpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Epetra_CrsMatrix>& A);
template<typename SC,typename LO,typename GO,typename NO>
RCP<Xpetra::MultiVector<SC, LO, GO, NO> >
EpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP<Epetra_MultiVector>& V);
#endif
#ifdef HAVE_MUELU_TPETRA
template<typename SC,typename LO,typename GO,typename NO>
RCP<Xpetra::Matrix<SC, LO, GO, NO> >
TpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Tpetra::CrsMatrix<SC, LO, GO, NO> >& Atpetra);
template<typename SC,typename LO,typename GO,typename NO>
RCP<Xpetra::MultiVector<SC, LO, GO, NO> >
TpetraCrs_To_XpetraMultiVector(const Teuchos::RCP<Tpetra::MultiVector<SC, LO, GO, NO> >& Vtpetra);
#endif
/*!
@class Utils
@brief MueLu utility class.
This class provides a number of static helper methods. Some are temporary and will eventually
go away, while others should be moved to Xpetra.
*/
template <class Scalar,
class LocalOrdinal = int,
class GlobalOrdinal = LocalOrdinal,
class Node = KokkosClassic::DefaultNode::DefaultNodeType>
class Utils {
#undef MUELU_UTILITIES_SHORT
#include "MueLu_UseShortNames.hpp"
public:
typedef typename Teuchos::ScalarTraits<SC>::magnitudeType Magnitude;
#ifdef HAVE_MUELU_EPETRA
//! Helper utility to pull out the underlying Epetra objects from an Xpetra object
// @{
static RCP<const Epetra_MultiVector> MV2EpetraMV(RCP<MultiVector> const Vec);
static RCP< Epetra_MultiVector> MV2NonConstEpetraMV(RCP<MultiVector> Vec);
static const Epetra_MultiVector& MV2EpetraMV(const MultiVector& Vec);
static Epetra_MultiVector& MV2NonConstEpetraMV(MultiVector& Vec);
static RCP<const Epetra_CrsMatrix> Op2EpetraCrs(RCP<const Matrix> Op);
static RCP< Epetra_CrsMatrix> Op2NonConstEpetraCrs(RCP<Matrix> Op);
static const Epetra_CrsMatrix& Op2EpetraCrs(const Matrix& Op);
static Epetra_CrsMatrix& Op2NonConstEpetraCrs(Matrix& Op);
static const Epetra_Map& Map2EpetraMap(const Map& map);
// @}
#endif
#ifdef HAVE_MUELU_TPETRA
//! Helper utility to pull out the underlying Tpetra objects from an Xpetra object
// @{
static RCP<const Tpetra::MultiVector<SC,LO,GO,NO> > MV2TpetraMV(RCP<MultiVector> const Vec);
static RCP< Tpetra::MultiVector<SC,LO,GO,NO> > MV2NonConstTpetraMV(RCP<MultiVector> Vec);
static RCP< Tpetra::MultiVector<SC,LO,GO,NO> > MV2NonConstTpetraMV2(MultiVector& Vec);
static const Tpetra::MultiVector<SC,LO,GO,NO>& MV2TpetraMV(const MultiVector& Vec);
static Tpetra::MultiVector<SC,LO,GO,NO>& MV2NonConstTpetraMV(MultiVector& Vec);
static RCP<const Tpetra::CrsMatrix<SC,LO,GO,NO> > Op2TpetraCrs(RCP<const Matrix> Op);
static RCP< Tpetra::CrsMatrix<SC,LO,GO,NO> > Op2NonConstTpetraCrs(RCP<Matrix> Op);
static const Tpetra::CrsMatrix<SC,LO,GO,NO>& Op2TpetraCrs(const Matrix& Op);
static Tpetra::CrsMatrix<SC,LO,GO,NO>& Op2NonConstTpetraCrs(Matrix& Op);
static RCP<const Tpetra::RowMatrix<SC,LO,GO,NO> > Op2TpetraRow(RCP<const Matrix> Op);
static RCP< Tpetra::RowMatrix<SC,LO,GO,NO> > Op2NonConstTpetraRow(RCP<Matrix> Op);
static const RCP<const Tpetra::Map<LO, GO, NO> > Map2TpetraMap(const Map& map);
#endif
static RCP<Xpetra::Matrix<SC,LO,GO,NO> > Crs2Op(RCP<CrsMatrix> Op);
/*! @brief Extract Matrix Diagonal
Returns Matrix diagonal in ArrayRCP.
NOTE -- it's assumed that A has been fillComplete'd.
*/
static Teuchos::ArrayRCP<SC> GetMatrixDiagonal(const Matrix& A);
/*! @brief Extract Matrix Diagonal
Returns inverse of the Matrix diagonal in ArrayRCP.
NOTE -- it's assumed that A has been fillComplete'd.
*/
static RCP<Vector> GetMatrixDiagonalInverse(const Matrix& A, Magnitude tol = Teuchos::ScalarTraits<SC>::eps()*100);
/*! @brief Extract Matrix Diagonal of lumped matrix
Returns Matrix diagonal of lumped matrix in ArrayRCP.
NOTE -- it's assumed that A has been fillComplete'd.
*/
static Teuchos::ArrayRCP<SC> GetLumpedMatrixDiagonal(const Matrix& A);
/*! @brief Extract Overlapped Matrix Diagonal
Returns overlapped Matrix diagonal in ArrayRCP.
The local overlapped diagonal has an entry for each index in A's column map.
NOTE -- it's assumed that A has been fillComplete'd.
*/
static RCP<Vector> GetMatrixOverlappedDiagonal(const Matrix& A);
/*! @brief Left scale matrix by an arbitrary vector.
Algorithmically, this left scales a matrix by a diagonal matrix.
The inverse of a diagonal matrix can also be applied.
@param Op matrix to be scaled
@param scalingVector vector that represents diagonal matrix
@doInverse Indicates whether the inverse of the diagonal matrix should be applied. (Default is to use inverse.)
*/
static void ScaleMatrix(Matrix& Op, const Teuchos::ArrayRCP<SC>& scalingVector, bool doInverse = true);
// TODO: should NOT return an Array. Definition must be changed to:
// - ArrayRCP<> ResidualNorm(Matrix const &Op, MultiVector const &X, MultiVector const &RHS)
// or
// - void ResidualNorm(Matrix const &Op, MultiVector const &X, MultiVector const &RHS, Array &)
static Teuchos::Array<Magnitude> ResidualNorm(const Operator& Op, const MultiVector& X, const MultiVector& RHS);
static RCP<MultiVector> Residual(const Operator& Op, const MultiVector& X, const MultiVector& RHS);
// NOTE:
// A better place for the Read/Write function is probably Xpetra
//! Read/Write methods
//@{
/*! @brief Save map to file. */
static void Write(const std::string& fileName, const Map& M);
/*! @brief Save vector to file in Matrix Market format. */
static void Write(const std::string& fileName, const MultiVector& Vec);
/*! @brief Save matrix to file in Matrix Market format. */
static void Write(const std::string& fileName, const Matrix& Op);
//! @brief Read matrix from file in Matrix Market or binary format.
static Teuchos::RCP<Matrix> Read(const std::string& fileName, Xpetra::UnderlyingLib lib, const RCP<const Teuchos::Comm<int> >& comm, bool binary = false);
/*! @brief Read matrix from file in Matrix Market or binary format.
If only rowMap is specified, then it is used for the domainMap and rangeMap, as well.
*/
static Teuchos::RCP<Matrix> Read(const std::string& filename,
const RCP<const Map> rowMap,
RCP<const Map> colMap = Teuchos::null,
const RCP<const Map> domainMap = Teuchos::null,
const RCP<const Map> rangeMap = Teuchos::null,
const bool callFillComplete = true,
const bool binary = false,
const bool tolerant = false,
const bool debug = false);
//@}
static void PauseForDebugger();
/*! @brief Simple transpose for Tpetra::CrsMatrix types
Note: This is very inefficient, as it inserts one entry at a time.
*/
/*! @brief Power method.
@param A matrix
@param scaleByDiag if true, estimate the largest eigenvalue of \f$ D^; A \f$.
@param niters maximum number of iterations
@param tolerance stopping tolerance
@verbose if true, print iteration information
(Shamelessly grabbed from tpetra/examples.)
*/
static Scalar PowerMethod(const Matrix& A, bool scaleByDiag = true,
LO niters = 10, Magnitude tolerance = 1e-2, bool verbose = false, unsigned int seed = 123);
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);
static RCP<Teuchos::FancyOStream> MakeFancy(std::ostream& os);
/*! @brief Squared distance between two rows in a multivector
Used for coordinate vectors.
*/
static typename Teuchos::ScalarTraits<Scalar>::magnitudeType Distance2(const MultiVector& v, LocalOrdinal i0, LocalOrdinal i1);
/*! @brief Detect Dirichlet rows
@param[in] A matrix
@param[in] tol If a row entry's magnitude is less than or equal to this tolerance, the entry is treated as zero.
@return boolean array. The ith entry is true iff row i is a Dirichlet row.
*/
static Teuchos::ArrayRCP<const bool> DetectDirichletRows(const Matrix& A, const Magnitude& tol = Teuchos::ScalarTraits<SC>::zero());
/*! @brief Set seed for random number generator.
Distribute the seeds evenly in [1,INT_MAX-1]. This guarantees nothing
about where random number streams on difference processes will intersect.
This does avoid overflow situations in parallel when multiplying by a PID.
It also avoids the pathological case of having the *same* random number stream
on each process.
*/
static void SetRandomSeed(const Teuchos::Comm<int> &comm);
static void findDirichletRows(Teuchos::RCP<Matrix> A,
std::vector<LO>& dirichletRows);
static void findDirichletCols(Teuchos::RCP<Matrix> A,
std::vector<LO>& dirichletRows,
std::vector<LO>& dirichletCols);
static void Apply_BCsToMatrixRows(Teuchos::RCP<Matrix>& A,
std::vector<LO>& dirichletRows);
static void Apply_BCsToMatrixCols(Teuchos::RCP<Matrix>& A,
std::vector<LO>& dirichletCols);
static void Remove_Zeroed_Rows(Teuchos::RCP<Matrix>& A, double tol=1.0e-14);
}; // class Utils
/*! Removes the following non-serializable data (A,P,R,Nullspace,Coordinates) from level-specific sublists from inList
and moves it to nonSerialList. Everything else is copied to serialList. This function returns the level number of the highest level
for which non-serializable data was provided.
*/
long ExtractNonSerializableData(const Teuchos::ParameterList& inList, Teuchos::ParameterList& serialList, Teuchos::ParameterList& nonSerialList);
/*! Tokenizes a (comma)-separated string, removing all leading and trailing whitespace
WARNING: This routine is not threadsafe on most architectures
*/
void TokenizeStringAndStripWhiteSpace(const std::string & stream, std::vector<std::string> & tokenList, const char* token = ",");
/*! Returns true if a parameter name is a valid Muemex custom level variable, e.g. "MultiVector myArray"
*/
bool IsParamMuemexVariable(const std::string& name);
#ifdef HAVE_MUELU_EPETRA
//This non-member templated function exists so that the matrix-matrix multiply will compile if Epetra, Tpetra, and ML are enabled.
template<class SC,class LO,class GO,class NO>
RCP<Xpetra::CrsMatrixWrap<SC,LO,GO,NO> >
Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap (RCP<Epetra_CrsMatrix> &epAB)
{
TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap cannot be used with Scalar != double, LocalOrdinal != int, GlobalOrdinal != int");
return Teuchos::null;
}
typedef KokkosClassic::DefaultNode::DefaultNodeType KDNT;
//specialization for the case of ScalarType=double and LocalOrdinal=GlobalOrdinal=int
template<>
inline RCP<Xpetra::CrsMatrixWrap<double,int,int,KDNT> > Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap<double,int,int,KDNT > (RCP<Epetra_CrsMatrix> &epAB) {
RCP<Xpetra::EpetraCrsMatrix> tmpC1 = rcp(new Xpetra::EpetraCrsMatrix(epAB));
RCP<Xpetra::CrsMatrix<double,int,int,KDNT> > tmpC2 = rcp_implicit_cast<Xpetra::CrsMatrix<double,int,int,KDNT> >(tmpC1);
RCP<Xpetra::CrsMatrixWrap<double,int,int,KDNT> > tmpC3 = rcp(new Xpetra::CrsMatrixWrap<double,int,int,KDNT>(tmpC2));
return tmpC3;
}
/*! \fn EpetraCrs_To_XpetraMatrix
@brief Helper function to convert a Epetra::CrsMatrix to an Xpetra::Matrix
TODO move this function to an Xpetra utility file
*/
template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
EpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Epetra_CrsMatrix>& A) {
typedef Xpetra::EpetraCrsMatrix XECrsMatrix;
typedef Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> XCrsMatrix;
typedef Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node> XCrsMatrixWrap;
RCP<XCrsMatrix> Atmp = rcp(new XECrsMatrix(A));
return rcp(new XCrsMatrixWrap(Atmp));
}
/*! \fn EpetraMultiVector_To_XpetraMultiVector
@brief Helper function to convert a Epetra::MultiVector to an Xpetra::MultiVector
TODO move this function to an Xpetra utility file
*/
template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
EpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP<Epetra_MultiVector>& V) {
return rcp(new Xpetra::EpetraMultiVector(V));
}
#endif
#ifdef HAVE_MUELU_TPETRA
/*! \fn TpetraCrs_To_XpetraMatrix
@brief Helper function to convert a Tpetra::CrsMatrix to an Xpetra::Matrix
TODO move this function to an Xpetra utility file
*/
template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
TpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& Atpetra) {
typedef Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> XTCrsMatrix;
typedef Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> XCrsMatrix;
typedef Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node> XCrsMatrixWrap;
RCP<XCrsMatrix> Atmp = rcp(new XTCrsMatrix(Atpetra));
return rcp(new XCrsMatrixWrap(Atmp));
}
/*! \fn TpetraMultiVector_To_XpetraMultiVector
@brief Helper function to convert a Tpetra::MultiVector to an Xpetra::MultiVector
TODO move this function to an Xpetra utility file
*/
template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
TpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& Vtpetra) {
return rcp(new Xpetra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Vtpetra));
}
#endif
//! Little helper function to convert non-string types to strings
template<class T>
std::string toString(const T& what) {
std::ostringstream buf;
buf << what;
return buf.str();
}
/*!
@class Utils2
@brief MueLu utility class.
Separate class for utilities that need a specialization for Epetra.
*/
template <class Scalar,
class LocalOrdinal = int,
class GlobalOrdinal = LocalOrdinal,
class Node = KokkosClassic::DefaultNode::DefaultNodeType>
class Utils2 {
#include "MueLu_UseShortNames.hpp"
public:
/*! @brief Transpose a Xpetra::Matrix
Note: Currently, an error is thrown if the matrix isn't a Tpetra::CrsMatrix or Epetra_CrsMatrix.
In principle, however, we could allow any Epetra_RowMatrix because the Epetra transposer does.
*/
static RCP<Matrix> Transpose(Matrix& Op, bool optimizeTranspose = false,const std::string & label = std::string());
//! Scale an Epetra matrix.
static void MyOldScaleMatrix_Epetra(Matrix& Op, const Teuchos::ArrayRCP<SC>& scalingVector, bool doFillComplete, bool doOptimizeStorage);
static RCP<MultiVector> ReadMultiVector (const std::string& fileName, const RCP<const Map>& map);
static RCP<const Map> ReadMap (const std::string& fileName, Xpetra::UnderlyingLib lib, const RCP<const Teuchos::Comm<int> >& comm);
}; // class Utils2
// specialization Utils2 for SC=double, LO=GO=int
template<>
class Utils2<double,int,int> {
typedef double SC;
typedef int LO;
typedef int GO;
typedef KokkosClassic::DefaultNode::DefaultNodeType NO;
typedef Xpetra::Map<int,int,NO> Map;
typedef Xpetra::Matrix<double,int,int,NO> Matrix;
typedef Xpetra::MultiVector<double,int,int,NO> MultiVector;
public:
static RCP<Matrix> Transpose (Matrix& Op, bool optimizeTranspose = false,const std::string & label = std::string());
static void MyOldScaleMatrix_Epetra (Matrix& Op, const Teuchos::ArrayRCP<SC>& scalingVector, bool doFillComplete, bool doOptimizeStorage);
static RCP<MultiVector> ReadMultiVector (const std::string& fileName, const RCP<const Map>& map);
static RCP<const Map> ReadMap (const std::string& fileName, Xpetra::UnderlyingLib lib, const RCP<const Teuchos::Comm<int> >& comm);
};
#ifdef HAVE_MUELU_EPETRA
/*! \fn EpetraCrs_To_XpetraMatrix
@brief Helper function to convert a Epetra::CrsMatrix to an Xpetra::Matrix
TODO move this function to an Xpetra utility file
*/
template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
EpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Epetra_CrsMatrix>& A);
/*! \fn EpetraMultiVector_To_XpetraMultiVector
@brief Helper function to convert a Epetra::MultiVector to an Xpetra::MultiVector
TODO move this function to an Xpetra utility file
*/
template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
EpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP<Epetra_MultiVector>& V);
#endif
#ifdef HAVE_MUELU_TPETRA
/*! \fn TpetraCrs_To_XpetraMatrix
@brief Helper function to convert a Tpetra::CrsMatrix to an Xpetra::Matrix
TODO move this function to an Xpetra utility file
*/
template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
TpetraCrs_To_XpetraMatrix(const Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& Atpetra);
/*! \fn TpetraMultiVector_To_XpetraMultiVector
@brief Helper function to convert a Tpetra::MultiVector to an Xpetra::MultiVector
TODO move this function to an Xpetra utility file
*/
template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
TpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& Vtpetra);
#endif
} //namespace MueLu
#define MUELU_UTILITIES_SHORT
#endif // MUELU_UTILITIES_DECL_HPP
|