44 #ifdef HAVE_TPETRACORE_MPI
45 # include "Teuchos_DefaultMpiComm.hpp"
46 # include "Teuchos_DefaultSerialComm.hpp"
48 #endif // HAVE_TPETRACORE_MPI
53 #ifdef HAVE_TPETRACORE_MPI
55 extractMpiCommFromTeuchos (
const Teuchos::Comm<int>& comm)
57 using ::Teuchos::MpiComm;
58 using ::Teuchos::SerialComm;
60 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
61 if (mpiComm != NULL) {
62 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
66 const SerialComm<int>* serialComm =
67 dynamic_cast<const SerialComm<int>*
> (&comm);
68 if (serialComm != NULL) {
72 throw std::invalid_argument (
"Tpetra::Details::extractMpiCommFromTeuchos: "
73 "Input Teuchos::Comm is "
74 "neither a Teuchos::MpiComm, "
75 "nor a Teuchos::SerialComm. "
76 "As a result, I don't know "
77 "how to get the MPI_Comm out of it.");
81 #endif // HAVE_TPETRACORE_MPI
83 #ifdef HAVE_TPETRACORE_MPI
86 const Teuchos::MpiComm<int>* mpiComm =
87 dynamic_cast<const Teuchos::MpiComm<int>*
> (&comm);
88 return mpiComm !=
nullptr;
95 #endif // HAVE_TPETRACORE_MPI
bool teuchosCommIsAnMpiComm(const Teuchos::Comm< int > &)
Is the given Comm a Teuchos::MpiComm<int> instance?