Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
trilinos_tpetra_communication_pattern.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2018 - 2019 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
17 
19 
20 #ifdef DEAL_II_TRILINOS_WITH_TPETRA
21 
22 # ifdef DEAL_II_WITH_MPI
23 
24 # include <deal.II/base/index_set.h>
25 
26 # include <Tpetra_Map.hpp>
27 
28 # include <memory>
29 
31 
32 namespace LinearAlgebra
33 {
34  namespace TpetraWrappers
35  {
37  const IndexSet &vector_space_vector_index_set,
38  const IndexSet &read_write_vector_index_set,
39  const MPI_Comm &communicator)
40  {
41  // virtual functions called in constructors and destructors never use the
42  // override in a derived class
43  // for clarity be explicit on which function is called
44  CommunicationPattern::reinit(vector_space_vector_index_set,
45  read_write_vector_index_set,
46  communicator);
47  }
48 
49 
50 
51  void
52  CommunicationPattern::reinit(const IndexSet &vector_space_vector_index_set,
53  const IndexSet &read_write_vector_index_set,
54  const MPI_Comm &communicator)
55  {
56  comm = std::make_shared<const MPI_Comm>(communicator);
57 
58  auto vector_space_vector_map =
59  Teuchos::rcp(new Tpetra::Map<int, types::global_dof_index>(
60  vector_space_vector_index_set.make_tpetra_map(*comm, false)));
61  auto read_write_vector_map =
62  Teuchos::rcp(new Tpetra::Map<int, types::global_dof_index>(
63  read_write_vector_index_set.make_tpetra_map(*comm, true)));
64 
65  // Target map is read_write_vector_map
66  // Source map is vector_space_vector_map. This map must have uniquely
67  // owned GID.
69  std_cxx14::make_unique<Tpetra::Import<int, types::global_dof_index>>(
70  read_write_vector_map, vector_space_vector_map);
72  std_cxx14::make_unique<Tpetra::Export<int, types::global_dof_index>>(
73  read_write_vector_map, vector_space_vector_map);
74  }
75 
76 
77 
78  const MPI_Comm &
80  {
81  return *comm;
82  }
83 
84 
85 
86  const Tpetra::Import<int, types::global_dof_index> &
88  {
89  return *tpetra_import;
90  }
91 
92 
93 
94  const Tpetra::Export<int, types::global_dof_index> &
96  {
97  return *tpetra_export;
98  }
99  } // namespace TpetraWrappers
100 } // namespace LinearAlgebra
101 
103 
104 # endif
105 
106 #endif
IndexSet
Definition: index_set.h:74
LinearAlgebra
Definition: communication_pattern_base.h:30
LinearAlgebra::TpetraWrappers::CommunicationPattern::get_tpetra_import
const Tpetra::Import< int, types::global_dof_index > & get_tpetra_import() const
Definition: trilinos_tpetra_communication_pattern.cc:87
LinearAlgebra::TpetraWrappers::CommunicationPattern::get_tpetra_export
const Tpetra::Export< int, types::global_dof_index > & get_tpetra_export() const
Definition: trilinos_tpetra_communication_pattern.cc:95
MPI_Comm
LinearAlgebra::TpetraWrappers::CommunicationPattern::tpetra_import
std::unique_ptr< Tpetra::Import< int, types::global_dof_index > > tpetra_import
Definition: trilinos_tpetra_communication_pattern.h:90
LinearAlgebra::TpetraWrappers::CommunicationPattern::reinit
virtual void reinit(const IndexSet &vector_space_vector_index_set, const IndexSet &read_write_vector_index_set, const MPI_Comm &communicator) override
Definition: trilinos_tpetra_communication_pattern.cc:52
LinearAlgebra::TpetraWrappers::CommunicationPattern::get_mpi_communicator
virtual const MPI_Comm & get_mpi_communicator() const override
Definition: trilinos_tpetra_communication_pattern.cc:79
LinearAlgebra::TpetraWrappers::CommunicationPattern::CommunicationPattern
CommunicationPattern(const IndexSet &vector_space_vector_index_set, const IndexSet &read_write_vector_index_set, const MPI_Comm &communicator)
Definition: trilinos_tpetra_communication_pattern.cc:36
index_set.h
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
IndexSet::make_tpetra_map
Tpetra::Map< int, types::global_dof_index > make_tpetra_map(const MPI_Comm &communicator=MPI_COMM_WORLD, const bool overlapping=false) const
Definition: index_set.cc:527
LinearAlgebra::TpetraWrappers::CommunicationPattern::comm
std::shared_ptr< const MPI_Comm > comm
Definition: trilinos_tpetra_communication_pattern.h:84
LinearAlgebra::TpetraWrappers::CommunicationPattern::tpetra_export
std::unique_ptr< Tpetra::Export< int, types::global_dof_index > > tpetra_export
Definition: trilinos_tpetra_communication_pattern.h:96
memory.h
trilinos_tpetra_communication_pattern.h
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359