DUNE-FUNCTIONS (unstable)

hierarchicallagrangebasis.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_HIERARCHICALLAGRANGEBASIS_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_HIERARCHICALLAGRANGEBASIS_HH
9
10#include <type_traits>
11
12#include <dune/common/exceptions.hh>
13
14#include <dune/localfunctions/hierarchical/hierarchicalp2.hh>
15
16#include <dune/functions/functionspacebases/nodes.hh>
17#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
18#include <dune/functions/functionspacebases/lfeprebasismixin.hh>
19
20#include <dune/geometry/type.hh>
21
22namespace Dune {
23 namespace Functions {
24
25 // *****************************************************************************
26 // Implementation for Hierarchical Lagrange Basis
27 //
28 // - only orders k=1,2 are implemented up to now
29 // - order k=1 is identical to the standard Lagrange basis
30 // - implementation is restricted to simplex grids
31 //
32 // *****************************************************************************
33
43 template<typename GV, int k, typename R = double>
45
46 template<typename GV, typename R>
48 : public LFEPreBasisMixin<GV, LagrangeSimplexLocalFiniteElement<typename GV::ctype,R,GV::dimension,1>>
49 {
51 public:
52 HierarchicalLagrangePreBasis (const GV& gridView) :
53 Base(gridView, [](GeometryType gt, int) -> std::size_t { return gt.isVertex() ? 1 : 0; })
54 {
55 for (auto gt : gridView.indexSet().types(0)) {
56 if (!gt.isSimplex())
57 DUNE_THROW(Dune::NotImplemented,
58 "Hierarchical Lagrange basis only implemented for simplex grids.");
59 }
60 }
61 };
62
63 template<typename GV, typename R>
64 class HierarchicalLagrangePreBasis<GV,2,R>
65 : public LFEPreBasisMixin<GV, HierarchicalP2LocalFiniteElement<typename GV::ctype,R,GV::dimension>>
66 {
67 using Base = LFEPreBasisMixin<GV, HierarchicalP2LocalFiniteElement<typename GV::ctype,R,GV::dimension>>;
68 public:
69 HierarchicalLagrangePreBasis (const GV& gridView) :
70 Base(gridView, [](GeometryType gt, int) -> std::size_t { return (gt.isVertex() || gt.isLine()) ? 1 : 0; })
71 {
72 for (auto gt : gridView.indexSet().types(0)) {
73 if (!gt.isSimplex())
74 DUNE_THROW(Dune::NotImplemented,
75 "Hierarchical Lagrange basis only implemented for simplex grids.");
76 }
77 }
78 };
79
80
81 namespace BasisFactory {
82
91 template<int k, typename R=double>
93 {
94 static_assert(0 < k && k <= 2);
95 return [](const auto& gridView) {
96 return HierarchicalLagrangePreBasis<std::decay_t<decltype(gridView)>, k, R>(gridView);
97 };
98 }
99
100 } // end namespace BasisFactory
101
112 template<typename GV, int k, typename R=double>
114
115 } // end namespace Functions
116} // end namespace Dune
117
118#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_HIERARCHICALLAGRANGEBASIS_HH
Global basis for given pre-basis.
Definition: defaultglobalbasis.hh:50
A pre-basis for a hierarchical Lagrange basis.
Definition: hierarchicallagrangebasis.hh:44
A pre-basis mixin class parametrized with a local finite-element and a DOF layout.
Definition: lfeprebasismixin.hh:57
auto hierarchicalLagrange()
A factory that can create a HierarchicalLagrange pre-basis.
Definition: hierarchicallagrangebasis.hh:92
Definition: polynomial.hh:17
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Aug 13, 22:30, 2024)