3#ifndef DUNE_ISTL_MATRIXREDISTRIBUTE_HH
4#define DUNE_ISTL_MATRIXREDISTRIBUTE_HH
7#include <dune/common/exceptions.hh>
8#include <dune/common/parallel/indexset.hh>
9#include <dune/common/unused.hh>
79 template<
typename T,
typename T1>
86 : interface(), setup_(
false)
97 auto ri = std::make_unique<RemoteIndices<IS> >(source, target, comm);
112 std::cout<<
"Interfaces do not match!"<<std::endl;
113 std::cout<<
rank<<
": redist interface new :"<<
inf<<std::endl;
114 std::cout<<
rank<<
": redist interface :"<<interface<<std::endl;
131 template<
class GatherScatter,
class D>
139 template<
class GatherScatter,
class D>
169 return rowSize[index];
174 return rowSize[index];
179 return copyrowSize[index];
184 return copyrowSize[index];
189 return backwardscopyrowSize[index];
194 return backwardscopyrowSize[index];
199 rowSize.resize(rows, 0);
204 copyrowSize.resize(rows, 0);
209 backwardscopyrowSize.resize(rows, 0);
213 std::vector<std::size_t> rowSize;
214 std::vector<std::size_t> copyrowSize;
215 std::vector<std::size_t> backwardscopyrowSize;
228 template<
class M,
class RI>
257 template<
class M,
class I>
280 const std::vector<typename M::size_type>&
rowsize_)
293 typedef typename Dune::GlobalLookupIndexSet<I>::const_iterator
IIter;
302 if(!OwnerSet::contains(i->local().attribute())) {
304 std::cout<<
rank<<
" Inserting diagonal for"<<i->local()<<std::endl;
306 sparsity[i->local()].insert(i->local());
315 m.setBuildMode(M::row_wise);
316 typename M::CreateIterator
citer=m.createbegin();
322 typedef typename std::vector<std::set<size_type> >::const_iterator Iter;
325 typedef typename std::set<size_type>::const_iterator
SIter;
329 if(i->find(
idx)==i->end()) {
332 std::cout<<
rank<<
": row "<<
idx<<
" is missing a diagonal entry! global="<<
gi->global()<<
" attr="<<
gi->local().attribute()<<
" "<<
333 OwnerSet::contains(
gi->local().attribute())<<
334 " row size="<<i->size()<<std::endl;
356 for (
unsigned int i = 0; i !=
sparsity.size(); ++i) {
358 typedef std::set<size_type> Set;
376 template<
class M,
class I>
393 return t.matrix[i].size();
397 return (*
t.rowsize)[i];
408 template<
class M,
class I>
437 typedef typename Dune::GlobalLookupIndexSet<I>::const_iterator Iter;
441 if(!OwnerSet::contains(i->local().attribute())) {
443 typedef typename M::ColIterator CIter;
444 for(CIter c=
matrix[i->local()].begin(), cend=
matrix[i->local()].end();
448 if(c.index()==i->local()) {
449 typedef typename M::block_type::RowIterator
RIter;
450 for(
RIter r=c->begin(), rend=c->end();
467 template<
class M,
class I>
476 typedef std::pair<typename I::GlobalIndex,typename M::block_type>
IndexedType;
484 return t.matrix[i].size();
488 return (*
t.rowsize)[i];
493 template<
class M,
class I,
class RI>
500 return cont.matrix[i].size();
505 cont.rowsize.getRowSize(i)=rowsize;
510 template<
class M,
class I,
class RI>
517 return cont.matrix[i].size();
522 if (rowsize >
cont.rowsize.getCopyRowSize(i))
523 cont.rowsize.getCopyRowSize(i)=rowsize;
528 template<
class M,
class I>
542 else if (
col!=
cont.matrix[i].end())
549 if (
col==
cont.matrix[i].end()) {
550 numlimits = std::numeric_limits<GlobalIndex>::max();
554 const typename I::IndexPair* index=
cont.idxset.pair(
col.index());
557 if ( index->local().attribute() != 2)
558 return index->global();
560 numlimits = std::numeric_limits<GlobalIndex>::max();
569 if (
gi != std::numeric_limits<GlobalIndex>::max()) {
570 const typename I::IndexPair&
ip=
cont.aggidxset.at(
gi);
576 if(!OwnerSet::contains(
ip.local().attribute()))
584 typedef typename Container::LookupIndexSet
GlobalLookup;
585 typedef typename GlobalLookup::IndexPair IndexPair;
591 if(OwnerSet::contains(
pi->local().attribute())) {
594 std::cout<<
rank<<
cont.aggidxset<<std::endl;
595 std::cout<<
rank<<
": row "<<i<<
" (global="<<
gi <<
") not in index set for owner index "<<
pi->global()<<std::endl;
603 template<
class M,
class I>
606 template<
class M,
class I>
610 template<
class M,
class I>
616 typedef typename std::pair<GlobalIndex,typename M::block_type>
Data;
625 else if (
col!=
cont.matrix[i].end())
631 if (
col==
cont.matrix[i].end()) {
632 numlimits = std::numeric_limits<GlobalIndex>::max();
638 const typename I::IndexPair* index=
cont.idxset.pair(
col.index());
642 if ( index->local().attribute() != 2)
645 numlimits = std::numeric_limits<GlobalIndex>::max();
655 if (
data.first != std::numeric_limits<GlobalIndex>::max()) {
656 typename M::size_type
column=
cont.aggidxset.at(
data.first).local();
667 template<
class M,
class I>
670 template<
class M,
class I>
673 template<
class M,
class I>
676 template<
typename M,
typename C>
682 typedef typename C::ParallelIndexSet IndexSet;
684 std::vector<typename M::size_type> rowsize(
newComm.indexSet().size(), 0);
694 for (std::size_t i=0; i <
newComm.indexSet().size(); i++) {
695 rowsize[i] = ri.getRowSize(i);
712 ri.getInterface().free();
720 for (std::size_t i=0; i <
newComm.indexSet().size(); i++) {
725 for (std::size_t i=0; i <
origComm.indexSet().size(); i++) {
745#ifdef DUNE_ISTL_WITH_CHECKING
748 typedef typename M::ConstRowIterator
RIter;
750 typedef typename M::ConstColIterator CIter;
751 for(CIter
col=row->begin(), cend=row->end();
col!=cend; ++
col)
756 std::cerr<<
newComm.communicator().rank()<<
": entry ("
757 <<
col.index()<<
","<<row.index()<<
") missing! for symmetry!"<<std::endl;
770 template<
typename M,
typename C>
774 typedef typename C::ParallelIndexSet IndexSet;
776 std::vector<typename M::size_type> rowsize(
newComm.indexSet().size(), 0);
780 for (std::size_t i=0; i <
newComm.indexSet().size(); i++) {
781 rowsize[i] = ri.getRowSize(i);
787 for (std::size_t i=0; i <
origComm.indexSet().size(); i++)
800 ri.getInterface().free();
814 newrow.setOverlapRowsToDirichlet();
833 template<
typename M,
typename C>
837 ri.setNoRows(
newComm.indexSet().size());
838 ri.setNoCopyRows(
newComm.indexSet().size());
839 ri.setNoBackwardsCopyRows(
origComm.indexSet().size());
Classes providing communication interfaces for overlapping Schwarz methods.
Functionality for redistributing a parallel index set using graph partitioning.
Col col
Definition matrixmatrix.hh:347
Definition basearray.hh:19
void redistributeMatrixEntries(M &origMatrix, M &newMatrix, C &origComm, C &newComm, RedistributeInformation< C > &ri)
Definition matrixredistribute.hh:771
void redistributeSparsityPattern(M &origMatrix, M &newMatrix, C &origComm, C &newComm, RedistributeInformation< C > &ri)
Definition matrixredistribute.hh:677
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
Statistics about compression achieved in implicit mode.
Definition bcrsmatrix.hh:81
derive error class from the base class in common
Definition istlexception.hh:16
Definition matrixredistribute.hh:21
void setNoBackwardsCopyRows(std::size_t size)
Definition matrixredistribute.hh:53
void redistribute(const D &from, D &to) const
Definition matrixredistribute.hh:27
void resetSetup()
Definition matrixredistribute.hh:40
void setNoCopyRows(std::size_t size)
Definition matrixredistribute.hh:48
bool isSetup() const
Definition matrixredistribute.hh:22
void setNoRows(std::size_t size)
Definition matrixredistribute.hh:43
void redistributeBackward(D &from, const D &to) const
Definition matrixredistribute.hh:34
std::size_t getBackwardsCopyRowSize(std::size_t index) const
Definition matrixredistribute.hh:70
std::size_t getRowSize(std::size_t index) const
Definition matrixredistribute.hh:58
std::size_t getCopyRowSize(std::size_t index) const
Definition matrixredistribute.hh:64
std::size_t getRowSize(std::size_t index) const
Definition matrixredistribute.hh:172
std::size_t & getBackwardsCopyRowSize(std::size_t index)
Definition matrixredistribute.hh:187
RedistributeInterface & getInterface()
Definition matrixredistribute.hh:89
void redistribute(const D &from, D &to) const
Definition matrixredistribute.hh:150
void setNoBackwardsCopyRows(std::size_t rows)
Definition matrixredistribute.hh:207
std::size_t & getCopyRowSize(std::size_t index)
Definition matrixredistribute.hh:177
RedistributeInformation()
Definition matrixredistribute.hh:85
std::size_t getCopyRowSize(std::size_t index) const
Definition matrixredistribute.hh:182
void setNoRows(std::size_t rows)
Definition matrixredistribute.hh:197
void reserve(std::size_t size)
Definition matrixredistribute.hh:164
OwnerOverlapCopyCommunication< T, T1 > Comm
Definition matrixredistribute.hh:83
void setNoCopyRows(std::size_t rows)
Definition matrixredistribute.hh:202
void redistributeBackward(D &from, const D &to) const
Definition matrixredistribute.hh:155
void setSetup()
Definition matrixredistribute.hh:120
std::size_t getBackwardsCopyRowSize(std::size_t index) const
Definition matrixredistribute.hh:192
void redistribute(const D &from, D &to) const
Definition matrixredistribute.hh:132
void resetSetup()
Definition matrixredistribute.hh:126
void redistributeBackward(D &from, const D &to) const
Definition matrixredistribute.hh:140
void checkInterface(const IS &source, const IS &target, MPI_Comm comm)
Definition matrixredistribute.hh:94
bool isSetup() const
Definition matrixredistribute.hh:159
std::size_t & getRowSize(std::size_t index)
Definition matrixredistribute.hh:167
Utility class to communicate and set the row sizes of a redistributed matrix.
Definition matrixredistribute.hh:230
M::size_type size_type
Definition matrixredistribute.hh:233
M::size_type value_type
Definition matrixredistribute.hh:232
RI & rowsize
Definition matrixredistribute.hh:244
const M & matrix
Definition matrixredistribute.hh:243
CommMatrixRowSize(const M &m_, RI &rowsize_)
Constructor.
Definition matrixredistribute.hh:240
Utility class to communicate and build the sparsity pattern of a redistributed matrix.
Definition matrixredistribute.hh:259
M::size_type size_type
Definition matrixredistribute.hh:260
const Dune::GlobalLookupIndexSet< I > & idxset
Definition matrixredistribute.hh:370
void storeSparsityPattern(M &m)
Creates and stores the sparsity pattern of the redistributed matrix.
Definition matrixredistribute.hh:290
const I & aggidxset
Definition matrixredistribute.hh:371
const std::vector< size_type > * rowsize
Definition matrixredistribute.hh:373
void completeSparsityPattern(std::vector< std::set< size_type > > add_sparsity)
Completes the sparsity pattern of the redistributed matrix with data from copy rows for the novlp cas...
Definition matrixredistribute.hh:354
CommMatrixSparsityPattern(const M &m_, const Dune::GlobalLookupIndexSet< I > &idxset_, const I &aggidxset_)
Constructor for the original side.
Definition matrixredistribute.hh:268
const M & matrix
Definition matrixredistribute.hh:368
CommMatrixSparsityPattern(const M &m_, const Dune::GlobalLookupIndexSet< I > &idxset_, const I &aggidxset_, const std::vector< typename M::size_type > &rowsize_)
Constructor for the redistruted side.
Definition matrixredistribute.hh:279
std::vector< std::set< size_type > > sparsity
Definition matrixredistribute.hh:372
Dune::GlobalLookupIndexSet< I > LookupIndexSet
Definition matrixredistribute.hh:369
static M::size_type getSize(const Type &t, std::size_t i)
Definition matrixredistribute.hh:390
CommMatrixSparsityPattern< M, I > Type
Definition matrixredistribute.hh:379
I::GlobalIndex IndexedType
The indexed type we send. This is the global index indentitfying the column.
Definition matrixredistribute.hh:385
VariableSize IndexedTypeFlag
Each row varies in size.
Definition matrixredistribute.hh:388
Utility class for comunicating the matrix entries.
Definition matrixredistribute.hh:410
std::vector< size_t > * rowsize
row size information for the receiving side.
Definition matrixredistribute.hh:464
M & matrix
The matrix to communicate the values of.
Definition matrixredistribute.hh:458
CommMatrixRow(M &m_, const Dune::GlobalLookupIndexSet< I > &idxset_, const I &aggidxset_, std::vector< size_t > &rowsize_)
Constructor.
Definition matrixredistribute.hh:426
const Dune::GlobalLookupIndexSet< I > & idxset
Index set for the original matrix.
Definition matrixredistribute.hh:460
void setOverlapRowsToDirichlet()
Sets the non-owner rows correctly as Dirichlet boundaries.
Definition matrixredistribute.hh:435
const I & aggidxset
Index set for the redistributed matrix.
Definition matrixredistribute.hh:462
CommMatrixRow(M &m_, const Dune::GlobalLookupIndexSet< I > &idxset_, const I &aggidxset_)
Constructor.
Definition matrixredistribute.hh:419
std::pair< typename I::GlobalIndex, typename M::block_type > IndexedType
The indexed type we send. This is the pair of global index indentitfying the column and the value its...
Definition matrixredistribute.hh:476
CommMatrixRow< M, I > Type
Definition matrixredistribute.hh:470
static std::size_t getSize(const Type &t, std::size_t i)
Definition matrixredistribute.hh:481
VariableSize IndexedTypeFlag
Each row varies in size.
Definition matrixredistribute.hh:479
Definition matrixredistribute.hh:495
static void scatter(Container &cont, const typename M::size_type &rowsize, std::size_t i)
Definition matrixredistribute.hh:502
static const M::size_type gather(const Container &cont, std::size_t i)
Definition matrixredistribute.hh:498
CommMatrixRowSize< M, RI > Container
Definition matrixredistribute.hh:496
Definition matrixredistribute.hh:512
static const M::size_type gather(const Container &cont, std::size_t i)
Definition matrixredistribute.hh:515
static void scatter(Container &cont, const typename M::size_type &rowsize, std::size_t i)
Definition matrixredistribute.hh:519
CommMatrixRowSize< M, RI > Container
Definition matrixredistribute.hh:513
Definition matrixredistribute.hh:530
M::ConstColIterator ColIter
Definition matrixredistribute.hh:533
static void scatter(Container &cont, const GlobalIndex &gi, std::size_t i, std::size_t j)
Definition matrixredistribute.hh:565
CommMatrixSparsityPattern< M, I > Container
Definition matrixredistribute.hh:532
static GlobalIndex numlimits
Definition matrixredistribute.hh:536
static ColIter col
Definition matrixredistribute.hh:535
I::GlobalIndex GlobalIndex
Definition matrixredistribute.hh:531
static const GlobalIndex & gather(const Container &cont, std::size_t i, std::size_t j)
Definition matrixredistribute.hh:538
Definition matrixredistribute.hh:612
I::GlobalIndex GlobalIndex
Definition matrixredistribute.hh:613
static Data datastore
Definition matrixredistribute.hh:618
static GlobalIndex numlimits
Definition matrixredistribute.hh:619
M::ConstColIterator ColIter
Definition matrixredistribute.hh:615
static const Data & gather(const Container &cont, std::size_t i, std::size_t j)
Definition matrixredistribute.hh:621
std::pair< GlobalIndex, typename M::block_type > Data
Definition matrixredistribute.hh:616
static void scatter(Container &cont, const Data &data, std::size_t i, std::size_t j)
Definition matrixredistribute.hh:651
static ColIter col
Definition matrixredistribute.hh:617
CommMatrixRow< M, I > Container
Definition matrixredistribute.hh:614
A class setting up standard communication for a two-valued attribute set with owner/overlap/copy sema...
Definition owneroverlapcopy.hh:173
Definition repartition.hh:255
@ nonoverlapping
Category for non-overlapping solvers.
Definition solvercategory.hh:23