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