dune-pdelab  2.4.1
backend/istl/utility.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_UTILITY_HH
4 #define DUNE_PDELAB_BACKEND_ISTL_UTILITY_HH
5 
6 #include <dune/common/typetraits.hh>
7 #include <dune/common/deprecated.hh>
8 
10 
11 namespace Dune {
12 
13  namespace PDELab {
14 
15  namespace istl {
16 
17  // ********************************************************************************
18  // Helper functions for uniform access to ISTL containers
19  //
20  // The following suite of raw() functions should be used in places where an
21  // algorithm might work on either the bare ISTL container or the PDELab
22  // wrapper and has to access the bare container.
23  // ********************************************************************************
24 
26  template<typename V>
27  DUNE_DEPRECATED_MSG("raw() is deprecated and will be removed after PDELab 2.4. Use Backend::native() instead")
28  V& raw(V& v)
29  {
30  return v;
31  }
32 
34  template<typename V>
35  DUNE_DEPRECATED_MSG("raw() is deprecated and will be removed after PDELab 2.4. Use Backend::native() instead")
36  const V& raw(const V& v)
37  {
38  return v;
39  }
40 
42  template<typename C>
43  struct
44  DUNE_DEPRECATED_MSG("raw_type<> is deprecated and will be removed after PDELab 2.4. Use Backend::Native<> instead")
45  raw_type
46  {
47  typedef C type;
48  };
49 
50 #ifndef DOXYGEN
51 
52 #pragma GCC diagnostic push
53 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
54 
55  template<typename GFS, typename C>
56  DUNE_DEPRECATED_MSG("raw() is deprecated and will be removed after PDELab 2.4. Use Backend::native() instead")
57  typename BlockVector<GFS,C>::Container&
58  raw(BlockVector<GFS,C>& v)
59  {
60  return v.base();
61  }
62 
63  template<typename GFS, typename C>
64  DUNE_DEPRECATED_MSG("raw() is deprecated and will be removed after PDELab 2.4. Use Backend::native() instead")
65  const typename BlockVector<GFS,C>::Container&
66  raw(const BlockVector<GFS,C>& v)
67  {
68  return v.base();
69  }
70 
71  template<typename GFSU, typename GFSV, typename C, typename Stats>
72  DUNE_DEPRECATED_MSG("raw() is deprecated and will be removed after PDELab 2.4. Use Backend::native() instead")
75  {
76  return m.base();
77  }
78 
79  template<typename GFSU, typename GFSV, typename C, typename Stats>
80  DUNE_DEPRECATED_MSG("raw() is deprecated and will be removed after PDELab 2.4. Use Backend::native() instead")
83  {
84  return m.base();
85  }
86 
87  template<typename GFS, typename C>
88  struct raw_type<BlockVector<GFS,C> >
89  {
90  typedef C type;
91  };
92 
93  template<typename GFSU, typename GFSV, typename C, typename Stats>
94  struct raw_type<BCRSMatrix<GFSU,GFSV,C,Stats> >
95  {
96  typedef C type;
97  };
98 
99 #pragma GCC diagnostic pop
100 
101  // ********************************************************************************
102  // Helpers for the nesting_depth TMP
103  // ********************************************************************************
104 
105  namespace impl {
106 
107  template<typename T, std::size_t depth, typename Tag>
108  struct nesting_depth;
109 
110  template<typename T, std::size_t depth>
111  struct nesting_depth<T,depth,tags::block_vector>
112  : public nesting_depth<typename T::block_type,depth+1,typename tags::container<typename T::block_type>::type::base_tag>
113  {};
114 
115  template<typename T, std::size_t depth>
116  struct nesting_depth<T,depth,tags::dynamic_vector>
117  : public integral_constant<std::size_t,depth+1>
118  {};
119 
120  template<typename T, std::size_t depth>
121  struct nesting_depth<T,depth,tags::field_vector>
122  : public integral_constant<std::size_t,depth+1>
123  {};
124 
125  template<typename T, std::size_t depth>
126  struct nesting_depth<T,depth,tags::bcrs_matrix>
127  : public nesting_depth<typename T::block_type,depth+1,typename tags::container<typename T::block_type>::type::base_tag>
128  {};
129 
130  template<typename T, std::size_t depth>
131  struct nesting_depth<T,depth,tags::dynamic_matrix>
132  : public integral_constant<std::size_t,depth+1>
133  {};
134 
135  template<typename T, std::size_t depth>
136  struct nesting_depth<T,depth,tags::field_matrix>
137  : public integral_constant<std::size_t,depth+1>
138  {};
139 
140  }
141 
142 #endif // DOXYGEN
143 
145 
149  template<typename T>
151  : public impl::nesting_depth<T,0,typename tags::container<T>::type::base_tag>
152  {};
153 
154  } // namespace istl
155  } // namespace PDELab
156 } // namespace Dune
157 
158 #endif // DUNE_PDELAB_BACKEND_ISTL_UTILITY_HH
C Container
Definition: istl/vector.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:28
Definition: istl/vector.hh:25
C Container
Definition: bcrsmatrix.hh:27
Definition: adaptivity.hh:27
const Container & base() const
Definition: bcrsmatrix.hh:204
Definition: bcrsmatrix.hh:17
TMP for figuring out the depth up to which ISTL containers are nested.
Definition: backend/istl/utility.hh:150
Returns the raw ISTL type associated with C, or C itself it is already an ISTL type.
Definition: backend/istl/utility.hh:43
Container & base()
Definition: istl/vector.hh:220
C type
Definition: backend/istl/utility.hh:47