10 #ifndef MUELU_UTILITIES_DECL_HPP
11 #define MUELU_UTILITIES_DECL_HPP
17 #include <Teuchos_DefaultComm.hpp>
21 #include <Xpetra_TpetraBlockCrsMatrix_fwd.hpp>
24 #include <Xpetra_CrsMatrixWrap.hpp>
35 #ifdef HAVE_MUELU_EPETRA
47 #ifdef HAVE_MUELU_EPETRAEXT
54 #include <Tpetra_CrsMatrix.hpp>
55 #include <Tpetra_BlockCrsMatrix.hpp>
56 #include <Tpetra_BlockCrsMatrix_Helpers.hpp>
57 #include <Tpetra_FECrsMatrix.hpp>
58 #include <Tpetra_RowMatrixTransposer.hpp>
59 #include <Tpetra_Map.hpp>
60 #include <Tpetra_MultiVector.hpp>
61 #include <Tpetra_FEMultiVector.hpp>
66 #include <MueLu_UtilitiesBase.hpp>
70 #ifdef HAVE_MUELU_EPETRA
72 template <
typename SC,
typename LO,
typename GO,
typename NO>
73 RCP<Xpetra::CrsMatrixWrap<SC, LO, GO, NO>>
76 template <
typename SC,
typename LO,
typename GO,
typename NO>
77 RCP<Xpetra::Matrix<SC, LO, GO, NO>>
80 template <
typename SC,
typename LO,
typename GO,
typename NO>
81 RCP<Xpetra::MultiVector<SC, LO, GO, NO>>
85 template <
typename SC,
typename LO,
typename GO,
typename NO>
86 RCP<Xpetra::Matrix<SC, LO, GO, NO>>
89 template <
typename SC,
typename LO,
typename GO,
typename NO>
90 RCP<Xpetra::Matrix<SC, LO, GO, NO>>
93 template <
typename SC,
typename LO,
typename GO,
typename NO>
94 RCP<Xpetra::MultiVector<SC, LO, GO, NO>>
97 template <
typename SC,
typename LO,
typename GO,
typename NO>
98 RCP<Xpetra::MultiVector<SC, LO, GO, NO>>
101 template <
typename SC,
typename LO,
typename GO,
typename NO>
104 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
120 class Utilities :
public UtilitiesBase<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
121 #undef MUELU_UTILITIES_SHORT
127 #ifdef HAVE_MUELU_EPETRA
172 bool doFillComplete =
true,
bool doOptimizeStorage =
true);
175 bool doFillComplete,
bool doOptimizeStorage);
177 bool doFillComplete,
bool doOptimizeStorage);
189 #ifdef HAVE_MUELU_EPETRA
207 #undef MUELU_UTILITIES_SHORT
219 if (tmpVec == Teuchos::null)
220 throw Exceptions::BadCast(
"Cast from Xpetra::MultiVector to Xpetra::EpetraMultiVector failed");
221 return tmpVec->getEpetra_MultiVector();
225 if (tmpVec == Teuchos::null)
226 throw Exceptions::BadCast(
"Cast from Xpetra::MultiVector to Xpetra::EpetraMultiVector failed");
227 return tmpVec->getEpetra_MultiVector();
241 if (crsOp == Teuchos::null)
244 if (tmp_ECrsMtx == Teuchos::null)
245 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
246 return tmp_ECrsMtx->getEpetra_CrsMatrix();
250 if (crsOp == Teuchos::null)
253 if (tmp_ECrsMtx == Teuchos::null)
254 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
255 return tmp_ECrsMtx->getEpetra_CrsMatrixNonConst();
260 const CrsMatrixWrap& crsOp =
dynamic_cast<const CrsMatrixWrap&
>(Op);
263 return *tmp_ECrsMtx.getEpetra_CrsMatrix();
264 }
catch (std::bad_cast&) {
265 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
267 }
catch (std::bad_cast&) {
273 CrsMatrixWrap& crsOp =
dynamic_cast<CrsMatrixWrap&
>(Op);
276 return *tmp_ECrsMtx.getEpetra_CrsMatrixNonConst();
277 }
catch (std::bad_cast&) {
278 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
280 }
catch (std::bad_cast&) {
287 if (xeMap == Teuchos::null)
288 throw Exceptions::BadCast(
"Utilities::Map2EpetraMap : Cast from Xpetra::Map to Xpetra::EpetraMap failed");
289 return xeMap->getEpetra_Map();
295 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
296 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
300 if (tmpVec == Teuchos::null)
301 throw Exceptions::BadCast(
"Cast from Xpetra::MultiVector to Xpetra::TpetraMultiVector failed");
302 return tmpVec->getTpetra_MultiVector();
306 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
307 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
311 if (tmpVec == Teuchos::null)
312 throw Exceptions::BadCast(
"Cast from Xpetra::MultiVector to Xpetra::TpetraMultiVector failed");
313 return tmpVec->getTpetra_MultiVector();
317 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
318 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
327 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
328 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
336 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
337 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
346 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
347 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
352 if (crsOp == Teuchos::null)
355 if (tmp_ECrsMtx == Teuchos::null)
356 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed");
357 return tmp_ECrsMtx->getTpetra_CrsMatrix();
361 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
362 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
366 if (crsOp == Teuchos::null)
369 if (tmp_ECrsMtx == Teuchos::null)
370 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed");
371 return tmp_ECrsMtx->getTpetra_CrsMatrixNonConst();
376 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
377 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
381 const CrsMatrixWrap& crsOp =
dynamic_cast<const CrsMatrixWrap&
>(Op);
385 }
catch (std::bad_cast&) {
386 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed");
388 }
catch (std::bad_cast&) {
394 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
395 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
399 CrsMatrixWrap& crsOp =
dynamic_cast<CrsMatrixWrap&
>(Op);
403 }
catch (std::bad_cast&) {
404 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix failed");
406 }
catch (std::bad_cast&) {
413 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
414 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
419 if (crsOp == Teuchos::null)
422 if (tmp_ECrsMtx == Teuchos::null)
423 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraBlockCrsMatrix failed");
424 return tmp_ECrsMtx->getTpetra_BlockCrsMatrix();
429 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
430 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
431 throw Exceptions::RuntimeError(
"Op2NonConstTpetraBlockCrs: Tpetra has not been compiled with support for LO=GO=int.");
434 if (crsOp == Teuchos::null)
437 if (tmp_ECrsMtx == Teuchos::null)
438 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraBlockCrsMatrix failed");
439 return tmp_ECrsMtx->getTpetra_BlockCrsMatrixNonConst();
444 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
445 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
449 const CrsMatrixWrap& crsOp =
dynamic_cast<const CrsMatrixWrap&
>(Op);
453 }
catch (std::bad_cast&) {
454 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraBlockCrsMatrix failed");
456 }
catch (std::bad_cast&) {
462 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
463 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
467 CrsMatrixWrap& crsOp =
dynamic_cast<CrsMatrixWrap&
>(Op);
471 }
catch (std::bad_cast&) {
472 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraBlockCrsMatrix failed");
474 }
catch (std::bad_cast&) {
481 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
482 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
489 if (crsOp == Teuchos::null)
496 return tmp_Crs->getTpetra_CrsMatrixNonConst();
499 if (tmp_BlockCrs.is_null())
500 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix and Xpetra::TpetraBlockCrsMatrix failed");
501 return tmp_BlockCrs->getTpetra_BlockCrsMatrixNonConst();
503 }
else if (!rmat.is_null()) {
504 return rmat->getTpetra_RowMatrix();
515 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
516 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
523 if (crsOp == Teuchos::null)
530 return tmp_Crs->getTpetra_CrsMatrixNonConst();
533 if (tmp_BlockCrs.is_null())
534 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::TpetraCrsMatrix and Xpetra::TpetraBlockCrsMatrix failed");
535 return tmp_BlockCrs->getTpetra_BlockCrsMatrixNonConst();
537 }
else if (!rmat.is_null()) {
538 return rmat->getTpetra_RowMatrixNonConst();
549 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
550 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
554 if (tmp_TMap == Teuchos::null)
555 throw Exceptions::BadCast(
"Utilities::Map2TpetraMap : Cast from Xpetra::Map to Xpetra::TpetraMap failed");
556 return tmp_TMap->getTpetra_Map();
561 bool doFillComplete =
true,
bool doOptimizeStorage =
true) {
565 for (
int i = 0; i < scalingVector.
size(); ++i)
566 sv[i] = one / scalingVector[i];
568 for (
int i = 0; i < scalingVector.
size(); ++i)
569 sv[i] = scalingVector[i];
572 switch (Op.getRowMap()->lib()) {
588 bool doFillComplete,
bool doOptimizeStorage) {
589 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
590 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
591 throw Exceptions::RuntimeError(
"Matrix scaling is not possible because Tpetra has not been compiled with support for LO=GO=int.");
601 if (maxRowSize == Teuchos::as<size_t>(-1))
604 std::vector<Scalar> scaledVals(maxRowSize);
608 if (Op.isLocallyIndexed() ==
true) {
611 for (
size_t i = 0; i < rowMap->getLocalNumElements(); ++i) {
614 if (nnz > maxRowSize) {
616 scaledVals.resize(maxRowSize);
618 for (
size_t j = 0; j < nnz; ++j)
619 scaledVals[j] = vals[j] * scalingVector[i];
632 for (
size_t i = 0; i < rowMap->getLocalNumElements(); ++i) {
636 if (nnz > maxRowSize) {
638 scaledVals.resize(maxRowSize);
641 for (
size_t j = 0; j < nnz; ++j)
642 scaledVals[j] = vals[j] * scalingVector[i];
652 if (doFillComplete) {
653 if (domainMap == Teuchos::null || rangeMap == Teuchos::null)
654 throw Exceptions::RuntimeError(
"In Utilities::Scaling: cannot fillComplete because the domain and/or range map hasn't been defined");
657 params->
set(
"Optimize Storage", doOptimizeStorage);
658 params->
set(
"No Nonlocal Changes",
true);
659 Op.fillComplete(Op.getDomainMap(), Op.getRangeMap(), params);
668 #ifdef HAVE_MUELU_EPETRA
680 for (
int j = 0; j < nnz; ++j)
681 vals[j] *= scalingVector[i];
689 #endif // HAVE_MUELU_EPETRA
698 switch (Op.getRowMap()->lib()) {
700 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
701 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
702 throw Exceptions::RuntimeError(
"Utilities::Transpose: Tpetra is not compiled with LO=GO=int. Add TPETRA_INST_INT_INT:BOOL=ON to your configuration!");
706 if (Helpers::isTpetraCrs(Op)) {
717 transposeParams->set(
"sort",
false);
725 if (Op.IsView(
"stridedMaps"))
726 AAAA->CreateView(
"stridedMaps", Teuchos::rcpFromRef(Op),
true );
731 else if (Helpers::isTpetraBlockCrs(Op)) {
742 transposeParams->set(
"sort",
false);
750 if (Op.IsView(
"stridedMaps"))
751 AAAA->CreateView(
"stridedMaps", Teuchos::rcpFromRef(Op),
true );
758 throw Exceptions::RuntimeError(
"Utilities::Transpose failed, perhaps because matrix is not a Crs or BlockCrs matrix");
763 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_EPETRAEXT)
776 if (Op.IsView(
"stridedMaps"))
777 AAAA->CreateView(
"stridedMaps", Teuchos::rcpFromRef(Op),
true );
806 #if (defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT)) || \
807 (!defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT))
812 #if !defined(HAVE_TPETRA_EXPLICIT_INSTANTIATION) || defined(HAVE_TPETRA_INST_FLOAT)
825 paramList.
remove(
"Coordinates");
827 #if !defined(HAVE_TPETRA_EXPLICIT_INSTANTIATION) || defined(HAVE_TPETRA_INST_FLOAT)
831 paramList.
remove(
"Coordinates");
832 doubleCoords =
rcp(
new tdMV(floatCoords->getMap(), floatCoords->getNumVectors()));
837 if (doubleCoords != Teuchos::null) {
841 #endif // Tpetra instantiated on GO=int and EpetraNode
843 #if defined(HAVE_MUELU_EPETRA)
847 paramList.
remove(
"Coordinates");
855 if (paramList.
isType<decltype(coordinates)>(
"Coordinates")) {
856 coordinates = paramList.
get<decltype(coordinates)>(
"Coordinates");
865 #endif // HAVE_MUELU_EPETRA
911 #ifdef HAVE_MUELU_EPETRA
916 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
917 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
924 return rcp(
new XCrsMatrixWrap(Atmp));
931 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
932 RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
942 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
943 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
950 return rcp(
new XCrsMatrixWrap(Atmp));
980 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
982 LocalOrdinal nBlks = (Amat.getRowMap()->getLocalNumElements()) / blkSize;
987 for (
size_t i = 0; i < blkSize; i++) rowScaling[i] = 1.0;
988 for (
size_t i = 0; i < blkSize; i++) colScaling[i] = 1.0;
990 for (
size_t k = 0; k < nSweeps; k++) {
992 for (
size_t i = 0; i < blkSize; i++) rowScaleUpdate[i] = 0.0;
995 for (
size_t j = 0; j < blkSize; j++) {
1000 for (
size_t kk = 0; kk < Teuchos::as<size_t>(vals.
size()); kk++) {
1001 size_t modGuy = (cols[kk] + 1) % blkSize;
1002 if (modGuy == 0) modGuy = blkSize;
1012 for (
size_t i = 0; i < blkSize; i++) rowScaleUpdate[i] = tempUpdate[i];
1020 for (
size_t i = 1; i < blkSize; i++) {
1021 Scalar temp = (rowScaleUpdate[i] / rowScaling[i]) / rowScaling[i];
1025 for (
size_t i = 0; i < blkSize; i++) rowScaling[i] *= sqrt(minUpdate / rowScaleUpdate[i]);
1028 for (
size_t i = 0; i < blkSize; i++) colScaleUpdate[i] = 0.0;
1031 for (
size_t j = 0; j < blkSize; j++) {
1035 for (
size_t kk = 0; kk < Teuchos::as<size_t>(vals.
size()); kk++) {
1036 size_t modGuy = (cols[kk] + 1) % blkSize;
1037 if (modGuy == 0) modGuy = blkSize;
1045 for (
size_t i = 0; i < blkSize; i++) colScaleUpdate[i] = tempUpdate[i];
1053 for (
size_t i = 1; i < blkSize; i++) {
1054 Scalar temp = (colScaleUpdate[i] / colScaling[i]) / colScaling[i];
1058 for (
size_t i = 0; i < blkSize; i++) colScaling[i] *= sqrt(minUpdate / colScaleUpdate[i]);
1066 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1067 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1074 RCP<XCrsMatrix> Atmp =
rcp(
new XTCrsMatrix(rcp_dynamic_cast<tpetra_crs_matrix_type>(Atpetra)));
1075 return rcp(
new XCrsMatrixWrap(Atmp));
1082 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1083 RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1092 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1093 RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1096 RCP<const MV> Vmv = Teuchos::rcp_dynamic_cast<
const MV>(Vtpetra);
1103 std::ostringstream buf;
1108 #ifdef HAVE_MUELU_EPETRA
1113 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1114 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1121 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1122 RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1130 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1131 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1138 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1139 RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
1146 std::string
lowerCase(
const std::string& s);
1148 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1161 toggleVec->putScalar(1);
1167 std::vector<GO> finalDropMapEntries = {};
1168 auto finalVec_h_2D = finalVec->getHostLocalView(Xpetra::Access::ReadOnly);
1169 auto finalVec_h_1D = Kokkos::subview(finalVec_h_2D, Kokkos::ALL(), 0);
1170 const size_t localLength = finalVec->getLocalLength();
1172 for (
size_t k = 0; k < localLength; ++k) {
1174 finalDropMapEntries.push_back(finalVec->getMap()->getGlobalElement(k));
1180 return finalDropMap;
1185 #define MUELU_UTILITIES_SHORT
1186 #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)
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.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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)