Reference documentation for deal.II version 8.5.1
trilinos_epetra_communication_pattern.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2015 - 2016 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/lac/trilinos_epetra_communication_pattern.h>
17 
18 #ifdef DEAL_II_WITH_TRILINOS
19 
20 #ifdef DEAL_II_WITH_MPI
21 
22 #include <deal.II/base/index_set.h>
23 #include <deal.II/base/std_cxx11/shared_ptr.h>
24 #include "Epetra_Map.h"
25 
26 DEAL_II_NAMESPACE_OPEN
27 
28 namespace LinearAlgebra
29 {
30  namespace EpetraWrappers
31  {
32  CommunicationPattern::CommunicationPattern(const IndexSet &vector_space_vector_index_set,
33  const IndexSet &read_write_vector_index_set,
34  const MPI_Comm &communicator)
35  {
36  reinit(vector_space_vector_index_set, read_write_vector_index_set, communicator);
37  }
38 
39 
40 
41  void CommunicationPattern::reinit(const IndexSet &vector_space_vector_index_set,
42  const IndexSet &read_write_vector_index_set,
43  const MPI_Comm &communicator)
44  {
45  comm = std_cxx11::make_shared<const MPI_Comm>(communicator);
46 
47  Epetra_Map vector_space_vector_map = vector_space_vector_index_set.make_trilinos_map(*comm,
48  false);
49  Epetra_Map read_write_vector_map = read_write_vector_index_set.make_trilinos_map(*comm,
50  true);
51 
52  // Target map is read_write_vector_map
53  // Source map is vector_space_vector_map. This map must have uniquely
54  // owned GID.
55  import.reset(new Epetra_Import(read_write_vector_map, vector_space_vector_map));
56  }
57 
58 
59 
61  {
62  return *comm;
63  }
64 
65 
66 
67  const Epetra_Import &CommunicationPattern::get_epetra_import() const
68  {
69  return *import;
70  }
71  }
72 }
73 
74 DEAL_II_NAMESPACE_CLOSE
75 
76 #endif
77 
78 #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:535
CommunicationPattern(const IndexSet &vector_space_vector_index_set, const IndexSet &read_write_vector_index_set, const MPI_Comm &communicator)