4#ifndef DUNE_PDELAB_ORDERING_LEAFLOCALORDERING_HH
5#define DUNE_PDELAB_ORDERING_LEAFLOCALORDERING_HH
7#include <dune/typetree/leafnode.hh>
9#include <dune/geometry/referenceelements.hh>
10#include <dune/localfunctions/common/interfaceswitch.hh>
11#include <dune/localfunctions/common/localkey.hh>
12#include <dune/pdelab/ordering/localorderingbase.hh>
20 template<
typename OrderingTag,
typename FEM,
typename ES,
typename DI,
typename CI>
21 class LeafLocalOrdering
22 :
public TypeTree::LeafNode
23 ,
public LocalOrderingBase<ES,DI,CI>
27 friend struct collect_used_geometry_types_from_cell_visitor;
30 friend struct extract_per_entity_sizes_from_cell_visitor;
32 typedef LocalOrderingBase<ES,DI,CI> BaseT;
36 typedef typename BaseT::Traits Traits;
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)
44 const typename Traits::EntitySet& entitySet()
const
49 const typename Traits::GridView& gridView()
const
51 return _es.gridView();
54 const FEM& finiteElementMap()
const
59 template<
typename CodimMask>
60 void collect_used_codims(CodimMask& codims)
const
62 for (
typename ES::dim_type codim = 0; codim <= ES::dimension; ++codim)
63 if (_fem->hasDOFs(codim))
67 void update_a_priori_fixed_size()
69 this->_fixed_size = _fem->fixedSize();
72 void setup_fixed_size_possible()
74 this->_fixed_size_possible =
true;
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);
96 typedef FiniteElementInterfaceSwitch<
97 typename FEM::Traits::FiniteElement
100 void collect_used_geometry_types_from_cell(
const typename Traits::EntitySet::Element& cell)
103 const auto& fe = _fem->find(cell);
106 this->_max_local_size =
std::max(this->_max_local_size,coeffs.size());
111 for (std::size_t i = 0; i < coeffs.size(); ++i)
113 const LocalKey& key = coeffs.localKey(i);
116 this->_codim_used.set(key.codim());
121 void extract_per_entity_sizes_from_cell(
const typename Traits::EntitySet::Element& cell,
122 std::vector<typename Traits::SizeType>& gt_sizes)
124 if (this->_fixed_size_possible)
125 std::fill(gt_sizes.begin(),gt_sizes.end(),0);
128 const auto& fe = _fem->find(cell);
131 this->_max_local_size =
std::max(this->_max_local_size,coeffs.size());
133 typedef typename Traits::SizeType size_type;
138 for (std::size_t i = 0; i < coeffs.size(); ++i)
140 const LocalKey& key = coeffs.localKey(i);
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));
149 if (this->_fixed_size_possible)
151 for (size_type i = 0; i < gt_sizes.size(); ++i)
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])
157 this->_fixed_size_possible =
false;
164 std::shared_ptr<const FEM> _fem;
169 template<
typename GFS,
typename Transformation,
typename Params>
170 struct leaf_gfs_to_local_ordering_descriptor<GFS,Transformation,LeafOrderingTag<Params> >
173 static const bool recursive =
false;
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
183 typedef std::shared_ptr<transformed_type> transformed_storage_type;
185 static transformed_type transform(
const GFS& gfs,
const Transformation& t)
187 return transformed_type(gfs.finiteElementMapStorage(),gfs.entitySet(),
false,&
const_cast<GFS*
>(gfs));
190 static transformed_storage_type transform_storage(std::shared_ptr<const GFS> gfs,
const Transformation& t)
192 return std::make_shared<transformed_type>(gfs->finiteElementMapStorage(),gfs->entitySet(),
false,
const_cast<GFS*
>(gfs.get()));
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:123
static constexpr std::size_t index(const GeometryType >)
Compute the index for the given geometry type over all dimensions.
Definition: typeindex.hh:136
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
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:130
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:156
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition: defaults.hh:79
Dune namespace.
Definition: alignedallocator.hh:11
static const Coefficients & coefficients(const FiniteElement &fe)
access coefficients
Definition: interfaceswitch.hh:43
FiniteElement::Traits::Coefficients Coefficients
export the type of the coefficients
Definition: interfaceswitch.hh:34
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:196