12 #ifndef XPETRA_MATRIXFACTORY2_DECL_HPP
13 #define XPETRA_MATRIXFACTORY2_DECL_HPP
17 #include "Xpetra_Matrix.hpp"
18 #include "Xpetra_CrsMatrixWrap.hpp"
20 #include "Xpetra_Map.hpp"
21 #include "Xpetra_BlockedMap.hpp"
23 #include "Xpetra_BlockedVector.hpp"
28 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
30 #undef XPETRA_MATRIXFACTORY2_SHORT
36 #define XPETRA_MATRIXFACTORY2_SHORT
46 #undef XPETRA_MATRIXFACTORY2_SHORT
50 RCP<const CrsMatrixWrap> oldOp = Teuchos::rcp_dynamic_cast<
const CrsMatrixWrap>(A);
51 if (oldOp == Teuchos::null)
54 RCP<const CrsMatrix> oldCrsOp = oldOp->getCrsMatrix();
56 #ifdef HAVE_XPETRA_EPETRA
57 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
59 if (oldECrsOp != Teuchos::null) {
63 if (setFixedBlockSize)
64 newOp->SetFixedBlockSize(A->GetFixedBlockSize());
70 #ifdef HAVE_XPETRA_TPETRA
72 RCP<const TpetraCrsMatrix> oldTCrsOp = Teuchos::rcp_dynamic_cast<
const TpetraCrsMatrix>(oldCrsOp);
73 if (oldTCrsOp != Teuchos::null) {
76 if (setFixedBlockSize)
77 newOp->SetFixedBlockSize(A->GetFixedBlockSize());
82 throw Exceptions::BadCast(
"Cast from Xpetra::Matrix to Xpetra::EpetraCrsMatrix or Xpetra::TpetraCrsMatrix failed");
83 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
89 #define XPETRA_MATRIXFACTORY2_SHORT
91 #ifdef HAVE_XPETRA_INT_LONG_LONG
93 class MatrixFactory2<double, int, long long, Node> {
94 typedef double Scalar;
95 typedef int LocalOrdinal;
96 typedef long long GlobalOrdinal;
98 #undef XPETRA_MATRIXFACTORY2_SHORT
102 RCP<const CrsMatrixWrap> oldOp = Teuchos::rcp_dynamic_cast<
const CrsMatrixWrap>(A);
103 if (oldOp == Teuchos::null)
104 throw Exceptions::BadCast(
"Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
106 RCP<const CrsMatrix> oldCrsOp = oldOp->getCrsMatrix();
108 #ifdef HAVE_XPETRA_EPETRA
109 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
110 RCP<const EpetraCrsMatrixT<GlobalOrdinal, Node> > oldECrsOp = Teuchos::rcp_dynamic_cast<
const EpetraCrsMatrixT<GlobalOrdinal, Node> >(oldCrsOp);
111 if (oldECrsOp != Teuchos::null) {
113 RCP<CrsMatrix> newECrsOp(
new EpetraCrsMatrixT<GlobalOrdinal, Node>(*oldECrsOp));
114 RCP<CrsMatrixWrap> newOp(
new CrsMatrixWrap(newECrsOp));
115 if (setFixedBlockSize)
116 newOp->SetFixedBlockSize(A->GetFixedBlockSize());
122 #ifdef HAVE_XPETRA_TPETRA
124 RCP<const TpetraCrsMatrix> oldTCrsOp = Teuchos::rcp_dynamic_cast<
const TpetraCrsMatrix>(oldCrsOp);
125 if (oldTCrsOp != Teuchos::null) {
126 RCP<CrsMatrix> newTCrsOp(
new TpetraCrsMatrix(*oldTCrsOp));
127 RCP<CrsMatrixWrap> newOp(
new CrsMatrixWrap(newTCrsOp));
128 if (setFixedBlockSize)
129 newOp->SetFixedBlockSize(A->GetFixedBlockSize());
133 throw Exceptions::BadCast(
"Cast from Xpetra::Matrix to Xpetra::EpetraCrsMatrix or Xpetra::TpetraCrsMatrix failed");
136 return Teuchos::null;
139 #endif // HAVE_XPETRA_INT_LONG_LONG
141 #define XPETRA_MATRIXFACTORY2_SHORT
145 #define XPETRA_MATRIXFACTORY2_SHORT
147 #endif // ifndef XPETRA_MATRIXFACTORY2_DECL_HPP
Exception indicating invalid cast attempted.
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A, bool setFixedBlockSize=true)
Concrete implementation of Xpetra::Matrix.
static RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > BuildCopy(const RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > A, bool setFixedBlockSize=true)
Xpetra-specific matrix class.