DUNE PDELab (git)

variableqkdgfem.hh
1// -*- tab-width: 4; indent-tabs-mode: nil -*-
2#ifndef DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEQKDGFEM_HH
3#define DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEQKDGFEM_HH
4
5#include <array>
6#include <memory>
7
9
10#include <dune/localfunctions/common/virtualwrappers.hh>
11#include "finiteelementmap.hh"
12#include "qkdg.hh"
13
14namespace Dune {
15 namespace PDELab {
16
17 namespace {
18 template<class D, class R, int d, int p>
19 struct InitVariableQkDGLocalFiniteElementMap
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>(LFE()));
27
28 InitVariableQkDGLocalFiniteElementMap<D,R,d,p-1>::init(c);
29 }
30 };
31 template<class D, class R, int d>
32 struct InitVariableQkDGLocalFiniteElementMap<D,R,d,-1>
33 {
34 template<typename C>
35 static void init(C & c) {}
36 };
37 }
38
41 template<class M, class D, class R, int d, int maxP=6>
43 {
47 public:
49
51 static constexpr int dimension = d;
52
53 VariableQkDGLocalFiniteElementMap (const M & m, unsigned int defaultP) :
54 mapper_(m), polOrder_(mapper_.size(), defaultP), defaultP_(defaultP)
55 {
56 InitVariableQkDGLocalFiniteElementMap<D,R,d,maxP>::init(finiteElements_);
57 }
58
60 template<class EntityType>
61 const typename Traits::FiniteElementType& find (const EntityType& e) const
62 {
63 return getFEM(getOrder(e));
64 }
65
67 const typename Traits::FiniteElementType& getFEM (unsigned int p) const
68 {
69 return *(finiteElements_[p]);
70 }
71
73 const typename Traits::FiniteElementType& getFEM () const
74 {
75 return *(finiteElements_[defaultP_]);
76 }
77
78 template<class EntityType>
79 void setOrder (const EntityType& e, unsigned int p)
80 {
81 assert(p <= maxP);
82 unsigned int i = mapper_.map(e);
83 polOrder_[i] = p;
84 }
85
86 template<class EntityType>
87 unsigned int getOrder (const EntityType& e) const
88 {
89 unsigned int i = mapper_.map(e);
90 unsigned int p = polOrder_[i];
91 assert(p <= maxP);
92 return p;
93 }
94
95 static constexpr bool fixedSize()
96 {
97 return false;
98 }
99
100 static constexpr bool hasDOFs(int codim)
101 {
102 return codim == 0;
103 }
104
105 std::size_t size(GeometryType gt) const
106 {
107 DUNE_THROW(Dune::Exception,"This should not be called!");
108 }
109
110 std::size_t maxLocalSize() const
111 {
112 return getFEM(maxP).localCoefficients().size();
113 }
114
115 private:
116 const M & mapper_;
117 std::vector<unsigned char> polOrder_;
118 unsigned int defaultP_;
119 std::array< std::shared_ptr<FiniteElementType>, maxP+1 > finiteElements_;
120 };
121
122
123 }
124}
125
126#endif // DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEQKDGFEM_HH
Base class for Dune-Exceptions.
Definition: exceptions.hh:96
virtual base class for local finite elements with functions
Definition: virtualinterface.hh:225
Definition: variableqkdgfem.hh:43
const Traits::FiniteElementType & getFEM() const
get local basis functions for the default order
Definition: variableqkdgfem.hh:73
static constexpr int dimension
The dimension of the finite elements returned by this map.
Definition: variableqkdgfem.hh:51
const Traits::FiniteElementType & find(const EntityType &e) const
get local basis functions for entity
Definition: variableqkdgfem.hh:61
const Traits::FiniteElementType & getFEM(unsigned int p) const
get local basis functions for a given polynomial order
Definition: variableqkdgfem.hh:67
Definition: qkdglagrange.hh:309
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:158
Dune namespace.
Definition: alignedallocator.hh:13
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
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)