47 #ifndef XPETRA_THYRAUTILS_HPP 48 #define XPETRA_THYRAUTILS_HPP 50 #ifdef HAVE_XPETRA_THYRA 54 #ifdef HAVE_XPETRA_TPETRA 55 #include "Tpetra_ConfigDefs.hpp" 58 #ifdef HAVE_XPETRA_EPETRA 59 #include "Epetra_CombineMode.h" 67 #include <Thyra_VectorSpaceBase.hpp> 68 #include <Thyra_ProductVectorSpaceBase.hpp> 69 #include <Thyra_VectorSpaceBase.hpp> 70 #include <Thyra_DefaultBlockedLinearOp.hpp> 73 #ifdef HAVE_XPETRA_TPETRA 75 #include <Thyra_TpetraThyraWrappers.hpp> 76 #include <Thyra_TpetraVector.hpp> 77 #include <Tpetra_Map.hpp> 78 #include <Tpetra_Vector.hpp> 79 #include <Tpetra_CrsMatrix.hpp> 83 #ifdef HAVE_XPETRA_EPETRA 84 #include <Thyra_EpetraLinearOp.hpp> 85 #include <Thyra_EpetraThyraWrappers.hpp> 86 #include <Thyra_SpmdVectorBase.hpp> 87 #include <Thyra_get_Epetra_Operator.hpp> 88 #include <Epetra_Map.h> 89 #include <Epetra_Vector.h> 90 #include <Epetra_CrsMatrix.h> 97 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
class BlockedCrsMatrix;
99 template <
class Scalar,
100 class LocalOrdinal = int,
101 class GlobalOrdinal = LocalOrdinal,
106 #undef XPETRA_THYRAUTILS_SHORT 116 if(stridedBlockId == -1) {
131 bool bIsTpetra =
false;
132 #ifdef HAVE_XPETRA_TPETRA 138 bool bIsEpetra = !bIsTpetra;
140 #ifdef HAVE_XPETRA_TPETRA 142 typedef Thyra::TpetraOperatorVectorExtraction<Scalar,LocalOrdinal,GlobalOrdinal,Node> TOE;
157 #ifdef HAVE_XPETRA_EPETRA 176 return Teuchos::null;
179 static bool isTpetra(
const Teuchos::RCP<
const Thyra::LinearOpBase<Scalar> > & op){
181 bool bIsTpetra =
false;
182 #ifdef HAVE_XPETRA_TPETRA 189 static bool isEpetra(
const Teuchos::RCP<
const Thyra::LinearOpBase<Scalar> > & op){
191 bool bIsEpetra =
false;
192 #ifdef HAVE_XPETRA_EPETRA 202 #ifdef HAVE_XPETRA_TPETRA 204 typedef Thyra::TpetraOperatorVectorExtraction<Scalar,LocalOrdinal,GlobalOrdinal,Node> TOE;
226 #ifdef HAVE_XPETRA_EPETRA 247 return Teuchos::null;
253 #ifdef HAVE_XPETRA_TPETRA 255 typedef Thyra::TpetraOperatorVectorExtraction<Scalar,LocalOrdinal,GlobalOrdinal,Node> TOE;
266 return xTpetraCrsMat;
270 #ifdef HAVE_XPETRA_EPETRA 282 return xEpetraCrsMat;
285 return Teuchos::null;
293 #ifdef HAVE_XPETRA_TPETRA 295 if(tpetraMat!=Teuchos::null) {
306 thyraOp = Thyra::createConstLinearOp(tpOperator);
311 #ifdef HAVE_XPETRA_EPETRA 313 if(epetraMat!=Teuchos::null) {
332 #ifdef HAVE_XPETRA_TPETRA 334 if(tpetraMat!=Teuchos::null) {
345 thyraOp = Thyra::createLinearOp(tpOperator);
350 #ifdef HAVE_XPETRA_EPETRA 352 if(epetraMat!=Teuchos::null) {
369 int nRows = mat->Rows();
370 int nCols = mat->Cols();
374 bool bTpetra =
false;
375 bool bEpetra =
false;
376 #ifdef HAVE_XPETRA_TPETRA 378 if(tpetraMat!=Teuchos::null) bTpetra =
true;
381 #ifdef HAVE_XPETRA_EPETRA 383 if(epetraMat!=Teuchos::null) bEpetra =
true;
390 Thyra::defaultBlockedLinearOp<Scalar>();
392 blockMat->beginBlockFill(nRows,nCols);
394 for (
int r=0; r<nRows; ++r) {
395 for (
int c=0; c<nCols; ++c) {
397 Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::toThyra(mat->getMatrix(r,c));
398 std::stringstream label; label <<
"A" << r << c;
399 blockMat->setBlock(r,c,thBlock);
403 blockMat->endBlockFill();
412 #define XPETRA_THYRAUTILS_SHORT 413 #endif // HAVE_XPETRA_THYRA 415 #endif // XPETRA_THYRAUTILS_HPP const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal > > &graph)
bool is_null(const std::shared_ptr< T > &p)
RCP< const CrsGraph< int, GlobalOrdinal > > toXpetra(const Epetra_CrsGraph &g)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static RCP< StridedMap > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, std::vector< size_t > &stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0, LocalGlobal lg=Xpetra::GloballyDistributed, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with Xpetra-defined contiguous uniform distribution.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
const RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > toXpetraNonConst(const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &)
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)