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