dune-pdelab  2.0.0
istl/descriptors.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_PDELAB_BACKEND_ISTL_DESCRIPTORS_HH
4 #define DUNE_PDELAB_BACKEND_ISTL_DESCRIPTORS_HH
5 
6 #include <dune/common/static_assert.hh>
10 #include <cstddef>
11 
12 namespace Dune {
13  namespace PDELab {
14 
15  namespace ISTLParameters {
16 
17  enum Blocking
18  {
22  };
23  }
24 
26 
27  template<ISTLParameters::Blocking blocking = ISTLParameters::no_blocking, std::size_t block_size_ = 1>
29  {
30 
32 
33  dune_static_assert((block_size_ > 0),"block size for FieldVector has to be positive");
34 
35  typedef std::size_t size_type;
36 
37  static const size_type blockSize = block_size_;
38 
39  struct Traits
40  {
41  static const ISTLParameters::Blocking block_type = blocking;
42  static const size_type block_size = block_size_;
43 
44  static const bool blocked = blocking != ISTLParameters::no_blocking;
45 
46  static const size_type max_blocking_depth = blocked ? 1 : 0;
47  };
48 
49  template<typename GFS>
50  bool blocked(const GFS& gfs) const
51  {
52  // We have to make an exception for static blocking and block_size == 1:
53  // In that case, the ISTL backends expect the redundant index information
54  // at that level to be elided, and keeping it in here will break vector
55  // and matrix accesses.
56  // To work around that problem, we override the user and just turn off
57  // blocking internally.
58  return Traits::blocked && (blocking != ISTLParameters::static_blocking || !GFS::isLeaf || block_size_ > 1);
59  }
60 
61  };
62 
64 
70  {
71 
72  typedef std::size_t size_type;
73 
74  // The default matrix construction method does not collect statistics, so provide a dummy type here.
75  typedef int Statistics;
76 
77 #if HAVE_TEMPLATE_ALIASES || DOXYGEN
78 
80  template<typename Matrix, typename GFSV, typename GFSU>
81  using Pattern = typename istl::build_pattern_type<
82  typename Matrix::Container,
83  GFSV,
84  GFSU,
85  typename GFSV::Ordering::ContainerAllocationTag
86  >::type;
87 
88 #else // HAVE_TEMPLATE_ALIASES
89 
90  template<typename Matrix, typename GFSV, typename GFSU>
91  struct Pattern
92  : public istl::build_pattern_type<typename Matrix::Container,
93  GFSV,
94  GFSU,
95  typename GFSV::Ordering::ContainerAllocationTag
96  >::type
97  {
98 
99  typedef OrderingBase<
100  typename GFSV::Ordering::Traits::DOFIndex,
101  typename GFSV::Ordering::Traits::ContainerIndex
102  > RowOrdering;
103 
104  typedef OrderingBase<
105  typename GFSU::Ordering::Traits::DOFIndex,
106  typename GFSU::Ordering::Traits::ContainerIndex
107  > ColOrdering;
108 
109  typedef typename istl::build_pattern_type<
110  typename Matrix::Container,
111  GFSV,
112  GFSU,
113  typename GFSV::Ordering::ContainerAllocationTag
114  >::type BaseT;
115 
116  Pattern(const RowOrdering& row_ordering, const ColOrdering& col_ordering)
117  : BaseT(row_ordering,col_ordering)
118  {}
119 
120  };
121 
122 #endif // HAVE_TEMPLATE_ALIASES
123 
124  template<typename VV, typename VU, typename E>
126  {
127  typedef ISTLMatrixContainer<
128  typename VV::GridFunctionSpace,
129  typename VU::GridFunctionSpace,
130  typename istl::build_matrix_type<
131  E,
132  typename VV::Container,
133  typename VU::Container
134  >::type,
135  Statistics
136  > type;
137  };
138 
139  template<typename GridOperator, typename Matrix>
140  std::vector<Statistics> buildPattern(const GridOperator& grid_operator, Matrix& matrix) const
141  {
142  Pattern<
143  Matrix,
146  > pattern(grid_operator.testGridFunctionSpace().ordering(),grid_operator.trialGridFunctionSpace().ordering());
147  grid_operator.fill_pattern(pattern);
148  allocate_matrix(grid_operator.testGridFunctionSpace().ordering(),
149  grid_operator.trialGridFunctionSpace().ordering(),
150  pattern,
151  istl::raw(matrix)
152  );
153  return std::vector<Statistics>();
154  }
155 
156  };
157 
158  } // namespace PDELab
159 } // namespace Dune
160 
161 
162 
163 #endif // DUNE_PDELAB_BACKEND_ISTL_DESCRIPTORS_HH
typename istl::build_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: istl/descriptors.hh:86
Definition: istl/descriptors.hh:28
std::size_t size_type
Definition: istl/descriptors.hh:35
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
Blocking
Definition: istl/descriptors.hh:17
const GFSU & trialGridFunctionSpace() const
Get the trial grid function space.
Definition: gridoperator.hh:87
istl_vector_backend_tag tag
Definition: istl/descriptors.hh:31
Backend using ISTL matrices.
Definition: istl/descriptors.hh:69
static const size_type block_size
Definition: istl/descriptors.hh:42
Definition: orderingbase.hh:22
Definition: istl/descriptors.hh:21
std::vector< Statistics > buildPattern(const GridOperator &grid_operator, Matrix &matrix) const
Definition: istl/descriptors.hh:140
Standard grid operator implementation.
Definition: gridoperator.hh:34
Definition: istl/descriptors.hh:19
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
Definition: istl/descriptors.hh:25
static const size_type max_blocking_depth
Definition: istl/descriptors.hh:46
Definition: istl/descriptors.hh:20
Definition: istl/descriptors.hh:39
Definition: istl/descriptors.hh:125
static const ISTLParameters::Blocking block_type
Definition: istl/descriptors.hh:41
static const bool blocked
Definition: istl/descriptors.hh:44
bool blocked(const GFS &gfs) const
Definition: istl/descriptors.hh:50
const GFSV & testGridFunctionSpace() const
Get the test grid function space.
Definition: gridoperator.hh:93
GFSV TestGridFunctionSpace
The test grid function space.
Definition: gridoperatorutilities.hh:40
static const size_type blockSize
Definition: istl/descriptors.hh:37
dune_static_assert((block_size_ > 0),"block size for FieldVector has to be positive")
std::size_t size_type
Definition: istl/descriptors.hh:72
ISTLMatrixContainer< typename VV::GridFunctionSpace, typename VU::GridFunctionSpace, typename istl::build_matrix_type< E, typename VV::Container, typename VU::Container >::type, Statistics > type
Definition: istl/descriptors.hh:136
Definition: istlmatrixbackend.hh:15
int Statistics
Definition: istl/descriptors.hh:75