hp-FEM
Adaptive hp-FEM suite for nano-optics
Loading...
Searching...
No Matches
h1_basis.hpp
Go to the documentation of this file.
1#pragma once
8
9#include <array>
10#include <cstddef>
11#include <span>
12
13#include "hpfem/core/types.hpp"
16
17namespace hpfem::fespace {
18
20template <int Dim>
22
24[[nodiscard]] constexpr Index h1_edge_functions(int p) noexcept {
25 return p >= 2 ? p - 1 : 0;
26}
27[[nodiscard]] constexpr Index h1_face_functions(int p) noexcept {
28 return p >= 3 ? static_cast<Index>(p - 1) * (p - 2) / 2 : 0;
29}
30template <int Dim>
31[[nodiscard]] constexpr Index h1_cell_functions(int p) noexcept {
32 if constexpr (Dim == 2) {
33 return h1_face_functions(p);
34 } else {
35 return p >= 4 ? static_cast<Index>(p - 1) * (p - 2) * (p - 3) / 6 : 0;
36 }
37}
38
42template <int Dim>
43class H1Basis {
44 public:
46 static constexpr std::size_t kNumVertices = static_cast<std::size_t>(Dim + 1);
47
49 explicit H1Basis(const CellLayout<Dim>& layout);
50
51 [[nodiscard]] const CellLayout<Dim>& layout() const noexcept { return layout_; }
53 [[nodiscard]] Index size() const noexcept { return size_; }
55 [[nodiscard]] int max_order() const noexcept { return layout_.cell_order; }
57 [[nodiscard]] Index edge_offset(std::size_t k) const noexcept { return edge_offsets_[k]; }
58 [[nodiscard]] Index face_offset(std::size_t k) const noexcept { return face_offsets_[k]; }
59 [[nodiscard]] Index cell_offset() const noexcept { return cell_offset_; }
60
63 void evaluate(const Point<Dim>& xi, std::span<Real> values,
64 std::span<Point<Dim>> gradients) const;
65
66 private:
67 CellLayout<Dim> layout_;
68 Index size_ = 0;
69 std::array<Index, CellLayout<Dim>::kNumEdges> edge_offsets_{};
70 std::array<Index, 4> face_offsets_{};
71 Index cell_offset_ = 0;
72};
73
74extern template class H1Basis<2>;
75extern template class H1Basis<3>;
76
77} // namespace hpfem::fespace
Definition h1_basis.hpp:43
static constexpr std::size_t kNumVertices
Definition h1_basis.hpp:46
Index size() const noexcept
Total number of shape functions.
Definition h1_basis.hpp:53
const CellLayout< Dim > & layout() const noexcept
Definition h1_basis.hpp:51
void evaluate(const Point< Dim > &xi, std::span< Real > values, std::span< Point< Dim > > gradients) const
Index cell_offset() const noexcept
Definition h1_basis.hpp:59
Index edge_offset(std::size_t k) const noexcept
First function index of the functions of edge / face k and of the interior.
Definition h1_basis.hpp:57
Index face_offset(std::size_t k) const noexcept
Definition h1_basis.hpp:58
int max_order() const noexcept
Maximal polynomial degree occurring.
Definition h1_basis.hpp:55
H1Basis(const CellLayout< Dim > &layout)
Definition cell_layout.hpp:13
constexpr Index h1_face_functions(int p) noexcept
Definition h1_basis.hpp:27
constexpr Index h1_edge_functions(int p) noexcept
Number of basis functions associated with an entity of the given order.
Definition h1_basis.hpp:24
constexpr Index h1_cell_functions(int p) noexcept
Definition h1_basis.hpp:31
Eigen::Matrix< Real, Dim, 1 > Point
Definition types.hpp:27
std::int64_t Index
global indices (DoFs, entities)
Definition types.hpp:17
Definition cell_layout.hpp:18
Local topology tables of the reference simplex in Dim dimensions.
Definition simplex_topology.hpp:27