KASKADE 7 development version
Public Types | Public Member Functions | Public Attributes | List of all members
Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType > Class Template Reference

A structure for holding a sequence of several local matrices to be filled sequentially and to be scattered jointly. More...

#include <localMatrices.hh>

Detailed Description

template<class Entry, bool diagonal, class SortedRowIdx, class SortedColIdx, class IT = void, class IndexType = std::size_t>
class Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >

A structure for holding a sequence of several local matrices to be filled sequentially and to be scattered jointly.

This realizes a container of dense or diagonal matrices (depending on the diagonal template parameter), with the critical feature that the entries for all the matrices are stored in a contiguous memory block. This should improve locality of memory access during assembly and scattering of local matrices.

Template Parameters
Entrythe type of matrix entries
diagonalif true, only diagonal
SortedRowIdxa range of row indices (global row, local row) sorted ascendingly by global row
SortedColIdxa range of column indices (global col, local col) sorted ascendingly by global col
ITa particular type that can be used to "store" static information associated to the buffer

Definition at line 179 of file localMatrices.hh.

Public Types

using value_type = LocalMatrix< Entry, diagonal, SortedRowIdx, SortedColIdx >
 
using InfoType = IT
 

Public Member Functions

 LocalMatrices (NumaBCRSMatrix< Entry, IndexType > &globalMatrix_, size_t maxStorage_=256 *1024)
 
 LocalMatrices ()
 Default constructor. More...
 
 ~LocalMatrices ()
 Destructor. More...
 
void push_back (SortedRowIdx const &ridx, SortedColIdx const &cidx)
 Appends another (zero-initialized) local matrix. More...
 
value_typeoperator[] (int n)
 A reference to the n-th local matrix. More...
 
value_type const & operator[] (int n) const
 
value_typeback ()
 A reference to the last pushed local matrix. More...
 
value_type const & back () const
 
size_t size () const
 The number of local matrices that are stored. More...
 
void scatter ()
 Scatters the local matrices into the global one and removes them from the local container. More...
 
void clear ()
 clears all the data, leaving an empty state More...
 
size_t storageSize () const
 reports the size of the local matrices storage in bytes More...
 
size_t storageSizeLimit () const
 reports the maximal desired local matrices storage size More...
 

Public Attributes

std::vector< value_typelocalMatrices
 

Member Typedef Documentation

◆ InfoType

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
using Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::InfoType = IT

Definition at line 183 of file localMatrices.hh.

◆ value_type

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
using Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::value_type = LocalMatrix<Entry,diagonal,SortedRowIdx,SortedColIdx>

Definition at line 182 of file localMatrices.hh.

Constructor & Destructor Documentation

◆ LocalMatrices() [1/2]

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::LocalMatrices ( NumaBCRSMatrix< Entry, IndexType > &  globalMatrix_,
size_t  maxStorage_ = 256*1024 
)
inline
Parameters
maxStorage_the desired maximum size of the occupied memory. This is no hard limit, merely a hint. Defaults to 256kB.

Definition at line 188 of file localMatrices.hh.

◆ LocalMatrices() [2/2]

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::LocalMatrices ( )
inline

Default constructor.

This creates an essentially useless empty local matrix buffer.

Definition at line 201 of file localMatrices.hh.

◆ ~LocalMatrices()

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::~LocalMatrices ( )
inline

Destructor.

The destructor scatters all remaining local matrices into the global matrix.

Definition at line 210 of file localMatrices.hh.

Member Function Documentation

◆ back() [1/2]

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
value_type & Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::back ( )
inline

A reference to the last pushed local matrix.

Definition at line 254 of file localMatrices.hh.

Referenced by Kaskade::NumaBCRSMatrix< Entry, Index >::conjugation(), and Kaskade::BDDC::KKTSolver< Domain >::KKTSolver().

◆ back() [2/2]

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
value_type const & Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::back ( ) const
inline

Definition at line 255 of file localMatrices.hh.

◆ clear()

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
void Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::clear ( )
inline

clears all the data, leaving an empty state

Definition at line 279 of file localMatrices.hh.

Referenced by Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::scatter().

◆ operator[]() [1/2]

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
value_type & Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::operator[] ( int  n)
inline

A reference to the n-th local matrix.

Definition at line 248 of file localMatrices.hh.

◆ operator[]() [2/2]

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
value_type const & Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::operator[] ( int  n) const
inline

Definition at line 249 of file localMatrices.hh.

◆ push_back()

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
void Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::push_back ( SortedRowIdx const &  ridx,
SortedColIdx const &  cidx 
)
inline

Appends another (zero-initialized) local matrix.

In case that appending the new local matrix exceeds the maximum storage size, the existing local matrices are scattered into the global matrix before the new matrix is created.

Parameters
ridxa range of (global idx, local idx) pairs sorted by global index defining the local matrix rows
cidxthe same for the columns

Definition at line 227 of file localMatrices.hh.

Referenced by Kaskade::NumaBCRSMatrix< Entry, Index >::conjugation(), and Kaskade::BDDC::KKTSolver< Domain >::KKTSolver().

◆ scatter()

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
void Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::scatter ( )
inline

Scatters the local matrices into the global one and removes them from the local container.

This is generally not necessary, as the LocalMatrices class scatters automatically as soon as its buffer is filled, and also on destruction. Use this only if you need to control the specific time point at which scattering occurs.

Definition at line 269 of file localMatrices.hh.

Referenced by Kaskade::BDDC::KKTSolver< Domain >::KKTSolver(), Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::push_back(), and Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::~LocalMatrices().

◆ size()

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
size_t Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::size ( ) const
inline

The number of local matrices that are stored.

Definition at line 260 of file localMatrices.hh.

Referenced by Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::push_back().

◆ storageSize()

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
size_t Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::storageSize ( ) const
inline

reports the size of the local matrices storage in bytes

This can be used to limit the number of local matrices such that their memory fits into the CPU cache.

Definition at line 290 of file localMatrices.hh.

◆ storageSizeLimit()

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
size_t Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::storageSizeLimit ( ) const
inline

reports the maximal desired local matrices storage size

Definition at line 298 of file localMatrices.hh.

Member Data Documentation

◆ localMatrices

template<class Entry , bool diagonal, class SortedRowIdx , class SortedColIdx , class IT = void, class IndexType = std::size_t>
std::vector<value_type> Kaskade::LocalMatrices< Entry, diagonal, SortedRowIdx, SortedColIdx, IT, IndexType >::localMatrices

The documentation for this class was generated from the following file: