dune-pdelab  2.5-dev
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 <memory>
6 
7 #include <dune/geometry/type.hh>
8 
9 #include <dune/localfunctions/common/virtualwrappers.hh>
10 #include <dune/common/array.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 FixedOrderLocalBasisTraits<
46  typename MonomialLocalFiniteElement<D,R,d,0>::Traits::LocalBasisType::Traits,0>::Traits T;
48  typedef LocalFiniteElementVirtualInterface<T> FiniteElementType;
49  public:
51 
52  VariableOPBLocalFiniteElementMap (const M & m, unsigned int defaultP) :
53  mapper_(m), polOrder_(mapper_.size(), defaultP), defaultP_(defaultP)
54  {
55  InitVariableOPBLocalFiniteElementMap<D,R,d,maxP,bt,ComputationFieldType>::init(finiteElements_);
56  }
57 
59  template<class EntityType>
60  const typename Traits::FiniteElementType& find (const EntityType& e) const
61  {
62  return getFEM(getOrder(e));
63  }
64 
66  const typename Traits::FiniteElementType& getFEM (unsigned int p) const
67  {
68  return *(finiteElements_[p]);
69  }
70 
72  const typename Traits::FiniteElementType& getFEM () const
73  {
74  return *(finiteElements_[defaultP_]);
75  }
76 
77  template<class EntityType>
78  void setOrder (const EntityType& e, unsigned int p)
79  {
80  assert(p <= maxP);
81  unsigned int i = mapper_.map(e);
82  polOrder_[i] = p;
83  }
84 
85  template<class EntityType>
86  unsigned int getOrder (const EntityType& e) const
87  {
88  unsigned int i = mapper_.map(e);
89  unsigned int p = polOrder_[i];
90  assert(p <= maxP);
91  return p;
92  }
93 
94  bool fixedSize() const
95  {
96  return false;
97  }
98 
99  bool hasDOFs(int codim) const
100  {
101  return codim == 0;
102  }
103 
104  std::size_t size(GeometryType gt) const
105  {
106  DUNE_THROW(Dune::Exception,"This should not be called!");
107  }
108 
109  std::size_t maxLocalSize() const
110  {
111  return getFEM(maxP).localCoefficients().size();
112  }
113 
114  private:
115  const M & mapper_;
116  std::vector<unsigned char> polOrder_;
117  unsigned int defaultP_;
118  std::array< std::shared_ptr<FiniteElementType>, maxP+1 > finiteElements_;
119  };
120 
121 
122 
123  }
124 }
125 
126 #endif // DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEOPBFEM_HH
const Traits::FiniteElementType & getFEM(unsigned int p) const
get local basis functions for a given polynomial order
Definition: variableopbfem.hh:66
const Entity & e
Definition: localfunctionspace.hh:111
const Traits::FiniteElementType & getFEM() const
get local basis functions for the default order
Definition: variableopbfem.hh:72
void setOrder(const EntityType &e, unsigned int p)
Definition: variableopbfem.hh:78
bool fixedSize() const
Definition: variableopbfem.hh:94
T FiniteElementType
Type of finite element from local functions.
Definition: finiteelementmap.hh:30
For backward compatibility – Do not use this!
Definition: adaptivity.hh:27
const P & p
Definition: constraints.hh:147
std::size_t maxLocalSize() const
Definition: variableopbfem.hh:109
std::size_t size(GeometryType gt) const
Definition: variableopbfem.hh:104
Definition: l2orthonormal.hh:873
const Traits::FiniteElementType & find(const EntityType &e) const
get local basis functions for entity
Definition: variableopbfem.hh:60
Definition: variableopbfem.hh:43
collect types exported by a finite element map
Definition: finiteelementmap.hh:27
unsigned int getOrder(const EntityType &e) const
Definition: variableopbfem.hh:86
FiniteElementMapTraits< FiniteElementType > Traits
Definition: variableopbfem.hh:50
bool hasDOFs(int codim) const
Definition: variableopbfem.hh:99
VariableOPBLocalFiniteElementMap(const M &m, unsigned int defaultP)
Definition: variableopbfem.hh:52
This file defines polynomial basis functions on the reference element in a generic way...