Dune Core Modules (2.6.0)

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, class PI>
20 struct PropertiesGraphCreator
21 {
22 typedef typename M::matrix_type Matrix;
23 typedef Dune::Amg::MatrixGraph<const Matrix> MatrixGraph;
24 typedef Dune::Amg::SubGraph<MatrixGraph,
25 std::vector<bool> > SubGraph;
26 typedef Dune::Amg::PropertiesGraph<SubGraph,
27 VertexProperties,
28 EdgeProperties,
29 IdentityMap,
30 typename SubGraph::EdgeIndexMap>
31 PropertiesGraph;
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>
60 struct PropertiesGraphCreator<M,SequentialInformation>
61 {
62 typedef typename M::matrix_type Matrix;
63
64 typedef Dune::Amg::MatrixGraph<const Matrix> MatrixGraph;
65
66 typedef Dune::Amg::PropertiesGraph<MatrixGraph,
67 VertexProperties,
68 EdgeProperties,
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);
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
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:307
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition: unused.hh:25
Dune namespace.
Definition: alignedallocator.hh:10
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.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)