DUNE PDELab (git)

variablemonomfem.hh
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
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 {
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 {
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
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
virtual base class for local finite elements with functions
Definition: virtualinterface.hh:225
Monomial basis for discontinuous Galerkin methods.
Definition: monomial.hh:41
FiniteElementMap exception raised when trying to obtain a finite element for an unsupported GeometryT...
Definition: finiteelementmap.hh:23
Definition: variablemonomfem.hh:43
VariableMonomLocalFiniteElementMap(const M &m, Dune::GeometryType gt, unsigned int defaultP)
Definition: variablemonomfem.hh:61
VariableMonomLocalFiniteElementMap(const M &m, unsigned int defaultP)
Definition: variablemonomfem.hh:54
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
const Traits::FiniteElementType & getFEM() const
get local basis functions for the default order
Definition: variablemonomfem.hh:83
#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
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:462
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 (Jul 15, 22:36, 2024)