Dune Core Modules (unstable)

aggregates.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_AGGREGATES_HH
6#define DUNE_AMG_AGGREGATES_HH
7
8
9#include "parameters.hh"
10#include "graph.hh"
11#include "properties.hh"
12#include "combinedfunctor.hh"
13
14#include <dune/common/timer.hh>
17#include <dune/common/sllist.hh>
21
22#include <utility>
23#include <set>
24#include <algorithm>
25#include <complex>
26#include <limits>
27#include <ostream>
28#include <tuple>
29#include <cmath>
30
31namespace Dune
32{
33 namespace Amg
34 {
35
49 template<class T>
50 class AggregationCriterion : public T
51 {
52
53 public:
58
69 : T()
70 {}
71
73 : T(parms)
74 {}
84 void setDefaultValuesIsotropic(std::size_t dim, std::size_t diameter=2)
85 {
86 this->setMaxDistance(diameter-1);
87 std::size_t csize=1;
88
89 for(; dim>0; dim--) {
90 csize*=diameter;
91 this->setMaxDistance(this->maxDistance()+diameter-1);
92 }
93 this->setMinAggregateSize(csize);
94 this->setMaxAggregateSize(static_cast<std::size_t>(csize*1.5));
95 }
96
107 void setDefaultValuesAnisotropic(std::size_t dim,std::size_t diameter=2)
108 {
109 setDefaultValuesIsotropic(dim, diameter);
110 this->setMaxDistance(this->maxDistance()+dim-1);
111 }
112 };
113
114 template<class T>
115 std::ostream& operator<<(std::ostream& os, const AggregationCriterion<T>& criterion)
116 {
117 os<<"{ maxdistance="<<criterion.maxDistance()<<" minAggregateSize="
118 <<criterion.minAggregateSize()<< " maxAggregateSize="<<criterion.maxAggregateSize()
119 <<" connectivity="<<criterion.maxConnectivity()<<" debugLevel="<<criterion.debugLevel()<<"}";
120 return os;
121 }
122
134 template<class M, class N>
136 {
137 public:
141 typedef M Matrix;
142
146 typedef N Norm;
147
151 typedef typename Matrix::row_type Row;
152
157
158 void init(const Matrix* matrix);
159
160 void initRow(const Row& row, int index);
161
162 void examine(const ColIter& col);
163
164 template<class G>
165 void examine(G& graph, const typename G::EdgeIterator& edge, const ColIter& col);
166
167 bool isIsolated();
168
169
171 : Parameters(parms)
172 {}
174 : Parameters()
175 {}
176
177 protected:
182 typedef typename FieldTraits<field_type>::real_type real_type;
183 real_type maxValue_;
187 int row_;
189 real_type diagonal_;
190 std::vector<real_type> vals_;
191 typename std::vector<real_type>::iterator valIter_;
192
193 };
194
195
196 template<class M, class N>
197 inline void SymmetricMatrixDependency<M,N>::init(const Matrix* matrix)
198 {
199 matrix_ = matrix;
200 }
201
202 template<class M, class N>
203 inline void SymmetricMatrixDependency<M,N>::initRow(const Row& row, int index)
204 {
205 using std::min;
206 vals_.assign(row.size(), 0.0);
207 assert(vals_.size()==row.size());
208 valIter_=vals_.begin();
209
211 diagonal_=norm_(row[index]);
212 row_ = index;
213 }
214
215 template<class M, class N>
216 inline void SymmetricMatrixDependency<M,N>::examine(const ColIter& col)
217 {
218 using std::max;
219 // skip positive offdiagonals if norm preserves sign of them.
220 real_type eij = norm_(*col);
221 if(!N::is_sign_preserving || eij<0) // || eji<0)
222 {
223 *valIter_ = eij/diagonal_*eij/norm_(matrix_->operator[](col.index())[col.index()]);
224 maxValue_ = max(maxValue_, *valIter_);
225 }else
226 *valIter_ =0;
227 ++valIter_;
228 }
229
230 template<class M, class N>
231 template<class G>
232 inline void SymmetricMatrixDependency<M,N>::examine(G&, const typename G::EdgeIterator& edge, const ColIter&)
233 {
234 if(*valIter_ > alpha() * maxValue_) {
235 edge.properties().setDepends();
236 edge.properties().setInfluences();
237 }
238 ++valIter_;
239 }
240
241 template<class M, class N>
242 inline bool SymmetricMatrixDependency<M,N>::isIsolated()
243 {
244 if(diagonal_==0)
245 DUNE_THROW(Dune::ISTLError, "No diagonal entry for row "<<row_<<".");
246 valIter_=vals_.begin();
247 return maxValue_ < beta();
248 }
249
253 template<class M, class N>
254 class Dependency : public Parameters
255 {
256 public:
260 typedef M Matrix;
261
265 typedef N Norm;
266
270 typedef typename Matrix::row_type Row;
271
276
277 void init(const Matrix* matrix);
278
279 void initRow(const Row& row, int index);
280
281 void examine(const ColIter& col);
282
283 template<class G>
284 void examine(G& graph, const typename G::EdgeIterator& edge, const ColIter& col);
285
286 bool isIsolated();
287
288 Dependency(const Parameters& parms)
289 : Parameters(parms)
290 {}
291
292 Dependency()
293 : Parameters()
294 {}
295
296 protected:
301 typedef typename FieldTraits<field_type>::real_type real_type;
302 real_type maxValue_;
306 int row_;
308 real_type diagonal_;
309 };
310
314 template<class M, class N>
316 {
317 public:
321 typedef M Matrix;
322
326 typedef N Norm;
327
331 typedef typename Matrix::row_type Row;
332
337
338 void init(const Matrix* matrix);
339
340 void initRow(const Row& row, int index);
341
342 void examine(const ColIter& col);
343
344 template<class G>
345 void examine(G& graph, const typename G::EdgeIterator& edge, const ColIter& col);
346
347 bool isIsolated();
348
349
350 SymmetricDependency(const Parameters& parms)
351 : Parameters(parms)
352 {}
354 : Parameters()
355 {}
356
357 protected:
362 typedef typename FieldTraits<field_type>::real_type real_type;
363 real_type maxValue_;
367 int row_;
369 real_type diagonal_;
370 private:
371 void initRow(const Row& row, int index, const std::true_type&);
372 void initRow(const Row& row, int index, const std::false_type&);
373 };
374
379 template<int N>
381 {
382 public:
383 enum { /* @brief We preserve the sign.*/
384 is_sign_preserving = true
385 };
386
391 template<class M>
392 typename FieldTraits<typename M::field_type>::real_type operator()(const M& m,
393 [[maybe_unused]] typename std::enable_if_t<!Dune::IsNumber<M>::value>* sfinae = nullptr) const
394 {
395 typedef typename M::field_type field_type;
396 typedef typename FieldTraits<field_type>::real_type real_type;
397 static_assert( std::is_convertible<field_type, real_type >::value,
398 "use of diagonal norm in AMG not implemented for complex field_type");
399 return m[N][N];
400 // possible implementation for complex types: return signed_abs(m[N][N]);
401 }
402
407 template<class M>
408 auto operator()(const M& m,
409 typename std::enable_if_t<Dune::IsNumber<M>::value>* sfinae = nullptr) const
410 {
411 typedef typename FieldTraits<M>::real_type real_type;
412 static_assert( std::is_convertible<M, real_type >::value,
413 "use of diagonal norm in AMG not implemented for complex field_type");
414 return m;
415 // possible implementation for complex types: return signed_abs(m[N][N]);
416 }
417
418 private:
419
421 template<typename T>
422 static T signed_abs(const T & v)
423 {
424 return v;
425 }
426
428 template<typename T>
429 static T signed_abs(const std::complex<T> & v)
430 {
431 // return sign * abs_value
432 // in case of complex numbers this extends to using the csgn function to determine the sign
433 return csgn(v) * std::abs(v);
434 }
435
437 template<typename T>
438 static T csgn(const T & v)
439 {
440 return (T(0) < v) - (v < T(0));
441 }
442
444 template<typename T>
445 static T csgn(std::complex<T> a)
446 {
447 return csgn(a.real())+(a.real() == 0.0)*csgn(a.imag());
448 }
449
450 };
451
456 class FirstDiagonal : public Diagonal<0>
457 {};
458
464 struct RowSum
465 {
466
467 enum { /* @brief We preserve the sign.*/
468 is_sign_preserving = false
469 };
474 template<class M>
475 auto operator()(const M& m) const
476 {
477 using std::abs;
478 if constexpr(Dune::IsNumber<M>::value)
479 return abs(m);
480 else
481 return m.infinity_norm();
482 }
483 };
484
485 struct FrobeniusNorm
486 {
487
488 enum { /* @brief We preserve the sign.*/
489 is_sign_preserving = false
490 };
495 template<class M>
496 typename FieldTraits<typename M::field_type>::real_type operator()(const M& m) const
497 {
498 return m.frobenius_norm();
499 }
500 };
501 struct AlwaysOneNorm
502 {
503
504 enum { /* @brief We preserve the sign.*/
505 is_sign_preserving = false
506 };
511 template<class M>
512 typename FieldTraits<typename M::field_type>::real_type operator()(const M& m) const
513 {
514 return 1;
515 }
516 };
523 template<class M, class Norm>
524 class SymmetricCriterion : public AggregationCriterion<SymmetricDependency<M,Norm> >
525 {
526 public:
527 SymmetricCriterion(const Parameters& parms)
529 {}
531 {}
532 };
533
534
543 template<class M, class Norm>
544 class UnSymmetricCriterion : public AggregationCriterion<Dependency<M,Norm> >
545 {
546 public:
547 UnSymmetricCriterion(const Parameters& parms)
549 {}
551 {}
552 };
553 // forward declaration
554 template<class G> class Aggregator;
555
556
564 template<class V>
566 {
567 public:
568
572 static const V UNAGGREGATED;
573
577 static const V ISOLATED;
582
587
593
599
604 {
605 public:
606 template<class EdgeIterator>
607 void operator()([[maybe_unused]] const EdgeIterator& edge) const
608 {}
609 };
610
611
616
623
628
640 template<class M, class G, class C>
641 std::tuple<int,int,int,int> buildAggregates(const M& matrix, G& graph, const C& criterion,
642 bool finestLevel);
643
661 template<bool reset, class G, class F, class VM>
662 std::size_t breadthFirstSearch(const VertexDescriptor& start,
663 const AggregateDescriptor& aggregate,
664 const G& graph,
665 F& aggregateVisitor,
666 VM& visitedMap) const;
667
691 template<bool remove, bool reset, class G, class L, class F1, class F2, class VM>
692 std::size_t breadthFirstSearch(const VertexDescriptor& start,
693 const AggregateDescriptor& aggregate,
694 const G& graph, L& visited, F1& aggregateVisitor,
695 F2& nonAggregateVisitor,
696 VM& visitedMap) const;
697
703 void allocate(std::size_t noVertices);
704
708 std::size_t noVertices() const;
709
713 void free();
714
721
728
729 typedef const AggregateDescriptor* const_iterator;
730
731 const_iterator begin() const
732 {
733 return aggregates_;
734 }
735
736 const_iterator end() const
737 {
738 return aggregates_+noVertices();
739 }
740
741 typedef AggregateDescriptor* iterator;
742
743 iterator begin()
744 {
745 return aggregates_;
746 }
747
748 iterator end()
749 {
750 return aggregates_+noVertices();
751 }
752 private:
754 AggregatesMap(const AggregatesMap<V>&) = delete;
756 AggregatesMap<V>& operator=(const AggregatesMap<V>&) = delete;
757
761 AggregateDescriptor* aggregates_;
762
766 std::size_t noVertices_;
767 };
768
772 template<class G, class C>
773 void buildDependency(G& graph,
774 const typename C::Matrix& matrix,
775 C criterion,
776 bool finestLevel);
777
782 template<class G, class S>
784 {
785
786 public:
787
788 /***
789 * @brief The type of the matrix graph we work with.
790 */
791 typedef G MatrixGraph;
796
802
807 typedef S VertexSet;
808
810 typedef typename VertexSet::const_iterator const_iterator;
811
815 typedef std::size_t* SphereMap;
816
825 Aggregate(MatrixGraph& graph, AggregatesMap<Vertex>& aggregates,
826 VertexSet& connectivity, std::vector<Vertex>& front_);
827
828 void invalidate()
829 {
830 --id_;
831 }
832
840
844 void seed(const Vertex& vertex);
845
849 void add(const Vertex& vertex);
850
851 void add(std::vector<Vertex>& vertex);
855 void clear();
856
860 typename VertexSet::size_type size();
864 typename VertexSet::size_type connectSize();
865
869 int id();
870
873
876
877 private:
881 VertexSet vertices_;
882
887 int id_;
888
892 MatrixGraph& graph_;
893
897 AggregatesMap<Vertex>& aggregates_;
898
902 VertexSet& connected_;
903
907 std::vector<Vertex>& front_;
908 };
909
913 template<class G>
915 {
916 public:
917
921 typedef G MatrixGraph;
922
927
930
935
940
957 template<class M, class C>
958 std::tuple<int,int,int,int> build(const M& m, G& graph,
959 AggregatesMap<Vertex>& aggregates, const C& c,
960 bool finestLevel);
961 private:
967
972
976 typedef std::set<Vertex,std::less<Vertex>,Allocator> VertexSet;
977
981 typedef std::size_t* SphereMap;
982
986 MatrixGraph* graph_;
987
992
996 std::vector<Vertex> front_;
997
1001 VertexSet connected_;
1002
1006 int size_;
1007
1011 class Stack
1012 {
1013 public:
1014 static const Vertex NullEntry;
1015
1016 Stack(const MatrixGraph& graph,
1017 const Aggregator<G>& aggregatesBuilder,
1018 const AggregatesMap<Vertex>& aggregates);
1019 ~Stack();
1020 Vertex pop();
1021 private:
1022 enum { N = 1300000 };
1023
1025 const MatrixGraph& graph_;
1027 const Aggregator<G>& aggregatesBuilder_;
1029 const AggregatesMap<Vertex>& aggregates_;
1031 int size_;
1032 Vertex maxSize_;
1034 typename MatrixGraph::ConstVertexIterator begin_;
1036
1038 Vertex* vals_;
1039
1040 };
1041
1042 friend class Stack;
1043
1054 template<class V>
1055 void visitAggregateNeighbours(const Vertex& vertex, const AggregateDescriptor& aggregate,
1056 const AggregatesMap<Vertex>& aggregates,
1057 V& visitor) const;
1058
1063 template<class V>
1064 class AggregateVisitor
1065 {
1066 public:
1070 typedef V Visitor;
1079 Visitor& visitor);
1080
1087 void operator()(const typename MatrixGraph::ConstEdgeIterator& edge);
1088
1089 private:
1091 const AggregatesMap<Vertex>& aggregates_;
1093 AggregateDescriptor aggregate_;
1095 Visitor* visitor_;
1096 };
1097
1101 class Counter
1102 {
1103 public:
1107 int value();
1108
1109 protected:
1114
1115 private:
1116 int count_;
1117 };
1118
1119
1124 class FrontNeighbourCounter : public Counter
1125 {
1126 public:
1132
1133 void operator()(const typename MatrixGraph::ConstEdgeIterator& edge);
1134
1135 private:
1136 const MatrixGraph& graph_;
1137 };
1138
1143 int noFrontNeighbours(const Vertex& vertex) const;
1144
1148 class TwoWayCounter : public Counter
1149 {
1150 public:
1151 void operator()(const typename MatrixGraph::ConstEdgeIterator& edge);
1152 };
1153
1165 int twoWayConnections(const Vertex&, const AggregateDescriptor& aggregate,
1166 const AggregatesMap<Vertex>& aggregates) const;
1167
1171 class OneWayCounter : public Counter
1172 {
1173 public:
1174 void operator()(const typename MatrixGraph::ConstEdgeIterator& edge);
1175 };
1176
1188 int oneWayConnections(const Vertex&, const AggregateDescriptor& aggregate,
1189 const AggregatesMap<Vertex>& aggregates) const;
1190
1197 class ConnectivityCounter : public Counter
1198 {
1199 public:
1205 ConnectivityCounter(const VertexSet& connected, const AggregatesMap<Vertex>& aggregates);
1206
1207 void operator()(const typename MatrixGraph::ConstEdgeIterator& edge);
1208
1209 private:
1211 const VertexSet& connected_;
1213 const AggregatesMap<Vertex>& aggregates_;
1214
1215 };
1216
1228 double connectivity(const Vertex& vertex, const AggregatesMap<Vertex>& aggregates) const;
1236 bool connected(const Vertex& vertex, const AggregateDescriptor& aggregate,
1237 const AggregatesMap<Vertex>& aggregates) const;
1238
1246 bool connected(const Vertex& vertex, const SLList<AggregateDescriptor>& aggregateList,
1247 const AggregatesMap<Vertex>& aggregates) const;
1248
1256 class DependencyCounter : public Counter
1257 {
1258 public:
1263
1264 void operator()(const typename MatrixGraph::ConstEdgeIterator& edge);
1265 };
1266
1273 class FrontMarker
1274 {
1275 public:
1282 FrontMarker(std::vector<Vertex>& front, MatrixGraph& graph);
1283
1284 void operator()(const typename MatrixGraph::ConstEdgeIterator& edge);
1285
1286 private:
1288 std::vector<Vertex>& front_;
1290 MatrixGraph& graph_;
1291 };
1292
1296 void unmarkFront();
1297
1312 int unusedNeighbours(const Vertex& vertex, const AggregatesMap<Vertex>& aggregates) const;
1313
1327 std::pair<int,int> neighbours(const Vertex& vertex,
1328 const AggregateDescriptor& aggregate,
1329 const AggregatesMap<Vertex>& aggregates) const;
1346 int aggregateNeighbours(const Vertex& vertex, const AggregateDescriptor& aggregate, const AggregatesMap<Vertex>& aggregates) const;
1347
1355 bool admissible(const Vertex& vertex, const AggregateDescriptor& aggregate, const AggregatesMap<Vertex>& aggregates) const;
1356
1364 std::size_t distance(const Vertex& vertex, const AggregatesMap<Vertex>& aggregates);
1365
1374 Vertex mergeNeighbour(const Vertex& vertex, const AggregatesMap<Vertex>& aggregates) const;
1375
1384 void nonisoNeighbourAggregate(const Vertex& vertex,
1385 const AggregatesMap<Vertex>& aggregates,
1386 SLList<Vertex>& neighbours) const;
1387
1395 template<class C>
1396 void growAggregate(const Vertex& vertex, const AggregatesMap<Vertex>& aggregates, const C& c);
1397 template<class C>
1398 void growIsolatedAggregate(const Vertex& vertex, const AggregatesMap<Vertex>& aggregates, const C& c);
1399 };
1400
1401#ifndef DOXYGEN
1402
1403 template<class M, class N>
1404 inline void SymmetricDependency<M,N>::init(const Matrix* matrix)
1405 {
1406 matrix_ = matrix;
1407 }
1408
1409 template<class M, class N>
1410 inline void SymmetricDependency<M,N>::initRow(const Row& row, int index)
1411 {
1412 initRow(row, index, std::is_convertible<field_type, real_type>());
1413 }
1414
1415 template<class M, class N>
1416 inline void SymmetricDependency<M,N>::initRow(const Row& row, int index, const std::false_type&)
1417 {
1418 DUNE_THROW(InvalidStateException, "field_type needs to convertible to real_type");
1419 }
1420
1421 template<class M, class N>
1422 inline void SymmetricDependency<M,N>::initRow([[maybe_unused]] const Row& row, int index, const std::true_type&)
1423 {
1424 using std::min;
1426 row_ = index;
1427 diagonal_ = norm_(matrix_->operator[](row_)[row_]);
1428 }
1429
1430 template<class M, class N>
1431 inline void SymmetricDependency<M,N>::examine(const ColIter& col)
1432 {
1433 using std::max;
1434 real_type eij = norm_(*col);
1435 typename Matrix::ConstColIterator opposite_entry =
1436 matrix_->operator[](col.index()).find(row_);
1437 if ( opposite_entry == matrix_->operator[](col.index()).end() )
1438 {
1439 // Consider this a weak connection we disregard.
1440 return;
1441 }
1442 real_type eji = norm_(*opposite_entry);
1443
1444 // skip positive offdiagonals if norm preserves sign of them.
1445 if(!N::is_sign_preserving || eij<0 || eji<0)
1446 maxValue_ = max(maxValue_,
1447 eij /diagonal_ * eji/
1448 norm_(matrix_->operator[](col.index())[col.index()]));
1449 }
1450
1451 template<class M, class N>
1452 template<class G>
1453 inline void SymmetricDependency<M,N>::examine(G& graph, const typename G::EdgeIterator& edge, const ColIter& col)
1454 {
1455 real_type eij = norm_(*col);
1456 typename Matrix::ConstColIterator opposite_entry =
1457 matrix_->operator[](col.index()).find(row_);
1458
1459 if ( opposite_entry == matrix_->operator[](col.index()).end() )
1460 {
1461 // Consider this as a weak connection we disregard.
1462 return;
1463 }
1464 real_type eji = norm_(*opposite_entry);
1465 // skip positive offdiagonals if norm preserves sign of them.
1466 if(!N::is_sign_preserving || (eij<0 || eji<0))
1467 if(eji / norm_(matrix_->operator[](edge.target())[edge.target()]) *
1468 eij/ diagonal_ > alpha() * maxValue_) {
1469 edge.properties().setDepends();
1470 edge.properties().setInfluences();
1471 typename G::EdgeProperties& other = graph.getEdgeProperties(edge.target(), edge.source());
1472 other.setInfluences();
1473 other.setDepends();
1474 }
1475 }
1476
1477 template<class M, class N>
1478 inline bool SymmetricDependency<M,N>::isIsolated()
1479 {
1480 return maxValue_ < beta();
1481 }
1482
1483
1484 template<class M, class N>
1485 inline void Dependency<M,N>::init(const Matrix* matrix)
1486 {
1487 matrix_ = matrix;
1488 }
1489
1490 template<class M, class N>
1491 inline void Dependency<M,N>::initRow([[maybe_unused]] const Row& row, int index)
1492 {
1493 using std::min;
1495 row_ = index;
1496 diagonal_ = norm_(matrix_->operator[](row_)[row_]);
1497 }
1498
1499 template<class M, class N>
1500 inline void Dependency<M,N>::examine(const ColIter& col)
1501 {
1502 using std::max;
1503 maxValue_ = max(maxValue_, -norm_(*col));
1504 }
1505
1506 template<class M, class N>
1507 template<class G>
1508 inline void Dependency<M,N>::examine(G& graph, const typename G::EdgeIterator& edge, const ColIter& col)
1509 {
1510 if(-norm_(*col) >= maxValue_ * alpha()) {
1511 edge.properties().setDepends();
1512 typedef typename G::EdgeDescriptor ED;
1513 ED e= graph.findEdge(edge.target(), edge.source());
1515 {
1516 typename G::EdgeProperties& other = graph.getEdgeProperties(e);
1517 other.setInfluences();
1518 }
1519 }
1520 }
1521
1522 template<class M, class N>
1523 inline bool Dependency<M,N>::isIsolated()
1524 {
1525 return maxValue_ < beta() * diagonal_;
1526 }
1527
1528 template<class G,class S>
1529 Aggregate<G,S>::Aggregate(MatrixGraph& graph, AggregatesMap<Vertex>& aggregates,
1530 VertexSet& connected, std::vector<Vertex>& front)
1531 : vertices_(), id_(-1), graph_(graph), aggregates_(aggregates),
1532 connected_(connected), front_(front)
1533 {}
1534
1535 template<class G,class S>
1537 {
1538 /*
1539 vertices_.push_back(vertex);
1540 typedef typename VertexList::const_iterator iterator;
1541 iterator begin = vertices_.begin();
1542 iterator end = vertices_.end();*/
1543 throw "Not yet implemented";
1544
1545 // while(begin!=end){
1546 //for();
1547 // }
1548
1549 }
1550
1551 template<class G,class S>
1552 inline void Aggregate<G,S>::seed(const Vertex& vertex)
1553 {
1554 dvverb<<"Connected cleared"<<std::endl;
1555 connected_.clear();
1556 vertices_.clear();
1557 connected_.insert(vertex);
1558 dvverb << " Inserting "<<vertex<<" size="<<connected_.size();
1559 ++id_ ;
1560 add(vertex);
1561 }
1562
1563
1564 template<class G,class S>
1565 inline void Aggregate<G,S>::add(const Vertex& vertex)
1566 {
1567 vertices_.insert(vertex);
1568 aggregates_[vertex]=id_;
1569 if(front_.size())
1570 front_.erase(std::lower_bound(front_.begin(), front_.end(), vertex));
1571
1572
1573 typedef typename MatrixGraph::ConstEdgeIterator iterator;
1574 const iterator end = graph_.endEdges(vertex);
1575 for(iterator edge = graph_.beginEdges(vertex); edge != end; ++edge) {
1576 dvverb << " Inserting "<<aggregates_[edge.target()];
1577 connected_.insert(aggregates_[edge.target()]);
1578 dvverb <<" size="<<connected_.size();
1579 if(aggregates_[edge.target()]==AggregatesMap<Vertex>::UNAGGREGATED &&
1580 !graph_.getVertexProperties(edge.target()).front())
1581 {
1582 front_.push_back(edge.target());
1583 graph_.getVertexProperties(edge.target()).setFront();
1584 }
1585 }
1586 dvverb <<std::endl;
1587 std::sort(front_.begin(), front_.end());
1588 }
1589
1590 template<class G,class S>
1591 inline void Aggregate<G,S>::add(std::vector<Vertex>& vertices)
1592 {
1593#ifndef NDEBUG
1594 std::size_t oldsize = vertices_.size();
1595#endif
1596 typedef typename std::vector<Vertex>::iterator Iterator;
1597
1598 typedef typename VertexSet::iterator SIterator;
1599
1600 SIterator pos=vertices_.begin();
1601 std::vector<Vertex> newFront;
1602 newFront.reserve(front_.capacity());
1603
1604 std::set_difference(front_.begin(), front_.end(), vertices.begin(), vertices.end(),
1605 std::back_inserter(newFront));
1606 front_=newFront;
1607
1608 for(Iterator vertex=vertices.begin(); vertex != vertices.end(); ++vertex)
1609 {
1610 pos=vertices_.insert(pos,*vertex);
1611 vertices_.insert(*vertex);
1612 graph_.getVertexProperties(*vertex).resetFront(); // Not a front node any more.
1613 aggregates_[*vertex]=id_;
1614
1615 typedef typename MatrixGraph::ConstEdgeIterator iterator;
1616 const iterator end = graph_.endEdges(*vertex);
1617 for(iterator edge = graph_.beginEdges(*vertex); edge != end; ++edge) {
1618 dvverb << " Inserting "<<aggregates_[edge.target()];
1619 connected_.insert(aggregates_[edge.target()]);
1620 if(aggregates_[edge.target()]==AggregatesMap<Vertex>::UNAGGREGATED &&
1621 !graph_.getVertexProperties(edge.target()).front())
1622 {
1623 front_.push_back(edge.target());
1624 graph_.getVertexProperties(edge.target()).setFront();
1625 }
1626 dvverb <<" size="<<connected_.size();
1627 }
1628 dvverb <<std::endl;
1629 }
1630 std::sort(front_.begin(), front_.end());
1631 assert(oldsize+vertices.size()==vertices_.size());
1632 }
1633 template<class G,class S>
1634 inline void Aggregate<G,S>::clear()
1635 {
1636 vertices_.clear();
1637 connected_.clear();
1638 id_=-1;
1639 }
1640
1641 template<class G,class S>
1642 inline typename Aggregate<G,S>::VertexSet::size_type
1644 {
1645 return vertices_.size();
1646 }
1647
1648 template<class G,class S>
1649 inline typename Aggregate<G,S>::VertexSet::size_type
1651 {
1652 return connected_.size();
1653 }
1654
1655 template<class G,class S>
1656 inline int Aggregate<G,S>::id()
1657 {
1658 return id_;
1659 }
1660
1661 template<class G,class S>
1663 {
1664 return vertices_.begin();
1665 }
1666
1667 template<class G,class S>
1669 {
1670 return vertices_.end();
1671 }
1672
1673 template<class V>
1675
1676 template<class V>
1678
1679 template<class V>
1681 : aggregates_(0)
1682 {}
1683
1684 template<class V>
1686 {
1687 if(aggregates_!=0)
1688 delete[] aggregates_;
1689 }
1690
1691
1692 template<class V>
1693 inline AggregatesMap<V>::AggregatesMap(std::size_t noVertices)
1694 {
1695 allocate(noVertices);
1696 }
1697
1698 template<class V>
1699 inline std::size_t AggregatesMap<V>::noVertices() const
1700 {
1701 return noVertices_;
1702 }
1703
1704 template<class V>
1705 inline void AggregatesMap<V>::allocate(std::size_t noVertices)
1706 {
1707 aggregates_ = new AggregateDescriptor[noVertices];
1708 noVertices_ = noVertices;
1709
1710 for(std::size_t i=0; i < noVertices; i++)
1711 aggregates_[i]=UNAGGREGATED;
1712 }
1713
1714 template<class V>
1715 inline void AggregatesMap<V>::free()
1716 {
1717 assert(aggregates_ != 0);
1718 delete[] aggregates_;
1719 aggregates_=0;
1720 }
1721
1722 template<class V>
1724 AggregatesMap<V>::operator[](const VertexDescriptor& v)
1725 {
1726 return aggregates_[v];
1727 }
1728
1729 template<class V>
1730 inline const typename AggregatesMap<V>::AggregateDescriptor&
1731 AggregatesMap<V>::operator[](const VertexDescriptor& v) const
1732 {
1733 return aggregates_[v];
1734 }
1735
1736 template<class V>
1737 template<bool reset, class G, class F,class VM>
1738 inline std::size_t AggregatesMap<V>::breadthFirstSearch(const V& start,
1739 const AggregateDescriptor& aggregate,
1740 const G& graph, F& aggregateVisitor,
1741 VM& visitedMap) const
1742 {
1743 VertexList vlist;
1744
1745 DummyEdgeVisitor dummy;
1746 return breadthFirstSearch<true,reset>(start, aggregate, graph, vlist, aggregateVisitor, dummy, visitedMap);
1747 }
1748
1749 template<class V>
1750 template<bool remove, bool reset, class G, class L, class F1, class F2, class VM>
1751 std::size_t AggregatesMap<V>::breadthFirstSearch(const V& start,
1752 const AggregateDescriptor& aggregate,
1753 const G& graph,
1754 L& visited,
1755 F1& aggregateVisitor,
1756 F2& nonAggregateVisitor,
1757 VM& visitedMap) const
1758 {
1759 typedef typename L::const_iterator ListIterator;
1760 int visitedSpheres = 0;
1761
1762 visited.push_back(start);
1763 put(visitedMap, start, true);
1764
1765 ListIterator current = visited.begin();
1766 ListIterator end = visited.end();
1767 std::size_t i=0, size=visited.size();
1768
1769 // visit the neighbours of all vertices of the
1770 // current sphere.
1771 while(current != end) {
1772
1773 for(; i<size; ++current, ++i) {
1774 typedef typename G::ConstEdgeIterator EdgeIterator;
1775 const EdgeIterator endEdge = graph.endEdges(*current);
1776
1777 for(EdgeIterator edge = graph.beginEdges(*current);
1778 edge != endEdge; ++edge) {
1779
1780 if(aggregates_[edge.target()]==aggregate) {
1781 if(!get(visitedMap, edge.target())) {
1782 put(visitedMap, edge.target(), true);
1783 visited.push_back(edge.target());
1784 aggregateVisitor(edge);
1785 }
1786 }else
1787 nonAggregateVisitor(edge);
1788 }
1789 }
1790 end = visited.end();
1791 size = visited.size();
1792 if(current != end)
1793 visitedSpheres++;
1794 }
1795
1796 if(reset)
1797 for(current = visited.begin(); current != end; ++current)
1798 put(visitedMap, *current, false);
1799
1800
1801 if(remove)
1802 visited.clear();
1803
1804 return visitedSpheres;
1805 }
1806
1807 template<class G>
1809 : graph_(0), aggregate_(0), front_(), connected_(), size_(-1)
1810 {}
1811
1812 template<class G>
1814 {
1815 size_=-1;
1816 }
1817
1818 template<class G, class C>
1819 void buildDependency(G& graph,
1820 const typename C::Matrix& matrix,
1821 C criterion, bool firstlevel)
1822 {
1823 // assert(graph.isBuilt());
1824 typedef typename C::Matrix Matrix;
1825 typedef typename G::VertexIterator VertexIterator;
1826
1827 criterion.init(&matrix);
1828
1829 for(VertexIterator vertex = graph.begin(); vertex != graph.end(); ++vertex) {
1830 typedef typename Matrix::row_type Row;
1831
1832 const Row& row = matrix[*vertex];
1833
1834 // Tell the criterion what row we will examine now
1835 // This might for example be used for calculating the
1836 // maximum offdiagonal value
1837 criterion.initRow(row, *vertex);
1838
1839 // On a first path all columns are examined. After this
1840 // the calculator should know whether the vertex is isolated.
1841 typedef typename Matrix::ConstColIterator ColIterator;
1842 ColIterator end = row.end();
1843 typename FieldTraits<typename Matrix::field_type>::real_type absoffdiag=0.;
1844
1845 using std::max;
1846 if(firstlevel) {
1847 for(ColIterator col = row.begin(); col != end; ++col)
1848 if(col.index()!=*vertex) {
1849 criterion.examine(col);
1850 absoffdiag = max(absoffdiag, Impl::asMatrix(*col).frobenius_norm());
1851 }
1852
1853 if(absoffdiag==0)
1854 vertex.properties().setExcludedBorder();
1855 }
1856 else
1857 for(ColIterator col = row.begin(); col != end; ++col)
1858 if(col.index()!=*vertex)
1859 criterion.examine(col);
1860
1861 // reset the vertex properties
1862 //vertex.properties().reset();
1863
1864 // Check whether the vertex is isolated.
1865 if(criterion.isIsolated()) {
1866 //std::cout<<"ISOLATED: "<<*vertex<<std::endl;
1867 vertex.properties().setIsolated();
1868 }else{
1869 // Examine all the edges beginning at this vertex.
1870 auto eEnd = vertex.end();
1871 auto col = matrix[*vertex].begin();
1872
1873 for(auto edge = vertex.begin(); edge!= eEnd; ++edge, ++col) {
1874 // Move to the right column.
1875 while(col.index()!=edge.target())
1876 ++col;
1877 criterion.examine(graph, edge, col);
1878 }
1879 }
1880
1881 }
1882 }
1883
1884
1885 template<class G>
1886 template<class V>
1887 inline Aggregator<G>::AggregateVisitor<V>::AggregateVisitor(const AggregatesMap<Vertex>& aggregates,
1888 const AggregateDescriptor& aggregate, V& visitor)
1889 : aggregates_(aggregates), aggregate_(aggregate), visitor_(&visitor)
1890 {}
1891
1892 template<class G>
1893 template<class V>
1894 inline void Aggregator<G>::AggregateVisitor<V>::operator()(const typename MatrixGraph::ConstEdgeIterator& edge)
1895 {
1896 if(aggregates_[edge.target()]==aggregate_)
1897 visitor_->operator()(edge);
1898 }
1899
1900 template<class G>
1901 template<class V>
1902 inline void Aggregator<G>::visitAggregateNeighbours(const Vertex& vertex,
1903 const AggregateDescriptor& aggregate,
1904 const AggregatesMap<Vertex>& aggregates,
1905 V& visitor) const
1906 {
1907 // Only evaluates for edge pointing to the aggregate
1908 AggregateVisitor<V> v(aggregates, aggregate, visitor);
1909 visitNeighbours(*graph_, vertex, v);
1910 }
1911
1912
1913 template<class G>
1914 inline Aggregator<G>::Counter::Counter()
1915 : count_(0)
1916 {}
1917
1918 template<class G>
1919 inline void Aggregator<G>::Counter::increment()
1920 {
1921 ++count_;
1922 }
1923
1924 template<class G>
1925 inline void Aggregator<G>::Counter::decrement()
1926 {
1927 --count_;
1928 }
1929 template<class G>
1930 inline int Aggregator<G>::Counter::value()
1931 {
1932 return count_;
1933 }
1934
1935 template<class G>
1936 inline void Aggregator<G>::TwoWayCounter::operator()(const typename MatrixGraph::ConstEdgeIterator& edge)
1937 {
1938 if(edge.properties().isTwoWay())
1939 Counter::increment();
1940 }
1941
1942 template<class G>
1943 int Aggregator<G>::twoWayConnections(const Vertex& vertex, const AggregateDescriptor& aggregate,
1944 const AggregatesMap<Vertex>& aggregates) const
1945 {
1946 TwoWayCounter counter;
1947 visitAggregateNeighbours(vertex, aggregate, aggregates, counter);
1948 return counter.value();
1949 }
1950
1951 template<class G>
1952 int Aggregator<G>::oneWayConnections(const Vertex& vertex, const AggregateDescriptor& aggregate,
1953 const AggregatesMap<Vertex>& aggregates) const
1954 {
1955 OneWayCounter counter;
1956 visitAggregateNeighbours(vertex, aggregate, aggregates, counter);
1957 return counter.value();
1958 }
1959
1960 template<class G>
1961 inline void Aggregator<G>::OneWayCounter::operator()(const typename MatrixGraph::ConstEdgeIterator& edge)
1962 {
1963 if(edge.properties().isOneWay())
1964 Counter::increment();
1965 }
1966
1967 template<class G>
1968 inline Aggregator<G>::ConnectivityCounter::ConnectivityCounter(const VertexSet& connected,
1969 const AggregatesMap<Vertex>& aggregates)
1970 : Counter(), connected_(connected), aggregates_(aggregates)
1971 {}
1972
1973
1974 template<class G>
1975 inline void Aggregator<G>::ConnectivityCounter::operator()(const typename MatrixGraph::ConstEdgeIterator& edge)
1976 {
1977 if(connected_.find(aggregates_[edge.target()]) == connected_.end() || aggregates_[edge.target()]==AggregatesMap<Vertex>::UNAGGREGATED)
1978 // Would be a new connection
1979 Counter::increment();
1980 else{
1981 Counter::increment();
1982 Counter::increment();
1983 }
1984 }
1985
1986 template<class G>
1987 inline double Aggregator<G>::connectivity(const Vertex& vertex, const AggregatesMap<Vertex>& aggregates) const
1988 {
1989 ConnectivityCounter counter(connected_, aggregates);
1990 double noNeighbours=visitNeighbours(*graph_, vertex, counter);
1991 return (double)counter.value()/noNeighbours;
1992 }
1993
1994 template<class G>
1995 inline Aggregator<G>::DependencyCounter::DependencyCounter()
1996 : Counter()
1997 {}
1998
1999 template<class G>
2000 inline void Aggregator<G>::DependencyCounter::operator()(const typename MatrixGraph::ConstEdgeIterator& edge)
2001 {
2002 if(edge.properties().depends())
2003 Counter::increment();
2004 if(edge.properties().influences())
2005 Counter::increment();
2006 }
2007
2008 template<class G>
2009 int Aggregator<G>::unusedNeighbours(const Vertex& vertex, const AggregatesMap<Vertex>& aggregates) const
2010 {
2011 return aggregateNeighbours(vertex, AggregatesMap<Vertex>::UNAGGREGATED, aggregates);
2012 }
2013
2014 template<class G>
2015 std::pair<int,int> Aggregator<G>::neighbours(const Vertex& vertex,
2016 const AggregateDescriptor& aggregate,
2017 const AggregatesMap<Vertex>& aggregates) const
2018 {
2019 DependencyCounter unused, aggregated;
2020 typedef AggregateVisitor<DependencyCounter> CounterT;
2021 typedef std::tuple<CounterT,CounterT> CounterTuple;
2022 CombinedFunctor<CounterTuple> visitors(CounterTuple(CounterT(aggregates, AggregatesMap<Vertex>::UNAGGREGATED, unused), CounterT(aggregates, aggregate, aggregated)));
2023 visitNeighbours(*graph_, vertex, visitors);
2024 return std::make_pair(unused.value(), aggregated.value());
2025 }
2026
2027
2028 template<class G>
2029 int Aggregator<G>::aggregateNeighbours(const Vertex& vertex, const AggregateDescriptor& aggregate, const AggregatesMap<Vertex>& aggregates) const
2030 {
2031 DependencyCounter counter;
2032 visitAggregateNeighbours(vertex, aggregate, aggregates, counter);
2033 return counter.value();
2034 }
2035
2036 template<class G>
2037 std::size_t Aggregator<G>::distance(const Vertex& vertex, const AggregatesMap<Vertex>& aggregates)
2038 {
2039 return 0;
2040 typename PropertyMapTypeSelector<VertexVisitedTag,G>::Type visitedMap = get(VertexVisitedTag(), *graph_);
2041 VertexList vlist;
2042 typename AggregatesMap<Vertex>::DummyEdgeVisitor dummy;
2043 return aggregates.template breadthFirstSearch<true,true>(vertex,
2044 aggregate_->id(), *graph_,
2045 vlist, dummy, dummy, visitedMap);
2046 }
2047
2048 template<class G>
2049 inline Aggregator<G>::FrontMarker::FrontMarker(std::vector<Vertex>& front, MatrixGraph& graph)
2050 : front_(front), graph_(graph)
2051 {}
2052
2053 template<class G>
2054 inline void Aggregator<G>::FrontMarker::operator()(const typename MatrixGraph::ConstEdgeIterator& edge)
2055 {
2056 Vertex target = edge.target();
2057
2058 if(!graph_.getVertexProperties(target).front()) {
2059 front_.push_back(target);
2060 graph_.getVertexProperties(target).setFront();
2061 }
2062 }
2063
2064 template<class G>
2065 inline bool Aggregator<G>::admissible(const Vertex& vertex, const AggregateDescriptor& aggregate, const AggregatesMap<Vertex>& aggregates) const
2066 {
2067 // Todo
2068 Dune::dvverb<<" Admissible not yet implemented!"<<std::endl;
2069 return true;
2070 //Situation 1: front node depends on two nodes. Then these
2071 // have to be strongly connected to each other
2072
2073 // Iterate over all all neighbours of front node
2074 typedef typename MatrixGraph::ConstEdgeIterator Iterator;
2075 Iterator vend = graph_->endEdges(vertex);
2076 for(Iterator edge = graph_->beginEdges(vertex); edge != vend; ++edge) {
2077 // if(edge.properties().depends() && !edge.properties().influences()
2078 if(edge.properties().isStrong()
2079 && aggregates[edge.target()]==aggregate)
2080 {
2081 // Search for another link to the aggregate
2082 Iterator edge1 = edge;
2083 for(++edge1; edge1 != vend; ++edge1) {
2084 //if(edge1.properties().depends() && !edge1.properties().influences()
2085 if(edge1.properties().isStrong()
2086 && aggregates[edge.target()]==aggregate)
2087 {
2088 //Search for an edge connecting the two vertices that is
2089 //strong
2090 bool found=false;
2091 Iterator v2end = graph_->endEdges(edge.target());
2092 for(Iterator edge2 = graph_->beginEdges(edge.target()); edge2 != v2end; ++edge2) {
2093 if(edge2.target()==edge1.target() &&
2094 edge2.properties().isStrong()) {
2095 found =true;
2096 break;
2097 }
2098 }
2099 if(found)
2100 {
2101 return true;
2102 }
2103 }
2104 }
2105 }
2106 }
2107
2108 // Situation 2: cluster node depends on front node and other cluster node
2110 vend = graph_->endEdges(vertex);
2111 for(Iterator edge = graph_->beginEdges(vertex); edge != vend; ++edge) {
2112 //if(!edge.properties().depends() && edge.properties().influences()
2113 if(edge.properties().isStrong()
2114 && aggregates[edge.target()]==aggregate)
2115 {
2116 // Search for a link from target that stays within the aggregate
2117 Iterator v1end = graph_->endEdges(edge.target());
2118
2119 for(Iterator edge1=graph_->beginEdges(edge.target()); edge1 != v1end; ++edge1) {
2120 //if(edge1.properties().depends() && !edge1.properties().influences()
2121 if(edge1.properties().isStrong()
2122 && aggregates[edge1.target()]==aggregate)
2123 {
2124 bool found=false;
2125 // Check if front node is also connected to this one
2126 Iterator v2end = graph_->endEdges(vertex);
2127 for(Iterator edge2 = graph_->beginEdges(vertex); edge2 != v2end; ++edge2) {
2128 if(edge2.target()==edge1.target()) {
2129 if(edge2.properties().isStrong())
2130 found=true;
2131 break;
2132 }
2133 }
2134 if(found)
2135 {
2136 return true;
2137 }
2138 }
2139 }
2140 }
2141 }
2142 return false;
2143 }
2144
2145 template<class G>
2146 void Aggregator<G>::unmarkFront()
2147 {
2148 typedef typename std::vector<Vertex>::const_iterator Iterator;
2149
2150 for(Iterator vertex=front_.begin(); vertex != front_.end(); ++vertex)
2151 graph_->getVertexProperties(*vertex).resetFront();
2152
2153 front_.clear();
2154 }
2155
2156 template<class G>
2157 inline void
2158 Aggregator<G>::nonisoNeighbourAggregate(const Vertex& vertex,
2159 const AggregatesMap<Vertex>& aggregates,
2160 SLList<Vertex>& neighbours) const
2161 {
2162 typedef typename MatrixGraph::ConstEdgeIterator Iterator;
2163 Iterator end=graph_->beginEdges(vertex);
2164 neighbours.clear();
2165
2166 for(Iterator edge=graph_->beginEdges(vertex); edge!=end; ++edge)
2167 {
2168 if(aggregates[edge.target()]!=AggregatesMap<Vertex>::UNAGGREGATED && graph_->getVertexProperties(edge.target()).isolated())
2169 neighbours.push_back(aggregates[edge.target()]);
2170 }
2171 }
2172
2173 template<class G>
2174 inline typename G::VertexDescriptor Aggregator<G>::mergeNeighbour(const Vertex& vertex, const AggregatesMap<Vertex>& aggregates) const
2175 {
2176 typedef typename MatrixGraph::ConstEdgeIterator Iterator;
2177
2178 Iterator end = graph_->endEdges(vertex);
2179 for(Iterator edge = graph_->beginEdges(vertex); edge != end; ++edge) {
2180 if(aggregates[edge.target()] != AggregatesMap<Vertex>::UNAGGREGATED &&
2181 graph_->getVertexProperties(edge.target()).isolated() == graph_->getVertexProperties(edge.source()).isolated()) {
2182 if( graph_->getVertexProperties(vertex).isolated() ||
2183 ((edge.properties().depends() || edge.properties().influences())
2184 && admissible(vertex, aggregates[edge.target()], aggregates)))
2185 return edge.target();
2186 }
2187 }
2189 }
2190
2191 template<class G>
2192 Aggregator<G>::FrontNeighbourCounter::FrontNeighbourCounter(const MatrixGraph& graph)
2193 : Counter(), graph_(graph)
2194 {}
2195
2196 template<class G>
2197 void Aggregator<G>::FrontNeighbourCounter::operator()(const typename MatrixGraph::ConstEdgeIterator& edge)
2198 {
2199 if(graph_.getVertexProperties(edge.target()).front())
2200 Counter::increment();
2201 }
2202
2203 template<class G>
2204 int Aggregator<G>::noFrontNeighbours(const Vertex& vertex) const
2205 {
2206 FrontNeighbourCounter counter(*graph_);
2207 visitNeighbours(*graph_, vertex, counter);
2208 return counter.value();
2209 }
2210 template<class G>
2211 inline bool Aggregator<G>::connected(const Vertex& vertex,
2212 const AggregateDescriptor& aggregate,
2213 const AggregatesMap<Vertex>& aggregates) const
2214 {
2215 typedef typename G::ConstEdgeIterator iterator;
2216 const iterator end = graph_->endEdges(vertex);
2217 for(iterator edge = graph_->beginEdges(vertex); edge != end; ++edge)
2218 if(aggregates[edge.target()]==aggregate)
2219 return true;
2220 return false;
2221 }
2222 template<class G>
2223 inline bool Aggregator<G>::connected(const Vertex& vertex,
2224 const SLList<AggregateDescriptor>& aggregateList,
2225 const AggregatesMap<Vertex>& aggregates) const
2226 {
2227 typedef typename SLList<AggregateDescriptor>::const_iterator Iter;
2228 for(Iter i=aggregateList.begin(); i!=aggregateList.end(); ++i)
2229 if(connected(vertex, *i, aggregates))
2230 return true;
2231 return false;
2232 }
2233
2234 template<class G>
2235 template<class C>
2236 void Aggregator<G>::growIsolatedAggregate(const Vertex& seed, const AggregatesMap<Vertex>& aggregates, const C& c)
2237 {
2238 SLList<Vertex> connectedAggregates;
2239 nonisoNeighbourAggregate(seed, aggregates,connectedAggregates);
2240
2241 while(aggregate_->size()< c.minAggregateSize() && aggregate_->connectSize() < c.maxConnectivity()) {
2242 double maxCon=-1;
2243 std::size_t maxFrontNeighbours=0;
2244
2246
2247 typedef typename std::vector<Vertex>::const_iterator Iterator;
2248
2249 for(Iterator vertex = front_.begin(); vertex != front_.end(); ++vertex) {
2250 if(distance(*vertex, aggregates)>c.maxDistance())
2251 continue; // distance of proposes aggregate too big
2252
2253 if(connectedAggregates.size()>0) {
2254 // there is already a neighbour cluster
2255 // front node must be connected to same neighbour cluster
2256
2257 if(!connected(*vertex, connectedAggregates, aggregates))
2258 continue;
2259 }
2260
2261 double con = connectivity(*vertex, aggregates);
2262
2263 if(con == maxCon) {
2264 std::size_t frontNeighbours = noFrontNeighbours(*vertex);
2265
2266 if(frontNeighbours >= maxFrontNeighbours) {
2267 maxFrontNeighbours = frontNeighbours;
2268 candidate = *vertex;
2269 }
2270 }else if(con > maxCon) {
2271 maxCon = con;
2272 maxFrontNeighbours = noFrontNeighbours(*vertex);
2273 candidate = *vertex;
2274 }
2275 }
2276
2278 break;
2279
2280 aggregate_->add(candidate);
2281 }
2282 }
2283
2284 template<class G>
2285 template<class C>
2286 void Aggregator<G>::growAggregate(const Vertex& seed, const AggregatesMap<Vertex>& aggregates, const C& c)
2287 {
2288 using std::min;
2289
2290 std::size_t distance_ =0;
2291 while(aggregate_->size() < c.minAggregateSize()&& distance_<c.maxDistance()) {
2292 int maxTwoCons=0, maxOneCons=0, maxNeighbours=-1;
2293 double maxCon=-1;
2294
2295 std::vector<Vertex> candidates;
2296 candidates.reserve(30);
2297
2298 typedef typename std::vector<Vertex>::const_iterator Iterator;
2299
2300 for(Iterator vertex = front_.begin(); vertex != front_.end(); ++vertex) {
2301 // Only nonisolated nodes are considered
2302 if(graph_->getVertexProperties(*vertex).isolated())
2303 continue;
2304
2305 int twoWayCons = twoWayConnections(*vertex, aggregate_->id(), aggregates);
2306
2307 /* The case of two way connections. */
2308 if( maxTwoCons == twoWayCons && twoWayCons > 0) {
2309 double con = connectivity(*vertex, aggregates);
2310
2311 if(con == maxCon) {
2312 int neighbours = noFrontNeighbours(*vertex);
2313
2314 if(neighbours > maxNeighbours) {
2315 maxNeighbours = neighbours;
2316 candidates.clear();
2317 candidates.push_back(*vertex);
2318 }else{
2319 candidates.push_back(*vertex);
2320 }
2321 }else if( con > maxCon) {
2322 maxCon = con;
2323 maxNeighbours = noFrontNeighbours(*vertex);
2324 candidates.clear();
2325 candidates.push_back(*vertex);
2326 }
2327 }else if(twoWayCons > maxTwoCons) {
2328 maxTwoCons = twoWayCons;
2329 maxCon = connectivity(*vertex, aggregates);
2330 maxNeighbours = noFrontNeighbours(*vertex);
2331 candidates.clear();
2332 candidates.push_back(*vertex);
2333
2334 // two way connections precede
2335 maxOneCons = std::numeric_limits<int>::max();
2336 }
2337
2338 if(twoWayCons > 0)
2339 {
2340 continue; // THis is a two-way node, skip tests for one way nodes
2341 }
2342
2343 /* The one way case */
2344 int oneWayCons = oneWayConnections(*vertex, aggregate_->id(), aggregates);
2345
2346 if(oneWayCons==0)
2347 continue; // No strong connections, skip the tests.
2348
2349 if(!admissible(*vertex, aggregate_->id(), aggregates))
2350 continue;
2351
2352 if( maxOneCons == oneWayCons && oneWayCons > 0) {
2353 double con = connectivity(*vertex, aggregates);
2354
2355 if(con == maxCon) {
2356 int neighbours = noFrontNeighbours(*vertex);
2357
2358 if(neighbours > maxNeighbours) {
2359 maxNeighbours = neighbours;
2360 candidates.clear();
2361 candidates.push_back(*vertex);
2362 }else{
2363 if(neighbours==maxNeighbours)
2364 {
2365 candidates.push_back(*vertex);
2366 }
2367 }
2368 }else if( con > maxCon) {
2369 maxCon = con;
2370 maxNeighbours = noFrontNeighbours(*vertex);
2371 candidates.clear();
2372 candidates.push_back(*vertex);
2373 }
2374 }else if(oneWayCons > maxOneCons) {
2375 maxOneCons = oneWayCons;
2376 maxCon = connectivity(*vertex, aggregates);
2377 maxNeighbours = noFrontNeighbours(*vertex);
2378 candidates.clear();
2379 candidates.push_back(*vertex);
2380 }
2381 }
2382
2383
2384 if(!candidates.size())
2385 break; // No more candidates found
2386 distance_=distance(seed, aggregates);
2387 candidates.resize(min(candidates.size(), c.maxAggregateSize()-
2388 aggregate_->size()));
2389 aggregate_->add(candidates);
2390 }
2391 }
2392
2393 template<typename V>
2394 template<typename M, typename G, typename C>
2395 std::tuple<int,int,int,int> AggregatesMap<V>::buildAggregates(const M& matrix, G& graph, const C& criterion,
2396 bool finestLevel)
2397 {
2398 Aggregator<G> aggregator;
2399 return aggregator.build(matrix, graph, *this, criterion, finestLevel);
2400 }
2401
2402 template<class G>
2403 template<class M, class C>
2404 std::tuple<int,int,int,int> Aggregator<G>::build(const M& m, G& graph, AggregatesMap<Vertex>& aggregates, const C& c,
2405 bool finestLevel)
2406 {
2407 using std::max;
2408 using std::min;
2409 // Stack for fast vertex access
2410 Stack stack_(graph, *this, aggregates);
2411
2412 graph_ = &graph;
2413
2414 aggregate_ = new Aggregate<G,VertexSet>(graph, aggregates, connected_, front_);
2415
2416 Timer watch;
2417 watch.reset();
2418
2419 buildDependency(graph, m, c, finestLevel);
2420
2421 dverb<<"Build dependency took "<< watch.elapsed()<<" seconds."<<std::endl;
2422 int noAggregates, conAggregates, isoAggregates, oneAggregates;
2423 std::size_t maxA=0, minA=1000000, avg=0;
2424 int skippedAggregates;
2425 noAggregates = conAggregates = isoAggregates = oneAggregates =
2426 skippedAggregates = 0;
2427
2428 while(true) {
2429 Vertex seed = stack_.pop();
2430
2431 if(seed == Stack::NullEntry)
2432 // No more unaggregated vertices. We are finished!
2433 break;
2434
2435 // Debugging output
2436 if((noAggregates+1)%10000 == 0)
2437 Dune::dverb<<"c";
2438 unmarkFront();
2439
2440 if(graph.getVertexProperties(seed).excludedBorder()) {
2441 aggregates[seed]=AggregatesMap<Vertex>::ISOLATED;
2442 ++skippedAggregates;
2443 continue;
2444 }
2445
2446 if(graph.getVertexProperties(seed).isolated()) {
2447 if(c.skipIsolated()) {
2448 // isolated vertices are not aggregated but skipped on the coarser levels.
2449 aggregates[seed]=AggregatesMap<Vertex>::ISOLATED;
2450 ++skippedAggregates;
2451 // skip rest as no agglomeration is done.
2452 continue;
2453 }else{
2454 aggregate_->seed(seed);
2455 growIsolatedAggregate(seed, aggregates, c);
2456 }
2457 }else{
2458 aggregate_->seed(seed);
2459 growAggregate(seed, aggregates, c);
2460 }
2461
2462 /* The rounding step. */
2463 while(!(graph.getVertexProperties(seed).isolated()) && aggregate_->size() < c.maxAggregateSize()) {
2464
2465 std::vector<Vertex> candidates;
2466 candidates.reserve(30);
2467
2468 typedef typename std::vector<Vertex>::const_iterator Iterator;
2469
2470 for(Iterator vertex = front_.begin(); vertex != front_.end(); ++vertex) {
2471
2472 if(graph.getVertexProperties(*vertex).isolated())
2473 continue; // No isolated nodes here
2474
2475 if(twoWayConnections( *vertex, aggregate_->id(), aggregates) == 0 &&
2476 (oneWayConnections( *vertex, aggregate_->id(), aggregates) == 0 ||
2477 !admissible( *vertex, aggregate_->id(), aggregates) ))
2478 continue;
2479
2480 std::pair<int,int> neighbourPair=neighbours(*vertex, aggregate_->id(),
2481 aggregates);
2482
2483 //if(aggregateNeighbours(*vertex, aggregate_->id(), aggregates) <= unusedNeighbours(*vertex, aggregates))
2484 // continue;
2485
2486 if(neighbourPair.first >= neighbourPair.second)
2487 continue;
2488
2489 if(distance(*vertex, aggregates) > c.maxDistance())
2490 continue; // Distance too far
2491 candidates.push_back(*vertex);
2492 break;
2493 }
2494
2495 if(!candidates.size()) break; // no more candidates found.
2496
2497 candidates.resize(min(candidates.size(), c.maxAggregateSize()-
2498 aggregate_->size()));
2499 aggregate_->add(candidates);
2500
2501 }
2502
2503 // try to merge aggregates consisting of only one nonisolated vertex with other aggregates
2504 if(aggregate_->size()==1 && c.maxAggregateSize()>1) {
2505 if(!graph.getVertexProperties(seed).isolated()) {
2506 Vertex mergedNeighbour = mergeNeighbour(seed, aggregates);
2507
2508 if(mergedNeighbour != AggregatesMap<Vertex>::UNAGGREGATED) {
2509 // assign vertex to the neighbouring cluster
2510 aggregates[seed] = aggregates[mergedNeighbour];
2511 aggregate_->invalidate();
2512 }else{
2513 ++avg;
2514 minA=min(minA,static_cast<std::size_t>(1));
2515 maxA=max(maxA,static_cast<std::size_t>(1));
2516 ++oneAggregates;
2517 ++conAggregates;
2518 }
2519 }else{
2520 ++avg;
2521 minA=min(minA,static_cast<std::size_t>(1));
2522 maxA=max(maxA,static_cast<std::size_t>(1));
2523 ++oneAggregates;
2524 ++isoAggregates;
2525 }
2526 ++avg;
2527 }else{
2528 avg+=aggregate_->size();
2529 minA=min(minA,aggregate_->size());
2530 maxA=max(maxA,aggregate_->size());
2531 if(graph.getVertexProperties(seed).isolated())
2532 ++isoAggregates;
2533 else
2534 ++conAggregates;
2535 }
2536
2537 }
2538
2539 Dune::dinfo<<"connected aggregates: "<<conAggregates;
2540 Dune::dinfo<<" isolated aggregates: "<<isoAggregates;
2541 if(conAggregates+isoAggregates>0)
2542 Dune::dinfo<<" one node aggregates: "<<oneAggregates<<" min size="
2543 <<minA<<" max size="<<maxA
2544 <<" avg="<<avg/(conAggregates+isoAggregates)<<std::endl;
2545
2546 delete aggregate_;
2547 return std::make_tuple(conAggregates+isoAggregates,isoAggregates,
2548 oneAggregates,skippedAggregates);
2549 }
2550
2551
2552 template<class G>
2553 Aggregator<G>::Stack::Stack(const MatrixGraph& graph, const Aggregator<G>& aggregatesBuilder,
2554 const AggregatesMap<Vertex>& aggregates)
2555 : graph_(graph), aggregatesBuilder_(aggregatesBuilder), aggregates_(aggregates), begin_(graph.begin()), end_(graph.end())
2556 {
2557 //vals_ = new Vertex[N];
2558 }
2559
2560 template<class G>
2561 Aggregator<G>::Stack::~Stack()
2562 {
2563 //Dune::dverb << "Max stack size was "<<maxSize_<<" filled="<<filled_<<std::endl;
2564 //delete[] vals_;
2565 }
2566
2567 template<class G>
2568 const typename Aggregator<G>::Vertex Aggregator<G>::Stack::NullEntry
2570
2571 template<class G>
2572 inline typename G::VertexDescriptor Aggregator<G>::Stack::pop()
2573 {
2574 for(; begin_!=end_ && aggregates_[*begin_] != AggregatesMap<Vertex>::UNAGGREGATED; ++begin_) ;
2575
2576 if(begin_!=end_)
2577 {
2578 typename G::VertexDescriptor current=*begin_;
2579 ++begin_;
2580 return current;
2581 }else
2582 return NullEntry;
2583 }
2584
2585#endif // DOXYGEN
2586
2587 template<class V>
2588 void printAggregates2d(const AggregatesMap<V>& aggregates, int n, int m, std::ostream& os)
2589 {
2590 using std::max;
2591
2592 std::ios_base::fmtflags oldOpts=os.flags();
2593
2594 os.setf(std::ios_base::right, std::ios_base::adjustfield);
2595
2596 V maxVal=0;
2597 int width=1;
2598
2599 for(int i=0; i< n*m; i++)
2600 maxVal=max(maxVal, aggregates[i]);
2601
2602 for(int i=10; i < 1000000; i*=10)
2603 if(maxVal/i>0)
2604 width++;
2605 else
2606 break;
2607
2608 for(int j=0, entry=0; j < m; j++) {
2609 for(int i=0; i<n; i++, entry++) {
2610 os.width(width);
2611 os<<aggregates[entry]<<" ";
2612 }
2613
2614 os<<std::endl;
2615 }
2616 os<<std::endl;
2617 os.flags(oldOpts);
2618 }
2619
2620
2621 } // namespace Amg
2622
2623} // namespace Dune
2624
2625
2626#endif
A class for temporarily storing the vertices of an aggregate in.
Definition: aggregates.hh:784
A Dummy visitor that does nothing for each visited edge.
Definition: aggregates.hh:604
Class providing information about the mapping of the vertices onto aggregates.
Definition: aggregates.hh:566
Base class of all aggregation criterions.
Definition: aggregates.hh:51
Class for building the aggregates.
Definition: aggregates.hh:915
Dependency policy for symmetric matrices.
Definition: aggregates.hh:255
Norm that uses only the [N][N] entry of the block to determine couplings.
Definition: aggregates.hh:381
Norm that uses only the [0][0] entry of the block to determine couplings.
Definition: aggregates.hh:457
Iterator over all edges starting from a vertex.
Definition: graph.hh:95
The vertex iterator type of the graph.
Definition: graph.hh:209
The (undirected) graph of a matrix.
Definition: graph.hh:51
M::size_type VertexDescriptor
The vertex descriptor.
Definition: graph.hh:73
EdgeIteratorT< const MatrixGraph< Matrix > > ConstEdgeIterator
The constant edge iterator type.
Definition: graph.hh:298
All parameters for AMG.
Definition: parameters.hh:416
Criterion taking advantage of symmetric matrices.
Definition: aggregates.hh:525
Dependency policy for symmetric matrices.
Definition: aggregates.hh:316
Dependency policy for symmetric matrices.
Definition: aggregates.hh:136
Criterion suitable for unsymmetric matrices.
Definition: aggregates.hh:545
derive error class from the base class in common
Definition: istlexception.hh:19
A generic dynamic dense matrix.
Definition: matrix.hh:561
typename Imp::BlockTraits< T >::field_type field_type
Export the type representing the underlying field.
Definition: matrix.hh:565
row_type::const_iterator ConstColIterator
Const iterator for the entries of each row.
Definition: matrix.hh:589
MatrixImp::DenseMatrixBase< T, A >::window_type row_type
The type implementing a matrix row.
Definition: matrix.hh:574
An allocator managing a pool of objects for reuse.
Definition: poolallocator.hh:223
A single linked list.
Definition: sllist.hh:44
Type traits to determine the type of reals (when working with complex numbers)
Provides classes for building the matrix graph.
SLListConstIterator< T, A > const_iterator
The constant iterator of the list.
Definition: sllist.hh:74
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:492
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:485
constexpr auto min
Function object that returns the smaller of the given values.
Definition: hybridutilities.hh:507
Matrix::ConstColIterator ColIter
Constant column iterator of the matrix.
Definition: aggregates.hh:275
Matrix::ConstColIterator ColIter
Constant column iterator of the matrix.
Definition: aggregates.hh:156
std::size_t breadthFirstSearch(const VertexDescriptor &start, const AggregateDescriptor &aggregate, const G &graph, L &visited, F1 &aggregateVisitor, F2 &nonAggregateVisitor, VM &visitedMap) const
Breadth first search within an aggregate.
PoolAllocator< VertexDescriptor, 100 > Allocator
The allocator we use for our lists and the set.
Definition: aggregates.hh:592
int id()
Get the id identifying the aggregate.
Norm norm_
The functor for calculating the norm.
Definition: aggregates.hh:304
MatrixGraph::VertexDescriptor Vertex
The vertex identifier.
Definition: aggregates.hh:926
AggregationCriterion()
Constructor.
Definition: aggregates.hh:68
const Matrix * matrix_
The matrix we work on.
Definition: aggregates.hh:359
auto operator()(const M &m, typename std::enable_if_t< Dune::IsNumber< M >::value > *sfinae=nullptr) const
Compute the norm of a scalar.
Definition: aggregates.hh:408
M Matrix
The matrix type we build the dependency of.
Definition: aggregates.hh:260
G MatrixGraph
The matrix graph type used.
Definition: aggregates.hh:921
Norm norm_
The functor for calculating the norm.
Definition: aggregates.hh:365
M Matrix
The matrix type we build the dependency of.
Definition: aggregates.hh:321
real_type diagonal_
The norm of the current diagonal.
Definition: aggregates.hh:189
N Norm
The norm to use for examining the matrix entries.
Definition: aggregates.hh:265
int row_
index of the currently evaluated row.
Definition: aggregates.hh:187
std::tuple< int, int, int, int > build(const M &m, G &graph, AggregatesMap< Vertex > &aggregates, const C &c, bool finestLevel)
Build the aggregates.
FrontNeighbourCounter(const MatrixGraph &front)
Constructor.
Matrix::row_type Row
Constant Row iterator of the matrix.
Definition: aggregates.hh:331
const Matrix * matrix_
The matrix we work on.
Definition: aggregates.hh:298
const AggregateDescriptor & operator[](const VertexDescriptor &v) const
Get the aggregate a vertex belongs to.
AggregateVisitor(const AggregatesMap< Vertex > &aggregates, const AggregateDescriptor &aggregate, Visitor &visitor)
Constructor.
Matrix::ConstColIterator ColIter
Constant column iterator of the matrix.
Definition: aggregates.hh:336
~AggregatesMap()
Destructor.
Matrix::field_type field_type
The current max value.
Definition: aggregates.hh:181
void decrement()
Decrement counter.
Aggregate(MatrixGraph &graph, AggregatesMap< Vertex > &aggregates, VertexSet &connectivity, std::vector< Vertex > &front_)
Constructor.
V Visitor
The type of the adapted visitor.
Definition: aggregates.hh:1070
std::size_t * SphereMap
Type of the mapping of aggregate members onto distance spheres.
Definition: aggregates.hh:815
Matrix::row_type Row
Constant Row iterator of the matrix.
Definition: aggregates.hh:270
VertexSet::size_type connectSize()
Get the number of connections to other aggregates.
N Norm
The norm to use for examining the matrix entries.
Definition: aggregates.hh:326
Norm norm_
The functor for calculating the norm.
Definition: aggregates.hh:185
VertexSet::const_iterator const_iterator
Const iterator over a vertex list.
Definition: aggregates.hh:810
MatrixGraph::VertexDescriptor AggregateDescriptor
The type of the aggregate descriptor.
Definition: aggregates.hh:929
real_type diagonal_
The norm of the current diagonal.
Definition: aggregates.hh:369
~Aggregator()
Destructor.
void add(const Vertex &vertex)
Add a vertex to the aggregate.
T DependencyPolicy
The policy for calculating the dependency graph.
Definition: aggregates.hh:57
auto operator()(const M &m) const
compute the norm of a matrix.
Definition: aggregates.hh:475
Aggregator()
Constructor.
void operator()(const typename MatrixGraph::ConstEdgeIterator &edge)
Examine an edge.
FrontMarker(std::vector< Vertex > &front, MatrixGraph &graph)
Constructor.
FieldTraits< typenameM::field_type >::real_type operator()(const M &m) const
compute the norm of a matrix.
Definition: aggregates.hh:512
int visitNeighbours(const G &graph, const typename G::VertexDescriptor &vertex, V &visitor)
Visit all neighbour vertices of a vertex in a graph.
void setDefaultValuesIsotropic(std::size_t dim, std::size_t diameter=2)
Sets reasonable default values for an isotropic problem.
Definition: aggregates.hh:84
V AggregateDescriptor
The aggregate descriptor type.
Definition: aggregates.hh:586
static const V ISOLATED
Identifier of isolated vertices.
Definition: aggregates.hh:577
int row_
index of the currently evaluated row.
Definition: aggregates.hh:367
real_type diagonal_
The norm of the current diagonal.
Definition: aggregates.hh:308
std::size_t noVertices() const
Get the number of vertices.
void setDefaultValuesAnisotropic(std::size_t dim, std::size_t diameter=2)
Sets reasonable default values for an aisotropic problem.
Definition: aggregates.hh:107
AggregatesMap(std::size_t noVertices)
Constructs with allocating memory.
Matrix::field_type field_type
The current max value.
Definition: aggregates.hh:361
AggregateDescriptor & operator[](const VertexDescriptor &v)
Get the aggregate a vertex belongs to.
AggregatesMap()
Constructs without allocating memory.
int value()
Access the current count.
SLList< VertexDescriptor, Allocator > VertexList
The type of a single linked list of vertex descriptors.
Definition: aggregates.hh:598
ConnectivityCounter(const VertexSet &connected, const AggregatesMap< Vertex > &aggregates)
Constructor.
VertexSet::size_type size()
Get the size of the aggregate.
const_iterator end() const
get an iterator over the vertices of the aggregate.
int row_
index of the currently evaluated row.
Definition: aggregates.hh:306
M Matrix
The matrix type we build the dependency of.
Definition: aggregates.hh:141
const Matrix * matrix_
The matrix we work on.
Definition: aggregates.hh:179
S VertexSet
The type of a single linked list of vertex descriptors.
Definition: aggregates.hh:807
FieldTraits< typenameM::field_type >::real_type operator()(const M &m) const
compute the norm of a matrix.
Definition: aggregates.hh:496
static const V UNAGGREGATED
Identifier of not yet aggregated vertices.
Definition: aggregates.hh:572
std::size_t breadthFirstSearch(const VertexDescriptor &start, const AggregateDescriptor &aggregate, const G &graph, F &aggregateVisitor, VM &visitedMap) const
Breadth first search within an aggregate.
Matrix::field_type field_type
The current max value.
Definition: aggregates.hh:300
void allocate(std::size_t noVertices)
Allocate memory for holding the information.
N Norm
The norm to use for examining the matrix entries.
Definition: aggregates.hh:146
void reconstruct(const Vertex &vertex)
Reconstruct the aggregat from an seed node.
const_iterator begin() const
get an iterator over the vertices of the aggregate.
FieldTraits< typenameM::field_type >::real_type operator()(const M &m, typename std::enable_if_t<!Dune::IsNumber< M >::value > *sfinae=nullptr) const
compute the norm of a matrix.
Definition: aggregates.hh:392
MatrixGraph::VertexDescriptor Vertex
The vertex descriptor type.
Definition: aggregates.hh:795
void seed(const Vertex &vertex)
Initialize the aggregate with one vertex.
void clear()
Clear the aggregate.
void free()
Free the allocated memory.
void increment()
Increment counter.
void buildDependency(G &graph, const typename C::Matrix &matrix, C criterion, bool finestLevel)
Build the dependency of the matrix graph.
V VertexDescriptor
The vertex descriptor type.
Definition: aggregates.hh:581
std::tuple< int, int, int, int > buildAggregates(const M &matrix, G &graph, const C &criterion, bool finestLevel)
Build the aggregates.
Matrix::row_type Row
Constant Row iterator of the matrix.
Definition: aggregates.hh:151
PoolAllocator< Vertex, 100 > Allocator
The allocator we use for our lists and the set.
Definition: aggregates.hh:801
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition: stdstreams.hh:96
DInfoType dinfo(std::cout)
Stream for informative output.
Definition: stdstreams.hh:141
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition: stdstreams.hh:117
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
constexpr std::integral_constant< T, I0 > front(std::integer_sequence< T, I0, II... >)
Return the first entry of the sequence.
Definition: integersequence.hh:39
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition: integersequence.hh:22
Parameter classes for customizing AMG.
An stl-compliant pool allocator.
Provides classes for handling internal properties in a graph.
Implements a scalar matrix view wrapper around an existing scalar.
Implements a singly linked list together with the necessary iterators.
Standard Dune debug streams.
Functor using the row sum (infinity) norm to determine strong couplings.
Definition: aggregates.hh:465
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition: typetraits.hh:194
A simple timing class.
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Nov 2, 23:43, 2025)