dune-pdelab  2.0.0
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/static_assert.hh>
15 #include <dune/common/stdstreams.hh>
16 #include <dune/common/typetraits.hh>
17 
18 #include <dune/geometry/referenceelements.hh>
19 #include <dune/geometry/type.hh>
20 
21 #include <dune/localfunctions/common/interfaceswitch.hh>
22 #include <dune/localfunctions/common/localkey.hh>
23 
24 #include <dune/typetree/typetree.hh>
25 
37 
38 namespace Dune {
39  namespace PDELab {
40 
44 
45  //=======================================
46  // grid function space : single component case
47  //=======================================
48 
50 
53  template<typename G, typename L, typename C, typename B, typename O>
55  {
57  static const bool isComposite = false;
58 
60  typedef G GridViewType;
61 
62  typedef G GridView;
63 
65  typedef B BackendType;
66 
67  typedef B Backend;
68 
70  typedef typename B::size_type SizeType;
71 
74 
76  typedef L FiniteElementMap;
77 
79  typedef typename L::Traits::FiniteElementType FiniteElementType;
80 
81  typedef typename L::Traits::FiniteElementType FiniteElement;
82 
84  typedef C ConstraintsType;
85 
87 
91  typedef O OrderingTag;
92 
93  };
94 
107  template<typename GV, typename FEM, typename CE=NoConstraints,
108  typename B=ISTLVectorBackend<>, typename P=DefaultLeafOrderingTag>
110  : public TypeTree::LeafNode
111  , public GridFunctionSpaceBase<
112  GridFunctionSpace<GV,FEM,CE,B,P>,
113  GridFunctionSpaceTraits<GV,FEM,CE,B,P>
114  >
116  , public DataHandleProvider<GridFunctionSpace<GV,FEM,CE,B,P> >
117  {
118 
119  typedef TypeTree::TransformTree<GridFunctionSpace,gfs_to_ordering<GridFunctionSpace> > ordering_transformation;
120 
121  template<typename,typename>
122  friend class GridFunctionSpaceBase;
123 
124  public:
127 
128  private:
129 
131 
132  public:
133 
134  typedef typename GV::Traits::template Codim<0>::Entity Element;
135  typedef typename GV::Traits::template Codim<0>::Iterator ElementIterator;
136 
137  typedef P SizeTag;
138 
139  typedef P OrderingTag;
140 
142 
143  typedef typename ordering_transformation::Type Ordering;
144 
146  template<typename E>
148  {
149 
151  typedef typename conditional<
152  is_same<
153  CE,
155  >::value,
158  >::type Type;
159 
160  private:
162  };
163 
165  GridFunctionSpace (const GV& gridview, const FEM& fem, const CE& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
166  : BaseT(backend,ordering_tag)
167  , gv(gridview)
168  , pfem(stackobject_to_shared_ptr(fem))
169  , _pce(stackobject_to_shared_ptr(ce))
170  {
171  }
172 
174  GridFunctionSpace (const GV& gridview, const shared_ptr<const FEM>& fem, const CE& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
175  DUNE_DEPRECATED_MSG("Use either a constructor that passes both FiniteElementMap and ConstraintsEngine as const reference \
176 (for objects with externally controlled lifetime) or as shared_ptr (this GridFunctionSpace will assume shared ownership of both objects).")
177  : BaseT(backend,ordering_tag)
178  , gv(gridview)
179  , pfem(fem)
180  , _pce(stackobject_to_shared_ptr(ce))
181  {}
182 
184  GridFunctionSpace (const GV& gridview, const shared_ptr<const FEM>& fem, const shared_ptr<const CE>& ce, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
185  : BaseT(backend,ordering_tag)
186  , gv(gridview)
187  , pfem(fem)
188  , _pce(ce)
189  {}
190 
192  GridFunctionSpace (const GV& gridview, const FEM& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
193  : BaseT(backend,ordering_tag)
194  , gv(gridview)
195  , pfem(stackobject_to_shared_ptr(fem))
196  , _pce(make_shared<CE>())
197  {}
198 
200  GridFunctionSpace (const GV& gridview, const shared_ptr<const FEM>& fem, const B& backend = B(), const OrderingTag& ordering_tag = OrderingTag())
201  : BaseT(backend,ordering_tag)
202  , gv(gridview)
203  , pfem(fem)
204  , _pce(make_shared<CE>())
205  {}
206 
208  const GV& gridView () const
209  {
210  return gv;
211  }
212 
214  const FEM& finiteElementMap () const
215  {
216  return *pfem;
217  }
218 
220  shared_ptr<const FEM> finiteElementMapStorage () const
221  {
222  return pfem;
223  }
224 
226  const typename Traits::ConstraintsType& constraints () const
227  {
228  return *_pce;
229  }
230 
232  shared_ptr<const CE> constraintsStorage () const
233  {
234  return _pce;
235  }
236 
237  //------------------------------
238 
240  const Ordering &ordering() const
241  {
242  if (!this->isRootSpace())
243  {
245  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
246  }
247  if (!_ordering)
248  {
249  create_ordering();
250  this->update(*_ordering);
251  }
252  return *_ordering;
253  }
254 
257  {
258  if (!this->isRootSpace())
259  {
261  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
262  }
263  if (!_ordering)
264  {
265  create_ordering();
266  this->update(*_ordering);
267  }
268  return *_ordering;
269  }
270 
272  shared_ptr<const Ordering> orderingStorage() const
273  {
274  if (!this->isRootSpace())
275  {
277  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
278  }
279  if (!_ordering)
280  {
281  create_ordering();
282  this->update(*_ordering);
283  }
284  return _ordering;
285  }
286 
288  shared_ptr<Ordering> orderingStorage()
289  {
290  if (!this->isRootSpace())
291  {
293  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
294  }
295  if (!_ordering)
296  {
297  create_ordering();
298  this->update(*_ordering);
299  }
300  return _ordering;
301  }
302 
303  private:
304 
305  // This method here is to avoid a double update of the Ordering when the user calls
306  // GFS::update() before GFS::ordering().
307  void create_ordering() const
308  {
309  _ordering = make_shared<Ordering>(ordering_transformation::transform(*this));
310  }
311 
312  GV gv;
313  shared_ptr<FEM const> pfem;
314  shared_ptr<CE const> _pce;
315 
316  mutable shared_ptr<Ordering> _ordering;
317  };
318 
319 
320  } // namespace PDELab
321 } // namespace Dune
322 
323 #endif
G GridView
Definition: gridfunctionspace.hh:62
LeafGridFunctionSpaceTag ImplementationTag
Definition: gridfunctionspace.hh:141
Definition: istl/descriptors.hh:28
shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: gridfunctionspace.hh:272
Definition: noconstraints.hh:16
collect types exported by a leaf grid function space
Definition: gridfunctionspace.hh:54
C ConstraintsType
type representing constraints
Definition: gridfunctionspace.hh:84
ordering_transformation::Type Ordering
Definition: gridfunctionspace.hh:143
GridFunctionSpace(const GV &gridview, const FEM &fem, const CE &ce, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:165
shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: gridfunctionspace.hh:288
GridFunctionSpace(const GV &gridview, const shared_ptr< const FEM > &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:200
static const bool isComposite
True if this grid function space is composed of others.
Definition: gridfunctionspace.hh:57
GridFunctionSpaceTraits< GV, FEM, CE, B, P > Traits
export Traits class
Definition: gridfunctionspace.hh:126
const FEM & finiteElementMap() const
get finite element map
Definition: gridfunctionspace.hh:214
L::Traits::FiniteElementType FiniteElement
Definition: gridfunctionspace.hh:81
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition: gridfunctionspace/tags.hh:216
Definition: common/constraintstransformation.hh:127
a class holding transformation for constrained spaces
Definition: common/constraintstransformation.hh:18
const GV & gridView() const
get grid view
Definition: gridfunctionspace.hh:208
Mixin base class for specifying output hints to I/O routines like VTK.
Definition: function.hh:124
L::Traits::FiniteElementType FiniteElementType
finite element
Definition: gridfunctionspace.hh:79
GV::Traits::template Codim< 0 >::Entity Element
Definition: gridfunctionspace.hh:134
Definition: gridfunctionspacebase.hh:137
const Traits::ConstraintsType & constraints() const
return constraints engine
Definition: gridfunctionspace.hh:226
O OrderingTag
tag describing the ordering.
Definition: gridfunctionspace.hh:91
extract type for storing constraints
Definition: gridfunctionspace.hh:147
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: gridfunctionspace.hh:240
B::size_type SizeType
short cut for size type exported by Backend
Definition: gridfunctionspace.hh:70
GV::Traits::template Codim< 0 >::Iterator ElementIterator
Definition: gridfunctionspace.hh:135
B Backend
Definition: gridfunctionspace.hh:67
L FiniteElementMap
finite element map
Definition: gridfunctionspace.hh:76
static const unsigned int value
Definition: gridfunctionspace/tags.hh:175
B BackendType
vector backend
Definition: gridfunctionspace.hh:65
Definition: datahandleprovider.hh:189
Definition: gridfunctionspace/tags.hh:28
GridFunctionSpace(const GV &gridview, const FEM &fem, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:192
A grid function space.
Definition: gridfunctionspace.hh:109
GridFunctionSpace(const GV &gridview, const shared_ptr< const FEM > &fem, const shared_ptr< const CE > &ce, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:184
Ordering & ordering()
Direct access to the DOF ordering.
Definition: gridfunctionspace.hh:256
P OrderingTag
Definition: gridfunctionspace.hh:139
GridFunctionSpace(const GV &gridview, const shared_ptr< const FEM > &fem, const CE &ce, const B &backend=B(), const OrderingTag &ordering_tag=OrderingTag())
constructor
Definition: gridfunctionspace.hh:174
shared_ptr< const CE > constraintsStorage() const
return storage of constraints engine
Definition: gridfunctionspace.hh:232
P SizeTag
Definition: gridfunctionspace.hh:137
L FiniteElementMapType
finite element map
Definition: gridfunctionspace.hh:73
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:158
G GridViewType
the grid view where grid function is defined upon
Definition: gridfunctionspace.hh:60
shared_ptr< const FEM > finiteElementMapStorage() const
get finite element map
Definition: gridfunctionspace.hh:220