Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_GFE_PARALLEL_P2MAPPER_HH
#define DUNE_GFE_PARALLEL_P2MAPPER_HH
#include <dune/geometry/type.hh>
#include <dune/common/typetraits.hh>
#include <dune/functions/functionspacebases/pqknodalbasis.hh>
/** \brief Mimic a dune-grid mapper for a P2 space, using the dune-functions dof ordering of such a space
*/
template<class GridView>
class P2BasisMapper
{
typedef typename GridView::Grid::template Codim<0>::Entity Element;
public:
typedef typename Dune::Functions::PQkNodalBasis<GridView,2>::MultiIndex::value_type Index;
P2BasisMapper(const GridView& gridView)
: p2Basis_(gridView)
{}
std::size_t size() const
{
return p2Basis_.size();
}
template <class Entity>
bool contains(const Entity& entity, uint subEntity, uint codim, Index& result) const
{
auto localView = p2Basis_.localView();
auto localIndexSet = p2Basis_.localIndexSet();
localView.bind(entity);
localIndexSet.bind(localView);
for (size_t i=0; i<localIndexSet.size(); i++)
{
if (localView.tree().finiteElement().localCoefficients().localKey(i).subEntity() == subEntity
and localView.tree().finiteElement().localCoefficients().localKey(i).codim() == codim)
{
result = localIndexSet.index(i)[0];
return true;
}
}
return false;
}
Dune::Functions::PQkNodalBasis<GridView,2> p2Basis_;
};
#endif