hp-FEM
Adaptive hp-FEM suite for nano-optics
Loading...
Searching...
No Matches
red_refinement.hpp
Go to the documentation of this file.
1#pragma once
7
8#include <array>
9
10#include "hpfem/core/types.hpp"
12
14
15template <int Dim>
17
18template <>
19struct RedRefinement<2> {
20 static constexpr Index kChildren = 4;
21 // edges: 3 = (0,1), 4 = (1,2), 5 = (2,0)
22 static constexpr std::array<std::array<LocalIndex, 3>, 4> kChildrenNodes{
23 {{0, 3, 5}, {3, 1, 4}, {5, 4, 2}, {3, 4, 5}}};
24};
25
26template <>
27struct RedRefinement<3> {
28 static constexpr Index kChildren = 8;
29 // edges: 4 = (0,1), 5 = (0,2), 6 = (0,3), 7 = (1,2), 8 = (1,3), 9 = (2,3)
30 // Bey (1995): four corner tetrahedra, then the octahedron cut along the diagonal 5-8.
31 static constexpr std::array<std::array<LocalIndex, 4>, 8> kChildrenNodes{{{0, 4, 5, 6},
32 {4, 1, 7, 8},
33 {5, 7, 2, 9},
34 {6, 8, 9, 3},
35 {4, 5, 6, 8},
36 {4, 5, 7, 8},
37 {5, 6, 8, 9},
38 {5, 7, 8, 9}}};
39};
40
42template <int Dim>
43[[nodiscard]] inline Point<Dim> reference_vertex(LocalIndex i) {
45 if (i > 0) xi(i - 1) = 1.0;
46 return xi;
47}
48
50template <int Dim>
51[[nodiscard]] inline Point<Dim> reference_node(LocalIndex n) {
52 if (n <= Dim) return reference_vertex<Dim>(n);
53 const auto& e = SimplexTopology<Dim>::kEdgeVertices[as_size(n - Dim - 1)];
54 return 0.5 * (reference_vertex<Dim>(e[0]) + reference_vertex<Dim>(e[1]));
55}
56
59template <int Dim>
60[[nodiscard]] inline Point<Dim> parent_reference(LocalIndex child, const Point<Dim>& xi) {
61 const auto& nodes = RedRefinement<Dim>::kChildrenNodes[as_size(child)];
62 Point<Dim> x = reference_node<Dim>(nodes[0]);
63 for (int j = 1; j <= Dim; ++j) {
64 x += xi(j - 1) * (reference_node<Dim>(nodes[as_size(j)]) - reference_node<Dim>(nodes[0]));
65 }
66 return x;
67}
68
69} // namespace hpfem::mesh::detail
Definition red_refinement.hpp:13
Point< Dim > reference_node(LocalIndex n)
Reference coordinates of local node n of the refined cell (vertex or edge midpoint).
Definition red_refinement.hpp:51
Point< Dim > parent_reference(LocalIndex child, const Point< Dim > &xi)
Definition red_refinement.hpp:60
Point< Dim > reference_vertex(LocalIndex i)
Reference vertex i of the simplex (0 = origin).
Definition red_refinement.hpp:43
Eigen::Matrix< Real, Dim, 1 > Point
Definition types.hpp:27
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
std::int32_t LocalIndex
element-local indices
Definition types.hpp:18
Local topology tables of the reference simplex in Dim dimensions.
Definition simplex_topology.hpp:27
Definition red_refinement.hpp:16