2 #ifndef DUNE_PDELAB_BACKEND_ISTL_BCRSMATRIXBACKEND_HH 3 #define DUNE_PDELAB_BACKEND_ISTL_BCRSMATRIXBACKEND_HH 22 template<
typename M,
typename RowOrdering,
typename ColOrdering,
bool pattern>
23 struct _build_bcrs_pattern_type
31 template<
typename M,
typename RowOrdering,
typename ColOrdering>
32 struct _build_bcrs_pattern_type<M,RowOrdering,ColOrdering,true>
36 typedef typename _build_bcrs_pattern_type<
37 typename M::block_type,
41 typename M::block_type
43 >::type BlockOrdering;
46 typedef typename std::conditional<
63 template<
typename M,
typename GFSV,
typename GFSU,
typename Tag>
64 struct build_bcrs_pattern_type
68 typename GFSV::Ordering::Traits::DOFIndex,
69 typename GFSV::Ordering::Traits::ContainerIndex
73 typename GFSU::Ordering::Traits::DOFIndex,
74 typename GFSU::Ordering::Traits::ContainerIndex
81 template<
typename M,
typename GFSV,
typename GFSU>
82 struct build_bcrs_pattern_type<M,GFSV,GFSU,FlatContainerAllocationTag>
84 typedef BCRSPattern<typename GFSV::Ordering, typename GFSU::Ordering> type;
89 template<
typename OrderingV,
typename OrderingU,
typename Pattern,
typename Container,
typename StatsVector>
90 typename std::enable_if<
93 allocate_bcrs_matrix(
const OrderingV& ordering_v,
94 const OrderingU& ordering_u,
99 c.setSize(ordering_v.blockCount(),ordering_u.blockCount(),0);
100 c.setBuildMode(Container::random);
102 std::vector<typename Pattern::size_type> row_sizes(p.sizes());
104 typename Pattern::size_type nnz = 0;
105 typename Pattern::size_type longest_row = 0;
107 for (
typename Pattern::size_type i = 0; i < c.N(); ++i)
110 longest_row = std::max(longest_row,row_sizes[i]);
111 c.setrowsize(i,row_sizes[i]);
115 stats.push_back(
typename StatsVector::value_type(nnz,longest_row,p.overflowCount(),p.entriesPerRow(),ordering_v.blockCount()));
117 for (
typename Pattern::size_type i = 0; i < c.N(); ++i)
118 c.setIndices(i,p.begin(i),p.end(i));
138 template<
typename OrderingV,
typename OrderingU,
typename Pattern,
typename Container,
typename StatsVector>
139 typename std::enable_if<
143 allocate_bcrs_matrix(
const OrderingV& ordering_v,
144 const OrderingU& ordering_u,
149 c.setSize(ordering_v.blockCount(),ordering_u.blockCount(),ordering_v.blockCount()*ordering_u.blockCount());
150 c.setBuildMode(Container::random);
152 for (std::size_t i = 0; i < c.N(); ++i)
153 c.setrowsize(i,ordering_u.blockCount());
156 for (std::size_t i = 0; i < c.N(); ++i)
157 for (std::size_t j = 0; j < c.M(); ++j)
161 for (std::size_t i = 0; i < c.N(); ++i)
162 for (std::size_t j = 0; j < c.M(); ++j)
164 allocate_bcrs_matrix(ordering_v.childOrdering(i),
165 ordering_u.childOrdering(j),
189 template<
typename EntriesPerRow = std::
size_t>
200 template<
typename Matrix,
typename GFSV,
typename GFSU>
201 using Pattern =
typename build_bcrs_pattern_type<
202 typename Matrix::Container,
205 typename GFSV::Ordering::ContainerAllocationTag
208 template<
typename VV,
typename VU,
typename E>
212 typename VV::GridFunctionSpace,
213 typename VU::GridFunctionSpace,
214 typename build_matrix_type<
216 typename VV::Container,
217 typename VU::Container
227 template<
typename Gr
idOperator,
typename Matrix>
236 std::vector<Statistics> stats;
253 : _entries_per_row(entries_per_row)
258 EntriesPerRow _entries_per_row;
266 #endif // DUNE_PDELAB_BACKEND_ISTL_BCRSMATRIXBACKEND_HH PatternStatistics< size_type > Statistics
The type of the object holding the statistics generated during pattern construction.
Definition: bcrsmatrixbackend.hh:197
Definition: bcrsmatrix.hh:20
Definition: bcrsmatrixbackend.hh:209
static const unsigned int value
Definition: gridfunctionspace/tags.hh:139
BCRSMatrixBackend(const EntriesPerRow &entries_per_row)
Constructs a BCRSMatrixBackend.
Definition: bcrsmatrixbackend.hh:252
const GFSU & trialGridFunctionSpace() const
Get the trial grid function space.
Definition: gridoperator.hh:120
void fill_pattern(Pattern &p) const
Fill pattern of jacobian matrix.
Definition: gridoperator.hh:191
Standard grid operator implementation.
Definition: gridoperator.hh:57
const GFSV & testGridFunctionSpace() const
Get the test grid function space.
Definition: gridoperator.hh:126
typename impl::BackendMatrixSelector< Backend, VU, VV, E >::Type Matrix
alias of the return type of BackendMatrixSelector
Definition: backend/interface.hh:127
std::size_t size_type
The size type of the BCRSMatrix.
Definition: bcrsmatrixbackend.hh:194
std::vector< Statistics > buildPattern(const GridOperator &grid_operator, Matrix &matrix) const
Builds the matrix pattern associated with grid_operator and initializes matrix with it...
Definition: bcrsmatrixbackend.hh:228
const P & p
Definition: constraints.hh:147
Backend using (possibly nested) ISTL BCRSMatrices.
Definition: bcrsmatrixbackend.hh:190
For backward compatibility – Do not use this!
Definition: adaptivity.hh:27
std::enable_if< std::is_base_of< impl::WrapperBase, T >::value, Native< T > &>::type native(T &t)
Definition: backend/interface.hh:192
typename build_bcrs_pattern_type< typename Matrix::Container, GFSV, GFSU, typename GFSV::Ordering::ContainerAllocationTag >::type Pattern
The type of the pattern object passed to the GridOperator for pattern construction.
Definition: bcrsmatrixbackend.hh:206
GFSU TrialGridFunctionSpace
The trial grid function space.
Definition: gridoperatorutilities.hh:37
BCRSMatrix< typename VV::GridFunctionSpace, typename VU::GridFunctionSpace, typename build_matrix_type< E, typename VV::Container, typename VU::Container >::type, Statistics > type
Definition: bcrsmatrixbackend.hh:220
GFSV TestGridFunctionSpace
The test grid function space.
Definition: gridoperatorutilities.hh:40
Statistics about the pattern of a BCRSMatrix.
Definition: patternstatistics.hh:16