dune-pdelab  2.0.0
variableqkdgfem.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil -*-
2 #ifndef DUNE_PDELAB_VARIABLEQKDGFEM_HH
3 #define DUNE_PDELAB_VARIABLEQKDGFEM_HH
4 
5 #include <dune/geometry/type.hh>
6 
7 #include <dune/localfunctions/common/virtualwrappers.hh>
8 #include <dune/common/array.hh>
9 #include <dune/common/shared_ptr.hh>
10 #include "finiteelementmap.hh"
11 #include "qkdg.hh"
12 
13 namespace Dune {
14  namespace PDELab {
15 
16  namespace {
17  template<class D, class R, int d, int p>
18  struct InitVariableQkDGLocalFiniteElementMap
19  {
20  template<typename C>
21  static void init(C & c)
22  {
24  typedef typename C::value_type ptr;
25  c[p] = ptr(new LocalFiniteElementVirtualImp<LFE>(LFE()));
26 
27  InitVariableQkDGLocalFiniteElementMap<D,R,d,p-1>::init(c);
28  }
29  };
30  template<class D, class R, int d>
31  struct InitVariableQkDGLocalFiniteElementMap<D,R,d,-1>
32  {
33  template<typename C>
34  static void init(C & c) {}
35  };
36  }
37 
40  template<class M, class D, class R, int d, int maxP=6>
42  {
43  typedef typename FixedOrderLocalBasisTraits<
46  typedef LocalFiniteElementVirtualInterface<T> FiniteElementType;
47  public:
49 
50  VariableQkDGLocalFiniteElementMap (const M & m, unsigned int defaultP) :
51  mapper_(m), polOrder_(mapper_.size(), defaultP), defaultP_(defaultP)
52  {
53  InitVariableQkDGLocalFiniteElementMap<D,R,d,maxP>::init(finiteElements_);
54  }
55 
57  template<class EntityType>
58  const typename Traits::FiniteElementType& find (const EntityType& e) const
59  {
60  return getFEM(getOrder(e));
61  }
62 
64  const typename Traits::FiniteElementType& getFEM (unsigned int p) const
65  {
66  return *(finiteElements_[p]);
67  }
68 
70  const typename Traits::FiniteElementType& getFEM () const
71  {
72  return *(finiteElements_[defaultP_]);
73  }
74 
75  template<class EntityType>
76  void setOrder (const EntityType& e, unsigned int p)
77  {
78  assert(p <= maxP);
79  unsigned int i = mapper_.map(e);
80  polOrder_[i] = p;
81  }
82 
83  template<class EntityType>
84  unsigned int getOrder (const EntityType& e) const
85  {
86  unsigned int i = mapper_.map(e);
87  unsigned int p = polOrder_[i];
88  assert(p <= maxP);
89  return p;
90  }
91 
92  bool fixedSize() const
93  {
94  return false;
95  }
96 
97  std::size_t size(GeometryType gt) const
98  {
99  DUNE_THROW(Dune::Exception,"This should not be called!");
100  }
101 
102  std::size_t maxLocalSize() const
103  {
104  return getFEM(maxP).localCoefficients().size();
105  }
106 
107  private:
108  const M & mapper_;
109  std::vector<unsigned char> polOrder_;
110  unsigned int defaultP_;
111  Dune::array< Dune::shared_ptr<FiniteElementType>, maxP+1 > finiteElements_;
112  };
113 
114 
115 
116  }
117 }
118 
119 #endif //DUNE_PDELAB_VARIABLEQKDGFEM_HH
bool fixedSize() const
Definition: variableqkdgfem.hh:92
Definition: variableqkdgfem.hh:41
const Traits::FiniteElementType & getFEM(unsigned int p) const
get local basis functions for a given polynomial order
Definition: variableqkdgfem.hh:64
VariableQkDGLocalFiniteElementMap(const M &m, unsigned int defaultP)
Definition: variableqkdgfem.hh:50
std::size_t size(GeometryType gt) const
Definition: variableqkdgfem.hh:97
collect types exported by a finite element map
Definition: finiteelementmap.hh:27
const Traits::FiniteElementType & find(const EntityType &e) const
get local basis functions for entity
Definition: variableqkdgfem.hh:58
const Traits::FiniteElementType & getFEM() const
get local basis functions for the default order
Definition: variableqkdgfem.hh:70
T FiniteElementType
Type of finite element from local functions.
Definition: finiteelementmap.hh:30
FiniteElementMapTraits< FiniteElementType > Traits
Definition: variableqkdgfem.hh:48
void setOrder(const EntityType &e, unsigned int p)
Definition: variableqkdgfem.hh:76
std::size_t maxLocalSize() const
Definition: variableqkdgfem.hh:102
R p(int i, D x)
Definition: qkdg.hh:62
Definition: qkdg.hh:299
const E & e
Definition: interpolate.hh:172
unsigned int getOrder(const EntityType &e) const
Definition: variableqkdgfem.hh:84