Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_EpetraRowMatrix.cpp
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Tpetra_EpetraRowMatrix.hpp"
11 #if defined(HAVE_TPETRA_EPETRA)
12 
13 #ifdef HAVE_TPETRACORE_MPI
14 #include "Epetra_MpiComm.h"
16 #else
17 #include "Epetra_SerialComm.h"
18 #endif // HAVE_TPETRACORE_MPI
19 
20 namespace Tpetra {
21 namespace Details {
22 
23 #ifdef HAVE_TPETRACORE_MPI
24 std::shared_ptr<Epetra_Comm>
25 makeEpetraCommFromTeuchosComm(const Teuchos::Comm<int>& teuchosComm) {
26  using Tpetra::Details::extractMpiCommFromTeuchos;
27  // NOTE (mfh 11 Oct 2017) Tpetra or Teuchos may free this MPI_Comm
28  // before Epetra is done with it. To ensure that this doesn't
29  // happen, best practice is not to let the Epetra_Comm outlive the
30  // input teuchosComm.
31  MPI_Comm mpiComm = extractMpiCommFromTeuchos(teuchosComm);
32  Epetra_MpiComm* epetraComm = new Epetra_MpiComm(mpiComm);
33  return std::shared_ptr<Epetra_Comm>(static_cast<Epetra_Comm*>(epetraComm));
34 }
35 #else
36 std::shared_ptr<Epetra_Comm>
37 makeEpetraCommFromTeuchosComm(const Teuchos::Comm<int>&) {
38  return std::shared_ptr<Epetra_Comm>(static_cast<Epetra_Comm*>(new Epetra_SerialComm));
39 }
40 #endif // HAVE_TPETRACORE_MPI
41 
42 } // namespace Details
43 } // namespace Tpetra
44 
45 #endif // defined(HAVE_TPETRA_EPETRA)
Declaration of Tpetra::Details::extractMpiCommFromTeuchos.