dune-pdelab 2.8
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
8
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
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 using BaseT::size;
78
88 typename Traits::SizeType
89 size(const typename Traits::ContainerIndex& suffix,
90 const typename Traits::DOFIndex::EntityIndex &index) const {
91 return this->node_size(*this,suffix,index);
92 }
93
94 private:
95
97 typename FEM::Traits::FiniteElement
98 > FESwitch;
99
100 void collect_used_geometry_types_from_cell(const typename Traits::EntitySet::Element& cell)
101 {
102 // notice that we keep the finite element alive on this scope (important if rvalue)
103 const auto& fe = _fem->find(cell);
104 const typename FESwitch::Coefficients& coeffs = FESwitch::coefficients(fe);
105
106 this->_max_local_size = std::max(this->_max_local_size,coeffs.size());
107
108 const auto& ref_el =
109 ReferenceElements<typename Traits::EntitySet::Traits::CoordinateField,Traits::EntitySet::dimension>::general(cell.type());
110
111 for (std::size_t i = 0; i < coeffs.size(); ++i)
112 {
113 const LocalKey& key = coeffs.localKey(i);
114 Dune::GeometryType gt = ref_el.type(key.subEntity(),key.codim());
116 this->_codim_used.set(key.codim());
117 }
118 }
119
120
121 void extract_per_entity_sizes_from_cell(const typename Traits::EntitySet::Element& cell,
123 {
124 if (this->_fixed_size_possible)
125 std::fill(gt_sizes.begin(),gt_sizes.end(),0);
126
127 // notice that we keep the finite element alive on this scope (important if rvalue)
128 const auto& fe = _fem->find(cell);
129 const typename FESwitch::Coefficients& coeffs = FESwitch::coefficients(fe);
130
131 this->_max_local_size = std::max(this->_max_local_size,coeffs.size());
132
133 typedef typename Traits::SizeType size_type;
134
135 const auto& ref_el =
136 ReferenceElements<typename Traits::EntitySet::Traits::CoordinateField,Traits::EntitySet::dimension>::general(cell.type());
137
138 for (std::size_t i = 0; i < coeffs.size(); ++i)
139 {
140 const LocalKey& key = coeffs.localKey(i);
141 GeometryType gt = ref_el.type(key.subEntity(),key.codim());
142 const size_type geometry_type_index = GlobalGeometryTypeIndex::index(gt);
143
144 const size_type entity_index = _es.indexSet().subIndex(cell,key.subEntity(),key.codim());
145 const size_type index = this->_gt_entity_offsets[geometry_type_index] + entity_index;
146 gt_sizes[geometry_type_index] = this->_entity_dof_offsets[index] = std::max(this->_entity_dof_offsets[index],static_cast<size_type>(key.index() + 1));
147 }
148
149 if (this->_fixed_size_possible)
150 {
151 for (size_type i = 0; i < gt_sizes.size(); ++i)
152 {
153 if (this->_gt_dof_offsets[i] == this->GT_UNUSED)
154 this->_gt_dof_offsets[i] = gt_sizes[i];
155 else if (this->_gt_dof_offsets[i] != gt_sizes[i])
156 {
157 this->_fixed_size_possible = false;
158 break;
159 }
160 }
161 }
162 }
163
165 ES _es;
166
167 };
168
169 template<typename GFS, typename Transformation, typename Params>
170 struct leaf_gfs_to_local_ordering_descriptor<GFS,Transformation,LeafOrderingTag<Params> >
171 {
172
173 static const bool recursive = false;
174
175 typedef LeafLocalOrdering<
176 typename GFS::Traits::OrderingTag,
177 typename GFS::Traits::FiniteElementMap,
178 typename GFS::Traits::EntitySet,
179 typename Transformation::DOFIndex,
180 typename Transformation::ContainerIndex
182
184
185 static transformed_type transform(const GFS& gfs, const Transformation& t)
186 {
187 return transformed_type(gfs.finiteElementMapStorage(),gfs.entitySet(),false,&const_cast<GFS*>(gfs));
188 }
189
191 {
192 return std::make_shared<transformed_type>(gfs->finiteElementMapStorage(),gfs->entitySet(),false,const_cast<GFS*>(gfs.get()));
193 }
194
195 };
196
198
199 } // namespace PDELab
200} // namespace Dune
201
202#endif // DUNE_PDELAB_ORDERING_LEAFLOCALORDERING_HH
std::size_t index
Definition interpolate.hh:97
For backward compatibility – Do not use this!
static constexpr std::size_t index(const GeometryType &gt)
static const Coefficients & coefficients(const FiniteElement &fe)
FiniteElement::Traits::Coefficients Coefficients
unsigned int codim() const
unsigned int subEntity() const
Tag indicating a standard ordering for a leaf GridfunctionSpace.
Definition gridfunctionspace/tags.hh:185
Definition leaflocalordering.hh:24
Traits::SizeType size(const typename Traits::ContainerIndex &suffix, const typename Traits::DOFIndex::EntityIndex &index) const
Returns the size for a given suffix.
Definition leaflocalordering.hh:89
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:181
static transformed_type transform(const GFS &gfs, const Transformation &t)
Definition leaflocalordering.hh:185
std::shared_ptr< transformed_type > transformed_storage_type
Definition leaflocalordering.hh:183
static transformed_storage_type transform_storage(std::shared_ptr< const GFS > gfs, const Transformation &t)
Definition leaflocalordering.hh:190
Entity-wise orderings.
Definition localorderingbase.hh:30
std::vector< typename Traits::SizeType > _gt_entity_offsets
Definition localorderingbase.hh:452
bool _fixed_size_possible
Definition localorderingbase.hh:442
Traits::SizeType node_size(const Node &node, typename Traits::ContainerIndex suffix, const typename Traits::DOFIndex::EntityIndex &index) const
Gives the size for a given entity and suffix.
Definition localorderingbase.hh:287
Traits::SizeType size(const typename Traits::DOFIndex::EntityIndex &index) const
Definition localorderingbase.hh:229
friend struct collect_used_geometry_types_from_cell
Definition localorderingbase.hh:46
bool _fixed_size
Definition localorderingbase.hh:441
std::vector< bool > _gt_used
Definition localorderingbase.hh:450
Traits::CodimFlag _codim_used
Definition localorderingbase.hh:449
friend struct extract_per_entity_sizes_from_cell
Definition localorderingbase.hh:49
impl::GridFunctionSpaceOrderingData< typename Traits::SizeType > GFSData
Definition localorderingbase.hh:69
std::vector< typename Traits::SizeType > _gt_dof_offsets
Definition localorderingbase.hh:453
static constexpr auto GT_UNUSED
Definition localorderingbase.hh:65
std::size_t _max_local_size
Definition localorderingbase.hh:444
std::vector< typename Traits::SizeType > _entity_dof_offsets
Definition localorderingbase.hh:454
std::size_t SizeType
Definition ordering/utility.hh:178
CI ContainerIndex
Definition ordering/utility.hh:176
Definition ordering/utility.hh:224
typename ES::GridView GridView
Definition ordering/utility.hh:227
ES EntitySet
Definition ordering/utility.hh:226
T begin(T... args)
T end(T... args)
T fill(T... args)
T get(T... args)
T max(T... args)
T set(T... args)
T size(T... args)