hp-FEM
Adaptive hp-FEM suite for nano-optics
Loading...
Searching...
No Matches
nedelec_basis.hpp
Go to the documentation of this file.
1#pragma once
11
12#include <array>
13#include <cstddef>
14#include <span>
15
16#include <Eigen/Core>
17
18#include "hpfem/core/types.hpp"
21
22namespace hpfem::fespace {
23
25template <int Dim>
26using CurlVector = Eigen::Matrix<Real, Dim == 2 ? 1 : 3, 1>;
27
29[[nodiscard]] constexpr Index nedelec_edge_functions(int p) noexcept {
30 return p >= 1 ? p : 0;
31}
32[[nodiscard]] constexpr Index nedelec_face_functions(int p) noexcept {
33 return p >= 2 ? static_cast<Index>(p) * (p - 1) : 0;
34}
35template <int Dim>
36[[nodiscard]] constexpr Index nedelec_cell_functions(int p) noexcept {
37 if constexpr (Dim == 2) {
38 return nedelec_face_functions(p);
39 } else {
40 return p >= 3 ? static_cast<Index>(p) * (p - 1) * (p - 2) / 2 : 0;
41 }
42}
44template <int Dim>
45[[nodiscard]] constexpr Index nedelec_dimension(int p) noexcept {
46 return Dim == 2 ? static_cast<Index>(p) * (p + 2) : static_cast<Index>(p) * (p + 2) * (p + 3) / 2;
47}
48
53template <int Dim>
55 public:
58
61
62 [[nodiscard]] const CellLayout<Dim>& layout() const noexcept { return layout_; }
63 [[nodiscard]] Index size() const noexcept { return size_; }
64 [[nodiscard]] int max_order() const noexcept { return layout_.cell_order; }
65 [[nodiscard]] Index edge_offset(std::size_t k) const noexcept { return edge_offsets_[k]; }
66 [[nodiscard]] Index face_offset(std::size_t k) const noexcept { return face_offsets_[k]; }
67 [[nodiscard]] Index cell_offset() const noexcept { return cell_offset_; }
68
71 void evaluate(const Point<Dim>& xi, std::span<Point<Dim>> values, std::span<Curl> curls) const;
72
73 private:
74 CellLayout<Dim> layout_;
75 Index size_ = 0;
76 std::array<Index, CellLayout<Dim>::kNumEdges> edge_offsets_{};
77 std::array<Index, 4> face_offsets_{};
78 Index cell_offset_ = 0;
79};
80
81extern template class NedelecBasis<2>;
82extern template class NedelecBasis<3>;
83
84} // namespace hpfem::fespace
Definition nedelec_basis.hpp:54
Index edge_offset(std::size_t k) const noexcept
Definition nedelec_basis.hpp:65
Index size() const noexcept
Definition nedelec_basis.hpp:63
int max_order() const noexcept
Definition nedelec_basis.hpp:64
void evaluate(const Point< Dim > &xi, std::span< Point< Dim > > values, std::span< Curl > curls) const
Index cell_offset() const noexcept
Definition nedelec_basis.hpp:67
CurlVector< Dim > Curl
Definition nedelec_basis.hpp:57
NedelecBasis(const CellLayout< Dim > &layout)
const CellLayout< Dim > & layout() const noexcept
Definition nedelec_basis.hpp:62
Index face_offset(std::size_t k) const noexcept
Definition nedelec_basis.hpp:66
Definition cell_layout.hpp:13
constexpr Index nedelec_face_functions(int p) noexcept
Definition nedelec_basis.hpp:32
Eigen::Matrix< Real, Dim==2 ? 1 :3, 1 > CurlVector
Curl of a reference field: a scalar (stored as a 1-vector) in 2D, a 3-vector in 3D.
Definition nedelec_basis.hpp:26
constexpr Index nedelec_edge_functions(int p) noexcept
Number of functions of the order-p space (Nédélec I, ND_p, lowest order p = 1) per entity.
Definition nedelec_basis.hpp:29
constexpr Index nedelec_dimension(int p) noexcept
dim ND_p of one cell with uniform order: p(p+2) (triangle), p(p+2)(p+3)/2 (tetrahedron).
Definition nedelec_basis.hpp:45
constexpr Index nedelec_cell_functions(int p) noexcept
Definition nedelec_basis.hpp:36
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