48 #ifdef HAVE_XPETRA_EPETRA
55 #include <Teuchos_DefaultMpiComm.hpp>
56 #include <Teuchos_OpaqueWrapper.hpp>
58 #include <Teuchos_DefaultSerialComm.hpp>
60 #include <Epetra_MpiComm.h>
62 #include <Epetra_SerialComm.h>
71 const RCP<const Epetra_Comm>
toEpetra(
const RCP<
const Teuchos::Comm<int> > & comm) {
73 const RCP<const Teuchos::MpiComm<int> > mpiComm = Teuchos::rcp_dynamic_cast<
const Teuchos::MpiComm<int> >(comm);
74 if (mpiComm != Teuchos::null) {
75 return Teuchos::rcp(
new Epetra_MpiComm(*mpiComm->getRawMpiComm()));
78 if ((Teuchos::rcp_dynamic_cast<
const Teuchos::SerialComm<int> >(comm) != Teuchos::null))
79 return Teuchos::rcp(
new Epetra_SerialComm());
81 TEUCHOS_TEST_FOR_EXCEPTION(1,
Xpetra::Exceptions::BadCast,
"Cannot convert a Teuchos::Comm to an Epetra_Comm: The exact type of the Teuchos::Comm object is unknown");
84 const RCP<const Teuchos::Comm<int> >
toXpetra(
const Epetra_Comm & comm) {
87 const Epetra_MpiComm& mpiComm =
dynamic_cast<const Epetra_MpiComm&
>(comm);
90 const int MAGIC_TAG = 26077;
91 return Teuchos::rcp(
new Teuchos::MpiComm<int>(Teuchos::opaqueWrapper(mpiComm.Comm()), MAGIC_TAG));
92 }
catch (std::bad_cast & ) {}
95 const Epetra_SerialComm& serialComm =
dynamic_cast<const Epetra_SerialComm&
>(comm);
97 return Teuchos::rcp(
new Teuchos::SerialComm<int>());
98 }
catch (std::bad_cast & ) {
99 TEUCHOS_TEST_FOR_EXCEPTION(1,
Xpetra::Exceptions::BadCast,
"Cannot convert an Epetra_Comm to a Teuchos::Comm: The exact type of the Epetra_Comm object is unknown");
104 if (trans == Teuchos::NO_TRANS)
106 else if (trans == Teuchos::TRANS)
109 TEUCHOS_TEST_FOR_EXCEPTION((trans != Teuchos::NO_TRANS) && (trans == Teuchos::TRANS),
Xpetra::Exceptions::NotImplemented,
"Cannot convert Teuchos::ETransp to a boolean.");
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
Exception indicating invalid cast attempted.
Exception throws when you call an unimplemented method of Xpetra.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)