DUNE PDELab (2.8)

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
14namespace Dune
15{
16 namespace Amg
17 {
18 template<class M, class PI>
19 struct PropertiesGraphCreator
20 {
21 typedef typename M::matrix_type Matrix;
22 typedef Dune::Amg::MatrixGraph<const Matrix> MatrixGraph;
23 typedef Dune::Amg::SubGraph<MatrixGraph,
24 std::vector<bool> > SubGraph;
25 typedef Dune::Amg::PropertiesGraph<SubGraph,
26 VertexProperties,
27 EdgeProperties,
28 IdentityMap,
29 typename SubGraph::EdgeIndexMap>
30 PropertiesGraph;
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>
59 struct PropertiesGraphCreator<M,SequentialInformation>
60 {
61 typedef typename M::matrix_type Matrix;
62
63 typedef Dune::Amg::MatrixGraph<const Matrix> MatrixGraph;
64
65 typedef Dune::Amg::PropertiesGraph<MatrixGraph,
66 VertexProperties,
67 EdgeProperties,
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
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.
Implementation of the BCRSMatrix class.
Provides classes for building the matrix graph.
ArrayList< IndexPair, N >::const_iterator const_iterator
The constant iterator over the pairs.
Definition: indexset.hh:296
Dune namespace.
Definition: alignedallocator.hh:11
Define general, extensible interface for operators. The available implementation wraps a matrix.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)