Go to the documentation of this file.
2 #ifndef DUNE_PDELAB_BACKEND_ISTL_BCRSMATRIX_HH
3 #define DUNE_PDELAB_BACKEND_ISTL_BCRSMATRIX_HH
5 #include <dune/common/typetraits.hh>
6 #include <dune/common/shared_ptr.hh>
7 #if DUNE_VERSION_GTE(ISTL,2,8)
8 #include <dune/istl/blocklevel.hh>
21 template<
typename GFSV,
typename GFSU,
typename C,
typename Stats>
23 :
public Backend::impl::Wrapper<C>
26 friend Backend::impl::Wrapper<C>;
40 typedef typename GFSV::Ordering::Traits::ContainerIndex
RowIndex;
41 typedef typename GFSU::Ordering::Traits::ContainerIndex
ColIndex;
43 typedef typename ISTL::build_pattern_type<C,GFSV,GFSU,typename GFSV::Ordering::ContainerAllocationTag>::type
Pattern;
53 typedef typename std::conditional<
54 #if DUNE_VERSION_LT(DUNE_ISTL,2,8)
57 (blockLevel<C>() > 2),
59 std::vector<PatternStatistics>,
61 >::type StatisticsReturnType;
65 template<
typename RowCache,
typename ColCache>
68 template<
typename RowCache,
typename ColCache>
71 template<
typename RowCache,
typename ColCache>
74 template<
typename RowCache,
typename ColCache>
79 : _container(std::make_shared<
Container>())
81 _stats = go.matrixBackend().buildPattern(go,*
this);
95 : _container(
Dune::stackobject_to_shared_ptr(container))
97 _stats = go.matrixBackend().buildPattern(go,*
this);
100 template<
typename GO>
102 : _container(std::make_shared<
Container>())
104 _stats = go.matrixBackend().buildPattern(go,*
this);
114 : _container(std::make_shared<
Container>())
118 : _container(std::make_shared<
Container>(*(rhs._container)))
128 (*_container) = (*(rhs._container));
132 _container = std::make_shared<Container>(*(rhs._container));
140 #if DUNE_VERSION_LT(DUNE_ISTL,2,8)
154 DUNE_THROW(InvalidStateException,
"no pattern statistics available");
158 const std::vector<PatternStatistics>&
patternStatistics(std::true_type multiple)
const
161 DUNE_THROW(InvalidStateException,
"no pattern statistics available");
175 void attach(std::shared_ptr<Container> container)
177 _container = container;
182 return bool(_container);
185 const std::shared_ptr<Container>&
storage()
const
192 return _container->N();
197 return _container->M();
214 return ISTL::access_matrix_element(
ISTL::container_tag(*_container),*_container,ri,ci,ri.size()-1,ci.size()-1);
219 return ISTL::access_matrix_element(
ISTL::container_tag(*_container),*_container,ri,ci,ri.size()-1,ci.size()-1);
236 template<
typename RowCache,
typename ColCache>
239 return &((*this)(row_cache.containerIndex(0),col_cache.containerIndex(0)));
242 template<
typename RowCache,
typename ColCache>
243 const value_type*
data(
const RowCache& row_cache,
const ColCache& col_cache)
const
245 return &((*this)(row_cache.containerIndex(0),col_cache.containerIndex(0)));
257 ISTL::write_matrix_element_if_exists(diagonal_entry,
ISTL::container_tag(*_container),*_container,ri,ri,ri.size()-1,ri.size()-1);
263 ISTL::write_matrix_element_if_exists_to_block(diagonal_entry,
ISTL::container_tag(*_container),*_container,ri,ri,ri.size()-1,ri.size()-1);
268 std::shared_ptr<Container> _container;
269 std::vector<PatternStatistics> _stats;
278 #endif // DUNE_PDELAB_BACKEND_ISTL_BCRSMATRIX_HH
Various tags for influencing backend behavior.
ElementType E
Definition: bcrsmatrix.hh:31
E & operator()(const RowIndex &ri, const ColIndex &ci)
Definition: bcrsmatrix.hh:212
const value_type * data(const RowCache &row_cache, const ColCache &col_cache) const
Definition: bcrsmatrix.hh:243
BCRSMatrix(Backend::unattached_container=Backend::unattached_container())
Creates an BCRSMatrix without allocating an underlying ISTL matrix.
Definition: bcrsmatrix.hh:109
BCRSMatrix(const BCRSMatrix &rhs)
Definition: bcrsmatrix.hh:117
Definition: uncachedmatrixview.hh:165
Tag for requesting a vector or matrix container without a pre-attached underlying object.
Definition: backend/common/tags.hh:23
C::block_type block_type
Definition: bcrsmatrix.hh:34
C::size_type size_type
Definition: bcrsmatrix.hh:35
value_type * data(const RowCache &row_cache, const ColCache &col_cache)
Definition: bcrsmatrix.hh:237
GFSV TestGridFunctionSpace
Definition: bcrsmatrix.hh:38
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Definition: uncachedmatrixview.hh:12
BCRSMatrix & operator=(const BCRSMatrix &rhs)
Definition: bcrsmatrix.hh:121
GFSU::Ordering::Traits::ContainerIndex ColIndex
Definition: bcrsmatrix.hh:41
const StatisticsReturnType & patternStatistics() const
Returns pattern statistics for all contained BCRSMatrix objects.
Definition: bcrsmatrix.hh:138
GFSU TrialGridFunctionSpace
Definition: bcrsmatrix.hh:37
size_type M() const
Definition: bcrsmatrix.hh:195
void detach()
Definition: bcrsmatrix.hh:169
Definition: aliasedmatrixview.hh:166
const Entity & e
Definition: localfunctionspace.hh:121
void clear_row(const RowIndex &ri, const E &diagonal_entry)
Definition: bcrsmatrix.hh:254
Definition: bcrsmatrix.hh:22
Statistics about the pattern of a BCRSMatrix.
Definition: patternstatistics.hh:13
C::field_type ElementType
Definition: bcrsmatrix.hh:30
BCRSMatrix(const GO &go, const E &e)
Definition: bcrsmatrix.hh:101
void clear_row_block(const RowIndex &ri, const E &diagonal_entry)
Definition: bcrsmatrix.hh:260
const std::shared_ptr< Container > & storage() const
Definition: bcrsmatrix.hh:185
Stats PatternStatistics
Definition: bcrsmatrix.hh:45
ISTL::build_pattern_type< C, GFSV, GFSU, typename GFSV::Ordering::ContainerAllocationTag >::type Pattern
Definition: bcrsmatrix.hh:43
tags::container< T >::type container_tag(const T &)
Gets instance of container tag associated with T.
Definition: backend/istl/tags.hh:234
E value_type
Definition: bcrsmatrix.hh:47
size_type N() const
Definition: bcrsmatrix.hh:190
BCRSMatrix(Backend::attached_container)
Creates an BCRSMatrix with an empty underlying ISTL matrix.
Definition: bcrsmatrix.hh:113
bool attached() const
Definition: bcrsmatrix.hh:180
void finalize()
Definition: bcrsmatrix.hh:251
GFSV::Ordering::Traits::ContainerIndex RowIndex
Definition: bcrsmatrix.hh:40
const E & operator()(const RowIndex &ri, const ColIndex &ci) const
Definition: bcrsmatrix.hh:217
C::field_type field_type
Definition: bcrsmatrix.hh:33
BCRSMatrix & operator*=(const E &e)
Definition: bcrsmatrix.hh:206
void flush()
Definition: bcrsmatrix.hh:248
void attach(std::shared_ptr< Container > container)
Definition: bcrsmatrix.hh:175
Tag for requesting a vector or matrix container with a pre-attached underlying object.
Definition: backend/common/tags.hh:27
C Container
Definition: bcrsmatrix.hh:32
BCRSMatrix(const GO &go, Container &container)
Construct matrix container using an externally given matrix as storage.
Definition: bcrsmatrix.hh:94
Definition: aliasedmatrixview.hh:12
BCRSMatrix(const GO &go)
Definition: bcrsmatrix.hh:78