dune-pdelab  2.4-dev
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 
9 #include <cstddef>
10 
11 namespace Dune {
12  namespace PDELab {
13 
14 #ifndef DOXYGEN
15  template<typename T>
16  constexpr bool deactivate_standard_blocking_for_ordering(const T&)
17  {
18  return false;
19  }
20 #endif
21 
22  namespace istl {
23 
25  enum class Blocking
26  {
28  none,
30  bcrs,
32 
39  fixed,
40  };
41 
43  struct vector_backend_tag {};
44 
45  template<Blocking blocking = Blocking::none, std::size_t block_size_ = 1>
47  {
48 
50 
51  static_assert((block_size_ > 0),"block size for FieldVector has to be positive");
52 
53  using size_type = std::size_t;
54 
55  static const size_type blockSize = block_size_;
56 
57  struct Traits
58  {
59  static const Blocking block_type = blocking;
60  static const size_type block_size = block_size_;
61 
62  static const bool blocked = blocking != Blocking::none;
63 
64  static const size_type max_blocking_depth = blocked ? 1 : 0;
65  };
66 
67  template<typename GFS>
68  bool blocked(const GFS& gfs) const
69  {
70  if (deactivate_standard_blocking_for_ordering(gfs.orderingTag()))
71  return false;
72  // We have to make an exception for static blocking and block_size == 1:
73  // In that case, the ISTL backends expect the redundant index information
74  // at that level to be elided, and keeping it in here will break vector
75  // and matrix accesses.
76  // To work around that problem, we override the user and just turn off
77  // blocking internally.
78  return Traits::blocked && (blocking != Blocking::fixed || !GFS::isLeaf || block_size_ > 1);
79  }
80 
81  };
82 
83  }
84 
85  namespace ISTLParameters {
86 
87  enum
88  DUNE_DEPRECATED_MSG("ISTLParameters::blocking is deprecated and will be removed after PDELab 2.4. Use the new istl::VectorBackend and istl::Blocking instead. Note that the enum values of istl::Blocking are named differently!")
89  Blocking
90  {
94  };
95  }
96 
97 #pragma GCC diagnostic push
98 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
99 
100  template<ISTLParameters::Blocking blocking = ISTLParameters::no_blocking, std::size_t block_size = 1>
101  using ISTLVectorBackend DUNE_DEPRECATED_MSG("ISTLVectorBackend is deprecated and will be removed after PDELab 2.4. Use istl::VectorBackend instead") = istl::VectorBackend<static_cast<istl::Blocking>(blocking),block_size>;
102 
103 #pragma GCC diagnostic pop
104 
106 
111  struct
112  DUNE_DEPRECATED_MSG("ISTLMatrixBackend has been deprecated and will be removed after the release of PDELab 2.4. Use istl::BCRSMatrixBackend with the newer pattern construction method instead")
114  {
115 
116  typedef std::size_t size_type;
117 
118  // The default matrix construction method does not collect statistics, so provide a dummy type here.
119  typedef int Statistics;
120 
122  template<typename Matrix, typename GFSV, typename GFSU>
123  using Pattern = typename istl::build_pattern_type<
124  typename Matrix::Container,
125  GFSV,
126  GFSU,
127  typename GFSV::Ordering::ContainerAllocationTag
128  >::type;
129 
130  template<typename VV, typename VU, typename E>
132  {
133  typedef istl::BCRSMatrix<
134  typename VV::GridFunctionSpace,
135  typename VU::GridFunctionSpace,
136  typename istl::build_matrix_type<
137  E,
138  typename VV::Container,
139  typename VU::Container
140  >::type,
141  Statistics
142  > type;
143  };
144 
145  template<typename GridOperator, typename Matrix>
146  std::vector<Statistics> buildPattern(const GridOperator& grid_operator, Matrix& matrix) const
147  {
148  Pattern<
149  Matrix,
152  > pattern(grid_operator.testGridFunctionSpace().ordering(),grid_operator.trialGridFunctionSpace().ordering());
153  grid_operator.fill_pattern(pattern);
154  allocate_matrix(grid_operator.testGridFunctionSpace().ordering(),
155  grid_operator.trialGridFunctionSpace().ordering(),
156  pattern,
157  Backend::native(matrix)
158  );
159  return std::vector<Statistics>();
160  }
161 
162  };
163 
164  } // namespace PDELab
165 } // namespace Dune
166 
167 
168 
169 #endif // DUNE_PDELAB_BACKEND_ISTL_DESCRIPTORS_HH
Creates one macro block for each child space, each block is a BlockVector / BCRS matrix.
Tag describing an ISTL BlockVector backend.
Definition: istl/descriptors.hh:43
const GFSU & trialGridFunctionSpace() const
Get the trial grid function space.
Definition: gridoperator.hh:87
Definition: bcrsmatrix.hh:17
void fill_pattern(Pattern &p) const
Fill pattern of jacobian matrix.
Definition: gridoperator.hh:158
Blocking
Definition: istl/descriptors.hh:87
DUNE_CONSTEXPR bool deactivate_standard_blocking_for_ordering(const Chunked< Decorated > &)
Definition: chunkedblockordering.hh:100
Create fixed size blocks that each group together a fixed number of DOFs from each child space...
static const size_type blockSize
Definition: istl/descriptors.hh:55
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:128
static const bool blocked
Definition: istl/descriptors.hh:62
Definition: istl/descriptors.hh:93
Standard grid operator implementation.
Definition: gridoperator.hh:34
istl::BCRSMatrix< 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:142
Definition: istl/descriptors.hh:91
Blocking
The type of blocking employed at this node in the function space tree.
Definition: istl/descriptors.hh:25
Definition: istl/descriptors.hh:92
Definition: istl/descriptors.hh:46
std::enable_if< std::is_base_of< impl::WrapperBase, T >::value, Native< T > & >::type native(T &t)
Definition: backend/interface.hh:198
const GFSV & testGridFunctionSpace() const
Get the test grid function space.
Definition: gridoperator.hh:93
static const size_type max_blocking_depth
Definition: istl/descriptors.hh:64
Definition: istl/descriptors.hh:131
Definition: istl/descriptors.hh:57
GFSU TrialGridFunctionSpace
The trial grid function space.
Definition: gridoperatorutilities.hh:37
Definition: adaptivity.hh:27
std::size_t size_type
Definition: istl/descriptors.hh:116
std::vector< Statistics > buildPattern(const GridOperator &grid_operator, Matrix &matrix) const
Definition: istl/descriptors.hh:146
typename impl::BackendMatrixSelector< Backend, VU, VV, E >::Type Matrix
alias of the return type of BackendMatrixSelector
Definition: backend/interface.hh:133
GFSV TestGridFunctionSpace
The test grid function space.
Definition: gridoperatorutilities.hh:40
static const Blocking block_type
Definition: istl/descriptors.hh:59
No blocking at this level.
bool blocked(const GFS &gfs) const
Definition: istl/descriptors.hh:68
int Statistics
Definition: istl/descriptors.hh:119
std::size_t size_type
Definition: istl/descriptors.hh:53
Backend using ISTL matrices.
Definition: istl/descriptors.hh:111
static const size_type block_size
Definition: istl/descriptors.hh:60