Thyra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
adapters
tpetra
src
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
19
template
<
typename
InputOrdinalType,
typename
OutputOrdinalType>
20
Teuchos::RCP<const Teuchos::Comm<OutputOrdinalType>
>
21
convertCommunicatorType(
const
Teuchos::RCP
<
const
Teuchos::Comm<InputOrdinalType>
> &inputComm)
22
{
23
using
Teuchos::rcp_dynamic_cast;
24
25
#ifdef HAVE_MPI
26
const
Teuchos::RCP<const Teuchos::MpiComm<InputOrdinalType>
> inputMpiComm =
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
);
35
return
Teuchos::createSerialComm<OutputOrdinalType>();
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
43
Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal>
>
44
Thyra::convertTpetraToThyraComm
(
const
RCP
<
const
Teuchos::Comm<int>
> &tpetraComm)
45
{
46
return
convertCommunicatorType<int, Thyra::Ordinal>(tpetraComm);
47
}
48
49
Teuchos::RCP<const Teuchos::Comm<int>
>
50
Thyra::convertThyraToTpetraComm
(
const
RCP<
const
Teuchos::Comm<Thyra::Ordinal>
> &thyraComm)
51
{
52
return
convertCommunicatorType<Thyra::Ordinal, int>(thyraComm);
53
}
Teuchos_DefaultMpiComm.hpp
Teuchos::Comm
Teuchos::RCP
Teuchos::nonnull
bool nonnull(const std::shared_ptr< T > &p)
Thyra::convertThyraToTpetraComm
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.
Thyra::convertTpetraToThyraComm
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.
Definition
Thyra_TpetraThyraWrappers.cpp:44
Generated by
1.17.0