3#ifndef DUNE_ISTL_COLCOMPMATRIX_HH
4#define DUNE_ISTL_COLCOMPMATRIX_HH
7#include <dune/common/fmatrix.hh>
8#include <dune/common/fvector.hh>
9#include <dune/common/typetraits.hh>
10#include <dune/common/unused.hh>
58 template<
class M,
class S>
88 :
public ForwardIteratorFacade<const_iterator, const typename Matrix::row_type>
92 typename RowIndexSet::const_iterator
pos)
99 return *(firstRow_+ *pos_);
109 typename RowIndexSet::value_type
index()
const
116 typename Matrix::const_iterator firstRow_;
118 typename RowIndexSet::const_iterator pos_;
156 template<
class M,
class X,
class TM,
class TD,
class T1>
159 template<
class T,
bool flag>
166 template<
class B,
class TA,
int n,
int m>
249 template<
class T,
class A,
int n,
int m>
252 template<
class I,
class S,
class D>
266 template<
typename Iter>
267 void addRowNnz(
const Iter& row)
const;
269 template<
typename Iter,
typename Set>
274 template<
typename Iter>
279 void calcColstart()
const;
281 template<
typename Iter>
282 void copyValue(
const Iter& row,
const CIter&
col)
const;
286 virtual void createMatrix()
const;
290 void allocateMatrixStorage()
const;
292 void allocateMarker();
299 template<
class T,
class A,
int n,
int m>
306 template<
class T,
class A,
int n,
int m>
308 :
mat(0), cols(0), marker(0)
311 template<
class T,
class A,
int n,
int m>
318 template<
class T,
class A,
int n,
int m>
319 template<
typename Iter>
322 mat->Nnz_+=row->getsize();
325 template<
class T,
class A,
int n,
int m>
326 template<
typename Iter,
typename Map>
328 const Map& indices)
const
330 typedef typename Iter::value_type::const_iterator
RIter;
331 typedef typename Map::const_iterator
MIter;
333 for(
RIter entry=row->begin(); entry!=row->end(); ++entry)
336 if(
siter==indices.end())
338 if(*
siter==entry.index())
344 template<
class T,
class A,
int n,
int m>
347 allocateMatrixStorage();
351 template<
class T,
class A,
int n,
int m>
356 mat->values=
new T[
mat->Nnz_];
357 mat->rowindex=
new int[
mat->Nnz_];
358 mat->colstart=
new int[cols+1];
361 template<
class T,
class A,
int n,
int m>
370 template<
class T,
class A,
int n,
int m>
371 template<
typename Iter>
378 template<
class T,
class A,
int n,
int m>
388 template<
class T,
class A,
int n,
int m>
394 mat->colstart[i+1]=
mat->colstart[i]+marker[i];
395 marker[i]=
mat->colstart[i];
399 template<
class T,
class A,
int n,
int m>
400 template<
typename Iter>
403 copyValue(
col, row.index(),
col.index());
406 template<
class T,
class A,
int n,
int m>
420 template<
class T,
class A,
int n,
int m>
427 template<
class F,
class MRS>
430 typedef typename MRS::const_iterator Iter;
431 typedef typename std::iterator_traits<Iter>::value_type::const_iterator CIter;
432 for(Iter row=
mrs.begin(); row!=
mrs.end(); ++row)
437 for(Iter row=
mrs.begin(); row!=
mrs.end(); ++row) {
439 for(CIter
col=row->begin();
col != row->end(); ++
col)
445 for(Iter row=
mrs.begin(); row!=
mrs.end(); ++row) {
446 for(CIter
col=row->begin();
col != row->end(); ++
col) {
454 template<
class F,
class M,
class S>
458 typedef typename MRS::RowIndexSet
SIS;
459 typedef typename SIS::const_iterator
SIter;
460 typedef typename MRS::const_iterator Iter;
461 typedef typename std::iterator_traits<Iter>::value_type row_type;
462 typedef typename row_type::const_iterator CIter;
465 for(Iter row=
mrs.begin(); row!=
mrs.end(); ++row)
470 typedef typename MRS::Matrix::size_type size_type;
477 std::numeric_limits<size_type>::max());
479 for(
SIter index =
mrs.rowIndexSet().begin(); index!=
mrs.rowIndexSet().end(); ++index)
482 for(Iter row=
mrs.begin(); row!=
mrs.end(); ++row)
483 for(CIter
col=row->begin();
col != row->end(); ++
col) {
491 for(Iter row=
mrs.begin(); row!=
mrs.end(); ++row)
492 for(CIter
col=row->begin();
col != row->end(); ++
col) {
502 template<
class B,
class TA,
int n,
int m>
503 ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >::ColCompMatrix()
504 : N_(0), M_(0), Nnz_(0), values(0), rowindex(0), colstart(0)
507 template<
class B,
class TA,
int n,
int m>
508 ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >
509 ::ColCompMatrix(
const Matrix&
mat)
510 : N_(n*
mat.N()), M_(m*
mat.M()), Nnz_(n*m*
mat.nonzeroes())
513 template<
class B,
class TA,
int n,
int m>
514 ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >&
515 ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >::operator=(
const Matrix&
mat)
523 template<
class B,
class TA,
int n,
int m>
524 ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >&
525 ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >::operator=(
const ColCompMatrix&
mat)
533 colstart=
new int[M_+1];
534 for(
int i=0; i<=M_; ++i)
535 colstart[i]=
mat.colstart[i];
539 values =
new B[Nnz_];
540 rowindex =
new int[Nnz_];
542 for(
int i=0; i<Nnz_; ++i)
543 values[i]=
mat.values[i];
545 for(
int i=0; i<Nnz_; ++i)
546 rowindex[i]=
mat.rowindex[i];
551 template<
class B,
class TA,
int n,
int m>
552 void ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >
553 ::setMatrix(
const Matrix&
mat)
557 ColCompMatrixInitializer<Matrix> initializer(*
this);
562 template<
class B,
class TA,
int n,
int m>
563 void ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >
564 ::setMatrix(
const Matrix&
mat,
const std::set<std::size_t>& mrs)
570 ColCompMatrixInitializer<Matrix> initializer(*
this);
575 template<
class B,
class TA,
int n,
int m>
576 ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >::~ColCompMatrix()
582 template<
class B,
class TA,
int n,
int m>
583 void ColCompMatrix<BCRSMatrix<FieldMatrix<B,n,m>,TA> >::free()
Implementation of the BCRSMatrix class.
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Col col
Definition matrixmatrix.hh:347
Matrix & mat
Definition matrixmatrix.hh:343
std::size_t countEntries(const BlockVector< FieldVector< T, i >, A > &vector)
Definition matrixmarket.hh:886
Definition basearray.hh:19
void copyToColCompMatrix(F &initializer, const MRS &mrs)
Definition colcompmatrix.hh:428
Statistics about compression achieved in implicit mode.
Definition bcrsmatrix.hh:81
A sparse block matrix with compressed row storage.
Definition bcrsmatrix.hh:412
A::size_type size_type
The type for the index access and the size.
Definition bcrsmatrix.hh:446
Iterator access to matrix rows
Definition bcrsmatrix.hh:527
Definition bvector.hh:660
Provides access to an iterator over all matrix rows.
Definition colcompmatrix.hh:22
Matrix::ConstRowIterator const_iterator
The matrix row iterator type.
Definition colcompmatrix.hh:27
const_iterator begin() const
Get the row iterator at the first row.
Definition colcompmatrix.hh:38
M Matrix
The type of the matrix.
Definition colcompmatrix.hh:25
MatrixRowSet(const Matrix &m)
Construct an row set over all matrix rows.
Definition colcompmatrix.hh:33
const_iterator end() const
Get the row iterator at the end of all rows.
Definition colcompmatrix.hh:43
Provides access to an iterator over an arbitrary subset of matrix rows.
Definition colcompmatrix.hh:60
const RowIndexSet & rowIndexSet() const
Definition colcompmatrix.hh:81
const Matrix & matrix() const
Definition colcompmatrix.hh:76
S RowIndexSet
the type of the set of valid row indices.
Definition colcompmatrix.hh:65
const_iterator begin() const
Get the row iterator at the first row.
Definition colcompmatrix.hh:122
M Matrix
the type of the matrix class.
Definition colcompmatrix.hh:63
MatrixRowSubset(const Matrix &m, const RowIndexSet &s)
Construct an row set over all matrix rows.
Definition colcompmatrix.hh:72
const_iterator end() const
Get the row iterator at the end of all rows.
Definition colcompmatrix.hh:127
The matrix row iterator type.
Definition colcompmatrix.hh:89
bool equals(const const_iterator &o) const
Definition colcompmatrix.hh:101
const Matrix::row_type & dereference() const
Definition colcompmatrix.hh:97
const_iterator(typename Matrix::const_iterator firstRow, typename RowIndexSet::const_iterator pos)
Definition colcompmatrix.hh:91
RowIndexSet::value_type index() const
Definition colcompmatrix.hh:109
void increment()
Definition colcompmatrix.hh:105
Utility class for converting an ISTL Matrix into a column-compressed matrix.
Definition colcompmatrix.hh:145
Inititializer for the ColCompMatrix as needed by OverlappingSchwarz.
Definition colcompmatrix.hh:154
Sequential overlapping Schwarz preconditioner.
Definition overlappingschwarz.hh:742
Definition overlappingschwarz.hh:683
int * rowindex
Definition colcompmatrix.hh:245
BCRSMatrix< FieldMatrix< B, n, m >, TA > Matrix
The type of the matrix to convert.
Definition colcompmatrix.hh:173
int M_
Definition colcompmatrix.hh:243
B * getValues() const
Definition colcompmatrix.hh:212
int * getRowIndex() const
Definition colcompmatrix.hh:217
B * values
Definition colcompmatrix.hh:244
int * colstart
Definition colcompmatrix.hh:246
Matrix::size_type size_type
Definition colcompmatrix.hh:176
int * getColStart() const
Definition colcompmatrix.hh:222
size_type nnz() const
Definition colcompmatrix.hh:198
ColCompMatrix(const Matrix &mat)
Constructor that initializes the data.
virtual void setMatrix(const Matrix &mat, const std::set< std::size_t > &mrs)
Initialize data from a given set of matrix rows and columns.
ColCompMatrix & operator=(const Matrix &mat)
ColCompMatrix & operator=(const ColCompMatrix &mat)
size_type N() const
Get the number of rows.
Definition colcompmatrix.hh:193
virtual void free()
free allocated space.
virtual ~ColCompMatrix()
Destructor.
virtual void setMatrix(const Matrix &mat)
Initialize data from given matrix.
size_type M() const
Get the number of columns.
Definition colcompmatrix.hh:207
size_type cols
Definition colcompmatrix.hh:295
Dune::BCRSMatrix< FieldMatrix< T, n, m >, A > Matrix
Definition colcompmatrix.hh:255
Dune::ColCompMatrix< Matrix > ColCompMatrix
Definition colcompmatrix.hh:256
Matrix::size_type size_type
Definition colcompmatrix.hh:258
void addRowNnz(const Iter &row, const Set &s) const
size_type * marker
Definition colcompmatrix.hh:296
Matrix::row_type::const_iterator CIter
Definition colcompmatrix.hh:257
ColCompMatrix * mat
Definition colcompmatrix.hh:294
ConstIterator class for sequential access.
Definition matrix.hh:398
A generic dynamic dense matrix.
Definition matrix.hh:555
Definition matrixutils.hh:25
Initializer for SuperLU Matrices representing the subdomains.
Definition overlappingschwarz.hh:43