PolyFEM
Loading...
Searching...
No Matches
Mesh2D.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <polyfem/Common.hpp>
7
8#include <Eigen/Dense>
9#include <geogram/mesh/mesh.h>
10
11namespace polyfem
12{
13 namespace mesh
14 {
15 class Mesh2D : public Mesh
16 {
17 public:
18 Mesh2D() = default;
19 virtual ~Mesh2D() = default;
20 Mesh2D(Mesh2D &&) = default;
21 Mesh2D &operator=(Mesh2D &&) = default;
22 Mesh2D(const Mesh2D &) = default;
23 Mesh2D &operator=(const Mesh2D &) = default;
24
25 bool is_volume() const override { return false; }
26
27 int n_cells() const override { return 0; }
28 inline int n_cell_vertices(const int c_id) const override { return n_face_vertices(c_id); }
29
30 bool is_boundary_face(const int face_global_id) const override
31 {
32 assert(false);
33 return false;
34 }
35
36 virtual std::pair<RowVectorNd, int> edge_node(const Navigation::Index &index, const int n_new_nodes, const int i) const = 0;
37 virtual std::pair<RowVectorNd, int> face_node(const Navigation::Index &index, const int n_new_nodes, const int i, const int j) const = 0;
38
39 RowVectorNd cell_barycenter(const int index) const override
40 {
41 assert(false);
42 return RowVectorNd(2);
43 }
44
45 void compute_face_jacobian(const int el_id, const Eigen::MatrixXd &reference_map, Eigen::MatrixXd &jacobian) const;
46
47 // Navigation wrapper
48 virtual Navigation::Index get_index_from_face(int f, int lv = 0) const = 0;
49
50 // Navigation in a surface mesh
54
55 void barycentric_coords(const RowVectorNd &p, const int el_id, Eigen::MatrixXd &coord) const override;
56 RowVectorNd face_barycenter(const int index) const override;
57 void compute_element_barycenters(Eigen::MatrixXd &barycenters) const override { face_barycenters(barycenters); }
58 void elements_boxes(std::vector<std::array<Eigen::Vector3d, 2>> &boxes) const override;
59
60 // Iterate in a mesh
63
64 void get_edges(Eigen::MatrixXd &p0, Eigen::MatrixXd &p1) const override;
65 void get_edges(Eigen::MatrixXd &p0, Eigen::MatrixXd &p1, const std::vector<bool> &valid_elements) const override;
66 };
67 } // namespace mesh
68} // namespace polyfem
Mesh2D & operator=(const Mesh2D &)=default
bool is_boundary_face(const int face_global_id) const override
is face boundary
Definition Mesh2D.hpp:30
void elements_boxes(std::vector< std::array< Eigen::Vector3d, 2 > > &boxes) const override
constructs a box around every element (3d cell, 2d face)
Definition Mesh2D.cpp:121
virtual Navigation::Index switch_edge(Navigation::Index idx) const =0
virtual std::pair< RowVectorNd, int > edge_node(const Navigation::Index &index, const int n_new_nodes, const int i) const =0
virtual std::pair< RowVectorNd, int > face_node(const Navigation::Index &index, const int n_new_nodes, const int i, const int j) const =0
RowVectorNd cell_barycenter(const int index) const override
cell barycenter
Definition Mesh2D.hpp:39
Mesh2D(const Mesh2D &)=default
RowVectorNd face_barycenter(const int index) const override
face barycenter
Definition Mesh2D.cpp:69
Navigation::Index next_around_vertex(Navigation::Index idx) const
Definition Mesh2D.hpp:62
Navigation::Index next_around_face(Navigation::Index idx) const
Definition Mesh2D.hpp:61
void barycentric_coords(const RowVectorNd &p, const int el_id, Eigen::MatrixXd &coord) const override
constructs barycentric coodiantes for a point p.
Definition Mesh2D.cpp:85
void get_edges(Eigen::MatrixXd &p0, Eigen::MatrixXd &p1) const override
Get all the edges.
Definition Mesh2D.cpp:21
bool is_volume() const override
checks if mesh is volume
Definition Mesh2D.hpp:25
virtual Navigation::Index switch_vertex(Navigation::Index idx) const =0
Mesh2D(Mesh2D &&)=default
int n_cells() const override
number of cells
Definition Mesh2D.hpp:27
Mesh2D & operator=(Mesh2D &&)=default
int n_cell_vertices(const int c_id) const override
number of vertices of a cell
Definition Mesh2D.hpp:28
virtual ~Mesh2D()=default
virtual Navigation::Index get_index_from_face(int f, int lv=0) const =0
void compute_element_barycenters(Eigen::MatrixXd &barycenters) const override
utility for 2d/3d.
Definition Mesh2D.hpp:57
void compute_face_jacobian(const int el_id, const Eigen::MatrixXd &reference_map, Eigen::MatrixXd &jacobian) const
Definition Mesh2D.cpp:101
virtual Navigation::Index switch_face(Navigation::Index idx) const =0
Abstract mesh class to capture 2d/3d conforming and non-conforming meshes.
Definition Mesh.hpp:39
void face_barycenters(Eigen::MatrixXd &barycenters) const
all face barycenters
Definition Mesh.cpp:311
virtual int n_face_vertices(const int f_id) const =0
number of vertices of a face
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
Definition Types.hpp:13