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