12 #ifdef HAVE_TPETRACORE_MPI
13 # include "Teuchos_DefaultMpiComm.hpp"
14 # include "Teuchos_DefaultSerialComm.hpp"
16 #endif // HAVE_TPETRACORE_MPI
21 #ifdef HAVE_TPETRACORE_MPI
23 extractMpiCommFromTeuchos (
const Teuchos::Comm<int>& comm)
25 using ::Teuchos::MpiComm;
26 using ::Teuchos::SerialComm;
28 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
29 if (mpiComm != NULL) {
30 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
34 const SerialComm<int>* serialComm =
35 dynamic_cast<const SerialComm<int>*
> (&comm);
36 if (serialComm != NULL) {
40 throw std::invalid_argument (
"Tpetra::Details::extractMpiCommFromTeuchos: "
41 "Input Teuchos::Comm is "
42 "neither a Teuchos::MpiComm, "
43 "nor a Teuchos::SerialComm. "
44 "As a result, I don't know "
45 "how to get the MPI_Comm out of it.");
49 #endif // HAVE_TPETRACORE_MPI
51 #ifdef HAVE_TPETRACORE_MPI
54 const Teuchos::MpiComm<int>* mpiComm =
55 dynamic_cast<const Teuchos::MpiComm<int>*
> (&comm);
56 return mpiComm !=
nullptr;
63 #endif // HAVE_TPETRACORE_MPI
bool teuchosCommIsAnMpiComm(const Teuchos::Comm< int > &)
Is the given Comm a Teuchos::MpiComm<int> instance?