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
virtual void reinit(const IndexSet &vector_space_vector_index_set, const IndexSet &read_write_vector_index_set, const MPI_Comm &communicator) override
CommunicationPattern(const IndexSet &vector_space_vector_index_set, const IndexSet &read_write_vector_index_set, const MPI_Comm &communicator)
std::unique_ptr< Tpetra::Import< int, types::global_dof_index > > tpetra_import
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
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
const Tpetra::Import< int, types::global_dof_index > & get_tpetra_import() const
const Tpetra::Export< int, types::global_dof_index > & get_tpetra_export() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
std::unique_ptr< Tpetra::Export< int, types::global_dof_index > > tpetra_export