dune-istl 2.10
Loading...
Searching...
No Matches
graphcreator.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_AMG_GRAPHCREATOR_HH
6#define DUNE_AMG_GRAPHCREATOR_HH
7
8#include <tuple>
9
10#include "graph.hh"
11#include "dependency.hh"
12#include "pinfo.hh"
15
16namespace Dune
17{
18 namespace Amg
19 {
20 template<class M, class PI>
22 {
23 typedef typename M::matrix_type Matrix;
26 std::vector<bool> > SubGraph;
30 IdentityMap,
33
34 typedef std::tuple<MatrixGraph*,PropertiesGraph*,SubGraph*> GraphTuple;
35
36 template<class OF, class T>
37 static GraphTuple create(const M& matrix, T& excluded,
38 PI& pinfo, const OF& of)
39 {
40 MatrixGraph* mg = new MatrixGraph(matrix.getmat());
41 typedef typename PI::ParallelIndexSet ParallelIndexSet;
42 typedef typename ParallelIndexSet::const_iterator IndexIterator;
43 IndexIterator iend = pinfo.indexSet().end();
44
45 for(IndexIterator index = pinfo.indexSet().begin(); index != iend; ++index)
46 excluded[index->local()] = of.contains(index->local().attribute());
47
48 SubGraph* sg= new SubGraph(*mg, excluded);
49 PropertiesGraph* pg = new PropertiesGraph(*sg, IdentityMap(), sg->getEdgeIndexMap());
50 return GraphTuple(mg,pg,sg);
51 }
52
53 static void free(GraphTuple& graphs)
54 {
55 delete std::get<2>(graphs);
56 delete std::get<1>(graphs);
57 }
58 };
59
60 template<class M>
62 {
63 typedef typename M::matrix_type Matrix;
64
66
70 IdentityMap,
71 IdentityMap> PropertiesGraph;
72
73 typedef std::tuple<MatrixGraph*,PropertiesGraph*> GraphTuple;
74
75 template<class OF, class T>
76 static GraphTuple create([[maybe_unused]] const M& matrix,
77 [[maybe_unused]] T& excluded,
78 [[maybe_unused]] const SequentialInformation& pinfo,
79 const OF&)
80 {
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
Provides classes for initializing the link attributes of a matrix graph.
Provides classes for building the matrix graph.
Implementation of the BCRSMatrix class.
Define general, extensible interface for operators. The available implementation wraps a matrix.
Definition allocator.hh:11
Class representing the properties of an edge in the matrix graph.
Definition dependency.hh:39
Class representing a node in the matrix graph.
Definition dependency.hh:126
The (undirected) graph of a matrix.
Definition graph.hh:51
A subgraph of a graph.
Definition graph.hh:443
EdgeIndexMap getEdgeIndexMap()
Get an edge index map for the graph.
An index map for mapping the edges to indices.
Definition graph.hh:470
Attaches properties to the edges and vertices of a graph.
Definition graph.hh:978
Definition graphcreator.hh:22
Dune::Amg::SubGraph< MatrixGraph, std::vector< bool > > SubGraph
Definition graphcreator.hh:26
Dune::Amg::PropertiesGraph< SubGraph, VertexProperties, EdgeProperties, IdentityMap, typename SubGraph::EdgeIndexMap > PropertiesGraph
Definition graphcreator.hh:32
M::matrix_type Matrix
Definition graphcreator.hh:23
static GraphTuple create(const M &matrix, T &excluded, PI &pinfo, const OF &of)
Definition graphcreator.hh:37
static void free(GraphTuple &graphs)
Definition graphcreator.hh:53
Dune::Amg::MatrixGraph< const Matrix > MatrixGraph
Definition graphcreator.hh:24
std::tuple< MatrixGraph *, PropertiesGraph *, SubGraph * > GraphTuple
Definition graphcreator.hh:34
Dune::Amg::MatrixGraph< const Matrix > MatrixGraph
Definition graphcreator.hh:65
M::matrix_type Matrix
Definition graphcreator.hh:63
Dune::Amg::PropertiesGraph< MatrixGraph, VertexProperties, EdgeProperties, IdentityMap, IdentityMap > PropertiesGraph
Definition graphcreator.hh:71
std::tuple< MatrixGraph *, PropertiesGraph * > GraphTuple
Definition graphcreator.hh:73
static GraphTuple create(const M &matrix, T &excluded, const SequentialInformation &pinfo, const OF &)
Definition graphcreator.hh:76
static void free(GraphTuple &graphs)
Definition graphcreator.hh:86
Definition pinfo.hh:28