dune-pdelab  2.4-dev
gridfunctionspace.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_GRIDFUNCTIONSPACE_HH
4 #define DUNE_PDELAB_GRIDFUNCTIONSPACE_HH
5 
6 #include <cstddef>
7 #include <map>
8 #include <ostream>
9 #include <set>
10 #include <vector>
11 
12 #include <dune/common/exceptions.hh>
13 #include <dune/common/shared_ptr.hh>
14 #include <dune/common/stdstreams.hh>
15 #include <dune/common/typetraits.hh>
16 
17 #include <dune/geometry/referenceelements.hh>
18 #include <dune/geometry/type.hh>
19 
20 #include <dune/localfunctions/common/interfaceswitch.hh>
21 #include <dune/localfunctions/common/localkey.hh>
22 
23 #include <dune/typetree/typetree.hh>
24 
36 
37 namespace Dune {
38  namespace PDELab {
39 
43 
44  //=======================================
45  // grid function space : single component case
46  //=======================================
47 
49 
52  template<typename G, typename L, typename C, typename B, typename O>
54  {
56  static const bool isComposite = false;
57 
59  typedef G GridViewType;
60 
61  typedef G GridView;
62 
64  typedef B BackendType;
65 
66  typedef B Backend;
67 
69  typedef typename B::size_type SizeType;
70 
73 
75  typedef L FiniteElementMap;
76 
78  typedef typename L::Traits::FiniteElementType FiniteElementType;
79 
80  typedef typename L::Traits::FiniteElementType FiniteElement;
81 
83  typedef C ConstraintsType;
84 
86 
90  typedef O OrderingTag;
91 
92  };
93 
106  template<typename GV, typename FEM, typename CE=NoConstraints,
107  typename B=istl::VectorBackend<>, typename P=DefaultLeafOrderingTag>
109  : public TypeTree::LeafNode
110  , public GridFunctionSpaceBase<
111  GridFunctionSpace<GV,FEM,CE,B,P>,
112  GridFunctionSpaceTraits<GV,FEM,CE,B,P>
113  >
115  , public DataHandleProvider<GridFunctionSpace<GV,FEM,CE,B,P> >
116  {
117 
118  typedef TypeTree::TransformTree<GridFunctionSpace,gfs_to_ordering<GridFunctionSpace> > ordering_transformation;
119 
120  template<typename,typename>
121  friend class GridFunctionSpaceBase;
122 
123  public:
126 
127  private:
128 
130 
131  public:
132 
133  typedef typename GV::Traits::template Codim<0>::Entity Element;
134  typedef typename GV::Traits::template Codim<0>::Iterator ElementIterator;
135 
136  typedef P SizeTag;
137 
138  typedef P OrderingTag;
139 
141 
142  typedef typename ordering_transformation::Type Ordering;
143 
145  template<typename E>
147  {
148 
150  typedef typename conditional<
151  is_same<
152  CE,
154  >::value,
157  >::type Type;
158 
159  private:
161  };
162 
164  GridFunctionSpace (const GV& gridview, const FEM& fem, const CE& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
165  : BaseT(backend,ordering_tag)
166  , gv(gridview)
167  , pfem(stackobject_to_shared_ptr(fem))
168  , _pce(stackobject_to_shared_ptr(ce))
169  {
170  }
171 
173  GridFunctionSpace (const GV& gridview, const std::shared_ptr<const FEM>& fem, const std::shared_ptr<const CE>& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
174  : BaseT(backend,ordering_tag)
175  , gv(gridview)
176  , pfem(fem)
177  , _pce(ce)
178  {}
179 
181  GridFunctionSpace (const GV& gridview, const FEM& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
182  : BaseT(backend,ordering_tag)
183  , gv(gridview)
184  , pfem(stackobject_to_shared_ptr(fem))
185  , _pce(std::make_shared<CE>())
186  {}
187 
189  GridFunctionSpace (const GV& gridview, const std::shared_ptr<const FEM>& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
190  : BaseT(backend,ordering_tag)
191  , gv(gridview)
192  , pfem(fem)
193  , _pce(std::make_shared<CE>())
194  {}
195 
197  const GV& gridView () const
198  {
199  return gv;
200  }
201 
203  const FEM& finiteElementMap () const
204  {
205  return *pfem;
206  }
207 
209  std::shared_ptr<const FEM> finiteElementMapStorage () const
210  {
211  return pfem;
212  }
213 
215  const typename Traits::ConstraintsType& constraints () const
216  {
217  return *_pce;
218  }
219 
221  std::shared_ptr<const CE> constraintsStorage () const
222  {
223  return _pce;
224  }
225 
226  //------------------------------
227 
229  const Ordering &ordering() const
230  {
231  if (!this->isRootSpace())
232  {
234  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
235  }
236  if (!_ordering)
237  {
238  create_ordering();
239  this->update(*_ordering);
240  }
241  return *_ordering;
242  }
243 
245  Ordering &ordering()
246  {
247  if (!this->isRootSpace())
248  {
250  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
251  }
252  if (!_ordering)
253  {
254  create_ordering();
255  this->update(*_ordering);
256  }
257  return *_ordering;
258  }
259 
261  std::shared_ptr<const Ordering> orderingStorage() const
262  {
263  if (!this->isRootSpace())
264  {
266  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
267  }
268  if (!_ordering)
269  {
270  create_ordering();
271  this->update(*_ordering);
272  }
273  return _ordering;
274  }
275 
277  std::shared_ptr<Ordering> orderingStorage()
278  {
279  if (!this->isRootSpace())
280  {
282  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
283  }
284  if (!_ordering)
285  {
286  create_ordering();
287  this->update(*_ordering);
288  }
289  return _ordering;
290  }
291 
292  private:
293 
294  // This method here is to avoid a double update of the Ordering when the user calls
295  // GFS::update() before GFS::ordering().
296  void create_ordering() const
297  {
298  _ordering = std::make_shared<Ordering>(ordering_transformation::transform(*this));
299  }
300 
301  GV gv;
302  std::shared_ptr<FEM const> pfem;
303  std::shared_ptr<CE const> _pce;
304 
305  mutable std::shared_ptr<Ordering> _ordering;
306  };
307 
308 
309  } // namespace PDELab
310 } // namespace Dune
311 
312 #endif
extract type for storing constraints
Definition: gridfunctionspace.hh:146
Definition: gridfunctionspacebase.hh:137
B Backend
Definition: gridfunctionspace.hh:66
L::Traits::FiniteElementType FiniteElement
Definition: gridfunctionspace.hh:80
L FiniteElementMapType
finite element map
Definition: gridfunctionspace.hh:72
O OrderingTag
tag describing the ordering.
Definition: gridfunctionspace.hh:90
GV::Traits::template Codim< 0 >::Entity Element
Definition: gridfunctionspace.hh:133
std::shared_ptr< const CE > constraintsStorage() const
return storage of constraints engine
Definition: gridfunctionspace.hh:221
GridFunctionSpace(const GV &gridview, const std::shared_ptr< const FEM > &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:189
P OrderingTag
Definition: gridfunctionspace.hh:138
STL namespace.
P SizeTag
Definition: gridfunctionspace.hh:136
GV::Traits::template Codim< 0 >::Iterator ElementIterator
Definition: gridfunctionspace.hh:134
LeafGridFunctionSpaceTag ImplementationTag
Definition: gridfunctionspace.hh:140
B BackendType
vector backend
Definition: gridfunctionspace.hh:64
static const unsigned int value
Definition: gridfunctionspace/tags.hh:175
Mixin base class for specifying output hints to I/O routines like VTK.
Definition: function.hh:123
ordering_transformation::Type Ordering
Definition: gridfunctionspace.hh:142
Definition: istl/descriptors.hh:46
L FiniteElementMap
finite element map
Definition: gridfunctionspace.hh:75
Definition: gridfunctionspace/tags.hh:32
GridFunctionSpace(const GV &gridview, const std::shared_ptr< const FEM > &fem, const std::shared_ptr< const CE > &ce, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:173
GridFunctionSpace(const GV &gridview, const FEM &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:181
G GridViewType
the grid view where grid function is defined upon
Definition: gridfunctionspace.hh:59
Definition: noconstraints.hh:16
std::shared_ptr< const FEM > finiteElementMapStorage() const
get finite element map
Definition: gridfunctionspace.hh:209
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: gridfunctionspace.hh:229
Definition: adaptivity.hh:27
conditional< is_same< CE, NoConstraints >::value, EmptyTransformation, ConstraintsTransformation< typename Ordering::Traits::DOFIndex, typename Ordering::Traits::ContainerIndex, E > >::type Type
define Type as the Type of a container of E's
Definition: gridfunctionspace.hh:157
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition: gridfunctionspace/tags.hh:216
Definition: datahandleprovider.hh:188
Definition: constraintstransformation.hh:111
std::shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: gridfunctionspace.hh:261
collect types exported by a leaf grid function space
Definition: gridfunctionspace.hh:53
const Traits::ConstraintsType & constraints() const
return constraints engine
Definition: gridfunctionspace.hh:215
GridFunctionSpaceTraits< GV, FEM, CE, B, P > Traits
export Traits class
Definition: gridfunctionspace.hh:125
C ConstraintsType
type representing constraints
Definition: gridfunctionspace.hh:83
std::shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: gridfunctionspace.hh:277
A grid function space.
Definition: gridfunctionspace.hh:108
L::Traits::FiniteElementType FiniteElementType
finite element
Definition: gridfunctionspace.hh:78
static const bool isComposite
True if this grid function space is composed of others.
Definition: gridfunctionspace.hh:56
GridFunctionSpace(const GV &gridview, const FEM &fem, const CE &ce, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:164
Ordering & ordering()
Direct access to the DOF ordering.
Definition: gridfunctionspace.hh:245
a class holding transformation for constrained spaces
Definition: constraintstransformation.hh:18
G GridView
Definition: gridfunctionspace.hh:61
const GV & gridView() const
get grid view
Definition: gridfunctionspace.hh:197
const FEM & finiteElementMap() const
get finite element map
Definition: gridfunctionspace.hh:203
B::size_type SizeType
short cut for size type exported by Backend
Definition: gridfunctionspace.hh:69