49 #ifdef HAVE_XPETRA_THYRA
57 #ifdef HAVE_XPETRA_EPETRA
59 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
62 Teuchos::RCP<Thyra::LinearOpBase<double>>
64 int nRows = mat->Rows();
65 int nCols = mat->Cols();
67 Teuchos::RCP<Xpetra::Matrix<double, int, int, EpetraNode>> Ablock = mat->getInnermostCrsMatrix();
69 TEUCHOS_TEST_FOR_EXCEPT(Ablock_wrap.is_null() ==
true);
73 #ifdef HAVE_XPETRA_TPETRA
75 #if ((defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT) && defined(HAVE_TPETRA_INST_DOUBLE)) || \
76 (!defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT) && defined(HAVE_TPETRA_INST_DOUBLE)))
78 if (tpetraMat != Teuchos::null) bTpetra =
true;
84 #ifdef HAVE_XPETRA_EPETRA
86 if (epetraMat != Teuchos::null) bEpetra =
true;
89 TEUCHOS_TEST_FOR_EXCEPT(bTpetra == bEpetra);
92 Teuchos::RCP<Thyra::PhysicallyBlockedLinearOpBase<Scalar>> blockMat =
93 Thyra::defaultBlockedLinearOp<Scalar>();
95 blockMat->beginBlockFill(nRows, nCols);
97 for (
int r = 0; r < nRows; ++r) {
98 for (
int c = 0; c < nCols; ++c) {
99 Teuchos::RCP<Matrix> xpmat = mat->getMatrix(r, c);
101 if (xpmat == Teuchos::null)
continue;
103 Teuchos::RCP<Thyra::LinearOpBase<Scalar>> thBlock = Teuchos::null;
106 Teuchos::RCP<BlockedCrsMatrix> xpblock = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(xpmat);
107 if (xpblock != Teuchos::null) {
108 if (xpblock->Rows() == 1 && xpblock->Cols() == 1) {
110 Teuchos::RCP<CrsMatrixWrap> xpwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(xpblock->getCrsMatrix());
111 TEUCHOS_TEST_FOR_EXCEPT(xpwrap.is_null() ==
true);
112 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpwrap->getCrsMatrix());
115 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpblock);
119 Teuchos::RCP<CrsMatrixWrap> xpwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(xpmat);
120 TEUCHOS_TEST_FOR_EXCEPT(xpwrap.is_null() ==
true);
121 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpwrap->getCrsMatrix());
124 blockMat->setBlock(r, c, thBlock);
128 blockMat->endBlockFill();
132 #endif //#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
134 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
137 Teuchos::RCP<Thyra::LinearOpBase<double>>
139 int nRows = mat->Rows();
140 int nCols = mat->Cols();
142 Teuchos::RCP<Xpetra::Matrix<double, int, long long, EpetraNode>> Ablock = mat->getInnermostCrsMatrix();
144 TEUCHOS_TEST_FOR_EXCEPT(Ablock_wrap.is_null() ==
true);
146 bool bTpetra =
false;
147 bool bEpetra =
false;
148 #ifdef HAVE_XPETRA_TPETRA
150 #if ((defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG) && defined(HAVE_TPETRA_INST_DOUBLE)) || \
151 (!defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG) && defined(HAVE_TPETRA_INST_DOUBLE)))
153 if (tpetraMat != Teuchos::null) bTpetra =
true;
159 #ifdef HAVE_XPETRA_EPETRA
161 if (epetraMat != Teuchos::null) bEpetra =
true;
164 TEUCHOS_TEST_FOR_EXCEPT(bTpetra == bEpetra);
167 Teuchos::RCP<Thyra::PhysicallyBlockedLinearOpBase<Scalar>> blockMat =
168 Thyra::defaultBlockedLinearOp<Scalar>();
170 blockMat->beginBlockFill(nRows, nCols);
172 for (
int r = 0; r < nRows; ++r) {
173 for (
int c = 0; c < nCols; ++c) {
174 Teuchos::RCP<Matrix> xpmat = mat->getMatrix(r, c);
176 if (xpmat == Teuchos::null)
continue;
178 Teuchos::RCP<Thyra::LinearOpBase<Scalar>> thBlock = Teuchos::null;
181 Teuchos::RCP<BlockedCrsMatrix> xpblock = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(xpmat);
182 if (xpblock != Teuchos::null) {
183 if (xpblock->Rows() == 1 && xpblock->Cols() == 1) {
185 Teuchos::RCP<CrsMatrixWrap> xpwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(xpblock->getCrsMatrix());
186 TEUCHOS_TEST_FOR_EXCEPT(xpwrap.is_null() ==
true);
187 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpwrap->getCrsMatrix());
190 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpblock);
194 Teuchos::RCP<CrsMatrixWrap> xpwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(xpmat);
195 TEUCHOS_TEST_FOR_EXCEPT(xpwrap.is_null() ==
true);
196 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpwrap->getCrsMatrix());
199 blockMat->setBlock(r, c, thBlock);
203 blockMat->endBlockFill();
207 #endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
213 #endif // HAVE_XPETRA_THYRA
Concrete implementation of Xpetra::Matrix.