46 #ifndef MUELU_UTILITIES_DECL_HPP
47 #define MUELU_UTILITIES_DECL_HPP
53 #include <Teuchos_DefaultComm.hpp>
57 #include <Xpetra_TpetraBlockCrsMatrix_fwd.hpp>
60 #include <Xpetra_CrsMatrixWrap.hpp>
71 #ifdef HAVE_MUELU_EPETRA
83 #ifdef HAVE_MUELU_EPETRAEXT
90 #include <Tpetra_CrsMatrix.hpp>
91 #include <Tpetra_BlockCrsMatrix.hpp>
92 #include <Tpetra_BlockCrsMatrix_Helpers.hpp>
93 #include <Tpetra_FECrsMatrix.hpp>
94 #include <Tpetra_RowMatrixTransposer.hpp>
95 #include <Tpetra_Map.hpp>
96 #include <Tpetra_MultiVector.hpp>
97 #include <Tpetra_FEMultiVector.hpp>
102 #include <MueLu_UtilitiesBase.hpp>
106 #ifdef HAVE_MUELU_EPETRA
108 template <
typename SC,
typename LO,
typename GO,
typename NO>
109 RCP<Xpetra::CrsMatrixWrap<SC, LO, GO, NO>>
112 template <
typename SC,
typename LO,
typename GO,
typename NO>
113 RCP<Xpetra::Matrix<SC, LO, GO, NO>>
116 template <
typename SC,
typename LO,
typename GO,
typename NO>
117 RCP<Xpetra::MultiVector<SC, LO, GO, NO>>
121 template <
typename SC,
typename LO,
typename GO,
typename NO>
122 RCP<Xpetra::Matrix<SC, LO, GO, NO>>
125 template <
typename SC,
typename LO,
typename GO,
typename NO>
126 RCP<Xpetra::Matrix<SC, LO, GO, NO>>
129 template <
typename SC,
typename LO,
typename GO,
typename NO>
130 RCP<Xpetra::MultiVector<SC, LO, GO, NO>>
133 template <
typename SC,
typename LO,
typename GO,
typename NO>
134 RCP<Xpetra::MultiVector<SC, LO, GO, NO>>
137 template <
typename SC,
typename LO,
typename GO,
typename NO>
140 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
156 class Utilities :
public UtilitiesBase<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
157 #undef MUELU_UTILITIES_SHORT
163 #ifdef HAVE_MUELU_EPETRA
208 bool doFillComplete =
true,
bool doOptimizeStorage =
true);
211 bool doFillComplete,
bool doOptimizeStorage);
213 bool doFillComplete,
bool doOptimizeStorage);
225 #ifdef HAVE_MUELU_EPETRA
243 #undef MUELU_UTILITIES_SHORT
255 if (tmpVec == Teuchos::null)
256 throw Exceptions::BadCast(
"Cast from Xpetra::MultiVector to Xpetra::EpetraMultiVector failed");
257 return tmpVec->getEpetra_MultiVector();
261 if (tmpVec == Teuchos::null)
262 throw Exceptions::BadCast(
"Cast from Xpetra::MultiVector to Xpetra::EpetraMultiVector failed");
263 return tmpVec->getEpetra_MultiVector();
277 if (crsOp == Teuchos::null)
280 if (tmp_ECrsMtx == Teuchos::null)
281 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
282 return tmp_ECrsMtx->getEpetra_CrsMatrix();
286 if (crsOp == Teuchos::null)
289 if (tmp_ECrsMtx == Teuchos::null)
290 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
291 return tmp_ECrsMtx->getEpetra_CrsMatrixNonConst();
296 const CrsMatrixWrap& crsOp =
dynamic_cast<const CrsMatrixWrap&
>(Op);
299 return *tmp_ECrsMtx.getEpetra_CrsMatrix();
300 }
catch (std::bad_cast&) {
301 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
303 }
catch (std::bad_cast&) {
309 CrsMatrixWrap& crsOp =
dynamic_cast<CrsMatrixWrap&
>(Op);
312 return *tmp_ECrsMtx.getEpetra_CrsMatrixNonConst();
313 }
catch (std::bad_cast&) {
314 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
316 }
catch (std::bad_cast&) {
323 if (xeMap == Teuchos::null)
324 throw Exceptions::BadCast(
"Utilities::Map2EpetraMap : Cast from Xpetra::Map to Xpetra::EpetraMap failed");
325 return xeMap->getEpetra_Map();
331 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
332 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
336 if (tmpVec == Teuchos::null)
337 throw Exceptions::BadCast(
"Cast from Xpetra::MultiVector to Xpetra::TpetraMultiVector failed");
338 return tmpVec->getTpetra_MultiVector();
342 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
343 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
347 if (tmpVec == Teuchos::null)
348 throw Exceptions::BadCast(
"Cast from Xpetra::MultiVector to Xpetra::TpetraMultiVector failed");
349 return tmpVec->getTpetra_MultiVector();
353 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
354 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
363 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
364 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
372 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
373 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
382 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
383 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
388 if (crsOp == Teuchos::null)
391 if (tmp_ECrsMtx == Teuchos::null)
392 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed");
393 return tmp_ECrsMtx->getTpetra_CrsMatrix();
397 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
398 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
402 if (crsOp == Teuchos::null)
405 if (tmp_ECrsMtx == Teuchos::null)
406 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed");
407 return tmp_ECrsMtx->getTpetra_CrsMatrixNonConst();
412 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
413 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
417 const CrsMatrixWrap& crsOp =
dynamic_cast<const CrsMatrixWrap&
>(Op);
421 }
catch (std::bad_cast&) {
422 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed");
424 }
catch (std::bad_cast&) {
430 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
431 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
435 CrsMatrixWrap& crsOp =
dynamic_cast<CrsMatrixWrap&
>(Op);
439 }
catch (std::bad_cast&) {
440 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed");
442 }
catch (std::bad_cast&) {
449 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
450 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
455 if (crsOp == Teuchos::null)
458 if (tmp_ECrsMtx == Teuchos::null)
459 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraBlockCrsMatrix failed");
460 return tmp_ECrsMtx->getTpetra_BlockCrsMatrix();
465 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
466 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
467 throw Exceptions::RuntimeError(
"Op2NonConstTpetraBlockCrs: Tpetra has not been compiled with support for LO=GO=int.");
470 if (crsOp == Teuchos::null)
473 if (tmp_ECrsMtx == Teuchos::null)
474 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraBlockCrsMatrix failed");
475 return tmp_ECrsMtx->getTpetra_BlockCrsMatrixNonConst();
480 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
481 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
485 const CrsMatrixWrap& crsOp =
dynamic_cast<const CrsMatrixWrap&
>(Op);
489 }
catch (std::bad_cast&) {
490 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraBlockCrsMatrix failed");
492 }
catch (std::bad_cast&) {
498 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
499 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
503 CrsMatrixWrap& crsOp =
dynamic_cast<CrsMatrixWrap&
>(Op);
507 }
catch (std::bad_cast&) {
508 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraBlockCrsMatrix failed");
510 }
catch (std::bad_cast&) {
517 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
518 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
525 if (crsOp == Teuchos::null)
532 return tmp_Crs->getTpetra_CrsMatrixNonConst();
535 if (tmp_BlockCrs.is_null())
536 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix and Xpetra::TpetraBlockCrsMatrix failed");
537 return tmp_BlockCrs->getTpetra_BlockCrsMatrixNonConst();
539 }
else if (!rmat.is_null()) {
540 return rmat->getTpetra_RowMatrix();
551 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
552 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
559 if (crsOp == Teuchos::null)
566 return tmp_Crs->getTpetra_CrsMatrixNonConst();
569 if (tmp_BlockCrs.is_null())
570 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix and Xpetra::TpetraBlockCrsMatrix failed");
571 return tmp_BlockCrs->getTpetra_BlockCrsMatrixNonConst();
573 }
else if (!rmat.is_null()) {
574 return rmat->getTpetra_RowMatrixNonConst();
585 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
586 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
590 if (tmp_TMap == Teuchos::null)
591 throw Exceptions::BadCast(
"Utilities::Map2TpetraMap : Cast from Xpetra::Map to Xpetra::TpetraMap failed");
592 return tmp_TMap->getTpetra_Map();
597 bool doFillComplete =
true,
bool doOptimizeStorage =
true) {
601 for (
int i = 0; i < scalingVector.
size(); ++i)
602 sv[i] = one / scalingVector[i];
604 for (
int i = 0; i < scalingVector.
size(); ++i)
605 sv[i] = scalingVector[i];
608 switch (Op.getRowMap()->lib()) {
624 bool doFillComplete,
bool doOptimizeStorage) {
625 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
626 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
627 throw Exceptions::RuntimeError(
"Matrix scaling is not possible because Tpetra has not been compiled with support for LO=GO=int.");
637 if (maxRowSize == Teuchos::as<size_t>(-1))
640 std::vector<Scalar> scaledVals(maxRowSize);
644 if (Op.isLocallyIndexed() ==
true) {
647 for (
size_t i = 0; i < rowMap->getLocalNumElements(); ++i) {
650 if (nnz > maxRowSize) {
652 scaledVals.resize(maxRowSize);
654 for (
size_t j = 0; j < nnz; ++j)
655 scaledVals[j] = vals[j] * scalingVector[i];
668 for (
size_t i = 0; i < rowMap->getLocalNumElements(); ++i) {
672 if (nnz > maxRowSize) {
674 scaledVals.resize(maxRowSize);
677 for (
size_t j = 0; j < nnz; ++j)
678 scaledVals[j] = vals[j] * scalingVector[i];
688 if (doFillComplete) {
689 if (domainMap == Teuchos::null || rangeMap == Teuchos::null)
690 throw Exceptions::RuntimeError(
"In Utilities::Scaling: cannot fillComplete because the domain and/or range map hasn't been defined");
693 params->
set(
"Optimize Storage", doOptimizeStorage);
694 params->
set(
"No Nonlocal Changes",
true);
695 Op.fillComplete(Op.getDomainMap(), Op.getRangeMap(), params);
704 #ifdef HAVE_MUELU_EPETRA
716 for (
int j = 0; j < nnz; ++j)
717 vals[j] *= scalingVector[i];
725 #endif // HAVE_MUELU_EPETRA
734 switch (Op.getRowMap()->lib()) {
736 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
737 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
738 throw Exceptions::RuntimeError(
"Utilities::Transpose: Tpetra is not compiled with LO=GO=int. Add TPETRA_INST_INT_INT:BOOL=ON to your configuration!");
742 if (Helpers::isTpetraCrs(Op)) {
753 transposeParams->set(
"sort",
false);
761 if (Op.IsView(
"stridedMaps"))
762 AAAA->CreateView(
"stridedMaps", Teuchos::rcpFromRef(Op),
true );
767 else if (Helpers::isTpetraBlockCrs(Op)) {
778 transposeParams->set(
"sort",
false);
786 if (Op.IsView(
"stridedMaps"))
787 AAAA->CreateView(
"stridedMaps", Teuchos::rcpFromRef(Op),
true );
794 throw Exceptions::RuntimeError(
"Utilities::Transpose failed, perhaps because matrix is not a Crs or BlockCrs matrix");
799 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_EPETRAEXT)
812 if (Op.IsView(
"stridedMaps"))
813 AAAA->CreateView(
"stridedMaps", Teuchos::rcpFromRef(Op),
true );
842 #if (defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT)) || \
843 (!defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))
848 #if !defined(HAVE_TPETRA_EXPLICIT_INSTANTIATION) || defined(HAVE_TPETRA_INST_FLOAT)
861 paramList.
remove(
"Coordinates");
863 #if !defined(HAVE_TPETRA_EXPLICIT_INSTANTIATION) || defined(HAVE_TPETRA_INST_FLOAT)
867 paramList.
remove(
"Coordinates");
868 doubleCoords =
rcp(
new tdMV(floatCoords->getMap(), floatCoords->getNumVectors()));
873 if (doubleCoords != Teuchos::null) {
877 #endif // Tpetra instantiated on GO=int and EpetraNode
879 #if defined(HAVE_MUELU_EPETRA)
883 paramList.
remove(
"Coordinates");
891 if (paramList.
isType<decltype(coordinates)>(
"Coordinates")) {
892 coordinates = paramList.
get<decltype(coordinates)>(
"Coordinates");
901 #endif // HAVE_MUELU_EPETRA
947 #ifdef HAVE_MUELU_EPETRA
952 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
953 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
960 return rcp(
new XCrsMatrixWrap(Atmp));
967 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
968 RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
978 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
979 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
986 return rcp(
new XCrsMatrixWrap(Atmp));
1016 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1018 LocalOrdinal nBlks = (Amat.getRowMap()->getLocalNumElements()) / blkSize;
1023 for (
size_t i = 0; i < blkSize; i++) rowScaling[i] = 1.0;
1024 for (
size_t i = 0; i < blkSize; i++) colScaling[i] = 1.0;
1026 for (
size_t k = 0; k < nSweeps; k++) {
1028 for (
size_t i = 0; i < blkSize; i++) rowScaleUpdate[i] = 0.0;
1031 for (
size_t j = 0; j < blkSize; j++) {
1036 for (
size_t kk = 0; kk < Teuchos::as<size_t>(vals.
size()); kk++) {
1037 size_t modGuy = (cols[kk] + 1) % blkSize;
1038 if (modGuy == 0) modGuy = blkSize;
1048 for (
size_t i = 0; i < blkSize; i++) rowScaleUpdate[i] = tempUpdate[i];
1056 for (
size_t i = 1; i < blkSize; i++) {
1057 Scalar temp = (rowScaleUpdate[i] / rowScaling[i]) / rowScaling[i];
1061 for (
size_t i = 0; i < blkSize; i++) rowScaling[i] *= sqrt(minUpdate / rowScaleUpdate[i]);
1064 for (
size_t i = 0; i < blkSize; i++) colScaleUpdate[i] = 0.0;
1067 for (
size_t j = 0; j < blkSize; j++) {
1071 for (
size_t kk = 0; kk < Teuchos::as<size_t>(vals.
size()); kk++) {
1072 size_t modGuy = (cols[kk] + 1) % blkSize;
1073 if (modGuy == 0) modGuy = blkSize;
1081 for (
size_t i = 0; i < blkSize; i++) colScaleUpdate[i] = tempUpdate[i];
1089 for (
size_t i = 1; i < blkSize; i++) {
1090 Scalar temp = (colScaleUpdate[i] / colScaling[i]) / colScaling[i];
1094 for (
size_t i = 0; i < blkSize; i++) colScaling[i] *= sqrt(minUpdate / colScaleUpdate[i]);
1102 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1103 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1105 typedef typename Tpetra::FECrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::crs_matrix_type tpetra_crs_matrix_type;
1110 RCP<XCrsMatrix> Atmp =
rcp(
new XTCrsMatrix(rcp_dynamic_cast<tpetra_crs_matrix_type>(Atpetra)));
1111 return rcp(
new XCrsMatrixWrap(Atmp));
1118 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1119 RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1128 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1129 RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1132 RCP<const MV> Vmv = Teuchos::rcp_dynamic_cast<
const MV>(Vtpetra);
1139 std::ostringstream buf;
1144 #ifdef HAVE_MUELU_EPETRA
1149 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1150 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1157 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1158 RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1166 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1167 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1174 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1175 RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1182 std::string
lowerCase(
const std::string& s);
1184 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1197 toggleVec->putScalar(1);
1203 std::vector<GO> finalDropMapEntries = {};
1204 auto finalVec_h_2D = finalVec->getHostLocalView(Xpetra::Access::ReadOnly);
1205 auto finalVec_h_1D = Kokkos::subview(finalVec_h_2D, Kokkos::ALL(), 0);
1206 const size_t localLength = finalVec->getLocalLength();
1208 for (
size_t k = 0; k < localLength; ++k) {
1210 finalDropMapEntries.push_back(finalVec->getMap()->getGlobalElement(k));
1216 return finalDropMap;
1221 #define MUELU_UTILITIES_SHORT
1222 #endif // MUELU_UTILITIES_DECL_HPP
Exception indicating invalid cast attempted.
static const Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > & Op2TpetraBlockCrs(const Matrix &Op)
static const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > Map2TpetraMap(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map)
static const Epetra_MultiVector & MV2EpetraMV(const MultiVector &vec)
MueLu::DefaultLocalOrdinal LocalOrdinal
static Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > & Op2NonConstTpetraCrs(Matrix &Op)
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.
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.
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
static RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2NonConstTpetraMV2(MultiVector &vec)
static void MyOldScaleMatrix(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const Teuchos::ArrayRCP< const Scalar > &scalingVector, bool doInverse=true, bool doFillComplete=true, bool doOptimizeStorage=true)
static RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > RealValuedToScalarMultiVector(RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::coordinateType, LocalOrdinal, GlobalOrdinal, Node >> X)
static const Epetra_Map & Map2EpetraMap(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &map)
Teuchos::RCP< const map_type > getRangeMap() const override
RCP< Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_BlockCrsMatrixNonConst() const
T & get(const std::string &name, T def_value)
static RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::magnitudeType, LocalOrdinal, GlobalOrdinal, Node > > ExtractCoordinatesFromParameterList(ParameterList ¶mList)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
static RCP< Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraRow(RCP< Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node >> Op)
bool is_null(const std::shared_ptr< T > &p)
static RCP< Epetra_CrsMatrix > Op2NonConstEpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> Op)
Teuchos::ScalarTraits< Scalar >::magnitudeType Magnitude
static RCP< const Epetra_CrsMatrix > Op2EpetraCrs(RCP< const Matrix > Op)
static RCP< const Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2TpetraBlockCrs(RCP< const Matrix > Op)
RCP< Xpetra::MultiVector< SC, LO, GO, NO > > TpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP< Tpetra::MultiVector< SC, LO, GO, NO >> &Vtpetra)
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
RCP< Xpetra::Matrix< SC, LO, GO, NO > > TpetraFECrs_To_XpetraMatrix(const Teuchos::RCP< Tpetra::FECrsMatrix< SC, LO, GO, NO >> &Atpetra)
static RCP< Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraRow(RCP< Operator > Op)
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::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2TpetraCrs(RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> Op)
bool IsParamMuemexVariable(const std::string &name)
static RCP< const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2TpetraMV(RCP< MultiVector > const vec)
Helper utility to pull out the underlying Tpetra objects from an Xpetra object.
static const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > Map2TpetraMap(const Map &map)
static void MyOldScaleMatrix_Tpetra(Matrix &Op, const Teuchos::ArrayRCP< Scalar > &scalingVector, bool doFillComplete, bool doOptimizeStorage)
static RCP< Time > getNewTimer(const std::string &name)
int ExtractMyRowView(int MyRow, int &NumEntries, double *&Values, int *&Indices) const
static RCP< Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraBlockCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> Op)
RCP< Xpetra::MultiVector< SC, LO, GO, NO > > TpetraFEMultiVector_To_XpetraMultiVector(const Teuchos::RCP< Tpetra::FEMultiVector< SC, LO, GO, NO >> &Vtpetra)
const Epetra_Map & RowMap() const
bool isParameter(const std::string &name) const
int NumMyElements() const
void deep_copy(MultiVector< DS, DL, DG, DN > &dst, const MultiVector< SS, SL, SG, SN > &src)
bool remove(std::string const &name, bool throwIfNotExists=true)
static Epetra_CrsMatrix & Op2NonConstEpetraCrs(Matrix &Op)
size_t getLocalMaxNumRowEntries() const override
virtual void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const =0
static RCP< Epetra_CrsMatrix > Op2NonConstEpetraCrs(RCP< Matrix > Op)
bool isFillComplete() const override
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static RCP< Epetra_MultiVector > MV2NonConstEpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >> vec)
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int >> &comm, LocalGlobal lg=Xpetra::GloballyDistributed)
RCP< const Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_BlockCrsMatrix() const
static Epetra_MultiVector & MV2NonConstEpetraMV(MultiVector &vec)
static RCP< Epetra_MultiVector > MV2NonConstEpetraMV(RCP< MultiVector > vec)
void leftRghtDofScalingWithinNode(const Xpetra::Matrix< SC, LO, GO, NO > &Atpetra, size_t blkSize, size_t nSweeps, Teuchos::ArrayRCP< SC > &rowScaling, Teuchos::ArrayRCP< SC > &colScaling)
RCP< Xpetra::Matrix< SC, LO, GO, NO > > TpetraCrs_To_XpetraMatrix(const Teuchos::RCP< Tpetra::CrsMatrix< SC, LO, GO, NO >> &Atpetra)
static const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & MV2TpetraMV(const MultiVector &vec)
static RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2NonConstTpetraMV2(Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec)
static RCP< const Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2TpetraCrs(RCP< const Matrix > Op)
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< Matrix > Transpose(Matrix &Op, bool=false, const std::string &label=std::string(), const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Transpose a Xpetra::Matrix.
local_ordinal_type replaceGlobalValues(const global_ordinal_type globalRow, const Kokkos::View< const global_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals)
RCP< Xpetra::CrsMatrixWrap< SC, LO, GO, NO > > Convert_Epetra_CrsMatrix_ToXpetra_CrsMatrixWrap(RCP< Epetra_CrsMatrix > &epAB)
size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const override
bool IsParamValidVariable(const std::string &name)
static RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2NonConstTpetraMV(RCP< MultiVector > vec)
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
static RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::magnitudeType, LocalOrdinal, GlobalOrdinal, Node > > RealValuedToScalarMultiVector(RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::coordinateType, LocalOrdinal, GlobalOrdinal, Node >> X)
Teuchos::RCP< bcrs_matrix_type > createTranspose(const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
static magnitudeType magnitude(T a)
std::string lowerCase(const std::string &s)
Teuchos::RCP< crs_matrix_type > createTranspose(const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
static RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2TpetraRow(RCP< const Operator > Op)
static void MyOldScaleMatrix_Epetra(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const Teuchos::ArrayRCP< Scalar > &scalingVector, bool doFillComplete, bool doOptimizeStorage)
static const Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > & Op2TpetraCrs(const Matrix &Op)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
Teuchos::RCP< const map_type > getDomainMap() const override
RCP< const Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_CrsMatrix() const
RCP< Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_CrsMatrixNonConst() const
Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > importOffRankDroppingInfo(Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node >> &localDropMap, Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> &Ain)
bool isType(const std::string &name) const
static RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2TpetraRow(RCP< const Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node >> Op)
virtual void getGlobalRowView(GlobalOrdinal GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const =0
Wraps an existing MueLu::Hierarchy as a Tpetra::Operator.
EpetraCrsMatrixT< int, EpetraNode > EpetraCrsMatrix
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.
RCP< Epetra_MultiVector > getEpetra_MultiVector() const
RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_MultiVector() const
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const override
Exception throws to report errors in the internal logical of the program.
virtual void getLocalRowView(LocalOrdinal LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const =0
static Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > & Op2NonConstTpetraBlockCrs(Matrix &Op)
static Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & MV2NonConstTpetraMV(MultiVector &vec)
local_ordinal_type replaceLocalValues(const local_ordinal_type localRow, const Kokkos::View< const local_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals)
static const Epetra_Map & Map2EpetraMap(const Map &map)
void TokenizeStringAndStripWhiteSpace(const std::string &stream, std::vector< std::string > &tokenList, const char *delimChars)
static RCP< const Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2TpetraBlockCrs(RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> Op)
static void MyOldScaleMatrix(Matrix &Op, const Teuchos::ArrayRCP< const Scalar > &scalingVector, bool doInverse=true, bool doFillComplete=true, bool doOptimizeStorage=true)
static void MyOldScaleMatrix_Epetra(Matrix &Op, const Teuchos::ArrayRCP< Scalar > &scalingVector, bool, bool)
static void MyOldScaleMatrix_Tpetra(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const Teuchos::ArrayRCP< Scalar > &scalingVector, bool doFillComplete, bool doOptimizeStorage)
Teuchos::RCP< const Teuchos::Comm< int > > GenerateNodeComm(RCP< const Teuchos::Comm< int > > &baseComm, int &NodeId, const int reductionFactor)
RCP< Xpetra::MultiVector< SC, LO, GO, NO > > EpetraMultiVector_To_XpetraMultiVector(const Teuchos::RCP< Epetra_MultiVector > &V)
static const Epetra_CrsMatrix & Op2EpetraCrs(const Matrix &Op)
Teuchos::ScalarTraits< Scalar >::magnitudeType Magnitude
static RCP< const Epetra_CrsMatrix > Op2EpetraCrs(RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> Op)
static RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::magnitudeType, LocalOrdinal, GlobalOrdinal, Node > > ExtractCoordinatesFromParameterList(ParameterList ¶mList)
Extract coordinates from parameter list and return them in a Xpetra::MultiVector. ...
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
static RCP< Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraCrs(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> Op)
static RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > MV2NonConstTpetraMV(RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >> vec)
static RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &source, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
static RCP< Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraBlockCrs(RCP< Matrix > Op)
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)
Extract non-serializable data from level-specific sublists and move it to a separate parameter list...
Teuchos::RCP< const map_type > getRowMap() const override
static RCP< Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Op2NonConstTpetraCrs(RCP< Matrix > Op)