dune-pdelab 2.7-git
Loading...
Searching...
No Matches
variablemonomfem.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil -*-
2#ifndef DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEMONOMFEM_HH
3#define DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEMONOMFEM_HH
4
5#include <array>
6#include <memory>
7
8#include <dune/geometry/type.hh>
9
10#include <dune/localfunctions/common/virtualwrappers.hh>
11#include <dune/localfunctions/monomial.hh>
12#include "finiteelementmap.hh"
13
14namespace Dune {
15 namespace PDELab {
16
17 namespace {
18 template<class D, class R, int d, int p>
19 struct InitVariableMonomLocalFiniteElementMap
20 {
21 template<typename C>
22 static void init(C & c, GeometryType gt)
23 {
24 typedef Dune::MonomialLocalFiniteElement<D,R,d,p> LFE;
25 typedef typename C::value_type ptr;
26 c[p] = ptr(new LocalFiniteElementVirtualImp<LFE>(LFE(gt)));
27
28 InitVariableMonomLocalFiniteElementMap<D,R,d,p-1>::init(c,gt);
29 }
30 };
31 template<class D, class R, int d>
32 struct InitVariableMonomLocalFiniteElementMap<D,R,d,-1>
33 {
34 template<typename C>
35 static void init(C &, GeometryType) {}
36 };
37 }
38
41 template<class M, class D, class R, int d, int maxP=6>
43 {
44 typedef typename MonomialLocalFiniteElement<D,R,d,0>::Traits::LocalBasisType::Traits T;
46 typedef LocalFiniteElementVirtualInterface<T> FiniteElementType;
47 public:
49
51 static constexpr int dimension = d;
52
54 VariableMonomLocalFiniteElementMap (const M & m, unsigned int defaultP) :
55 gt_(Dune::GeometryType::cube,d), mapper_(m), polOrder_(mapper_.size(), defaultP), defaultP_(defaultP)
56 {
57 InitVariableMonomLocalFiniteElementMap<D,R,d,maxP>::init(finiteElements_, gt_);
58 }
59
61 VariableMonomLocalFiniteElementMap (const M & m, Dune::GeometryType gt, unsigned int defaultP) :
62 gt_(gt), mapper_(m), polOrder_(mapper_.size(), defaultP), defaultP_(defaultP)
63 {
64 InitVariableMonomLocalFiniteElementMap<D,R,d,maxP>::init(finiteElements_, gt_);
65 }
66
68 template<class EntityType>
69 const typename Traits::FiniteElementType& find (const EntityType& e) const
70 {
71 if (e.type() != gt_)
72 DUNE_THROW(InvalidGeometryType,"Unsupported geometry type: Support only " << gt_ << ", but got " << e.type());
73 return getFEM(getOrder(e));
74 }
75
77 const typename Traits::FiniteElementType& getFEM (unsigned int p) const
78 {
79 return *(finiteElements_[p]);
80 }
81
83 const typename Traits::FiniteElementType& getFEM () const
84 {
85 return *(finiteElements_[defaultP_]);
86 }
87
88 template<class EntityType>
89 void setOrder (const EntityType& e, unsigned int p)
90 {
91 assert(p <= maxP);
92 unsigned int i = mapper_.index(e);
93 polOrder_[i] = p;
94 }
95
96 template<class EntityType>
97 unsigned int getOrder (const EntityType& e) const
98 {
99 unsigned int i = mapper_.index(e);
100 unsigned int p = polOrder_[i];
101 assert(p <= maxP);
102 return p;
103 }
104
105 static constexpr bool fixedSize()
106 {
107 return false;
108 }
109
110 static constexpr bool hasDOFs(int codim)
111 {
112 return codim == 0;
113 }
114
115 std::size_t size(GeometryType gt) const
116 {
117 DUNE_THROW(VariableElementSize,"VariableMonomLocalFiniteElementMap can contain elements of variable order.");
118 }
119
120 std::size_t maxLocalSize() const
121 {
122 DUNE_THROW(VariableElementSize,"VariableMonomLocalFiniteElementMap can contain elements of variable order.");
123 }
124
125 private:
126 const Dune::GeometryType gt_;
127 const M & mapper_;
128 std::vector<unsigned char> polOrder_;
129 unsigned int defaultP_;
130 std::array< std::shared_ptr<FiniteElementType>, maxP+1 > finiteElements_;
131 };
132
133
134
135 }
136}
137
138#endif // DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEMONOMFEM_HH
const P & p
Definition: constraints.hh:148
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
FiniteElementMap exception concerning the computation of the FiniteElementMap size.
Definition: finiteelementmap.hh:21
FiniteElementMap exception raised when trying to obtain a finite element for an unsupported GeometryT...
Definition: finiteelementmap.hh:23
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: variablemonomfem.hh:43
VariableMonomLocalFiniteElementMap(const M &m, Dune::GeometryType gt, unsigned int defaultP)
Definition: variablemonomfem.hh:61
std::size_t maxLocalSize() const
Definition: variablemonomfem.hh:120
static constexpr bool fixedSize()
Definition: variablemonomfem.hh:105
static constexpr bool hasDOFs(int codim)
Definition: variablemonomfem.hh:110
std::size_t size(GeometryType gt) const
Definition: variablemonomfem.hh:115
VariableMonomLocalFiniteElementMap(const M &m, unsigned int defaultP)
Definition: variablemonomfem.hh:54
FiniteElementMapTraits< FiniteElementType > Traits
Definition: variablemonomfem.hh:48
const Traits::FiniteElementType & find(const EntityType &e) const
get local basis functions for entity
Definition: variablemonomfem.hh:69
const Traits::FiniteElementType & getFEM(unsigned int p) const
get local basis functions for a given polynomial order
Definition: variablemonomfem.hh:77
static constexpr int dimension
The dimension of the finite elements returned by this map.
Definition: variablemonomfem.hh:51
unsigned int getOrder(const EntityType &e) const
Definition: variablemonomfem.hh:97
const Traits::FiniteElementType & getFEM() const
get local basis functions for the default order
Definition: variablemonomfem.hh:83
void setOrder(const EntityType &e, unsigned int p)
Definition: variablemonomfem.hh:89