12 #ifdef HAVE_XPETRA_EPETRA
19 #include <Teuchos_DefaultMpiComm.hpp>
20 #include <Teuchos_OpaqueWrapper.hpp>
22 #include <Teuchos_DefaultSerialComm.hpp>
24 #include <Epetra_MpiComm.h>
26 #include <Epetra_SerialComm.h>
34 const RCP<const Epetra_Comm>
toEpetra(
const RCP<
const Teuchos::Comm<int> >& comm) {
36 const RCP<const Teuchos::MpiComm<int> > mpiComm = Teuchos::rcp_dynamic_cast<
const Teuchos::MpiComm<int> >(comm);
37 if (mpiComm != Teuchos::null) {
38 return Teuchos::rcp(
new Epetra_MpiComm(*mpiComm->getRawMpiComm()));
41 if ((Teuchos::rcp_dynamic_cast<
const Teuchos::SerialComm<int> >(comm) != Teuchos::null))
42 return Teuchos::rcp(
new Epetra_SerialComm());
44 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");
47 const RCP<const Teuchos::Comm<int> >
toXpetra(
const Epetra_Comm& comm) {
50 const Epetra_MpiComm& mpiComm =
dynamic_cast<const Epetra_MpiComm&
>(comm);
53 const int MAGIC_TAG = 26077;
54 return Teuchos::rcp(
new Teuchos::MpiComm<int>(Teuchos::opaqueWrapper(mpiComm.Comm()), MAGIC_TAG));
55 }
catch (std::bad_cast& ) {
59 const Epetra_SerialComm& serialComm =
dynamic_cast<const Epetra_SerialComm&
>(comm);
61 return Teuchos::rcp(
new Teuchos::SerialComm<int>());
62 }
catch (std::bad_cast& ) {
63 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");
68 if (trans == Teuchos::NO_TRANS)
70 else if (trans == Teuchos::TRANS)
73 TEUCHOS_TEST_FOR_EXCEPTION((trans != Teuchos::NO_TRANS) && (trans == Teuchos::TRANS),
Xpetra::Exceptions::NotImplemented,
"Cannot convert Teuchos::ETransp to a boolean.");
Exception indicating invalid cast attempted.
Exception throws when you call an unimplemented method of Xpetra.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)