Dune Core Modules (2.4.2)

graphcreator.hh
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>
19 struct PropertiesGraphCreator
20 {};
21
22 template<class M>
23 struct PropertiesGraphCreator<M,SolverCategory::sequential>
24 {
25 typedef typename M::matrix_type Matrix;
26
27 typedef Dune::Amg::MatrixGraph<const Matrix> MatrixGraph;
28
29 typedef Dune::Amg::PropertiesGraph<MatrixGraph,
30 VertexProperties,
31 EdgeProperties,
32 IdentityMap,
33 IdentityMap> PropertiesGraph;
34
35 typedef Dune::tuple<MatrixGraph*,PropertiesGraph*> GraphTuple;
36
37 template<class OF, class T>
38 static GraphTuple create(const M& matrix, T& excluded,
39 const SequentialInformation& pinfo,
40 const OF&)
41 {
42 DUNE_UNUSED_PARAMETER(excluded);
44 MatrixGraph* mg = new MatrixGraph(matrix.getmat());
45 PropertiesGraph* pg = new PropertiesGraph(*mg, IdentityMap(), IdentityMap());
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>
57 struct PropertiesGraphCreator<M,SolverCategory::overlapping>
58 {
59 typedef typename M::matrix_type Matrix;
60 typedef Dune::Amg::MatrixGraph<const Matrix> MatrixGraph;
61 typedef Dune::Amg::SubGraph<MatrixGraph,
62 std::vector<bool> > SubGraph;
63 typedef Dune::Amg::PropertiesGraph<SubGraph,
64 VertexProperties,
65 EdgeProperties,
66 IdentityMap,
67 typename SubGraph::EdgeIndexMap>
68 PropertiesGraph;
69
70 typedef Dune::tuple<MatrixGraph*,PropertiesGraph*,SubGraph*> GraphTuple;
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
84 SubGraph* sg= new SubGraph(*mg, excluded);
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;
100 typedef Dune::Amg::MatrixGraph<const Matrix> MatrixGraph;
101 typedef Dune::Amg::SubGraph<MatrixGraph,
102 std::vector<bool> > SubGraph;
103 typedef Dune::Amg::PropertiesGraph<SubGraph,
104 VertexProperties,
105 EdgeProperties,
106 IdentityMap,
107 typename SubGraph::EdgeIndexMap>
108 PropertiesGraph;
109
110 typedef Dune::tuple<MatrixGraph*,PropertiesGraph*,SubGraph*> GraphTuple;
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
Implementation of the BCRSMatrix class.
The (undirected) graph of a matrix.
Definition: graph.hh:49
Attaches properties to the edges and vertices of a graph.
Definition: graph.hh:976
A subgraph of a graph.
Definition: graph.hh:441
Provides classes for initializing the link attributes of a matrix graph.
Provides classes for building the matrix graph.
ArrayList< IndexPair, N >::const_iterator const_iterator
The constant iterator over the pairs.
Definition: indexset.hh:305
Dune namespace.
Definition: alignment.hh:10
Define general, extensible interface for operators. The available implementation wraps a matrix.
Fallback implementation of the std::tuple class.
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentional unused function parameters with.
Definition: unused.hh:18
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)