DUNE PDELab (git)

variableopbfem.hh
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 <array>
6#include <memory>
7
9
10#include <dune/localfunctions/common/virtualwrappers.hh>
11#include <dune/pdelab/finiteelementmap/finiteelementmap.hh>
13#include <dune/pdelab/finiteelementmap/monomfem.hh>
14
15namespace 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 {
25 typedef Dune::OPBLocalFiniteElement<D,R,p,d,bt,ComputationFieldType> LFE;
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 {
48 public:
50
52 static constexpr int dimension = d;
53
54 VariableOPBLocalFiniteElementMap (const M & m, unsigned int defaultP) :
55 mapper_(m), polOrder_(mapper_.size(), defaultP), defaultP_(defaultP)
56 {
57 InitVariableOPBLocalFiniteElementMap<D,R,d,maxP,bt,ComputationFieldType>::init(finiteElements_);
58 }
59
61 template<class EntityType>
62 const typename Traits::FiniteElementType& find (const EntityType& e) const
63 {
64 return getFEM(getOrder(e));
65 }
66
68 const typename Traits::FiniteElementType& getFEM (unsigned int p) const
69 {
70 return *(finiteElements_[p]);
71 }
72
74 const typename Traits::FiniteElementType& getFEM () const
75 {
76 return *(finiteElements_[defaultP_]);
77 }
78
79 template<class EntityType>
80 void setOrder (const EntityType& e, unsigned int p)
81 {
82 assert(p <= maxP);
83 unsigned int i = mapper_.map(e);
84 polOrder_[i] = p;
85 }
86
87 template<class EntityType>
88 unsigned int getOrder (const EntityType& e) const
89 {
90 unsigned int i = mapper_.map(e);
91 unsigned int p = polOrder_[i];
92 assert(p <= maxP);
93 return p;
94 }
95
96 static constexpr bool fixedSize()
97 {
98 return false;
99 }
100
101 static constexpr bool hasDOFs(int codim)
102 {
103 return codim == 0;
104 }
105
106 std::size_t size(GeometryType gt) const
107 {
108 DUNE_THROW(Dune::Exception,"This should not be called!");
109 }
110
111 std::size_t maxLocalSize() const
112 {
113 return getFEM(maxP).localCoefficients().size();
114 }
115
116 private:
117 const M & mapper_;
118 std::vector<unsigned char> polOrder_;
119 unsigned int defaultP_;
120 std::array< std::shared_ptr<FiniteElementType>, maxP+1 > finiteElements_;
121 };
122
123
124
125 }
126}
127
128#endif // DUNE_PDELAB_FINITEELEMENTMAP_VARIABLEOPBFEM_HH
Base class for Dune-Exceptions.
Definition: exceptions.hh:96
virtual base class for local finite elements with functions
Definition: virtualinterface.hh:225
Monomial basis for discontinuous Galerkin methods.
Definition: monomial.hh:41
Definition: variableopbfem.hh:44
static constexpr int dimension
The dimension of the finite elements returned by this map.
Definition: variableopbfem.hh:52
const Traits::FiniteElementType & getFEM(unsigned int p) const
get local basis functions for a given polynomial order
Definition: variableopbfem.hh:68
const Traits::FiniteElementType & find(const EntityType &e) const
get local basis functions for entity
Definition: variableopbfem.hh:62
const Traits::FiniteElementType & getFEM() const
get local basis functions for the default order
Definition: variableopbfem.hh:74
#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
This file defines polynomial basis functions on the reference element in a generic way.
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 23, 23:29, 2024)