dune-istl  2.8.0
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 
14 namespace Dune
15 {
16  namespace Amg
17  {
18  template<class M, class PI>
20  {
21  typedef typename M::matrix_type Matrix;
24  std::vector<bool> > SubGraph;
28  IdentityMap,
29  typename SubGraph::EdgeIndexMap>
31 
32  typedef std::tuple<MatrixGraph*,PropertiesGraph*,SubGraph*> GraphTuple;
33 
34  template<class OF, class T>
35  static GraphTuple create(const M& matrix, T& excluded,
36  PI& pinfo, const OF& of)
37  {
38  MatrixGraph* mg = new MatrixGraph(matrix.getmat());
39  typedef typename PI::ParallelIndexSet ParallelIndexSet;
40  typedef typename ParallelIndexSet::const_iterator IndexIterator;
41  IndexIterator iend = pinfo.indexSet().end();
42 
43  for(IndexIterator index = pinfo.indexSet().begin(); index != iend; ++index)
44  excluded[index->local()] = of.contains(index->local().attribute());
45 
46  SubGraph* sg= new SubGraph(*mg, excluded);
47  PropertiesGraph* pg = new PropertiesGraph(*sg, IdentityMap(), sg->getEdgeIndexMap());
48  return GraphTuple(mg,pg,sg);
49  }
50 
51  static void free(GraphTuple& graphs)
52  {
53  delete std::get<2>(graphs);
54  delete std::get<1>(graphs);
55  }
56  };
57 
58  template<class M>
60  {
61  typedef typename M::matrix_type Matrix;
62 
64 
68  IdentityMap,
69  IdentityMap> PropertiesGraph;
70 
71  typedef std::tuple<MatrixGraph*,PropertiesGraph*> GraphTuple;
72 
73  template<class OF, class T>
74  static GraphTuple create([[maybe_unused]] const M& matrix,
75  [[maybe_unused]] T& excluded,
76  [[maybe_unused]] const SequentialInformation& pinfo,
77  const OF&)
78  {
79  MatrixGraph* mg = new MatrixGraph(matrix.getmat());
80  PropertiesGraph* pg = new PropertiesGraph(*mg, IdentityMap(), IdentityMap());
81  return GraphTuple(mg,pg);
82  }
83 
84  static void free(GraphTuple& graphs)
85  {
86  delete std::get<1>(graphs);
87  }
88 
89  };
90 
91  } //namespace Amg
92 } // namespace Dune
93 #endif
Implementation of the BCRSMatrix class.
Define general, extensible interface for operators. The available implementation wraps a matrix.
Provides classes for initializing the link attributes of a matrix graph.
Provides classes for building the matrix graph.
Definition: allocator.hh:9
Class representing the properties of an ede in the matrix graph.
Definition: dependency.hh:37
Class representing a node in the matrix graph.
Definition: dependency.hh:124
The (undirected) graph of a matrix.
Definition: graph.hh:49
A subgraph of a graph.
Definition: graph.hh:441
EdgeIndexMap getEdgeIndexMap()
Get an edge index map for the graph.
An index map for mapping the edges to indices.
Definition: graph.hh:468
Attaches properties to the edges and vertices of a graph.
Definition: graph.hh:976
Definition: graphcreator.hh:20
Dune::Amg::SubGraph< MatrixGraph, std::vector< bool > > SubGraph
Definition: graphcreator.hh:24
Dune::Amg::PropertiesGraph< SubGraph, VertexProperties, EdgeProperties, IdentityMap, typename SubGraph::EdgeIndexMap > PropertiesGraph
Definition: graphcreator.hh:30
M::matrix_type Matrix
Definition: graphcreator.hh:21
static GraphTuple create(const M &matrix, T &excluded, PI &pinfo, const OF &of)
Definition: graphcreator.hh:35
static void free(GraphTuple &graphs)
Definition: graphcreator.hh:51
Dune::Amg::MatrixGraph< const Matrix > MatrixGraph
Definition: graphcreator.hh:22
std::tuple< MatrixGraph *, PropertiesGraph *, SubGraph * > GraphTuple
Definition: graphcreator.hh:32
Dune::Amg::MatrixGraph< const Matrix > MatrixGraph
Definition: graphcreator.hh:63
M::matrix_type Matrix
Definition: graphcreator.hh:61
Dune::Amg::PropertiesGraph< MatrixGraph, VertexProperties, EdgeProperties, IdentityMap, IdentityMap > PropertiesGraph
Definition: graphcreator.hh:69
std::tuple< MatrixGraph *, PropertiesGraph * > GraphTuple
Definition: graphcreator.hh:71
static GraphTuple create([[maybe_unused]] const M &matrix, [[maybe_unused]] T &excluded, [[maybe_unused]] const SequentialInformation &pinfo, const OF &)
Definition: graphcreator.hh:74
static void free(GraphTuple &graphs)
Definition: graphcreator.hh:84
Definition: pinfo.hh:26