dune-pdelab  2.0.0
compositegridfunctionspace.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=8 sw=2 sts=2:
3 
4 #ifndef DUNE_PDELAB_GRIDFUNCTIONSPACE_COMPOSITEGRIDFUNCTIONSPACE_HH
5 #define DUNE_PDELAB_GRIDFUNCTIONSPACE_COMPOSITEGRIDFUNCTIONSPACE_HH
6 
7 #include <dune/common/shared_ptr.hh>
8 
9 #include <dune/typetree/compositenodemacros.hh>
10 #include <dune/typetree/utility.hh>
11 
15 
16 namespace Dune {
17  namespace PDELab {
18 
19  //=======================================
20  // composite grid function space
21  //=======================================
22 
26 
37  template<typename Backend,
38  typename OrderingTag,
39  DUNE_TYPETREE_COMPOSITENODE_TEMPLATE_CHILDREN>
41  : public DUNE_TYPETREE_COMPOSITENODE_BASETYPE
43  CompositeGridFunctionSpace<
44  Backend,
45  OrderingTag,
46  DUNE_TYPETREE_COMPOSITENODE_CHILDTYPES>,
47  typename DUNE_TYPETREE_COMPOSITENODE_BASETYPE::template Child<0>::
48  Type::Traits::GridViewType,
49  Backend,
50  OrderingTag,
51  DUNE_TYPETREE_COMPOSITENODE_BASETYPE::CHILDREN
52  >
53  , public DataHandleProvider<CompositeGridFunctionSpace<Backend,OrderingTag,DUNE_TYPETREE_COMPOSITENODE_CHILDTYPES> >
54  {
55  typedef DUNE_TYPETREE_COMPOSITENODE_BASETYPE NodeT;
56 
59  typename NodeT::template Child<0>::Type::Traits::GridViewType,
60  Backend,
62  NodeT::CHILDREN> ImplementationBase;
63 
65  CompositeGridFunctionSpace,
66  typename NodeT::template Child<0>::Type::Traits::GridViewType,
67  Backend,
69  NodeT::CHILDREN>;
70 
71  typedef TypeTree::TransformTree<CompositeGridFunctionSpace,
72  gfs_to_ordering<CompositeGridFunctionSpace>
73  > ordering_transformation;
74 
75  template<typename,typename>
76  friend class GridFunctionSpaceBase;
77 
78  public:
80 
81  typedef typename ordering_transformation::Type Ordering;
82 
84 
85  // ********************************************************************************
86  // constructors for stack-constructed children passed in by reference
87  // ********************************************************************************
88 
89  CompositeGridFunctionSpace(const Backend& backend, DUNE_TYPETREE_COMPOSITENODE_CONSTRUCTOR_SIGNATURE)
90  : NodeT(DUNE_TYPETREE_COMPOSITENODE_CHILDVARIABLES_THROUGH_FUNCTION(TypeTree::assertGridViewType<typename NodeT::template Child<0>::Type>))
91  , ImplementationBase(backend,OrderingTag())
92  { }
93 
94  CompositeGridFunctionSpace(const OrderingTag& ordering_tag, DUNE_TYPETREE_COMPOSITENODE_CONSTRUCTOR_SIGNATURE)
95  : NodeT(DUNE_TYPETREE_COMPOSITENODE_CHILDVARIABLES_THROUGH_FUNCTION(TypeTree::assertGridViewType<typename NodeT::template Child<0>::Type>))
96  , ImplementationBase(Backend(),ordering_tag)
97  { }
98 
99  CompositeGridFunctionSpace(const Backend& backend, const OrderingTag& ordering_tag, DUNE_TYPETREE_COMPOSITENODE_CONSTRUCTOR_SIGNATURE)
100  : NodeT(DUNE_TYPETREE_COMPOSITENODE_CHILDVARIABLES_THROUGH_FUNCTION(TypeTree::assertGridViewType<typename NodeT::template Child<0>::Type>))
101  , ImplementationBase(backend,ordering_tag)
102  { }
103 
104  CompositeGridFunctionSpace(DUNE_TYPETREE_COMPOSITENODE_CONSTRUCTOR_SIGNATURE)
105  : NodeT(DUNE_TYPETREE_COMPOSITENODE_CHILDVARIABLES_THROUGH_FUNCTION(TypeTree::assertGridViewType<typename NodeT::template Child<0>::Type>))
106  , ImplementationBase(Backend(),OrderingTag())
107  { }
108 
109  // ********************************************************************************
110  // constructors for heap-constructed children passed in as shared_ptrs
111  // ********************************************************************************
112 
113  CompositeGridFunctionSpace(const Backend& backend, DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
114  : NodeT(DUNE_TYPETREE_COMPOSITENODE_CHILDVARIABLES)
115  , ImplementationBase(backend,OrderingTag())
116  { }
117 
118  CompositeGridFunctionSpace(const OrderingTag& ordering_tag, DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
119  : NodeT(DUNE_TYPETREE_COMPOSITENODE_CHILDVARIABLES)
120  , ImplementationBase(Backend(),ordering_tag)
121  { }
122 
123  CompositeGridFunctionSpace(const Backend& backend, const OrderingTag& ordering_tag, DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
124  : NodeT(DUNE_TYPETREE_COMPOSITENODE_CHILDVARIABLES)
125  , ImplementationBase(backend,ordering_tag)
126  { }
127 
128  CompositeGridFunctionSpace(DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
129  : NodeT(DUNE_TYPETREE_COMPOSITENODE_CHILDVARIABLES)
130  , ImplementationBase(Backend(),OrderingTag())
131  { }
132 
133 
135  const Ordering &ordering() const
136  {
137  if (!this->isRootSpace())
138  {
140  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
141  }
142  if (!_ordering)
143  {
144  create_ordering();
145  this->update(*_ordering);
146  }
147  return *_ordering;
148  }
149 
152  {
153  if (!this->isRootSpace())
154  {
156  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
157  }
158  if (!_ordering)
159  {
160  create_ordering();
161  this->update(*_ordering);
162  }
163  return *_ordering;
164  }
165 
167  shared_ptr<const Ordering> orderingStorage() const
168  {
169  if (!this->isRootSpace())
170  {
172  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
173  }
174  if (!_ordering)
175  {
176  create_ordering();
177  this->update(*_ordering);
178  }
179  return _ordering;
180  }
181 
183  shared_ptr<Ordering> orderingStorage()
184  {
185  if (!this->isRootSpace())
186  {
188  "Ordering can only be obtained for root space in GridFunctionSpace tree.");
189  }
190  if (!_ordering)
191  {
192  create_ordering();
193  this->update(*_ordering);
194  }
195  return _ordering;
196  }
197 
198 
199  private:
200 
201  // This method here is to avoid a double update of the Ordering when the user calls
202  // GFS::update() before GFS::ordering().
203  void create_ordering() const
204  {
205  _ordering = make_shared<Ordering>(ordering_transformation::transform(*this));
206  }
207 
208  mutable shared_ptr<Ordering> _ordering;
209 
210  };
211 
213 
214  } // namespace PDELab
215 } // namespace Dune
216 
217 #endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_COMPOSITEGRIDFUNCTIONSPACE_HH
Ordering & ordering()
Direct access to the DOF ordering.
Definition: compositegridfunctionspace.hh:151
CompositeGridFunctionSpace(DUNE_TYPETREE_COMPOSITENODE_CONSTRUCTOR_SIGNATURE)
Definition: compositegridfunctionspace.hh:104
CompositeGridFunctionSpace(const Backend &backend, DUNE_TYPETREE_COMPOSITENODE_CONSTRUCTOR_SIGNATURE)
Definition: compositegridfunctionspace.hh:89
CompositeGridFunctionSpace(const Backend &backend, const OrderingTag &ordering_tag, DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
Definition: compositegridfunctionspace.hh:123
shared_ptr< const Ordering > orderingStorage() const
Direct access to the storage of the DOF ordering.
Definition: compositegridfunctionspace.hh:167
CompositeGridFunctionSpace(const Backend &backend, DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
Definition: compositegridfunctionspace.hh:113
const Ordering & ordering() const
Direct access to the DOF ordering.
Definition: compositegridfunctionspace.hh:135
ordering_transformation::Type Ordering
Definition: compositegridfunctionspace.hh:81
CompositeGridFunctionSpace(DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
Definition: compositegridfunctionspace.hh:128
Definition: gridfunctionspace/tags.hh:26
Definition: gridfunctionspacebase.hh:137
CompositeGridFunctionSpace(const OrderingTag &ordering_tag, DUNE_TYPETREE_COMPOSITENODE_CONSTRUCTOR_SIGNATURE)
Definition: compositegridfunctionspace.hh:94
CompositeGridFunctionSpace(const OrderingTag &ordering_tag, DUNE_TYPETREE_COMPOSITENODE_STORAGE_CONSTRUCTOR_SIGNATURE)
Definition: compositegridfunctionspace.hh:118
CompositeGridFunctionSpace(const Backend &backend, const OrderingTag &ordering_tag, DUNE_TYPETREE_COMPOSITENODE_CONSTRUCTOR_SIGNATURE)
Definition: compositegridfunctionspace.hh:99
Definition: datahandleprovider.hh:189
Mixin class providing common functionality of PowerGridFunctionSpace and CompositeGridFunctionSpace.
Definition: powercompositegridfunctionspacebase.hh:65
shared_ptr< Ordering > orderingStorage()
Direct access to the storage of the DOF ordering.
Definition: compositegridfunctionspace.hh:183
Trait class for the multi component grid function spaces.
Definition: powercompositegridfunctionspacebase.hh:33
base class for tuples of grid function spaces base class that holds implementation of the methods thi...
Definition: compositegridfunctionspace.hh:40