Reference documentation for deal.II version 9.0.0
trilinos_epetra_communication_pattern.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2015 - 2018 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #include <deal.II/base/std_cxx14/memory.h>
17 #include <deal.II/lac/trilinos_epetra_communication_pattern.h>
18 
19 #ifdef DEAL_II_WITH_TRILINOS
20 
21 #ifdef DEAL_II_WITH_MPI
22 
23 #include <deal.II/base/index_set.h>
24 
25 # include <Epetra_Map.h>
26 
27 #include <memory>
28 
29 DEAL_II_NAMESPACE_OPEN
30 
31 namespace LinearAlgebra
32 {
33  namespace EpetraWrappers
34  {
35  CommunicationPattern::CommunicationPattern(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, read_write_vector_index_set, communicator);
43  }
44 
45 
46 
47  void CommunicationPattern::reinit(const IndexSet &vector_space_vector_index_set,
48  const IndexSet &read_write_vector_index_set,
49  const MPI_Comm &communicator)
50  {
51  comm = std::make_shared<const MPI_Comm>(communicator);
52 
53  Epetra_Map vector_space_vector_map = vector_space_vector_index_set.make_trilinos_map(*comm,
54  false);
55  Epetra_Map read_write_vector_map = read_write_vector_index_set.make_trilinos_map(*comm,
56  true);
57 
58  // Target map is read_write_vector_map
59  // Source map is vector_space_vector_map. This map must have uniquely
60  // owned GID.
61  import = std_cxx14::make_unique<Epetra_Import>(read_write_vector_map, vector_space_vector_map);
62  }
63 
64 
65 
67  {
68  return *comm;
69  }
70 
71 
72 
73  const Epetra_Import &CommunicationPattern::get_epetra_import() const
74  {
75  return *import;
76  }
77  }
78 }
79 
80 DEAL_II_NAMESPACE_CLOSE
81 
82 #endif
83 
84 #endif
void reinit(const IndexSet &vector_space_vector_index_set, const IndexSet &read_write_vector_index_set, const MPI_Comm &communicator)
Epetra_Map make_trilinos_map(const MPI_Comm &communicator=MPI_COMM_WORLD, const bool overlapping=false) const
Definition: index_set.cc:549
CommunicationPattern(const IndexSet &vector_space_vector_index_set, const IndexSet &read_write_vector_index_set, const MPI_Comm &communicator)