DUNE-FUNCTIONS (unstable)

lfeprebasismixin.hh
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LFEPREBASISMIXIN_HH
4 #define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LFEPREBASISMIXIN_HH
5 
6 #include <cassert>
7 #include <type_traits>
8 
9 #include <dune/common/exceptions.hh>
10 
11 #include <dune/functions/functionspacebases/leafprebasismappermixin.hh>
12 #include <dune/functions/functionspacebases/nodes.hh>
13 
14 #include <dune/grid/common/mcmgmapper.hh>
15 
16 namespace Dune::Functions {
17 
50 template <class GV, class LFE>
52  public LeafPreBasisMapperMixin< GV >
53 {
55 
56 public:
57 
59  using GridView = GV;
60 
62  class Node;
63 
69  template <class LFE_ = LFE,
70  std::enable_if_t<std::is_default_constructible_v<LFE_>, int> = 0>
71  LFEPreBasisMixin (const GridView& gv, MCMGLayout layout)
72  : Base(gv, layout)
73  , lfe_{}
74  {}
75 
81  template <class LFE_>
82  LFEPreBasisMixin (const GridView& gv, LFE_&& lfe, MCMGLayout layout)
83  : Base(gv, layout)
84  , lfe_(std::forward<LFE_>(lfe))
85  {}
86 
88  Node makeNode () const
89  {
90  return Node(lfe_);
91  }
92 
93 private:
94  LFE lfe_;
95 };
96 
97 // deduction guide
98 template <class GV, class LFE>
99 LFEPreBasisMixin(const GV&, const LFE&, MCMGLayout)
100  -> LFEPreBasisMixin<GV,LFE>;
101 
102 
103 
113 template <class GV, class LFE>
114 class LFEPreBasisMixin<GV,LFE>::Node
115  : public LeafBasisNode
116 {
117  static constexpr int dim = GV::dimension;
118 
119 public:
120  using size_type = std::size_t;
121  using Element = typename GV::template Codim<0>::Entity;
122  using FiniteElement = LFE;
123 
125  explicit Node (const LFE& lfe)
126  : lfe_{&lfe}
127  , element_{nullptr}
128  {}
129 
131  const Element& element () const
132  {
133  assert(!!element_);
134  return *element_;
135  }
136 
142  const FiniteElement& finiteElement () const
143  {
144  assert(!!lfe_);
145  return *lfe_;
146  }
147 
149  void bind (const Element& e)
150  {
151  element_ = &e;
152  this->setSize(lfe_->size());
153  }
154 
155 protected:
156  const FiniteElement* lfe_;
157  const Element* element_;
158 };
159 
160 
161 } // end namespace Dune::Functions
162 
163 
164 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LFEPREBASISMIXIN_HH
Leaf basis node that encapsulates a local finite-element given from the LFEPreBasisMixin of type LFE.
Definition: lfeprebasismixin.hh:116
const FiniteElement & finiteElement() const
Return the LocalFiniteElement for the element we are bound to; might raise an error if unbound.
Definition: lfeprebasismixin.hh:142
void bind(const Element &e)
Bind to element. Stores a pointer to the passed element reference.
Definition: lfeprebasismixin.hh:149
Node(const LFE &lfe)
Constructor; stores a pointer to the passed local finite-element lfe.
Definition: lfeprebasismixin.hh:125
const Element & element() const
Return current element; might raise an error if unbound.
Definition: lfeprebasismixin.hh:131
A pre-basis mixin class parametrized with a local finite-element and a DOF layout.
Definition: lfeprebasismixin.hh:53
LFEPreBasisMixin(const GridView &gv, LFE_ &&lfe, MCMGLayout layout)
Constructor for a given grid view object, local finite-element and layout.
Definition: lfeprebasismixin.hh:82
LFEPreBasisMixin(const GridView &gv, MCMGLayout layout)
Constructor for a given grid view object and layout.
Definition: lfeprebasismixin.hh:71
Node makeNode() const
Create tree node.
Definition: lfeprebasismixin.hh:88
A generic MixIn class for PreBasis with flat indices computed from a mapper.
Definition: leafprebasismappermixin.hh:58
GV GridView
Type of the associated GridView.
Definition: leafprebasismappermixin.hh:64
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)