dune-pdelab  2.7-git
variableopbfem.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil -*-
2 #ifndef DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEOPBFEM_HH
3 #define DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEOPBFEM_HH
4 
5 #include <array>
6 #include <memory>
7 
8 #include <dune/geometry/type.hh>
9 
10 #include <dune/localfunctions/common/virtualwrappers.hh>
14 
15 namespace Dune {
16  namespace PDELab {
17 
18  namespace {
19  template<class D, class R, int d, int p, Dune::GeometryType::BasicType bt, typename ComputationFieldType>
20  struct InitVariableOPBLocalFiniteElementMap
21  {
22  template<typename C>
23  static void init(C & c)
24  {
26  typedef typename C::value_type ptr;
27  c[p] = ptr(new LocalFiniteElementVirtualImp<LFE>);
28 
29  InitVariableOPBLocalFiniteElementMap<D,R,d,p-1,bt,ComputationFieldType>::init(c);
30  }
31  };
32  template<class D, class R, int d, Dune::GeometryType::BasicType bt, typename ComputationFieldType>
33  struct InitVariableOPBLocalFiniteElementMap<D,R,d,-1,bt,ComputationFieldType>
34  {
35  template<typename C>
36  static void init(C & c) {}
37  };
38  }
39 
42  template<class M, class D, class R, int d, typename ComputationFieldType=R, int maxP=6, Dune::GeometryType::BasicType bt=Dune::GeometryType::cube>
44  {
45  typedef typename MonomialLocalFiniteElement<D,R,d,0>::Traits::LocalBasisType::Traits T;
47  typedef LocalFiniteElementVirtualInterface<T> FiniteElementType;
48  public:
50 
52  static constexpr int dimension = d;
53 
54  VariableOPBLocalFiniteElementMap (const M & m, unsigned int defaultP) :
55  mapper_(m), polOrder_(mapper_.size(), defaultP), defaultP_(defaultP)
56  {
57  InitVariableOPBLocalFiniteElementMap<D,R,d,maxP,bt,ComputationFieldType>::init(finiteElements_);
58  }
59 
61  template<class EntityType>
62  const typename Traits::FiniteElementType& find (const EntityType& e) const
63  {
64  return getFEM(getOrder(e));
65  }
66 
68  const typename Traits::FiniteElementType& getFEM (unsigned int p) const
69  {
70  return *(finiteElements_[p]);
71  }
72 
74  const typename Traits::FiniteElementType& getFEM () const
75  {
76  return *(finiteElements_[defaultP_]);
77  }
78 
79  template<class EntityType>
80  void setOrder (const EntityType& e, unsigned int p)
81  {
82  assert(p <= maxP);
83  unsigned int i = mapper_.map(e);
84  polOrder_[i] = p;
85  }
86 
87  template<class EntityType>
88  unsigned int getOrder (const EntityType& e) const
89  {
90  unsigned int i = mapper_.map(e);
91  unsigned int p = polOrder_[i];
92  assert(p <= maxP);
93  return p;
94  }
95 
96  static constexpr bool fixedSize()
97  {
98  return false;
99  }
100 
101  static constexpr bool hasDOFs(int codim)
102  {
103  return codim == 0;
104  }
105 
106  std::size_t size(GeometryType gt) const
107  {
108  DUNE_THROW(Dune::Exception,"This should not be called!");
109  }
110 
111  std::size_t maxLocalSize() const
112  {
113  return getFEM(maxP).localCoefficients().size();
114  }
115 
116  private:
117  const M & mapper_;
118  std::vector<unsigned char> polOrder_;
119  unsigned int defaultP_;
120  std::array< std::shared_ptr<FiniteElementType>, maxP+1 > finiteElements_;
121  };
122 
123 
124 
125  }
126 }
127 
128 #endif // DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEOPBFEM_HH
const P & p
Definition: constraints.hh:148
This file defines polynomial basis functions on the reference element in a generic way.
const Entity & e
Definition: localfunctionspace.hh:123
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Definition: l2orthonormal.hh:791
collect types exported by a finite element map
Definition: finiteelementmap.hh:28
T FiniteElementType
Type of finite element from local functions.
Definition: finiteelementmap.hh:30
Definition: variableopbfem.hh:44
VariableOPBLocalFiniteElementMap(const M &m, unsigned int defaultP)
Definition: variableopbfem.hh:54
unsigned int getOrder(const EntityType &e) const
Definition: variableopbfem.hh:88
std::size_t maxLocalSize() const
Definition: variableopbfem.hh:111
std::size_t size(GeometryType gt) const
Definition: variableopbfem.hh:106
static constexpr bool hasDOFs(int codim)
Definition: variableopbfem.hh:101
const Traits::FiniteElementType & getFEM() const
get local basis functions for the default order
Definition: variableopbfem.hh:74
static constexpr int dimension
The dimension of the finite elements returned by this map.
Definition: variableopbfem.hh:52
const Traits::FiniteElementType & getFEM(unsigned int p) const
get local basis functions for a given polynomial order
Definition: variableopbfem.hh:68
static constexpr bool fixedSize()
Definition: variableopbfem.hh:96
FiniteElementMapTraits< FiniteElementType > Traits
Definition: variableopbfem.hh:49
const Traits::FiniteElementType & find(const EntityType &e) const
get local basis functions for entity
Definition: variableopbfem.hh:62
void setOrder(const EntityType &e, unsigned int p)
Definition: variableopbfem.hh:80