2 #ifndef DUNE_PDELAB_BACKEND_ISTL_BCRSMATRIXBACKEND_HH
3 #define DUNE_PDELAB_BACKEND_ISTL_BCRSMATRIXBACKEND_HH
19 template<
typename M,
typename RowOrdering,
typename ColOrdering,
bool pattern>
20 struct _build_bcrs_pattern_type
28 template<
typename M,
typename RowOrdering,
typename ColOrdering>
29 struct _build_bcrs_pattern_type<M,RowOrdering,ColOrdering,true>
33 typedef typename _build_bcrs_pattern_type<
34 typename M::block_type,
38 typename M::block_type
40 >::type BlockOrdering;
43 typedef typename conditional<
60 template<
typename M,
typename GFSV,
typename GFSU,
typename Tag>
61 struct build_bcrs_pattern_type
65 typename GFSV::Ordering::Traits::DOFIndex,
66 typename GFSV::Ordering::Traits::ContainerIndex
70 typename GFSU::Ordering::Traits::DOFIndex,
71 typename GFSU::Ordering::Traits::ContainerIndex
78 template<
typename M,
typename GFSV,
typename GFSU>
79 struct build_bcrs_pattern_type<M,GFSV,GFSU,FlatContainerAllocationTag>
97 template<
typename OrderingV,
typename OrderingU,
typename Pattern,
typename Container,
typename StatsVector>
102 allocate_bcrs_matrix(
const OrderingV& ordering_v,
103 const OrderingU& ordering_u,
108 c.setSize(ordering_v.blockCount(),ordering_u.blockCount(),ordering_v.blockCount()*ordering_u.blockCount());
109 c.setBuildMode(Container::random);
111 for (std::size_t i = 0; i < c.N(); ++i)
112 c.setrowsize(i,ordering_u.blockCount());
115 for (std::size_t i = 0; i < c.N(); ++i)
116 for (std::size_t j = 0; j < c.M(); ++j)
120 for (std::size_t i = 0; i < c.N(); ++i)
121 for (std::size_t j = 0; j < c.M(); ++j)
123 allocate_matrix(ordering_v.childOrdering(i),
124 ordering_u.childOrdering(j),
132 template<
typename OrderingV,
typename OrderingU,
typename Pattern,
typename Container,
typename StatsVector>
136 allocate_bcrs_matrix(
const OrderingV& ordering_v,
137 const OrderingU& ordering_u,
142 c.setSize(ordering_v.blockCount(),ordering_u.blockCount(),0);
143 c.setBuildMode(Container::random);
145 std::vector<typename Pattern::size_type> row_sizes(p.sizes());
147 typename Pattern::size_type nnz = 0;
148 typename Pattern::size_type longest_row = 0;
150 for (
typename Pattern::size_type i = 0; i < c.N(); ++i)
153 longest_row = std::max(longest_row,row_sizes[i]);
154 c.setrowsize(i,row_sizes[i]);
158 stats.push_back(
typename StatsVector::value_type(nnz,longest_row,p.overflowCount(),p.entriesPerRow(),ordering_v.blockCount()));
160 for (
typename Pattern::size_type i = 0; i < c.N(); ++i)
161 c.setIndices(i,p.begin(i),p.end(i));
186 template<
typename EntriesPerRow = std::
size_t>
196 #if HAVE_TEMPLATE_ALIASES || DOXYGEN
199 template<
typename Matrix,
typename GFSV,
typename GFSU>
200 using Pattern =
typename build_bcrs_pattern_type<
201 typename Matrix::Container,
204 typename GFSV::Ordering::ContainerAllocationTag
207 #else // HAVE_TEMPLATE_ALIASES
209 template<
typename Matrix,
typename GFSV,
typename GFSU>
211 :
public build_bcrs_pattern_type<typename Matrix::Container,
214 typename GFSV::Ordering::ContainerAllocationTag
219 typename GFSV::Ordering::Traits::DOFIndex,
220 typename GFSV::Ordering::Traits::ContainerIndex
224 typename GFSU::Ordering::Traits::DOFIndex,
225 typename GFSU::Ordering::Traits::ContainerIndex
228 typedef typename build_bcrs_pattern_type<
229 typename Matrix::Container,
232 typename GFSV::Ordering::ContainerAllocationTag
235 template<
typename EntriesPerRow_>
236 Pattern(
const RowOrdering& row_ordering,
const ColOrdering& col_ordering,
const EntriesPerRow_& entries_per_row)
237 : BaseT(row_ordering,col_ordering,entries_per_row)
242 #endif // HAVE_TEMPLATE_ALIASES
244 template<
typename VV,
typename VU,
typename E>
248 typename VV::GridFunctionSpace,
249 typename VU::GridFunctionSpace,
250 typename build_matrix_type<
252 typename VV::Container,
253 typename VU::Container
263 template<
typename Gr
idOperator,
typename Matrix>
272 std::vector<Statistics> stats;
279 #if HAVE_RVALUE_REFERENCES
280 return std::move(stats);
293 : _entries_per_row(entries_per_row)
298 EntriesPerRow _entries_per_row;
306 #endif // DUNE_PDELAB_BACKEND_ISTL_BCRSMATRIXBACKEND_HH
ISTLMatrixContainer< typename VV::GridFunctionSpace, typename VU::GridFunctionSpace, typename build_matrix_type< E, typename VV::Container, typename VU::Container >::type, Statistics > type
Definition: bcrsmatrixbackend.hh:256
GFSU TrialGridFunctionSpace
The trial grid function space.
Definition: gridoperatorutilities.hh:37
void fill_pattern(Pattern &p) const
Fill pattern of jacobian matrix.
Definition: gridoperator.hh:158
Pattern builder for generic BCRS-like sparse matrices.
Definition: bcrspattern.hh:43
Pattern builder for nested hierarchies of generic BCRS-like sparse matrices.
Definition: bcrspattern.hh:328
const GFSU & trialGridFunctionSpace() const
Get the trial grid function space.
Definition: gridoperator.hh:87
Definition: orderingbase.hh:22
Backend using (possibly nested) ISTL BCRSMatrices.
Definition: bcrsmatrixbackend.hh:187
Definition: bcrsmatrixbackend.hh:245
Standard grid operator implementation.
Definition: gridoperator.hh:34
V & raw(V &v)
Returns the raw ISTL object associated with v, or v itself it is already an ISTL object.
Definition: backend/istl/utility.hh:26
PatternStatistics< size_type > Statistics
The type of the object holding the statistics generated during pattern construction.
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:264
static const unsigned int value
Definition: gridfunctionspace/tags.hh:175
const GFSV & testGridFunctionSpace() const
Get the test grid function space.
Definition: gridoperator.hh:93
Statistics about the pattern of a BCRSMatrix.
Definition: patternstatistics.hh:13
GFSV TestGridFunctionSpace
The test grid function space.
Definition: gridoperatorutilities.hh:40
R p(int i, D x)
Definition: qkdg.hh:62
Definition: istlmatrixbackend.hh:15
std::size_t size_type
The size type of the BCRSMatrix.
Definition: bcrsmatrixbackend.hh:191
BCRSMatrixBackend(const EntriesPerRow &entries_per_row)
Constructs a BCRSMatrixBackend.
Definition: bcrsmatrixbackend.hh:292
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:205