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;
79 typedef FiniteElementInterfaceSwitch<
80 typename FEM::Traits::FiniteElement
83 void collect_used_geometry_types_from_cell(
const typename Traits::EntitySet::Element& cell)
90 this->_max_local_size =
std::max(this->_max_local_size,coeffs.size());
95 for (std::size_t i = 0; i < coeffs.size(); ++i)
97 const LocalKey& key = coeffs.localKey(i);
100 this->_codim_used.set(key.codim());
105 void extract_per_entity_sizes_from_cell(
const typename Traits::EntitySet::Element& cell,
106 std::vector<typename Traits::SizeType>& gt_sizes)
108 if (this->_fixed_size_possible)
109 std::fill(gt_sizes.begin(),gt_sizes.end(),0);
116 this->_max_local_size =
std::max(this->_max_local_size,coeffs.size());
118 typedef typename Traits::SizeType size_type;
123 for (std::size_t i = 0; i < coeffs.size(); ++i)
125 const LocalKey& key = coeffs.localKey(i);
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));
134 if (this->_fixed_size_possible)
136 for (size_type i = 0; i < gt_sizes.size(); ++i)
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])
142 this->_fixed_size_possible =
false;
149 std::shared_ptr<const FEM> _fem;
155 template<
typename GFS,
typename Transformation,
typename Params>
156 struct leaf_gfs_to_local_ordering_descriptor<GFS,Transformation,LeafOrderingTag<Params> >
159 static const bool recursive =
false;
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
169 typedef std::shared_ptr<transformed_type> transformed_storage_type;
171 static transformed_type transform(
const GFS& gfs,
const Transformation& t)
173 return transformed_type(gfs.finiteElementMapStorage(),gfs.entitySet(),
false,&
const_cast<GFS*
>(gfs));
176 static transformed_storage_type transform_storage(std::shared_ptr<const GFS> gfs,
const Transformation& t)
178 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:280
static constexpr std::size_t index(const GeometryType >)
Compute the index for the given geometry type over all dimensions.
Definition: typeindex.hh:133
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:180
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:14
static const Coefficients & coefficients(const FiniteElement &fe)
access coefficients
Definition: interfaceswitch.hh:42
FiniteElement::Traits::Coefficients Coefficients
export the type of the coefficients
Definition: interfaceswitch.hh:33
static void setStore(Store &store, const FiniteElement &fe)
Store a finite element in the store.
Definition: interfaceswitch.hh:75
std::shared_ptr< const FiniteElement > Store
Type for storing finite elements.
Definition: interfaceswitch.hh:68
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:196