hp-FEM
Adaptive hp-FEM suite for nano-optics
Loading...
Searching...
No Matches
generators.hpp
Go to the documentation of this file.
1#pragma once
5
6#include <functional>
7#include <span>
8
10#include "hpfem/mesh/mesh.hpp"
11
12namespace hpfem::mesh {
13
16namespace box_tag {
17inline constexpr Tag kXMin = 1;
18inline constexpr Tag kXMax = 2;
19inline constexpr Tag kYMin = 3;
20inline constexpr Tag kYMax = 4;
21inline constexpr Tag kZMin = 5;
22inline constexpr Tag kZMax = 6;
23} // namespace box_tag
24
30[[nodiscard]] Mesh<2> rectangle(Index nx, Index ny, const Point<2>& lower = Point<2>::Zero(),
31 const Point<2>& upper = Point<2>::Ones(), bool tag_sides = true);
32
38[[nodiscard]] Mesh<3> box(Index nx, Index ny, Index nz, const Point<3>& lower = Point<3>::Zero(),
39 const Point<3>& upper = Point<3>::Ones(), bool tag_sides = true);
40
42inline constexpr Tag kDiscBoundary = 1;
43
51[[nodiscard]] Mesh<2> disc(Index n, const Point<2>& center = Point<2>::Zero(), Real radius = 1.0,
52 bool curved = true);
58[[nodiscard]] Mesh<3> ball(Index n, const Point<3>& center = Point<3>::Zero(), Real radius = 1.0,
59 bool curved = true);
60
72[[nodiscard]] Mesh<2> square_with_disc(Index n, Real radius, Real half_width, Real outer,
73 Tag inclusion_tag = 2);
74
84[[nodiscard]] Mesh<3> box_with_ball(Index n, Real radius, Real half_width, Real outer,
85 Tag inclusion_tag = 2);
86
92template <int Dim>
93[[nodiscard]] Mesh<Dim> extract(const Mesh<Dim>& mesh, std::span<const Index> cells);
95template <int Dim>
96[[nodiscard]] Mesh<Dim> extract(const Mesh<Dim>& mesh,
97 const std::function<bool(const Point<Dim>&)>& keep);
98
99extern template Mesh<2> extract<2>(const Mesh<2>&, std::span<const Index>);
100extern template Mesh<3> extract<3>(const Mesh<3>&, std::span<const Index>);
101extern template Mesh<2> extract<2>(const Mesh<2>&, const std::function<bool(const Point<2>&)>&);
102extern template Mesh<3> extract<3>(const Mesh<3>&, const std::function<bool(const Point<3>&)>&);
103
104} // namespace hpfem::mesh
Definition mesh.hpp:61
constexpr Tag kXMin
Definition generators.hpp:17
constexpr Tag kZMin
Definition generators.hpp:21
constexpr Tag kXMax
Definition generators.hpp:18
constexpr Tag kYMin
Definition generators.hpp:19
constexpr Tag kYMax
Definition generators.hpp:20
constexpr Tag kZMax
Definition generators.hpp:22
Definition adaptive_mesh.hpp:19
Mesh< 2 > rectangle(Index nx, Index ny, const Point< 2 > &lower=Point< 2 >::Zero(), const Point< 2 > &upper=Point< 2 >::Ones(), bool tag_sides=true)
std::int32_t Tag
Integer tag of a physical group (Gmsh convention: positive; 0 means untagged).
Definition mesh.hpp:23
Mesh< 2 > square_with_disc(Index n, Real radius, Real half_width, Real outer, Tag inclusion_tag=2)
constexpr Tag kDiscBoundary
Facet tag of the boundary of disc and ball.
Definition generators.hpp:42
Mesh< 2 > disc(Index n, const Point< 2 > &center=Point< 2 >::Zero(), Real radius=1.0, bool curved=true)
template Mesh< 2 > extract< 2 >(const Mesh< 2 > &, std::span< const Index >)
template Mesh< 3 > extract< 3 >(const Mesh< 3 > &, std::span< const Index >)
Mesh< 3 > box_with_ball(Index n, Real radius, Real half_width, Real outer, Tag inclusion_tag=2)
Mesh< 3 > box(Index nx, Index ny, Index nz, const Point< 3 > &lower=Point< 3 >::Zero(), const Point< 3 > &upper=Point< 3 >::Ones(), bool tag_sides=true)
Mesh< 3 > ball(Index n, const Point< 3 > &center=Point< 3 >::Zero(), Real radius=1.0, bool curved=true)
Mesh< Dim > extract(const Mesh< Dim > &mesh, std::span< const Index > cells)
double Real
Definition types.hpp:15
Eigen::Matrix< Real, Dim, 1 > Point
Definition types.hpp:27
std::int64_t Index
global indices (DoFs, entities)
Definition types.hpp:17