dune-istl  2.5-git
graphcreator.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_AMG_GRAPHCREATOR_HH
4 #define DUNE_AMG_GRAPHCREATOR_HH
5 
6 #include <tuple>
7 
8 #include "graph.hh"
9 #include "dependency.hh"
10 #include "pinfo.hh"
11 #include <dune/istl/operators.hh>
12 #include <dune/istl/bcrsmatrix.hh>
13 #include <dune/common/unused.hh>
14 
15 namespace Dune
16 {
17  namespace Amg
18  {
19  template<class M, int cat=M::category>
21  {};
22 
23  template<class M>
24  struct PropertiesGraphCreator<M,SolverCategory::sequential>
25  {
26  typedef typename M::matrix_type Matrix;
27 
29 
30  typedef Dune::Amg::PropertiesGraph<MatrixGraph,
33  IdentityMap,
34  IdentityMap> PropertiesGraph;
35 
36  typedef std::tuple<MatrixGraph*,PropertiesGraph*> GraphTuple;
37 
38  template<class OF, class T>
39  static GraphTuple create(const M& matrix, T& excluded,
40  const SequentialInformation& pinfo,
41  const OF&)
42  {
43  DUNE_UNUSED_PARAMETER(excluded);
44  DUNE_UNUSED_PARAMETER(pinfo);
45  MatrixGraph* mg = new MatrixGraph(matrix.getmat());
46  PropertiesGraph* pg = new PropertiesGraph(*mg, IdentityMap(), IdentityMap());
47  return GraphTuple(mg,pg);
48  }
49 
50  static void free(GraphTuple& graphs)
51  {
52  delete std::get<1>(graphs);
53  }
54 
55  };
56 
57  template<class M>
58  struct PropertiesGraphCreator<M,SolverCategory::overlapping>
59  {
60  typedef typename M::matrix_type Matrix;
62  typedef Dune::Amg::SubGraph<MatrixGraph,
63  std::vector<bool> > SubGraph;
64  typedef Dune::Amg::PropertiesGraph<SubGraph,
67  IdentityMap,
68  typename SubGraph::EdgeIndexMap>
70 
71  typedef std::tuple<MatrixGraph*,PropertiesGraph*,SubGraph*> GraphTuple;
72 
73  template<class OF, class T, class PI>
74  static GraphTuple create(const M& matrix, T& excluded,
75  PI& pinfo, const OF& of)
76  {
77  MatrixGraph* mg = new MatrixGraph(matrix.getmat());
78  typedef typename PI::ParallelIndexSet ParallelIndexSet;
79  typedef typename ParallelIndexSet::const_iterator IndexIterator;
80  IndexIterator iend = pinfo.indexSet().end();
81 
82  for(IndexIterator index = pinfo.indexSet().begin(); index != iend; ++index)
83  excluded[index->local()] = of.contains(index->local().attribute());
84 
85  SubGraph* sg= new SubGraph(*mg, excluded);
86  PropertiesGraph* pg = new PropertiesGraph(*sg, IdentityMap(), sg->getEdgeIndexMap());
87  return GraphTuple(mg,pg,sg);
88  }
89 
90  static void free(GraphTuple& graphs)
91  {
92  delete std::get<2>(graphs);
93  delete std::get<1>(graphs);
94  }
95  };
96 
97  template<class M>
98  struct PropertiesGraphCreator<M,SolverCategory::nonoverlapping>
99  {
100  typedef typename M::matrix_type Matrix;
102  typedef Dune::Amg::SubGraph<MatrixGraph,
103  std::vector<bool> > SubGraph;
104  typedef Dune::Amg::PropertiesGraph<SubGraph,
107  IdentityMap,
108  typename SubGraph::EdgeIndexMap>
110 
111  typedef std::tuple<MatrixGraph*,PropertiesGraph*,SubGraph*> GraphTuple;
112 
113  template<class OF, class T, class PI>
114  static GraphTuple create(const M& matrix, T& excluded,
115  PI& pinfo, const OF& of)
116  {
117  MatrixGraph* mg = new MatrixGraph(matrix.getmat());
118  typedef typename PI::ParallelIndexSet ParallelIndexSet;
119  typedef typename ParallelIndexSet::const_iterator IndexIterator;
120  IndexIterator iend = pinfo.indexSet().end();
121 
122  for(IndexIterator index = pinfo.indexSet().begin(); index != iend; ++index)
123  excluded[index->local()] = of.contains(index->local().attribute());
124 
125  SubGraph* sg= new SubGraph(*mg, excluded);
126  PropertiesGraph* pg = new PropertiesGraph(*sg, IdentityMap(), sg->getEdgeIndexMap());
127  return GraphTuple(mg,pg,sg);
128  }
129 
130  static void free(GraphTuple& graphs)
131  {
132  delete std::get<2>(graphs);
133  delete std::get<1>(graphs);
134  }
135  };
136 
137  } //namespace Amg
138 } // namespace Dune
139 #endif
Attaches properties to the edges and vertices of a graph.
Definition: graph.hh:975
Dune::Amg::PropertiesGraph< SubGraph, VertexProperties, EdgeProperties, IdentityMap, typename SubGraph::EdgeIndexMap > PropertiesGraph
Definition: graphcreator.hh:69
Dune::Amg::MatrixGraph< const Matrix > MatrixGraph
Definition: graphcreator.hh:28
static void free(GraphTuple &graphs)
Definition: graphcreator.hh:90
std::tuple< MatrixGraph *, PropertiesGraph * > GraphTuple
Definition: graphcreator.hh:36
Class representing the properties of an ede in the matrix graph.
Definition: dependency.hh:37
static GraphTuple create(const M &matrix, T &excluded, PI &pinfo, const OF &of)
Definition: graphcreator.hh:114
static GraphTuple create(const M &matrix, T &excluded, PI &pinfo, const OF &of)
Definition: graphcreator.hh:74
Dune::Amg::MatrixGraph< const Matrix > MatrixGraph
Definition: graphcreator.hh:61
A subgraph of a graph.
Definition: graph.hh:440
The (undirected) graph of a matrix.
Definition: graph.hh:48
Categories for the solvers.
Definition: solvercategory.hh:17
M::matrix_type Matrix
Definition: graphcreator.hh:100
EdgeIndexMap getEdgeIndexMap()
Get an edge index map for the graph.
Definition: pinfo.hh:25
Dune::Amg::SubGraph< MatrixGraph, std::vector< bool > > SubGraph
Definition: graphcreator.hh:103
static GraphTuple create(const M &matrix, T &excluded, const SequentialInformation &pinfo, const OF &)
Definition: graphcreator.hh:39
M::matrix_type Matrix
Definition: graphcreator.hh:26
std::tuple< MatrixGraph *, PropertiesGraph *, SubGraph * > GraphTuple
Definition: graphcreator.hh:111
static void free(GraphTuple &graphs)
Definition: graphcreator.hh:50
Definition: basearray.hh:19
Dune::Amg::PropertiesGraph< SubGraph, VertexProperties, EdgeProperties, IdentityMap, typename SubGraph::EdgeIndexMap > PropertiesGraph
Definition: graphcreator.hh:109
static void free(GraphTuple &graphs)
Definition: graphcreator.hh:130
Definition: graphcreator.hh:20
Provides classes for building the matrix graph.
Implementation of the BCRSMatrix class.
Provides classes for initializing the link attributes of a matrix graph.
Dune::Amg::PropertiesGraph< MatrixGraph, VertexProperties, EdgeProperties, IdentityMap, IdentityMap > PropertiesGraph
Definition: graphcreator.hh:34
std::tuple< MatrixGraph *, PropertiesGraph *, SubGraph * > GraphTuple
Definition: graphcreator.hh:71
Class representing a node in the matrix graph.
Definition: dependency.hh:125
Define general, extensible interface for operators. The available implementation wraps a matrix...
M::matrix_type Matrix
Definition: graphcreator.hh:60
An index map for mapping the edges to indices.
Definition: graph.hh:467
Dune::Amg::SubGraph< MatrixGraph, std::vector< bool > > SubGraph
Definition: graphcreator.hh:63
Dune::Amg::MatrixGraph< const Matrix > MatrixGraph
Definition: graphcreator.hh:101