3 #ifndef DUNE_AMGHIERARCHY_HH 4 #define DUNE_AMGHIERARCHY_HH 15 #include <dune/common/stdstreams.hh> 16 #include <dune/common/unused.hh> 17 #include <dune/common/timer.hh> 18 #include <dune/common/tuples.hh> 19 #include <dune/common/bigunsignedint.hh> 21 #include <dune/common/parallel/indexset.hh> 65 template<
typename T,
typename A=std::allocator<T> >
74 template<
typename T1,
typename T2>
96 MemberType* redistributed_;
110 typedef typename A::template rebind<Element>::other
Allocator;
157 template<
class C,
class T1>
159 :
public BidirectionalIteratorFacade<LevelIterator<C,T1>,T1,T1&>
161 friend class LevelIterator<typename
std::remove_const<C>::type,
162 typename std::remove_const<T1>::type >;
163 friend class
LevelIterator<const typename std::remove_const<C>::type,
164 const typename std::remove_const<T1>::type >;
178 typename std::remove_const<T1>::type>& other)
179 : element_(other.element_)
184 const typename std::remove_const<T1>::type>& other)
185 : element_(other.element_)
192 typename std::remove_const<T1>::type>& other)
const 194 return element_ == other.element_;
201 const typename std::remove_const<T1>::type>& other)
const 203 return element_ == other.element_;
209 return *(element_->element_);
215 element_ = element_->coarser_;
221 element_ = element_->finer_;
230 return element_->redistributed_;
239 assert(element_->redistributed_);
240 return *element_->redistributed_;
244 element_->redistributed_ = t;
249 element_->redistributed_ =
nullptr;
279 ConstIterator
finest()
const;
291 std::size_t
levels()
const;
302 Element* nonAllocated_;
304 Allocator allocator_;
315 template<
class M,
class PI,
class A=std::allocator<M> >
323 typedef typename MatrixOperator::matrix_type
Matrix;
341 typedef typename Allocator::template rebind<AggregatesMap*>::other
AAllocator;
350 typedef typename Allocator::template rebind<RedistributeInfoType>::other
RILAllocator;
361 const ParallelInformation& pinfo=ParallelInformation());
371 template<
typename O,
typename T>
372 void build(
const T& criterion);
382 void recalculateGalerkin(
const F& copyFlags);
388 template<
class V,
class TA>
396 template<
class S,
class TA>
404 std::size_t
levels()
const;
410 std::size_t maxlevels()
const;
412 bool hasCoarsest()
const;
418 bool isBuilt()
const;
424 const ParallelMatrixHierarchy& matrices()
const;
430 const ParallelInformationHierarchy& parallelInformation()
const;
436 const AggregatesMapList& aggregatesMaps()
const;
443 const RedistributeInfoList& redistributeInformation()
const;
461 void getCoarsestAggregatesOnFinest(std::vector<std::size_t>& data)
const;
467 AggregatesMapList aggregatesMaps_;
469 RedistributeInfoList redistributes_;
471 ParallelMatrixHierarchy matrices_;
473 ParallelInformationHierarchy parallelInformation_;
481 typename MatrixOperator::field_type prolongDamp_;
486 template<
class Matrix,
bool pr
int>
493 static void stats(
const Matrix& matrix)
495 DUNE_UNUSED_PARAMETER(matrix);
499 template<
class Matrix>
500 struct MatrixStats<Matrix,true>
509 min=std::numeric_limits<size_type>::max();
516 min=std::min(min, row.
size());
517 max=std::max(max, row.
size());
528 static void stats(
const Matrix& matrix)
530 calc c= for_each(matrix.begin(), matrix.end(), calc());
531 dinfo<<
"Matrix row: min="<<c.min<<
" max="<<c.max
532 <<
" average="<<
static_cast<double>(c.sum)/matrix.N()
563 : AggregationCriterion(
Dune::Amg::
Parameters(maxLevel, coarsenTarget, minCoarsenRate, prolongDamp, accumulate))
567 : AggregationCriterion(parms)
572 template<
typename M,
typename C1>
577 int nparts, C1& criterion)
579 DUNE_UNUSED_PARAMETER(origMatrix);
580 DUNE_UNUSED_PARAMETER(newMatrix);
581 DUNE_UNUSED_PARAMETER(origSequentialInformationomm);
582 DUNE_UNUSED_PARAMETER(newComm);
583 DUNE_UNUSED_PARAMETER(ri);
584 DUNE_UNUSED_PARAMETER(nparts);
585 DUNE_UNUSED_PARAMETER(criterion);
586 DUNE_THROW(NotImplemented,
"Redistribution does not make sense in sequential code!");
590 template<
typename M,
typename C,
typename C1>
593 int nparts, C1& criterion)
596 #ifdef AMG_REPART_ON_COMM_GRAPH 600 criterion.debugLevel()>1);
609 MatrixGraph graph(origMatrix);
610 PropertiesGraph pgraph(graph);
614 if(origComm.communicator().rank()==0)
615 std::cout<<
"Original matrix"<<std::endl;
616 origComm.communicator().barrier();
620 newComm, ri.getInterface(),
621 criterion.debugLevel()>1);
622 #endif // if else AMG_REPART 624 if(origComm.communicator().rank()==0 && criterion.debugLevel()>1)
625 std::cout<<
"Repartitioning took "<<time.elapsed()<<
" seconds."<<std::endl;
630 ri.checkInterface(origComm.indexSet(), newComm->indexSet(), origComm.communicator());
636 if(origComm.communicator().rank()==0)
637 std::cout<<
"Original matrix"<<std::endl;
638 origComm.communicator().barrier();
639 if(newComm->communicator().size()>0)
641 origComm.communicator().barrier();
644 if(origComm.communicator().rank()==0 && criterion.debugLevel()>1)
645 std::cout<<
"Redistributing matrix took "<<time.elapsed()<<
" seconds."<<std::endl;
646 return existentOnRedist;
659 template<
class M,
class IS,
class A>
661 const ParallelInformation& pinfo)
662 : matrices_(const_cast<MatrixOperator&>(fineOperator)),
663 parallelInformation_(const_cast<ParallelInformation&>(pinfo))
665 static_assert((static_cast<int>(MatrixOperator::category) ==
667 || static_cast<int>(MatrixOperator::category) ==
669 || static_cast<int>(MatrixOperator::category) ==
671 "MatrixOperator must be of category sequential or overlapping or nonoverlapping");
672 if (static_cast<int>(MatrixOperator::category) != static_cast<int>(pinfo.getSolverCategory()))
673 DUNE_THROW(
ISTLError,
"MatrixOperator and ParallelInformation must belong to the same category!");
677 template<
class M,
class IS,
class A>
678 template<
typename O,
typename T>
681 prolongDamp_ = criterion.getProlongationDampingFactor();
682 typedef O OverlapFlags;
688 typedef bigunsignedint<sizeof(int)*8*noints> BIGINT;
690 MatIterator mlevel = matrices_.
finest();
691 MatrixStats<typename M::matrix_type,MINIMAL_DEBUG_LEVEL<=INFO_DEBUG_LEVEL>::stats(mlevel->getmat());
693 PInfoIterator infoLevel = parallelInformation_.
finest();
695 finenonzeros = infoLevel->communicator().sum(finenonzeros);
696 BIGINT allnonzeros = finenonzeros;
702 BIGINT unknowns = mlevel->getmat().N();
704 unknowns = infoLevel->communicator().sum(unknowns);
705 double dunknowns=unknowns.todouble();
706 infoLevel->buildGlobalLookup(mlevel->getmat().N());
709 for(; level < criterion.maxLevel(); ++level, ++mlevel) {
710 assert(matrices_.
levels()==redistributes_.size());
711 rank = infoLevel->communicator().rank();
712 if(rank==0 && criterion.debugLevel()>1)
713 std::cout<<
"Level "<<level<<
" has "<<dunknowns<<
" unknowns, "<<dunknowns/infoLevel->communicator().size()
714 <<
" unknowns per proc (procs="<<infoLevel->communicator().size()<<
")"<<std::endl;
716 MatrixOperator* matrix=&(*mlevel);
717 ParallelInformation* info =&(*infoLevel);
726 && dunknowns < 30*infoLevel->communicator().size()))
727 && infoLevel->communicator().size()>1 &&
728 dunknowns/infoLevel->communicator().size() <= criterion.coarsenTarget())
731 Matrix* redistMat=
new Matrix();
732 ParallelInformation* redistComm=0;
733 std::size_t nodomains = (std::size_t)std::ceil(dunknowns/(criterion.minAggregateSize()
734 *criterion.coarsenTarget()));
735 if( nodomains<=criterion.minAggregateSize()/2 ||
736 dunknowns <= criterion.coarsenTarget() )
739 bool existentOnNextLevel =
741 redistComm, redistributes_.back(), nodomains,
743 BIGINT unknownsRedist = redistMat->N();
744 unknownsRedist = infoLevel->communicator().sum(unknownsRedist);
745 dunknowns= unknownsRedist.todouble();
746 if(redistComm->communicator().rank()==0 && criterion.debugLevel()>1)
747 std::cout<<
"Level "<<level<<
" (redistributed) has "<<dunknowns<<
" unknowns, "<<dunknowns/redistComm->communicator().size()
748 <<
" unknowns per proc (procs="<<redistComm->communicator().size()<<
")"<<std::endl;
749 MatrixArgs args(*redistMat, *redistComm);
751 assert(mlevel.isRedistributed());
752 infoLevel.addRedistributed(redistComm);
753 infoLevel->freeGlobalLookup();
755 if(!existentOnNextLevel)
760 matrix = &(mlevel.getRedistributed());
761 info = &(infoLevel.getRedistributed());
762 info->buildGlobalLookup(matrix->getmat().N());
765 rank = info->communicator().rank();
766 if(dunknowns <= criterion.coarsenTarget())
772 typedef typename GraphCreator::GraphTuple GraphTuple;
776 std::vector<bool> excluded(matrix->getmat().N(),
false);
778 GraphTuple graphs = GraphCreator::create(*matrix, excluded, *info, OverlapFlags());
780 AggregatesMap* aggregatesMap=
new AggregatesMap(get<1>(graphs)->maxVertex()+1);
782 aggregatesMaps_.push_back(aggregatesMap);
786 int noAggregates, isoAggregates, oneAggregates, skippedAggregates;
788 tie(noAggregates, isoAggregates, oneAggregates, skippedAggregates) =
789 aggregatesMap->
buildAggregates(matrix->getmat(), *(get<1>(graphs)), criterion, level==0);
791 if(rank==0 && criterion.debugLevel()>2)
792 std::cout<<
" Have built "<<noAggregates<<
" aggregates totally ("<<isoAggregates<<
" isolated aggregates, "<<
793 oneAggregates<<
" aggregates of one vertex, and skipped "<<
794 skippedAggregates<<
" aggregates)."<<std::endl;
798 int start, end, overlapStart, overlapEnd;
799 int procs=info->communicator().rank();
800 int n = UNKNOWNS/procs;
801 int bigger = UNKNOWNS%procs;
806 end = (rank+1)*(n+1);
808 start = bigger + rank * n;
809 end = bigger + (rank + 1) * n;
814 overlapStart = start - 1;
816 overlapStart = start;
819 overlapEnd = end + 1;
823 assert((UNKNOWNS)*(overlapEnd-overlapStart)==aggregatesMap->
noVertices());
824 for(
int j=0; j< UNKNOWNS; ++j)
825 for(
int i=0; i < UNKNOWNS; ++i)
827 if(i>=overlapStart && i<overlapEnd)
829 int no = (j/2)*((UNKNOWNS)/2)+i/2;
830 (*aggregatesMap)[j*(overlapEnd-overlapStart)+i-overlapStart]=no;
835 if(criterion.debugLevel()>1 && info->communicator().rank()==0)
836 std::cout<<
"aggregating finished."<<std::endl;
838 BIGINT gnoAggregates=noAggregates;
839 gnoAggregates = info->communicator().sum(gnoAggregates);
840 double dgnoAggregates = gnoAggregates.todouble();
842 BIGINT gnoAggregates=((UNKNOWNS)/2)*((UNKNOWNS)/2);
845 if(criterion.debugLevel()>2 && rank==0)
846 std::cout <<
"Building "<<dgnoAggregates<<
" aggregates took "<<watch.elapsed()<<
" seconds."<<std::endl;
848 if(dgnoAggregates==0 || dunknowns/dgnoAggregates<criterion.minCoarsenRate())
853 std::cerr <<
"Stopped coarsening because of rate breakdown "<<dunknowns<<
"/"<<dgnoAggregates
854 <<
"="<<dunknowns/dgnoAggregates<<
"<" 855 <<criterion.minCoarsenRate()<<std::endl;
857 std::cerr<<
"Could not build any aggregates. Probably no connected nodes."<<std::endl;
859 aggregatesMap->
free();
860 delete aggregatesMap;
861 aggregatesMaps_.pop_back();
863 if(criterion.accumulate() && mlevel.isRedistributed() && info->communicator().size()>1) {
867 delete &(mlevel.getRedistributed().getmat());
868 mlevel.deleteRedistributed();
869 delete &(infoLevel.getRedistributed());
870 infoLevel.deleteRedistributed();
871 redistributes_.back().resetSetup();
876 unknowns = noAggregates;
877 dunknowns = dgnoAggregates;
879 CommunicationArgs commargs(info->communicator(),info->getSolverCategory());
884 typename PropertyMapTypeSelector<VertexVisitedTag,PropertiesGraph>::Type visitedMap =
895 GraphCreator::free(graphs);
897 if(criterion.debugLevel()>2) {
899 std::cout<<
"Coarsening of index sets took "<<watch.elapsed()<<
" seconds."<<std::endl;
904 infoLevel->buildGlobalLookup(aggregates);
907 infoLevel->globalLookup());
910 if(criterion.debugLevel()>2) {
912 std::cout<<
"Communicating global aggregate numbers took "<<watch.elapsed()<<
" seconds."<<std::endl;
916 std::vector<bool>& visited=excluded;
918 typedef std::vector<bool>::iterator Iterator;
919 typedef IteratorPropertyMap<Iterator, IdentityMap> VisitedMap2;
920 Iterator end = visited.end();
921 for(Iterator iter= visited.begin(); iter != end; ++iter)
924 VisitedMap2 visitedMap2(visited.begin(), Dune::IdentityMap());
926 typename MatrixOperator::matrix_type* coarseMatrix;
928 coarseMatrix = productBuilder.
build(*(get<0>(graphs)), visitedMap2,
933 dverb<<
"Building of sparsity pattern took "<<watch.elapsed()<<std::endl;
935 info->freeGlobalLookup();
937 delete get<0>(graphs);
938 productBuilder.
calculate(matrix->getmat(), *aggregatesMap, *coarseMatrix, *infoLevel, OverlapFlags());
940 if(criterion.debugLevel()>2) {
942 std::cout<<
"Calculation entries of Galerkin product took "<<watch.elapsed()<<
" seconds."<<std::endl;
946 allnonzeros = allnonzeros + infoLevel->communicator().sum(nonzeros);
947 MatrixArgs args(*coarseMatrix, *infoLevel);
954 infoLevel->freeGlobalLookup();
958 aggregatesMaps_.push_back(aggregatesMap);
960 if(criterion.debugLevel()>0) {
961 if(level==criterion.maxLevel()) {
962 BIGINT unknownsLevel = mlevel->getmat().N();
963 unknownsLevel = infoLevel->communicator().sum(unknownsLevel);
964 double dunknownsLevel = unknownsLevel.todouble();
965 if(rank==0 && criterion.debugLevel()>1) {
966 std::cout<<
"Level "<<level<<
" has "<<dunknownsLevel<<
" unknowns, "<<dunknownsLevel/infoLevel->communicator().size()
967 <<
" unknowns per proc (procs="<<infoLevel->communicator().size()<<
")"<<std::endl;
972 if(criterion.accumulate() && !redistributes_.back().isSetup() &&
973 infoLevel->communicator().size()>1) {
974 #if HAVE_MPI && !HAVE_PARMETIS 976 infoLevel->communicator().rank()==0)
977 std::cerr<<
"Successive accumulation of data on coarse levels only works with ParMETIS installed." 978 <<
" Fell back to accumulation to one domain on coarsest level"<<std::endl;
982 Matrix* redistMat=
new Matrix();
983 ParallelInformation* redistComm=0;
987 redistComm, redistributes_.back(), nodomains,criterion);
988 MatrixArgs args(*redistMat, *redistComm);
989 BIGINT unknownsRedist = redistMat->N();
990 unknownsRedist = infoLevel->communicator().sum(unknownsRedist);
992 if(redistComm->communicator().rank()==0 && criterion.debugLevel()>1) {
993 double dunknownsRedist = unknownsRedist.todouble();
994 std::cout<<
"Level "<<level<<
" redistributed has "<<dunknownsRedist<<
" unknowns, "<<dunknownsRedist/redistComm->communicator().size()
995 <<
" unknowns per proc (procs="<<redistComm->communicator().size()<<
")"<<std::endl;
998 infoLevel.addRedistributed(redistComm);
999 infoLevel->freeGlobalLookup();
1003 maxlevels_ = parallelInformation_.
finest()->communicator().max(levels);
1004 assert(matrices_.
levels()==redistributes_.size());
1005 if(
hasCoarsest() && rank==0 && criterion.debugLevel()>1)
1006 std::cout<<
"operator complexity: "<<allnonzeros.todouble()/finenonzeros.todouble()<<std::endl;
1010 template<
class M,
class IS,
class A>
1017 template<
class M,
class IS,
class A>
1021 return parallelInformation_;
1024 template<
class M,
class IS,
class A>
1028 int maxlevels=parallelInformation_.
finest()->communicator().max(levels);
1031 std::vector<std::size_t> tmp;
1032 std::vector<std::size_t> *coarse, *fine;
1049 if(levels==maxlevels) {
1055 m=std::max(*iter,m);
1057 coarse->resize(m+1);
1059 srand((
unsigned)std::clock());
1060 std::set<size_t> used;
1061 for(
typename std::vector<std::size_t>::iterator iter=coarse->begin(); iter != coarse->end();
1064 std::pair<std::set<std::size_t>::iterator,
bool> ibpair
1065 = used.insert(static_cast<std::size_t>((((
double)rand())/(RAND_MAX+1.0)))*coarse->size());
1067 while(!ibpair.second)
1068 ibpair = used.insert(static_cast<std::size_t>((((
double)rand())/(RAND_MAX+1.0))*coarse->size()));
1069 *iter=*(ibpair.first);
1077 for(
typename AggregatesMapList::const_reverse_iterator aggregates=++
aggregatesMaps().rbegin();
1080 fine->resize((*aggregates)->noVertices());
1081 fine->assign(fine->size(), 0);
1083 ::prolongateVector(*(*aggregates), *coarse, *fine, static_cast<std::size_t>(1), *pinfo);
1085 std::swap(coarse, fine);
1089 assert(coarse==&data);
1092 template<
class M,
class IS,
class A>
1096 return aggregatesMaps_;
1098 template<
class M,
class IS,
class A>
1102 return redistributes_;
1105 template<
class M,
class IS,
class A>
1108 typedef typename AggregatesMapList::reverse_iterator AggregatesMapIterator;
1112 AggregatesMapIterator amap = aggregatesMaps_.rbegin();
1113 InfoIterator info = parallelInformation_.
coarsest();
1114 for(Iterator level=matrices_.
coarsest(), finest=matrices_.
finest(); level != finest; --level, --info, ++amap) {
1117 delete &level->getmat();
1118 if(level.isRedistributed())
1119 delete &(level.getRedistributed().getmat());
1124 template<
class M,
class IS,
class A>
1125 template<
class V,
class TA>
1128 assert(hierarchy.levels()==1);
1130 typedef typename RedistributeInfoList::const_iterator RIter;
1131 RIter redist = redistributes_.begin();
1133 Iterator matrix = matrices_.
finest(), coarsest = matrices_.
coarsest();
1135 if(redist->isSetup())
1136 hierarchy.addRedistributedOnCoarsest(matrix.getRedistributed().getmat().N());
1137 Dune::dvverb<<
"Level "<<level<<
" has "<<matrices_.
finest()->getmat().N()<<
" unknowns!"<<std::endl;
1139 while(matrix != coarsest) {
1140 ++matrix; ++level; ++redist;
1141 Dune::dvverb<<
"Level "<<level<<
" has "<<matrix->getmat().N()<<
" unknowns!"<<std::endl;
1143 hierarchy.addCoarser(matrix->getmat().N());
1144 if(redist->isSetup())
1145 hierarchy.addRedistributedOnCoarsest(matrix.getRedistributed().getmat().N());
1151 template<
class M,
class IS,
class A>
1152 template<
class S,
class TA>
1156 assert(smoothers.
levels()==0);
1159 typedef typename AggregatesMapList::const_iterator AggregatesIterator;
1162 cargs.setArgs(sargs);
1163 PinfoIterator pinfo = parallelInformation_.
finest();
1164 AggregatesIterator aggregates = aggregatesMaps_.begin();
1166 for(MatrixIterator matrix = matrices_.
finest(), coarsest = matrices_.
coarsest();
1167 matrix != coarsest; ++matrix, ++pinfo, ++aggregates, ++level) {
1168 cargs.setMatrix(matrix->getmat(), **aggregates);
1169 cargs.setComm(*pinfo);
1174 cargs.setMatrix(matrices_.
coarsest()->getmat(), **aggregates);
1175 cargs.setComm(*pinfo);
1181 template<
class M,
class IS,
class A>
1185 typedef typename AggregatesMapList::iterator AggregatesMapIterator;
1189 AggregatesMapIterator amap = aggregatesMaps_.begin();
1191 InfoIterator info = parallelInformation_.
finest();
1192 typename RedistributeInfoList::iterator riIter = redistributes_.begin();
1193 Iterator level = matrices_.
finest(), coarsest=matrices_.
coarsest();
1194 if(level.isRedistributed()) {
1195 info->buildGlobalLookup(level->getmat().N());
1197 const_cast<Matrix&>(level.getRedistributed().getmat()),
1198 *info,info.getRedistributed(), *riIter);
1199 info->freeGlobalLookup();
1202 for(; level!=coarsest; ++amap) {
1203 const Matrix& fine = (level.isRedistributed() ? level.getRedistributed() : *level).getmat();
1207 productBuilder.
calculate(fine, *(*amap), const_cast<Matrix&>(level->getmat()), *info, copyFlags);
1208 if(level.isRedistributed()) {
1209 info->buildGlobalLookup(level->getmat().N());
1211 const_cast<Matrix&>(level.getRedistributed().getmat()), *info,
1212 info.getRedistributed(), *riIter);
1213 info->freeGlobalLookup();
1218 template<
class M,
class IS,
class A>
1221 return matrices_.
levels();
1224 template<
class M,
class IS,
class A>
1230 template<
class M,
class IS,
class A>
1234 (!matrices_.
coarsest().isRedistributed() ||matrices_.
coarsest()->getmat().N()>0);
1237 template<
class M,
class IS,
class A>
1243 template<
class T,
class A>
1245 : finest_(0), coarsest_(0), nonAllocated_(0), allocator_(), levels_(0)
1248 template<
class T,
class A>
1252 finest_ = allocator_.allocate(1,0);
1253 finest_->element_ = &first;
1254 finest_->redistributed_ =
nullptr;
1255 nonAllocated_ = finest_;
1256 coarsest_ = finest_;
1257 coarsest_->coarser_ = coarsest_->finer_ =
nullptr;
1261 template<
class T,
class A>
1265 finest_ = allocator_.allocate(1,0);
1266 finest_->element_ = first;
1267 finest_->redistributed_ =
nullptr;
1268 nonAllocated_ =
nullptr;
1269 coarsest_ = finest_;
1270 coarsest_->coarser_ = coarsest_->finer_ =
nullptr;
1273 template<
class T,
class A>
1277 Element* current = coarsest_;
1278 coarsest_ = coarsest_->finer_;
1279 if(current != nonAllocated_) {
1280 if(current->redistributed_)
1284 allocator_.deallocate(current, 1);
1290 template<
class T,
class A>
1292 : nonAllocated_(), allocator_(other.allocator_),
1293 levels_(other.levels_)
1297 finest_=coarsest_=nonAllocated_=
nullptr;
1300 finest_=allocator_.allocate(1,0);
1301 Element* finer_ =
nullptr;
1302 Element* current_ = finest_;
1303 Element* otherCurrent_ = other.finest_;
1305 while(otherCurrent_)
1307 T* t=
new T(*(otherCurrent_->element_));
1308 current_->element_=t;
1309 current_->finer_=finer_;
1310 if(otherCurrent_->redistributed_)
1311 current_->redistributed_ =
new T(*otherCurrent_->redistributed_);
1313 current_->redistributed_=
nullptr;
1315 if(otherCurrent_->coarser_)
1317 current_->coarser_=allocator_.allocate(1,0);
1318 current_=current_->coarser_;
1320 current_->coarser_=
nullptr;
1321 otherCurrent_=otherCurrent_->coarser_;
1326 template<
class T,
class A>
1332 template<
class T,
class A>
1338 template<
class T,
class A>
1343 coarsest_ = allocator_.allocate(1,0);
1345 finest_ = coarsest_;
1346 coarsest_->finer_ =
nullptr;
1348 coarsest_->coarser_ = allocator_.allocate(1,0);
1349 coarsest_->coarser_->finer_ = coarsest_;
1350 coarsest_ = coarsest_->coarser_;
1353 coarsest_->redistributed_ =
nullptr;
1354 coarsest_->coarser_=
nullptr;
1359 template<
class T,
class A>
1364 finest_ = allocator_.allocate(1,0);
1366 coarsest_ = finest_;
1367 coarsest_->coarser_ = coarsest_->finer_ =
nullptr;
1369 finest_->finer_ = allocator_.allocate(1,0);
1370 finest_->finer_->coarser_ = finest_;
1371 finest_ = finest_->finer_;
1372 finest_->finer =
nullptr;
1378 template<
class T,
class A>
1384 template<
class T,
class A>
1390 template<
class T,
class A>
1396 template<
class T,
class A>
Definition: globalaggregates.hh:129
The hierarchies build by the coarsening process.
Definition: hierarchy.hh:316
MatrixOperator::matrix_type Matrix
The type of the matrix.
Definition: hierarchy.hh:323
Attaches properties to the edges and vertices of a graph.
Definition: graph.hh:975
Definition: galerkin.hh:115
Allocator::template rebind< RedistributeInfoType >::other RILAllocator
Allocator for RedistributeInfoType.
Definition: hierarchy.hh:350
All parameters for AMG.
Definition: parameters.hh:390
Provides a class for building the index set and remote indices on the coarse level.
A hierarchy of coantainers (e.g. matrices or vectors)
Definition: hierarchy.hh:66
Provdes class for identifying aggregates globally.
Traits class for getting the attribute class of a smoother.
Definition: smoother.hh:63
Accumulate data to on process at once.
Definition: parameters.hh:242
Dune::Amg::Hierarchy< MatrixOperator, Allocator > ParallelMatrixHierarchy
The type of the parallel matrix hierarchy.
Definition: hierarchy.hh:335
bool isRedistributed() const
Check whether there was a redistribution at the current level.
Definition: hierarchy.hh:228
int countNonZeros(const M &matrix)
Get the number of nonzero fields in the matrix.
Definition: matrixutils.hh:153
std::size_t maxlevels() const
Get the max number of levels in the hierarchy of processors.
Definition: hierarchy.hh:1225
A::size_type size_type
Type for indices and sizes.
Definition: matrix.hh:571
bool equals(const LevelIterator< const typename std::remove_const< C >::type, const typename std::remove_const< T1 >::type > &other) const
Equality check.
Definition: hierarchy.hh:200
LevelIterator< const Hierarchy< T, A >, const T > ConstIterator
Type of the const iterator.
Definition: hierarchy.hh:260
Definition: indicescoarsener.hh:34
bool graphRepartition(const G &graph, Dune::OwnerOverlapCopyCommunication< T1, T2 > &oocomm, idxtype nparts, Dune::OwnerOverlapCopyCommunication< T1, T2 > *&outcomm, RedistributeInterface &redistInf, bool verbose=false)
execute a graph repartition for a giving graph and indexset.
Definition: repartition.hh:1255
Class representing the properties of an ede in the matrix graph.
Definition: dependency.hh:37
void getCoarsestAggregatesOnFinest(std::vector< std::size_t > &data) const
Get the mapping of fine level unknowns to coarse level aggregates.
Definition: hierarchy.hh:1025
ConstructionTraits< T >::Arguments Arguments
Definition: hierarchy.hh:112
const AggregateDescriptor * const_iterator
Definition: aggregates.hh:710
size_type min
Definition: hierarchy.hh:521
void operator()(const matrix_row &row)
Definition: hierarchy.hh:514
calc()
Definition: hierarchy.hh:507
Category for sequential solvers.
Definition: solvercategory.hh:21
Functionality for redistributing a sparse matrix.
~MatrixHierarchy()
Definition: hierarchy.hh:1106
G::MutableMatrix * build(G &fineGraph, V &visitedMap, const ParallelInformation &pinfo, AggregatesMap< typename G::VertexDescriptor > &aggregates, const typename G::Matrix::size_type &size, const Set ©)
Calculates the coarse matrix via a Galerkin product.
Definition: galerkin.hh:564
void build(const T &criterion)
Build the matrix hierarchy using aggregation.
Definition: hierarchy.hh:679
size_type sum
Definition: hierarchy.hh:523
bool equals(const LevelIterator< typename std::remove_const< C >::type, typename std::remove_const< T1 >::type > &other) const
Equality check.
Definition: hierarchy.hh:191
The criterion describing the stop criteria for the coarsening process.
Definition: hierarchy.hh:542
Allocator::template rebind< AggregatesMap * >::other AAllocator
Allocator for pointers.
Definition: hierarchy.hh:341
CoarsenCriterion(const Dune::Amg::Parameters &parms)
Definition: hierarchy.hh:566
Matrix::row_type matrix_row
Definition: hierarchy.hh:505
RedistributeInformation< ParallelInformation > RedistributeInfoType
The type of the redistribute information.
Definition: hierarchy.hh:347
std::size_t noVertices() const
Get the number of vertices.
bool hasCoarsest() const
Definition: hierarchy.hh:1231
Tag idnetifying the visited property of a vertex.
Definition: properties.hh:26
const void * Arguments
A type holding all the arguments needed to call the constructor.
Definition: construction.hh:44
Definition: galerkin.hh:97
Prolongation and restriction for amg.
const ParallelInformationHierarchy & parallelInformation() const
Get the hierarchy of the parallel data distribution information.
Definition: hierarchy.hh:1019
Graph::VertexDescriptor VertexDescriptor
The vertex descriptor.
Definition: graph.hh:986
void coarsenSmoother(Hierarchy< S, TA > &smoothers, const typename SmootherTraits< S >::Arguments &args) const
Coarsen the smoother hierarchy according to the matrix hierarchy.
Definition: hierarchy.hh:1153
void calculate(const M &fine, const AggregatesMap< V > &aggregates, M &coarse, const I &pinfo, const O ©)
Calculate the galerkin product.
void coarsenVector(Hierarchy< BlockVector< V, TA > > &hierarchy) const
Coarsen the vector hierarchy according to the matrix hierarchy.
Definition: hierarchy.hh:1126
std::list< AggregatesMap *, AAllocator > AggregatesMapList
The type of the aggregates maps list.
Definition: hierarchy.hh:344
PI ParallelInformation
The type of the index set.
Definition: hierarchy.hh:326
Traits class for generically constructing non default constructable types.
Definition: novlpschwarz.hh:328
void printGlobalSparseMatrix(const M &mat, C &ooc, std::ostream &os)
Definition: matrixutils.hh:175
CoarsenCriterion(int maxLevel=100, int coarsenTarget=1000, double minCoarsenRate=1.2, double prolongDamp=1.6, AccumulationMode accumulate=successiveAccu)
Constructor.
Definition: hierarchy.hh:561
tuple< int, int, int, int > buildAggregates(const M &matrix, G &graph, const C &criterion, bool finestLevel)
Build the aggregates.
LevelIterator(const LevelIterator< const typename std::remove_const< C >::type, const typename std::remove_const< T1 >::type > &other)
Copy constructor.
Definition: hierarchy.hh:183
Matrix::size_type size_type
Definition: hierarchy.hh:504
void increment()
Move to the next coarser level.
Definition: hierarchy.hh:213
Helper classes for the construction of classes without empty constructor.
void free()
Free the allocated memory.
Hierarchy()
Construct a new empty hierarchy.
Definition: hierarchy.hh:1244
bool isBuilt() const
Whether the hierarchy was built.
Definition: hierarchy.hh:1238
Iterator finest()
Get an iterator positioned at the finest level.
Definition: hierarchy.hh:1379
Definition: basearray.hh:19
void deleteRedistributed()
Definition: hierarchy.hh:247
T MemberType
The type of the container we store.
Definition: hierarchy.hh:72
This file implements a vector space as a tensor product of a given vector space. The number of compon...
void redistributeMatrixEntries(M &origMatrix, M &newMatrix, C &origComm, C &newComm, RedistributeInformation< C > &ri)
Definition: matrixredistribute.hh:771
Class providing information about the mapping of the vertices onto aggregates.
Definition: aggregates.hh:542
void recalculateGalerkin(const F ©Flags)
Recalculate the galerkin products.
Definition: hierarchy.hh:1183
Category for overlapping solvers.
Definition: solvercategory.hh:25
Definition: example.cc:35
Definition: transfer.hh:30
Definition: graphcreator.hh:19
~Hierarchy()
Destructor.
Definition: hierarchy.hh:1274
void addRedistributed(T1 *t)
Definition: hierarchy.hh:242
void addCoarser(Arguments &args)
Add an element on a coarser level.
Definition: hierarchy.hh:1339
const ParallelMatrixHierarchy & matrices() const
Get the matrix hierarchy.
Definition: hierarchy.hh:1012
Provides classes for building the matrix graph.
MatrixOperator::field_type getProlongationDampingFactor() const
Definition: hierarchy.hh:446
Dune::Amg::Hierarchy< ParallelInformation, Allocator > ParallelInformationHierarchy
The type of the parallel informarion hierarchy.
Definition: hierarchy.hh:338
LevelIterator(const LevelIterator< typename std::remove_const< C >::type, typename std::remove_const< T1 >::type > &other)
Copy constructor.
Definition: hierarchy.hh:177
std::size_t levels() const
Get the number of levels in the hierarchy.
Definition: hierarchy.hh:1327
Classes for the generic construction and application of the smoothers.
A vector of blocks with memory management.
Definition: bvector.hh:308
Provides classes for initializing the link attributes of a matrix graph.
AccumulationMode
Identifiers for the different accumulation modes.
Definition: parameters.hh:230
MatrixHierarchy(const MatrixOperator &fineMatrix, const ParallelInformation &pinfo=ParallelInformation())
Constructor.
Definition: hierarchy.hh:660
Provides classes for the Coloring process of AMG.
std::size_t levels() const
Get the number of levels in the hierarchy.
Definition: hierarchy.hh:1219
M MatrixOperator
The type of the matrix operator.
Definition: hierarchy.hh:320
const_iterator end() const
Definition: aggregates.hh:717
Successively accumulate to fewer processes.
Definition: parameters.hh:246
Hard limit for the number of processes allowed.
Definition: hierarchy.hh:55
LevelIterator< Hierarchy< T, A >, T > Iterator
Type of the mutable iterator.
Definition: hierarchy.hh:257
Iterator over the levels in the hierarchy.
Definition: hierarchy.hh:75
T1 & getRedistributed() const
Get the redistributed container.
Definition: hierarchy.hh:237
T AggregationCriterion
The criterion for tagging connections as strong and nodes as isolated. This might be e...
Definition: hierarchy.hh:549
LevelIterator(Element *element)
Definition: hierarchy.hh:172
const_iterator begin() const
Definition: aggregates.hh:712
size_type size() const
number of blocks in the array (are of size 1 here)
Definition: basearray.hh:240
void redistributeMatrix(M &origMatrix, M &newMatrix, C &origComm, C &newComm, RedistributeInformation< C > &ri)
Redistribute a matrix according to given domain decompositions.
Definition: matrixredistribute.hh:834
Definition: matrixredistribute.hh:20
Class representing a node in the matrix graph.
Definition: dependency.hh:125
static const V ISOLATED
Identifier of isolated vertices.
Definition: aggregates.hh:554
bool repartitionAndDistributeMatrix(const M &origMatrix, M &newMatrix, SequentialInformation &origSequentialInformationomm, SequentialInformation *&newComm, RedistributeInformation< SequentialInformation > &ri, int nparts, C1 &criterion)
Definition: hierarchy.hh:573
Some handy generic functions for ISTL matrices.
void decrement()
Move to the next fine level.
Definition: hierarchy.hh:219
std::list< RedistributeInfoType, RILAllocator > RedistributeInfoList
The type of the list of redistribute information.
Definition: hierarchy.hh:353
void addFiner(Arguments &args)
Add an element on a finer level.
Definition: hierarchy.hh:1360
Dune::Amg::AggregatesMap< typename MatrixGraph< Matrix >::VertexDescriptor > AggregatesMap
The type of the aggregates map we use.
Definition: hierarchy.hh:332
const RedistributeInfoList & redistributeInformation() const
Get the hierarchy of the information about redistributions,.
Definition: hierarchy.hh:1100
derive error class from the base class in common
Definition: istlexception.hh:16
const AggregatesMapList & aggregatesMaps() const
Get the hierarchy of the mappings of the nodes onto aggregates.
Definition: hierarchy.hh:1094
Category for non-overlapping solvers.
Definition: solvercategory.hh:23
T1 & dereference() const
Dereference the iterator.
Definition: hierarchy.hh:207
bool commGraphRepartition(const M &mat, Dune::OwnerOverlapCopyCommunication< T1, T2 > &oocomm, idxtype nparts, Dune::OwnerOverlapCopyCommunication< T1, T2 > *&outcomm, RedistributeInterface &redistInf, bool verbose=false)
Definition: repartition.hh:846
Iterator coarsest()
Get an iterator positioned at the coarsest level.
Definition: hierarchy.hh:1385
void addRedistributedOnCoarsest(Arguments &args)
Definition: hierarchy.hh:1333
A::template rebind< Element >::other Allocator
If true only the method addCoarser will be usable otherwise only the method addFiner will be usable...
Definition: hierarchy.hh:110
void buildDependency(G &graph, const typename C::Matrix &matrix, C criterion, bool finestLevel)
Build the dependency of the matrix graph.
size_type max
Definition: hierarchy.hh:522
Definition: bvector.hh:659
Provides a class for building the galerkin product based on a aggregation scheme. ...