dune-pdelab 2.7-git
Loading...
Searching...
No Matches
leaflocalordering.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_LEAFLOCALORDERING_HH
5#define DUNE_PDELAB_ORDERING_LEAFLOCALORDERING_HH
6
7#include <dune/typetree/leafnode.hh>
8
9#include <dune/geometry/referenceelements.hh>
10#include <dune/localfunctions/common/interfaceswitch.hh>
11#include <dune/localfunctions/common/localkey.hh>
13
14namespace Dune {
15 namespace PDELab {
16
19
20 template<typename OrderingTag, typename FEM, typename ES, typename DI, typename CI>
22 : public TypeTree::LeafNode
23 , public LocalOrderingBase<ES,DI,CI>
24 {
25
26 template<typename>
28
29 template<typename>
31
32 typedef LocalOrderingBase<ES,DI,CI> BaseT;
33
34 public:
35
36 typedef typename BaseT::Traits Traits;
37
38 LeafLocalOrdering(const std::shared_ptr<const FEM>& fem, const ES& es, bool backend_blocked, typename BaseT::GFSData* gfs_data)
39 : BaseT(*this,backend_blocked,gfs_data)
40 , _fem(fem)
41 , _es(es)
42 {}
43
44 const typename Traits::EntitySet& entitySet() const
45 {
46 return _es;
47 }
48
49 const typename Traits::GridView& gridView() const
50 {
51 return _es.gridView();
52 }
53
54 const FEM& finiteElementMap() const
55 {
56 return *_fem;
57 }
58
59 template<typename CodimMask>
60 void collect_used_codims(CodimMask& codims) const
61 {
62 for (typename ES::dim_type codim = 0; codim <= ES::dimension; ++codim)
63 if (_fem->hasDOFs(codim))
64 codims.set(codim);
65 }
66
68 {
69 this->_fixed_size = _fem->fixedSize();
70 }
71
73 {
74 this->_fixed_size_possible = true;
75 }
76
77 private:
78
79 typedef FiniteElementInterfaceSwitch<
80 typename FEM::Traits::FiniteElement
81 > FESwitch;
82
83 void collect_used_geometry_types_from_cell(const typename Traits::EntitySet::Element& cell)
84 {
85 FESwitch::setStore(_pfe,_fem->find(cell));
86
87 const typename FESwitch::Coefficients& coeffs =
88 FESwitch::coefficients(*_pfe);
89
90 this->_max_local_size = std::max(this->_max_local_size,coeffs.size());
91
92 const auto& ref_el =
93 ReferenceElements<typename Traits::EntitySet::Traits::CoordinateField,Traits::EntitySet::dimension>::general(cell.type());
94
95 for (std::size_t i = 0; i < coeffs.size(); ++i)
96 {
97 const LocalKey& key = coeffs.localKey(i);
98 Dune::GeometryType gt = ref_el.type(key.subEntity(),key.codim());
99 this->_gt_used[GlobalGeometryTypeIndex::index(gt)] = true;
100 this->_codim_used.set(key.codim());
101 }
102 }
103
104
105 void extract_per_entity_sizes_from_cell(const typename Traits::EntitySet::Element& cell,
106 std::vector<typename Traits::SizeType>& gt_sizes)
107 {
108 if (this->_fixed_size_possible)
109 std::fill(gt_sizes.begin(),gt_sizes.end(),0);
110
111 FESwitch::setStore(_pfe,_fem->find(cell));
112
113 const typename FESwitch::Coefficients& coeffs =
114 FESwitch::coefficients(*_pfe);
115
116 this->_max_local_size = std::max(this->_max_local_size,coeffs.size());
117
118 typedef typename Traits::SizeType size_type;
119
120 const auto& ref_el =
121 ReferenceElements<typename Traits::EntitySet::Traits::CoordinateField,Traits::EntitySet::dimension>::general(cell.type());
122
123 for (std::size_t i = 0; i < coeffs.size(); ++i)
124 {
125 const LocalKey& key = coeffs.localKey(i);
126 GeometryType gt = ref_el.type(key.subEntity(),key.codim());
127 const size_type geometry_type_index = GlobalGeometryTypeIndex::index(gt);
128
129 const size_type entity_index = _es.indexSet().subIndex(cell,key.subEntity(),key.codim());
130 const size_type index = this->_gt_entity_offsets[geometry_type_index] + entity_index;
131 gt_sizes[geometry_type_index] = this->_entity_dof_offsets[index] = std::max(this->_entity_dof_offsets[index],static_cast<size_type>(key.index() + 1));
132 }
133
134 if (this->_fixed_size_possible)
135 {
136 for (size_type i = 0; i < gt_sizes.size(); ++i)
137 {
138 if (this->_gt_dof_offsets[i] == this->GT_UNUSED)
139 this->_gt_dof_offsets[i] = gt_sizes[i];
140 else if (this->_gt_dof_offsets[i] != gt_sizes[i])
141 {
142 this->_fixed_size_possible = false;
143 break;
144 }
145 }
146 }
147 }
148
149 std::shared_ptr<const FEM> _fem;
150 ES _es;
151 typename FESwitch::Store _pfe;
152
153 };
154
155 template<typename GFS, typename Transformation, typename Params>
156 struct leaf_gfs_to_local_ordering_descriptor<GFS,Transformation,LeafOrderingTag<Params> >
157 {
158
159 static const bool recursive = false;
160
161 typedef LeafLocalOrdering<
162 typename GFS::Traits::OrderingTag,
163 typename GFS::Traits::FiniteElementMap,
164 typename GFS::Traits::EntitySet,
165 typename Transformation::DOFIndex,
166 typename Transformation::ContainerIndex
168
169 typedef std::shared_ptr<transformed_type> transformed_storage_type;
170
171 static transformed_type transform(const GFS& gfs, const Transformation& t)
172 {
173 return transformed_type(gfs.finiteElementMapStorage(),gfs.entitySet(),false,&const_cast<GFS*>(gfs));
174 }
175
176 static transformed_storage_type transform_storage(std::shared_ptr<const GFS> gfs, const Transformation& t)
177 {
178 return std::make_shared<transformed_type>(gfs->finiteElementMapStorage(),gfs->entitySet(),false,const_cast<GFS*>(gfs.get()));
179 }
180
181 };
182
184
185 } // namespace PDELab
186} // namespace Dune
187
188#endif // DUNE_PDELAB_ORDERING_LEAFLOCALORDERING_HH
std::size_t index
Definition interpolate.hh:97
For backward compatibility – Do not use this!
Definition adaptivity.hh:28
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition gridfunctionspace/tags.hh:185
Definition leaflocalordering.hh:24
const Traits::GridView & gridView() const
Definition leaflocalordering.hh:49
const Traits::EntitySet & entitySet() const
Definition leaflocalordering.hh:44
void collect_used_codims(CodimMask &codims) const
Definition leaflocalordering.hh:60
BaseT::Traits Traits
Definition leaflocalordering.hh:36
LeafLocalOrdering(const std::shared_ptr< const FEM > &fem, const ES &es, bool backend_blocked, typename BaseT::GFSData *gfs_data)
Definition leaflocalordering.hh:38
void setup_fixed_size_possible()
Definition leaflocalordering.hh:72
const FEM & finiteElementMap() const
Definition leaflocalordering.hh:54
void update_a_priori_fixed_size()
Definition leaflocalordering.hh:67
LeafLocalOrdering< typename GFS::Traits::OrderingTag, typename GFS::Traits::FiniteElementMap, typename GFS::Traits::EntitySet, typename Transformation::DOFIndex, typename Transformation::ContainerIndex > transformed_type
Definition leaflocalordering.hh:167
static transformed_type transform(const GFS &gfs, const Transformation &t)
Definition leaflocalordering.hh:171
std::shared_ptr< transformed_type > transformed_storage_type
Definition leaflocalordering.hh:169
static transformed_storage_type transform_storage(std::shared_ptr< const GFS > gfs, const Transformation &t)
Definition leaflocalordering.hh:176
Definition localorderingbase.hh:20
std::vector< typename Traits::SizeType > _gt_entity_offsets
Definition localorderingbase.hh:360
bool _fixed_size_possible
Definition localorderingbase.hh:350
friend struct collect_used_geometry_types_from_cell
Definition localorderingbase.hh:36
bool _fixed_size
Definition localorderingbase.hh:349
std::vector< bool > _gt_used
Definition localorderingbase.hh:358
Traits::CodimFlag _codim_used
Definition localorderingbase.hh:357
friend struct extract_per_entity_sizes_from_cell
Definition localorderingbase.hh:39
std::vector< typename Traits::SizeType > _gt_dof_offsets
Definition localorderingbase.hh:361
static constexpr auto GT_UNUSED
Definition localorderingbase.hh:59
std::size_t _max_local_size
Definition localorderingbase.hh:352
std::vector< typename Traits::SizeType > _entity_dof_offsets
Definition localorderingbase.hh:362