dune-pdelab  2.0.0
leafgridviewordering.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_ORDERING_LEAFGRIDVIEWORDERING_HH
5 #define DUNE_PDELAB_ORDERING_LEAFGRIDVIEWORDERING_HH
6 
9 
10 namespace Dune {
11  namespace PDELab {
12 
15 
17  template<typename LocalOrdering>
19  : public LeafOrderingBase<LocalOrdering>
20  {
21  public:
22  typedef typename LocalOrdering::Traits Traits;
23 
24  private:
25 
26  typedef typename Traits::GridView GV;
27 
29  typedef typename BaseT::NodeT NodeT;
30 
31  public:
32 
33  LeafGridViewOrdering(const typename NodeT::NodeStorage& local_ordering, bool container_blocked, typename BaseT::GFSData* gfs_data)
34  : BaseT(local_ordering, container_blocked, gfs_data)
35  , _gv(this->template child<0>().gridView())
36  {}
37 
38 #ifndef DOXYGEN
39 
40 // we need to override the default copy / move ctor to fix the delegate pointer, but that is
41 // hardly interesting to our users...
42 
44  : BaseT(r)
45  , _gv(r._gv)
46  {}
47 
48 #if HAVE_RVALUE_REFERENCES
49 
51  : BaseT(std::move(r))
52  , _gv(r._gv)
53  {}
54 
55 #endif // HAVE_RVALUE_REFERENCES
56 
57 #endif // DOXYGEN
58 
59  virtual void update()
60  {
61  LocalOrdering& lo = this->localOrdering();
62  lo.update_a_priori_fixed_size();
63 
64  const std::size_t dim = GV::dimension;
65 
66  typedef typename Traits::SizeType size_type;
67  typedef std::vector<GeometryType> GTVector;
68  GTVector geom_types;
69 
70  for (size_type cc = 0; cc <= dim; ++cc)
71  {
72  const GTVector& per_codim_geom_types = _gv.indexSet().geomTypes(cc);
73  std::copy(per_codim_geom_types.begin(),per_codim_geom_types.end(),std::back_inserter(geom_types));
74  }
75 
76  if (lo._fixed_size)
77  {
78  lo.update_fixed_size(geom_types.begin(),geom_types.end());
79  }
80  else
81  {
82  lo.pre_collect_used_geometry_types_from_cell();
83 
84  typedef typename GV::template Codim<0>::Iterator CellIterator;
85 
86  const CellIterator end_it = _gv.template end<0>();
87  for (CellIterator it = _gv.template begin<0>(); it != end_it; ++it)
88  {
89  lo.collect_used_geometry_types_from_cell(*it);
90  }
91 
92  lo.allocate_entity_offset_vector(geom_types.begin(),geom_types.end());
93 
94  for (CellIterator it = _gv.template begin<0>(); it != end_it; ++it)
95  {
96  lo.extract_per_entity_sizes_from_cell(*it);
97  }
98 
99  // FIXME: handling of blocked containers!
100  lo.finalize_non_fixed_size_update();
101  }
102 
103  // we need to re-test here, as the local ordering could have detected a fixed size ordering
104  // and switched its implementation
105  if (lo._fixed_size)
106  {
107  _gt_dof_offsets.assign(GlobalGeometryTypeIndex::size(dim) + 1,0);
108  _size = 0;
109 
110  const GTVector::const_iterator end_it = geom_types.end();
111  for (GTVector::const_iterator it = geom_types.begin(); it != end_it; ++it)
112  {
113  const size_type gt_index = GlobalGeometryTypeIndex::index(*it);
114  size_type gt_size = lo.size(gt_index,0);
115  size_type entity_count = _gv.indexSet().size(*it);
116  _size += gt_size * entity_count;
117  if (_container_blocked)
118  gt_size = gt_size > 0;
119  _gt_dof_offsets[gt_index + 1] = gt_size * entity_count;
120  }
121  std::partial_sum(_gt_dof_offsets.begin(),_gt_dof_offsets.end(),_gt_dof_offsets.begin());
122  _block_count = _gt_dof_offsets.back();
123  _codim_fixed_size.set();
124  }
125  else
126  {
127  _block_count = _size = lo._entity_dof_offsets.back();
128  _codim_fixed_size.reset();
129  }
130 
131  _fixed_size = lo._fixed_size;
132  _max_local_size = lo.maxLocalSize();
133 
134  _codim_used = lo._codim_used;
135  _codim_fixed_size = lo._codim_fixed_size;
136 
137  }
138 
139  using BaseT::fixedSize;
140 
141  private:
142 
144  using BaseT::_size;
145  using BaseT::_block_count;
147  using BaseT::_fixed_size;
148  using BaseT::_codim_used;
151 
152  typename Traits::GridView _gv;
153  };
154 
155 
156  template<typename GFS, typename Transformation>
158  {
159 
160  static const bool recursive = false;
161 
162  typedef DirectLeafLocalOrdering<typename GFS::Traits::OrderingTag,
163  typename GFS::Traits::FiniteElementMap,
164  typename GFS::Traits::GridView,
165  typename Transformation::DOFIndex,
166  typename Transformation::ContainerIndex
168 
170 
172  typedef shared_ptr<transformed_type> transformed_storage_type;
173 
174  static transformed_type transform(const GFS& gfs, const Transformation& t)
175  {
176  return transformed_type(make_tuple(make_shared<LocalOrdering>(gfs.finiteElementMapStorage(),gfs.gridView())),gfs.backend().blocked(gfs),const_cast<GFS*>(&gfs));
177  }
178 
179  static transformed_storage_type transform_storage(shared_ptr<const GFS> gfs, const Transformation& t)
180  {
181  return make_shared<transformed_type>(make_tuple(make_shared<LocalOrdering>(gfs->finiteElementMapStorage(),gfs->gridView())),gfs->backend().blocked(*gfs),const_cast<GFS*>(gfs.get()));
182  }
183 
184  };
185 
186 
187  template<typename GFS, typename Transformation, typename Params>
188  direct_leaf_gfs_to_gridview_ordering_descriptor<GFS,Transformation>
189  register_leaf_gfs_to_ordering_descriptor(GFS*,Transformation*,LeafOrderingTag<Params>*);
190 
192  } // namespace PDELab
193 } // namespace Dune
194 
195 #endif // DUNE_PDELAB_ORDERING_LEAFORDERING_HH
bool fixedSize(typename Traits::SizeType codim) const
Definition: orderingbase.hh:214
Definition: directleaflocalordering.hh:27
LeafGridViewOrdering(const typename NodeT::NodeStorage &local_ordering, bool container_blocked, typename BaseT::GFSData *gfs_data)
Definition: leafgridviewordering.hh:33
static transformed_storage_type transform_storage(shared_ptr< const GFS > gfs, const Transformation &t)
Definition: leafgridviewordering.hh:179
static const int dim
Definition: adaptivity.hh:82
shared_ptr< transformed_type > transformed_storage_type
Definition: leafgridviewordering.hh:172
static const bool recursive
Definition: leafgridviewordering.hh:160
Gridview ordering for leaf spaces.
Definition: leafgridviewordering.hh:18
LeafGridViewOrdering< LocalOrdering > GridViewOrdering
Definition: leafgridviewordering.hh:169
static transformed_type transform(const GFS &gfs, const Transformation &t)
Definition: leafgridviewordering.hh:174
GridViewOrdering transformed_type
Definition: leafgridviewordering.hh:171
TypeTree::VariadicCompositeNode< LocalOrdering > NodeT
Definition: leaforderingbase.hh:37
Generic infrastructure for orderings for leaf spaces.
Definition: leaforderingbase.hh:21
LocalOrdering::Traits Traits
Definition: leafgridviewordering.hh:22
direct_leaf_gfs_to_gridview_ordering_descriptor< GFS, Transformation > register_leaf_gfs_to_ordering_descriptor(GFS *, Transformation *, LeafOrderingTag< Params > *)
std::vector< typename Traits::SizeType > _gt_dof_offsets
Definition: leaforderingbase.hh:286
LocalOrdering & localOrdering()
Definition: leaforderingbase.hh:44
virtual void update()
Definition: leafgridviewordering.hh:59
DirectLeafLocalOrdering< typename GFS::Traits::OrderingTag, typename GFS::Traits::FiniteElementMap, typename GFS::Traits::GridView, typename Transformation::DOFIndex, typename Transformation::ContainerIndex > LocalOrdering
Definition: leafgridviewordering.hh:167
Dune::PDELab::impl::GridFunctionSpaceOrderingData< typename Traits::SizeType > GFSData
Definition: orderingbase.hh:35