Reference documentation for deal.II version 9.3.3
\(\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 - 2020 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
18#ifdef DEAL_II_TRILINOS_WITH_TPETRA
19
20# ifdef DEAL_II_WITH_MPI
21
23
24# include <Tpetra_Map.hpp>
25
26# include <memory>
27
29
30namespace LinearAlgebra
31{
32 namespace TpetraWrappers
33 {
35 const IndexSet &vector_space_vector_index_set,
36 const IndexSet &read_write_vector_index_set,
37 const MPI_Comm &communicator)
38 {
39 // virtual functions called in constructors and destructors never use the
40 // override in a derived class
41 // for clarity be explicit on which function is called
42 CommunicationPattern::reinit(vector_space_vector_index_set,
43 read_write_vector_index_set,
44 communicator);
45 }
46
47
48
49 void
50 CommunicationPattern::reinit(const IndexSet &vector_space_vector_index_set,
51 const IndexSet &read_write_vector_index_set,
52 const MPI_Comm &communicator)
53 {
54 comm = std::make_shared<const MPI_Comm>(communicator);
55
56 auto vector_space_vector_map =
57 Teuchos::rcp(new Tpetra::Map<int, types::global_dof_index>(
58 vector_space_vector_index_set.make_tpetra_map(*comm, false)));
59 auto read_write_vector_map =
60 Teuchos::rcp(new Tpetra::Map<int, types::global_dof_index>(
61 read_write_vector_index_set.make_tpetra_map(*comm, true)));
62
63 // Target map is read_write_vector_map
64 // Source map is vector_space_vector_map. This map must have uniquely
65 // owned GID.
67 std::make_unique<Tpetra::Import<int, types::global_dof_index>>(
68 read_write_vector_map, vector_space_vector_map);
70 std::make_unique<Tpetra::Export<int, types::global_dof_index>>(
71 read_write_vector_map, vector_space_vector_map);
72 }
73
74
75
76 const MPI_Comm &
78 {
79 return *comm;
80 }
81
82
83
84 const Tpetra::Import<int, types::global_dof_index> &
86 {
87 return *tpetra_import;
88 }
89
90
91
92 const Tpetra::Export<int, types::global_dof_index> &
94 {
95 return *tpetra_export;
96 }
97 } // namespace TpetraWrappers
98} // namespace LinearAlgebra
99
101
102# endif
103
104#endif
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
const Tpetra::Export< int, types::global_dof_index > & get_tpetra_export() const
std::unique_ptr< Tpetra::Export< int, types::global_dof_index > > tpetra_export
std::unique_ptr< Tpetra::Import< int, types::global_dof_index > > tpetra_import
virtual void reinit(const IndexSet &vector_space_vector_index_set, const IndexSet &read_write_vector_index_set, const MPI_Comm &communicator) override
const Tpetra::Import< int, types::global_dof_index > & get_tpetra_import() const
CommunicationPattern(const IndexSet &vector_space_vector_index_set, const IndexSet &read_write_vector_index_set, const MPI_Comm &communicator)
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403