dune-istl 3.0-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 "graph.hh"
7#include "dependency.hh"
8#include "pinfo.hh"
11#include <dune/common/tuples.hh>
12#include <dune/common/unused.hh>
13
14namespace Dune
15{
16 namespace Amg
17 {
18 template<class M, int cat=M::category>
21
22 template<class M>
24 {
25 typedef typename M::matrix_type Matrix;
26
28
34
36
37 template<class OF, class T>
38 static GraphTuple create(const M& matrix, T& excluded,
39 const SequentialInformation& pinfo,
40 const OF&)
41 {
44 MatrixGraph* mg = new MatrixGraph(matrix.getmat());
46 return GraphTuple(mg,pg);
47 }
48
49 static void free(GraphTuple& graphs)
50 {
51 delete get<1>(graphs);
52 }
53
54 };
55
56 template<class M>
58 {
59 typedef typename M::matrix_type Matrix;
62 std::vector<bool> > SubGraph;
69
71
72 template<class OF, class T, class PI>
73 static GraphTuple create(const M& matrix, T& excluded,
74 PI& pinfo, const OF& of)
75 {
76 MatrixGraph* mg = new MatrixGraph(matrix.getmat());
77 typedef typename PI::ParallelIndexSet ParallelIndexSet;
78 typedef typename ParallelIndexSet::const_iterator IndexIterator;
79 IndexIterator iend = pinfo.indexSet().end();
80
81 for(IndexIterator index = pinfo.indexSet().begin(); index != iend; ++index)
82 excluded[index->local()] = of.contains(index->local().attribute());
83
85 PropertiesGraph* pg = new PropertiesGraph(*sg, IdentityMap(), sg->getEdgeIndexMap());
86 return GraphTuple(mg,pg,sg);
87 }
88
89 static void free(GraphTuple& graphs)
90 {
91 delete get<2>(graphs);
92 delete get<1>(graphs);
93 }
94 };
95
96 template<class M>
97 struct PropertiesGraphCreator<M,SolverCategory::nonoverlapping>
98 {
99 typedef typename M::matrix_type Matrix;
102 std::vector<bool> > SubGraph;
107 typename SubGraph::EdgeIndexMap>
109
111
112 template<class OF, class T, class PI>
113 static GraphTuple create(const M& matrix, T& excluded,
114 PI& pinfo, const OF& of)
115 {
116 MatrixGraph* mg = new MatrixGraph(matrix.getmat());
117 typedef typename PI::ParallelIndexSet ParallelIndexSet;
118 typedef typename ParallelIndexSet::const_iterator IndexIterator;
119 IndexIterator iend = pinfo.indexSet().end();
120
121 for(IndexIterator index = pinfo.indexSet().begin(); index != iend; ++index)
122 excluded[index->local()] = of.contains(index->local().attribute());
123
124 SubGraph* sg= new SubGraph(*mg, excluded);
125 PropertiesGraph* pg = new PropertiesGraph(*sg, IdentityMap(), sg->getEdgeIndexMap());
126 return GraphTuple(mg,pg,sg);
127 }
128
129 static void free(GraphTuple& graphs)
130 {
131 delete get<2>(graphs);
132 delete get<1>(graphs);
133 }
134 };
135
136 } //namespace Amg
137} // namespace Dune
138#endif
Define general, extensible interface for operators. The available implementation wraps a matrix.
Implementation of the BCRSMatrix class.
Provides classes for initializing the link attributes of a matrix graph.
Provides classes for building the matrix graph.
Definition basearray.hh:19
Statistics about compression achieved in implicit mode.
Definition bcrsmatrix.hh:81
Class representing the properties of an ede in the matrix graph.
Definition dependency.hh:38
Class representing a node in the matrix graph.
Definition dependency.hh:125
The (undirected) graph of a matrix.
Definition graph.hh:49
A subgraph of a graph.
Definition graph.hh:441
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
M::matrix_type Matrix
Definition graphcreator.hh:25
static void free(GraphTuple &graphs)
Definition graphcreator.hh:49
static GraphTuple create(const M &matrix, T &excluded, const SequentialInformation &pinfo, const OF &)
Definition graphcreator.hh:38
Dune::tuple< MatrixGraph *, PropertiesGraph * > GraphTuple
Definition graphcreator.hh:35
Dune::Amg::MatrixGraph< const Matrix > MatrixGraph
Definition graphcreator.hh:27
Dune::Amg::PropertiesGraph< MatrixGraph, VertexProperties, EdgeProperties, IdentityMap, IdentityMap > PropertiesGraph
Definition graphcreator.hh:33
Dune::Amg::MatrixGraph< const Matrix > MatrixGraph
Definition graphcreator.hh:60
Dune::Amg::PropertiesGraph< SubGraph, VertexProperties, EdgeProperties, IdentityMap, typename SubGraph::EdgeIndexMap > PropertiesGraph
Definition graphcreator.hh:68
static void free(GraphTuple &graphs)
Definition graphcreator.hh:89
static GraphTuple create(const M &matrix, T &excluded, PI &pinfo, const OF &of)
Definition graphcreator.hh:73
Dune::tuple< MatrixGraph *, PropertiesGraph *, SubGraph * > GraphTuple
Definition graphcreator.hh:70
M::matrix_type Matrix
Definition graphcreator.hh:59
Dune::Amg::SubGraph< MatrixGraph, std::vector< bool > > SubGraph
Definition graphcreator.hh:62
Dune::Amg::MatrixGraph< const Matrix > MatrixGraph
Definition graphcreator.hh:100
Dune::Amg::SubGraph< MatrixGraph, std::vector< bool > > SubGraph
Definition graphcreator.hh:102
static GraphTuple create(const M &matrix, T &excluded, PI &pinfo, const OF &of)
Definition graphcreator.hh:113
static void free(GraphTuple &graphs)
Definition graphcreator.hh:129
Dune::tuple< MatrixGraph *, PropertiesGraph *, SubGraph * > GraphTuple
Definition graphcreator.hh:110
Dune::Amg::PropertiesGraph< SubGraph, VertexProperties, EdgeProperties, IdentityMap, typename SubGraph::EdgeIndexMap > PropertiesGraph
Definition graphcreator.hh:108
Definition pinfo.hh:26
Categories for the solvers.
Definition solvercategory.hh:18