[Trilinos-Users] Teuchos MpiComm

Bartlett, Roscoe A. bartlettra at ornl.gov
Tue Dec 23 11:49:08 MST 2014


> > Teuchos::RCP<matrix_t> A...;
> >
> > //doesn't work:
> > Teuchos::RCP< const Teuchos::MpiComm< int > >  tr_comm = m_A-
> > >getComm();
> >
> > //works, but I don't have an MpiComm:
> > Teuchos::RCP< const Teuchos::Comm< int > >  tr_comm = m_A-
> >getComm();
> >
> > //fails because I don't have an MpiComm
> > Teuchos::RCP<const Teuchos::OpaqueWrapper<int> > cmm =
> > tr_comm->getRawMpiComm();
> 
> Teuchos::RCP<const Teuchos::OpaqueWrapper<int> >  cmm =
>    rcp_dynamic_cast<Teuchos::MpiComm<int> > (tr_comm, true)-
> >getRawMpiComm();

Forgot the const.

Teuchos::RCP<const Teuchos::OpaqueWrapper<int> >  cmm =
   rcp_dynamic_cast<const Teuchos::MpiComm<int> > (tr_comm, true)->getRawMpiComm();

NOTE: You should not need Teuchos:: before the rcp_dynamic_cast due to ADL.  The "true" is so that if the dynamic cast fails, you get a good error message and not just a null pointer.

-Ross




More information about the Trilinos-Users mailing list