Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_TpetraThyraWrappers.cpp
1// @HEADER
2// *****************************************************************************
3// Thyra: Interfaces and Support for Abstract Numerical Algorithms
4//
5// Copyright 2004 NTESS and the Thyra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10//#include "Thyra_TpetraThyraWrappers.hpp"
11#include "Thyra_TpetraThyraWrappers_decl.hpp"
12
13
14#include "Teuchos_DefaultSerialComm.hpp"
15#ifdef HAVE_MPI
16# include "Teuchos_DefaultMpiComm.hpp"
17#endif
18
19template<typename InputOrdinalType, typename OutputOrdinalType>
21convertCommunicatorType(const Teuchos::RCP<const Teuchos::Comm<InputOrdinalType> > &inputComm)
22{
23 using Teuchos::rcp_dynamic_cast;
24
25#ifdef HAVE_MPI
27 rcp_dynamic_cast<const Teuchos::MpiComm<InputOrdinalType> >(inputComm);
28 if (Teuchos::nonnull(inputMpiComm)) {
29 return Teuchos::createMpiComm<OutputOrdinalType>(inputMpiComm->getRawMpiComm(),inputMpiComm->getTag());
30 }
31#endif // HAVE_MPI
32
33 // Assert conversion to Teuchos::SerialComm as a last resort (or throw)
34 rcp_dynamic_cast<const Teuchos::SerialComm<InputOrdinalType> >(inputComm, true);
36
37 // NOTE: Above will throw if the type is not Teuchos::SerialComm. In this
38 // case, the type could not be converted. We need to either get rid of the
39 // Ordinal templating on Comm or we need to use the same ordinal type for
40 // Tpetra and Thyra so this conversion function goes away!
41}
42
45{
46 return convertCommunicatorType<int, Thyra::Ordinal>(tpetraComm);
47}
48
51{
52 return convertCommunicatorType<Thyra::Ordinal, int>(thyraComm);
53}
bool nonnull(const std::shared_ptr< T > &p)
RCP< const Teuchos::Comm< int > > convertThyraToTpetraComm(const RCP< const Teuchos::Comm< Ordinal > > &thyraComm)
Given an Tpetra Teuchos::Comm<Ordinal> object, return an equivalent Teuchos::Comm<int> object.
RCP< const Teuchos::Comm< Ordinal > > convertTpetraToThyraComm(const RCP< const Teuchos::Comm< int > > &tpetraComm)
Given an Tpetra Teuchos::Comm<int> object, return an equivalent Teuchos::Comm<Ordinal> object.
T_To & dyn_cast(T_From &from)