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 {
27  using Tpetra::Details::extractMpiCommFromTeuchos;
28  // NOTE (mfh 11 Oct 2017) Tpetra or Teuchos may free this MPI_Comm
29  // before Epetra is done with it. To ensure that this doesn't
30  // happen, best practice is not to let the Epetra_Comm outlive the
31  // input teuchosComm.
32  MPI_Comm mpiComm = extractMpiCommFromTeuchos (teuchosComm);
33  Epetra_MpiComm* epetraComm = new Epetra_MpiComm (mpiComm);
34  return std::shared_ptr<Epetra_Comm> (static_cast<Epetra_Comm*> (epetraComm));
35 }
36 #else
37 std::shared_ptr<Epetra_Comm>
38 makeEpetraCommFromTeuchosComm (const Teuchos::Comm<int>&)
39 {
40  return std::shared_ptr<Epetra_Comm> (static_cast<Epetra_Comm*> (new Epetra_SerialComm));
41 }
42 #endif // HAVE_TPETRACORE_MPI
43 
44 } // namespace Details
45 } // namespace Tpetra
46 
47 #endif // defined(HAVE_TPETRA_EPETRA)
Declaration of Tpetra::Details::extractMpiCommFromTeuchos.