hp-FEM
Adaptive hp-FEM suite for nano-optics
Loading...
Searching...
No Matches
dof_map.hpp
Go to the documentation of this file.
1#pragma once
7
8#include <span>
9#include <vector>
10
11#include "hpfem/core/types.hpp"
15#include "hpfem/mesh/mesh.hpp"
16
17namespace hpfem::fespace {
18
20struct H1Counts {
21 static constexpr Index kVertexDofs = 1;
22 [[nodiscard]] static constexpr Index edge(int p) noexcept { return h1_edge_functions(p); }
23 [[nodiscard]] static constexpr Index face(int p) noexcept { return h1_face_functions(p); }
24 template <int Dim>
25 [[nodiscard]] static constexpr Index cell(int p) noexcept {
26 return h1_cell_functions<Dim>(p);
27 }
28};
29
32 static constexpr Index kVertexDofs = 0;
33 [[nodiscard]] static constexpr Index edge(int p) noexcept { return nedelec_edge_functions(p); }
34 [[nodiscard]] static constexpr Index face(int p) noexcept { return nedelec_face_functions(p); }
35 template <int Dim>
36 [[nodiscard]] static constexpr Index cell(int p) noexcept {
37 return nedelec_cell_functions<Dim>(p);
38 }
39};
40
50template <int Dim, class Counts>
52 public:
54 EntityDofMap(const mesh::Mesh<Dim>& mesh, std::vector<int> cell_orders);
56 EntityDofMap(const mesh::Mesh<Dim>& mesh, int order);
57
58 [[nodiscard]] const mesh::Mesh<Dim>& mesh() const noexcept { return *mesh_; }
59 [[nodiscard]] Index num_dofs() const noexcept { return num_dofs_; }
60 [[nodiscard]] int cell_order(Index c) const { return cell_orders_[as_size(c)]; }
61 [[nodiscard]] int edge_order(Index e) const { return edge_orders_[as_size(e)]; }
62 [[nodiscard]] int face_order(Index f) const
63 requires(Dim == 3)
64 {
65 return face_orders_[as_size(f)];
66 }
67 [[nodiscard]] int max_order() const noexcept { return max_order_; }
68
70 [[nodiscard]] Index vertex_dof(Index v) const noexcept
71 requires(Counts::kVertexDofs == 1)
72 {
73 return v;
74 }
76 [[nodiscard]] std::span<const Index> edge_dofs(Index e) const;
77 [[nodiscard]] std::span<const Index> face_dofs(Index f) const
78 requires(Dim == 3);
79 [[nodiscard]] std::span<const Index> interior_dofs(Index c) const;
80
82 [[nodiscard]] CellLayout<Dim> cell_layout(Index c) const;
84 [[nodiscard]] std::span<const Index> cell_dofs(Index c) const;
85
88 [[nodiscard]] std::vector<Index> facet_dofs(Index f) const;
90 [[nodiscard]] std::vector<Index> dofs_on_tag(mesh::Tag tag) const;
91
92 private:
93 void build();
94
95 const mesh::Mesh<Dim>* mesh_;
96 std::vector<int> cell_orders_;
97 std::vector<int> edge_orders_;
98 std::vector<int> face_orders_;
99 int max_order_ = 1;
100 Index num_dofs_ = 0;
101 std::vector<Index> all_dofs_;
102 std::vector<Index> edge_offsets_;
103 std::vector<Index> face_offsets_;
104 std::vector<Index> cell_offsets_;
105 std::vector<Index> cell_dofs_;
106 std::vector<Index> cell_dof_offsets_;
107};
108
110template <int Dim>
113template <int Dim>
115
116extern template class EntityDofMap<2, H1Counts>;
117extern template class EntityDofMap<3, H1Counts>;
118extern template class EntityDofMap<2, NedelecCounts>;
119extern template class EntityDofMap<3, NedelecCounts>;
120
121} // namespace hpfem::fespace
Definition dof_map.hpp:51
EntityDofMap(const mesh::Mesh< Dim > &mesh, int order)
Uniform order p on every cell.
std::span< const Index > face_dofs(Index f) const
int cell_order(Index c) const
Definition dof_map.hpp:60
std::span< const Index > cell_dofs(Index c) const
Global DoFs of cell c in basis function order.
std::span< const Index > edge_dofs(Index e) const
Global DoFs of the functions of edge e (ascending degree), possibly empty.
int face_order(Index f) const
Definition dof_map.hpp:62
CellLayout< Dim > cell_layout(Index c) const
Basis layout (orders and orientation codes) of cell c.
EntityDofMap(const mesh::Mesh< Dim > &mesh, std::vector< int > cell_orders)
Variable order: one entry per cell, all ≥ 1.
const mesh::Mesh< Dim > & mesh() const noexcept
Definition dof_map.hpp:58
int max_order() const noexcept
Definition dof_map.hpp:67
std::vector< Index > dofs_on_tag(mesh::Tag tag) const
Union of facet_dofs over all facets carrying tag, sorted and unique.
Index num_dofs() const noexcept
Definition dof_map.hpp:59
std::vector< Index > facet_dofs(Index f) const
Index vertex_dof(Index v) const noexcept
Global DoF of vertex v (H1 spaces only).
Definition dof_map.hpp:70
int edge_order(Index e) const
Definition dof_map.hpp:61
std::span< const Index > interior_dofs(Index c) const
Definition mesh.hpp:61
Definition cell_layout.hpp:13
constexpr Index nedelec_face_functions(int p) noexcept
Definition nedelec_basis.hpp:32
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 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
std::int32_t Tag
Integer tag of a physical group (Gmsh convention: positive; 0 means untagged).
Definition mesh.hpp:23
constexpr std::size_t as_size(Index i) noexcept
Converts a non-negative global or local index to a container index.
Definition types.hpp:34
std::int64_t Index
global indices (DoFs, entities)
Definition types.hpp:17
Definition cell_layout.hpp:18
DoFs per entity of the H1 space: one per vertex, p − 1 per edge, …
Definition dof_map.hpp:20
static constexpr Index kVertexDofs
Definition dof_map.hpp:21
static constexpr Index face(int p) noexcept
Definition dof_map.hpp:23
static constexpr Index cell(int p) noexcept
Definition dof_map.hpp:25
static constexpr Index edge(int p) noexcept
Definition dof_map.hpp:22
DoFs per entity of the Nédélec space: none per vertex, p per edge, p(p − 1) per face,...
Definition dof_map.hpp:31
static constexpr Index cell(int p) noexcept
Definition dof_map.hpp:36
static constexpr Index kVertexDofs
Definition dof_map.hpp:32
static constexpr Index face(int p) noexcept
Definition dof_map.hpp:34
static constexpr Index edge(int p) noexcept
Definition dof_map.hpp:33