dune-istl  2.2.1
graphcreator.hh
Go to the documentation of this file.
1 #ifndef DUNE_AMG_GRAPHCREATOR_HH
2 #define DUNE_AMG_GRAPHCREATOR_HH
3 
4 #include"graph.hh"
5 #include"dependency.hh"
6 #include"pinfo.hh"
9 #include<dune/common/tuples.hh>
10 
11 namespace Dune
12 {
13  namespace Amg
14  {
15  template<class M, int cat=M::category>
17  {
18  };
19 
20  template<class M>
21  struct PropertiesGraphCreator<M,SolverCategory::sequential>
22  {
23  typedef typename M::matrix_type Matrix;
24 
26 
30  IdentityMap,
31  IdentityMap> PropertiesGraph;
32 
33  typedef Dune::tuple<MatrixGraph*,PropertiesGraph*> GraphTuple;
34 
35  template<class OF, class T>
36  static GraphTuple create(const M& matrix, T& excluded,
37  const SequentialInformation& pinfo,
38  const OF&)
39  {
40  MatrixGraph* mg = new MatrixGraph(matrix.getmat());
41  PropertiesGraph* pg = new PropertiesGraph(*mg, IdentityMap(), IdentityMap());
42  return GraphTuple(mg,pg);
43  }
44 
45  static void free(GraphTuple& graphs)
46  {
47  delete get<1>(graphs);
48  }
49 
50  };
51 
52  template<class M>
53  struct PropertiesGraphCreator<M,SolverCategory::overlapping>
54  {
55  typedef typename M::matrix_type Matrix;
58  std::vector<bool> > SubGraph;
62  IdentityMap,
63  typename SubGraph::EdgeIndexMap>
65 
66  typedef Dune::tuple<MatrixGraph*,PropertiesGraph*,SubGraph*> GraphTuple;
67 
68  template<class OF, class T, class PI>
69  static GraphTuple create(const M& matrix, T& excluded,
70  PI& pinfo, const OF& of)
71  {
72  typedef OF OverlapFlags;
73  MatrixGraph* mg = new MatrixGraph(matrix.getmat());
74  typedef typename PI::ParallelIndexSet ParallelIndexSet;
75  typedef typename ParallelIndexSet::const_iterator IndexIterator;
76  IndexIterator iend = pinfo.indexSet().end();
77 
78  for(IndexIterator index = pinfo.indexSet().begin(); index != iend; ++index)
79  excluded[index->local()] = of.contains(index->local().attribute());
80 
81  SubGraph* sg= new SubGraph(*mg, excluded);
82  PropertiesGraph* pg = new PropertiesGraph(*sg, IdentityMap(), sg->getEdgeIndexMap());
83  return GraphTuple(mg,pg,sg);
84  }
85 
86  static void free(GraphTuple& graphs)
87  {
88  delete get<2>(graphs);
89  delete get<1>(graphs);
90  }
91  };
92 
93  template<class M>
94  struct PropertiesGraphCreator<M,SolverCategory::nonoverlapping>
95  {
96  typedef typename M::matrix_type Matrix;
99  std::vector<bool> > SubGraph;
103  IdentityMap,
104  typename SubGraph::EdgeIndexMap>
106 
107  typedef Dune::tuple<MatrixGraph*,PropertiesGraph*,SubGraph*> GraphTuple;
108 
109  template<class OF, class T, class PI>
110  static GraphTuple create(const M& matrix, T& excluded,
111  PI& pinfo, const OF& of)
112  {
113  typedef OF OverlapFlags;
114  MatrixGraph* mg = new MatrixGraph(matrix.getmat());
115  typedef typename PI::ParallelIndexSet ParallelIndexSet;
116  typedef typename ParallelIndexSet::const_iterator IndexIterator;
117  IndexIterator iend = pinfo.indexSet().end();
118 
119  for(IndexIterator index = pinfo.indexSet().begin(); index != iend; ++index)
120  excluded[index->local()] = of.contains(index->local().attribute());
121 
122  SubGraph* sg= new SubGraph(*mg, excluded);
123  PropertiesGraph* pg = new PropertiesGraph(*sg, IdentityMap(), sg->getEdgeIndexMap());
124  return GraphTuple(mg,pg,sg);
125  }
126 
127  static void free(GraphTuple& graphs)
128  {
129  delete get<2>(graphs);
130  delete get<1>(graphs);
131  }
132  };
133 
134  }//namespace Amg
135 } // namespace Dune
136 #endif