Loading [MathJax]/extensions/TeX/AMSsymbols.js
 Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
trilinos_tpetra_communication_pattern.cc
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 
16 #include <deal.II/base/std_cxx14/memory.h>
17 
18 #include <deal.II/lac/trilinos_tpetra_communication_pattern.h>
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 
30 DEAL_II_NAMESPACE_OPEN
31 
32 namespace LinearAlgebra
33 {
34  namespace TpetraWrappers
35  {
36  CommunicationPattern::CommunicationPattern(
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.
68  tpetra_import =
69  std_cxx14::make_unique<Tpetra::Import<int, types::global_dof_index>>(
70  read_write_vector_map, vector_space_vector_map);
71  tpetra_export =
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 &
79  CommunicationPattern::get_mpi_communicator() const
80  {
81  return *comm;
82  }
83 
84 
85 
86  const Tpetra::Import<int, types::global_dof_index> &
87  CommunicationPattern::get_tpetra_import() const
88  {
89  return *tpetra_import;
90  }
91 
92 
93 
94  const Tpetra::Export<int, types::global_dof_index> &
95  CommunicationPattern::get_tpetra_export() const
96  {
97  return *tpetra_export;
98  }
99  } // namespace TpetraWrappers
100 } // namespace LinearAlgebra
101 
102 DEAL_II_NAMESPACE_CLOSE
103 
104 # endif
105 
106 #endif