55 #include "TpetraCore_config.h"
57 #if defined(HAVE_TPETRA_EPETRA) && defined(HAVE_TPETRA_TSQR)
60 #include <Epetra_ConfigDefs.h>
61 #include <Teuchos_ConfigDefs.hpp>
64 #if defined(EPETRA_MPI) && ! defined(HAVE_TEUCHOS_MPI)
65 # error "The Epetra package defines EPETRA_MPI, but the Teuchos package does NOT define HAVE_TEUCHOS_MPI. This means that one package thinks MPI exists, but the other package doesn't. This may indicate that Trilinos was not configured correctly. We can't continue building Trilinos in this case."
66 #elif ! defined(EPETRA_MPI) && defined(HAVE_TEUCHOS_MPI)
67 # error "The Epetra package does not define EPETRA_MPI, but the Teuchos package DOES define HAVE_TEUCHOS_MPI. This means that one package thinks MPI exists, but the other package doesn't. This may indicate that Trilinos was not configured correctly. We can't continue building Trilinos in this case."
72 # include <Epetra_MpiComm.h>
74 #include <Epetra_SerialComm.h>
77 #ifdef HAVE_TEUCHOS_MPI
78 # include <Teuchos_DefaultMpiComm.hpp>
79 #endif // HAVE_TEUCHOS_MPI
80 #include <Teuchos_DefaultSerialComm.hpp>
86 Teuchos::RCP<const Teuchos::Comm<int> >
87 extractTeuchosComm (
const Teuchos::RCP<const Epetra_Comm>& epetraComm)
91 using Teuchos::rcp_dynamic_cast;
92 using Teuchos::rcp_implicit_cast;
95 RCP<const Epetra_MpiComm> epetraMpiComm =
96 rcp_dynamic_cast<
const Epetra_MpiComm> (epetraComm,
false);
97 if (! epetraMpiComm.is_null ()) {
101 MPI_Comm rawMpiComm = epetraMpiComm->Comm ();
102 RCP<const Teuchos::MpiComm<int> > teuchosMpiComm =
103 rcp (
new Teuchos::MpiComm<int> (rawMpiComm));
104 return rcp_implicit_cast<
const Teuchos::Comm<int> > (teuchosMpiComm);
108 RCP<const Epetra_SerialComm> epetraSerialComm =
109 rcp_dynamic_cast<
const Epetra_SerialComm> (epetraComm,
false);
110 if (! epetraSerialComm.is_null ()) {
111 RCP<const Teuchos::SerialComm<int> > teuchosSerialComm =
112 rcp (
new Teuchos::SerialComm<int> ());
113 return rcp_implicit_cast<
const Teuchos::Comm<int> > (teuchosSerialComm);
116 TEUCHOS_TEST_FOR_EXCEPTION(
117 true, std::invalid_argument,
"The input Epetra_Comm object is neither "
118 "an Epetra_MpiComm nor an Epetra_SerialComm. This means that we don't"
119 " know how to convert it into a Teuchos::Comm<int> instance. You are "
120 "probably seeing this error message as a result of trying to invoke "
121 "TSQR (the Tall Skinny QR factorization) on an Epetra_MultiVector, "
122 "probably as a block orthogonalization method in either Anasazi or "
123 "Belos. TSQR currently only works on an Epetra_MultiVector if the "
124 "latter's communicator is either an Epetra_MpiComm (wraps MPI) or an "
125 "Epetra_SerialComm (\"stub\" communicator for a single process without "
131 #endif // defined(HAVE_TPETRA_EPETRA) && defined(HAVE_TPETRA_TSQR)
Function for wrapping Epetra_Comm in a communicator wrapper that TSQR can use.