PolyFEM
Loading...
Searching...
No Matches
CMesh2D.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <polyfem/Common.hpp>
7
8#include <Eigen/Dense>
9
11
12namespace polyfem
13{
14 namespace mesh
15 {
23 class CMesh2D : public Mesh2D
24 {
25 public:
26 CMesh2D() = default;
27 virtual ~CMesh2D() = default;
28 CMesh2D(CMesh2D &&) = default;
29 CMesh2D &operator=(CMesh2D &&) = default;
30 CMesh2D(const CMesh2D &) = default;
31 CMesh2D &operator=(const CMesh2D &) = default;
32
33 void refine(const int n_refinement, const double t) override;
34
35 bool is_conforming() const override { return true; }
36
37 int n_faces() const override { return mesh_.n_facets(); }
38 int n_edges() const override { return mesh_.n_edges(); }
39 int n_vertices() const override { return mesh_.n_vertices(); }
40
41 inline int n_face_vertices(const int f_id) const override { return mesh_.n_facet_vertices(f_id); }
42
43 inline int face_vertex(const int f_id, const int lv_id) const override { return mesh_.facet_vertex(f_id, lv_id); }
44 inline int edge_vertex(const int e_id, const int lv_id) const override { return mesh_.edge_vertex(e_id, lv_id); }
45 inline int cell_vertex(const int f_id, const int lv_id) const override { return mesh_.facet_vertex(f_id, lv_id); }
46
47 bool is_boundary_vertex(const int vertex_global_id) const override
48 {
49 return mesh_.boundary_vertex[vertex_global_id];
50 }
51 bool is_boundary_edge(const int edge_global_id) const override
52 {
53 return mesh_.boundary_edge[edge_global_id];
54 }
55
56 bool is_boundary_element(const int element_global_id) const override;
57
58 bool build_topology(const MeshData &data) override;
59
60 void attach_higher_order_nodes(const Eigen::MatrixXd &V, const std::vector<std::vector<int>> &nodes) override;
61 std::pair<RowVectorNd, int> edge_node(const Navigation::Index &index, const int n_new_nodes, const int i) const override;
62 std::pair<RowVectorNd, int> face_node(const Navigation::Index &index, const int n_new_nodes, const int i, const int j) const override;
63
64 void normalize() override;
65
66 double edge_length(const int gid) const override;
67
68 void compute_elements_tag() override;
69 virtual void update_elements_tag() override;
70
71 void set_point(const int global_index, const RowVectorNd &p) override;
72
73 virtual RowVectorNd point(const int global_index) const override;
74 virtual RowVectorNd edge_barycenter(const int index) const override;
75
76 virtual void bounding_box(RowVectorNd &min, RowVectorNd &max) const override;
77
78 void compute_boundary_ids(const std::function<int(const size_t, const std::vector<int> &, const RowVectorNd &, bool)> &marker) override;
79
80 void compute_body_ids(const std::function<int(const size_t, const std::vector<int> &, const RowVectorNd &)> &marker) override;
81
82 // Navigation wrapper
83 inline Navigation::Index get_index_from_face(int f, int lv = 0) const override { return Navigation::get_index_from_face(mesh_, f, lv); }
84
85 // Navigation in a surface mesh
89
90 // void triangulate_faces(Eigen::MatrixXi &tris, Eigen::MatrixXd &pts, std::vector<int> &ranges) const override;
91
92 void append(const Mesh &mesh) override;
93
94 std::unique_ptr<Mesh> copy() const override;
95
96 protected:
97 void remove_elements(const std::vector<bool> &keep) override;
98
99 private:
101 };
102 } // namespace mesh
103} // namespace polyfem
int V
Eigen::RowVectorXd point
Conforming 2D mesh of arbitrary polygons, stored in a PolygonMesh.
Definition CMesh2D.hpp:24
virtual RowVectorNd edge_barycenter(const int index) const override
edge barycenter
Definition CMesh2D.cpp:570
Navigation::Index switch_edge(Navigation::Index idx) const override
Definition CMesh2D.hpp:87
void normalize() override
normalize the mesh
Definition CMesh2D.cpp:410
void compute_elements_tag() override
compute element types, see ElementType
Definition CMesh2D.cpp:559
virtual ~CMesh2D()=default
int n_faces() const override
number of faces
Definition CMesh2D.hpp:37
int n_face_vertices(const int f_id) const override
number of vertices of a face
Definition CMesh2D.hpp:41
CMesh2D & operator=(const CMesh2D &)=default
int n_vertices() const override
number of vertices
Definition CMesh2D.hpp:39
CMesh2D(CMesh2D &&)=default
int n_edges() const override
number of edges
Definition CMesh2D.hpp:38
Navigation::Index switch_face(Navigation::Index idx) const override
Definition CMesh2D.hpp:88
bool is_boundary_element(const int element_global_id) const override
is cell boundary
Definition CMesh2D.cpp:483
double edge_length(const int gid) const override
edge length
Definition CMesh2D.cpp:460
std::pair< RowVectorNd, int > edge_node(const Navigation::Index &index, const int n_new_nodes, const int i) const override
Definition CMesh2D.cpp:330
std::unique_ptr< Mesh > copy() const override
Create a copy of the mesh.
Definition CMesh2D.cpp:636
Navigation::Index switch_vertex(Navigation::Index idx) const override
Definition CMesh2D.hpp:86
int face_vertex(const int f_id, const int lv_id) const override
id of the face vertex
Definition CMesh2D.hpp:43
void compute_boundary_ids(const std::function< int(const size_t, const std::vector< int > &, const RowVectorNd &, bool)> &marker) override
computes boundary selections based on a function
Definition CMesh2D.cpp:590
void set_point(const int global_index, const RowVectorNd &p) override
Set the point.
Definition CMesh2D.cpp:468
bool build_topology(const MeshData &data) override
Construct only the dimension-specific topology.
Definition CMesh2D.cpp:151
bool is_boundary_edge(const int edge_global_id) const override
is edge boundary
Definition CMesh2D.hpp:51
CMesh2D & operator=(CMesh2D &&)=default
std::pair< RowVectorNd, int > face_node(const Navigation::Index &index, const int n_new_nodes, const int i, const int j) const override
Definition CMesh2D.cpp:352
void append(const Mesh &mesh) override
appends a new mesh to the end of this
Definition CMesh2D.cpp:604
int edge_vertex(const int e_id, const int lv_id) const override
id of the edge vertex
Definition CMesh2D.hpp:44
Navigation::Index get_index_from_face(int f, int lv=0) const override
Definition CMesh2D.hpp:83
virtual void bounding_box(RowVectorNd &min, RowVectorNd &max) const override
computes the bbox of the mesh
Definition CMesh2D.cpp:396
CMesh2D(const CMesh2D &)=default
bool is_boundary_vertex(const int vertex_global_id) const override
is vertex boundary
Definition CMesh2D.hpp:47
void remove_elements(const std::vector< bool > &keep) override
Remove all top-dimensional elements whose mask entry is false.
Definition CMesh2D.cpp:20
int cell_vertex(const int f_id, const int lv_id) const override
id of the vertex of a cell
Definition CMesh2D.hpp:45
void attach_higher_order_nodes(const Eigen::MatrixXd &V, const std::vector< std::vector< int > > &nodes) override
attach high order nodes
Definition CMesh2D.cpp:186
void refine(const int n_refinement, const double t) override
refine the mesh
Definition CMesh2D.cpp:89
void compute_body_ids(const std::function< int(const size_t, const std::vector< int > &, const RowVectorNd &)> &marker) override
computes boundary selections based on a function
Definition CMesh2D.cpp:578
bool is_conforming() const override
if the mesh is conforming
Definition CMesh2D.hpp:35
virtual void update_elements_tag() override
Update elements types.
Definition CMesh2D.cpp:565
2D mesh interface: the elements are the faces (polygons) and the boundary elements are the edges.
Definition Mesh2D.hpp:18
Format-independent input used to construct a runtime Mesh.
Definition MeshData.hpp:12
Abstract mesh class to capture 2d/3d conforming and non-conforming meshes.
Definition Mesh.hpp:77
Minimal polygonal surface mesh used as the storage of CMesh2D.
int facet_vertex(const int f, const int lv) const
int n_facet_vertices(const int f) const
std::vector< bool > boundary_edge
Whether each edge is on the boundary.
int edge_vertex(const int e, const int lv) const
std::vector< bool > boundary_vertex
Whether each vertex is on the boundary.
Index switch_face(const PolygonMesh &M, Index idx)
Index get_index_from_face(const PolygonMesh &M, int f, int lv)
Index switch_edge(const PolygonMesh &M, Index idx)
Index switch_vertex(const PolygonMesh &M, Index idx)
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
Definition Types.hpp:13