Dune Core Modules (2.5.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 <tuple>
7
8#include "graph.hh"
9#include "dependency.hh"
10#include "pinfo.hh"
13#include <dune/common/unused.hh>
14
15namespace Dune
16{
17 namespace Amg
18 {
19 template<class M, int cat=M::category>
20 struct PropertiesGraphCreator
21 {};
22
23 template<class M>
24 struct PropertiesGraphCreator<M,SolverCategory::sequential>
25 {
26 typedef typename M::matrix_type Matrix;
27
28 typedef Dune::Amg::MatrixGraph<const Matrix> MatrixGraph;
29
30 typedef Dune::Amg::PropertiesGraph<MatrixGraph,
31 VertexProperties,
32 EdgeProperties,
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);
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;
61 typedef Dune::Amg::MatrixGraph<const Matrix> MatrixGraph;
62 typedef Dune::Amg::SubGraph<MatrixGraph,
63 std::vector<bool> > SubGraph;
64 typedef Dune::Amg::PropertiesGraph<SubGraph,
65 VertexProperties,
66 EdgeProperties,
67 IdentityMap,
68 typename SubGraph::EdgeIndexMap>
69 PropertiesGraph;
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;
101 typedef Dune::Amg::MatrixGraph<const Matrix> MatrixGraph;
102 typedef Dune::Amg::SubGraph<MatrixGraph,
103 std::vector<bool> > SubGraph;
104 typedef Dune::Amg::PropertiesGraph<SubGraph,
105 VertexProperties,
106 EdgeProperties,
107 IdentityMap,
108 typename SubGraph::EdgeIndexMap>
109 PropertiesGraph;
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
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:11
Define general, extensible interface for operators. The available implementation wraps a matrix.
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition: unused.hh:18
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)