10#include <geogram/mesh/mesh.h>
75 static std::unique_ptr<Mesh>
create(
const std::string &path,
const bool non_conforming =
false);
83 static std::unique_ptr<Mesh>
create(GEO::Mesh &M,
const bool non_conforming =
false);
92 static std::unique_ptr<Mesh>
create(
const Eigen::MatrixXd &vertices,
const Eigen::MatrixXi &cells,
const bool non_conforming =
false);
100 static std::unique_ptr<Mesh>
create(
const int dim,
const bool non_conforming =
false);
104 virtual std::unique_ptr<Mesh>
copy()
const = 0;
140 virtual void refine(
const int n_refinement,
const double t) = 0;
202 virtual int edge_vertex(
const int e_id,
const int lv_id)
const = 0;
208 virtual int face_vertex(
const int f_id,
const int lv_id)
const = 0;
214 virtual int cell_vertex(
const int f_id,
const int lv_id)
const = 0;
231 std::vector<int> res;
234 std::sort(res.begin(), res.end());
264 virtual bool save(
const std::string &path)
const = 0;
377 virtual void elements_boxes(std::vector<std::array<Eigen::Vector3d, 2>> &boxes)
const = 0;
400 bool is_cube(
const int el_id)
const;
466 return std::numeric_limits<int>::max();
495 void update_nodes(
const Eigen::VectorXi &in_node_to_node);
531 virtual void get_edges(Eigen::MatrixXd &p0, Eigen::MatrixXd &p1)
const = 0;
537 virtual void get_edges(Eigen::MatrixXd &p0, Eigen::MatrixXd &p1,
const std::vector<bool> &valid_elements)
const = 0;
596 std::vector<std::pair<int, int>>
edges()
const;
600 std::vector<std::vector<int>>
faces()
const;
632 void append(
const std::unique_ptr<Mesh> &mesh)
648 virtual bool load(
const std::string &path) = 0;
653 virtual bool load(
const GEO::Mesh &M) = 0;
Class to store the high-order cells nodes.
std::vector< int > nodes_ids
Class to store the high-order edge nodes.
std::vector< int > nodes_ids
Class to store the high-order face nodes.
std::vector< int > nodes_ids
Abstract mesh class to capture 2d/3d conforming and non-conforming meshes.
int n_elements() const
utitlity to return the number of elements, cells or faces in 3d and 2d
virtual int n_vertices() const =0
number of vertices
virtual int get_body_id(const int primitive) const
Get the volume selection of an element (cell in 3d, face in 2d)
virtual void compute_element_barycenters(Eigen::MatrixXd &barycenters) const =0
utility for 2d/3d.
virtual double edge_length(const int gid) const
edge length
void set_cell_weights(const std::vector< std::vector< double > > &in_cell_weights)
Set the cell weights for rational polynomial meshes.
const Eigen::MatrixXi & in_ordered_edges() const
Order of the input edges.
bool is_polytope(const int el_id) const
checks if element is polygon compatible
Eigen::MatrixXi orders_
list of geometry orders, one per cell
std::unordered_map< std::pair< int, int >, size_t, polyfem::utils::HashPair > edges_to_ids() const
map from edge (pair of v id) to the id of the edge
bool is_rational() const
check if curved mesh has rational polynomials elements
Mesh()=default
Construct a new Mesh object.
std::vector< ElementType > elements_tag_
list of element types
virtual RowVectorNd edge_barycenter(const int e) const =0
edge barycenter
virtual void get_edges(Eigen::MatrixXd &p0, Eigen::MatrixXd &p1) const =0
Get all the edges.
int element_vertex(const int el_id, const int lv_id) const
id of the vertex of a element
bool is_rational_
stores if the mesh is rational
bool has_boundary_ids() const
checks if surface selections are available
virtual void compute_boundary_ids(const std::function< int(const size_t, const std::vector< int > &, const RowVectorNd &, bool)> &marker)=0
computes boundary selections based on a function
virtual double tri_area(const int gid) const
area of a tri face of a tet mesh
void cell_barycenters(Eigen::MatrixXd &barycenters) const
all cells barycenters
virtual void get_edges(Eigen::MatrixXd &p0, Eigen::MatrixXd &p1, const std::vector< bool > &valid_elements) const =0
Get all the edges according to valid_elements selection.
bool is_simplicial() const
checks if the mesh is simplicial
virtual bool is_conforming() const =0
if the mesh is conforming
virtual void bounding_box(RowVectorNd &min, RowVectorNd &max) const =0
computes the bbox of the mesh
virtual void barycentric_coords(const RowVectorNd &p, const int el_id, Eigen::MatrixXd &coord) const =0
constructs barycentric coodiantes for a point p.
virtual RowVectorNd face_barycenter(const int f) const =0
face barycenter
virtual void update_elements_tag()
Update elements types.
Mesh & operator=(const Mesh &)=default
virtual void compute_elements_tag()=0
compute element types, see ElementType
virtual bool build_from_matrices(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F)=0
build a mesh from matrices
virtual void set_point(const int global_index, const RowVectorNd &p)=0
Set the point.
bool is_cube(const int el_id) const
checks if element is cube compatible
bool has_node_ids() const
checks if points selections are available
virtual void set_body_ids(const std::vector< int > &body_ids)
Set the volume sections.
virtual RowVectorNd point(const int global_index) const =0
point coordinates
const Eigen::MatrixXi & orders() const
order of each element
virtual bool is_boundary_face(const int face_global_id) const =0
is face boundary
Eigen::MatrixXi in_ordered_faces_
Order of the input faces, TODO: change to std::vector of Eigen::Vector.
void compute_node_ids(const std::function< int(const size_t, const RowVectorNd &, bool)> &marker)
computes boundary selections based on a function
virtual int get_boundary_id(const int primitive) const
Get the boundary selection of an element (face in 3d, edge in 2d)
virtual bool is_boundary_vertex(const int vertex_global_id) const =0
is vertex boundary
bool is_simplex(const int el_id) const
checks if element is simples compatible
void face_barycenters(Eigen::MatrixXd &barycenters) const
all face barycenters
virtual double quad_area(const int gid) const
area of a quad face of an hex mesh
virtual bool has_body_ids() const
checks if volumes selections are available
virtual void normalize()=0
normalize the mesh
bool is_spline_compatible(const int el_id) const
checks if element is spline compatible
virtual void prepare_mesh()
method used to finalize the mesh.
virtual void load_boundary_ids(const std::string &path)
loads the boundary selections for a file
void set_is_rational(const bool in_is_rational)
Set the is rational object.
Mesh & operator=(Mesh &&)=default
Copy constructor.
std::vector< int > boundary_ids_
list of surface labels
bool is_linear() const
check if the mesh is linear
void apply_affine_transformation(const MatrixNd &A, const VectorNd &b)
Apply an affine transformation to the vertex positions .
std::vector< int > node_ids_
list of node labels
std::unordered_map< std::vector< int >, size_t, polyfem::utils::HashVector > faces_to_ids() const
map from face (tuple of v id) to the id of the face
virtual void refine(const int n_refinement, const double t)=0
refine the mesh
std::vector< CellNodes > cell_nodes_
high-order nodes associates to cells
std::vector< std::vector< double > > cell_weights_
weights associates to cells for rational polynomail meshes
const std::vector< double > & cell_weights(const int cell_index) const
weights for rational polynomial meshes
virtual bool load(const GEO::Mesh &M)=0
loads a mesh from a geo mesh
virtual bool is_volume() const =0
checks if mesh is volume
std::vector< std::pair< int, int > > edges() const
list of sorted edges.
void update_nodes(const Eigen::VectorXi &in_node_to_node)
Update the node ids to reorder them.
virtual int edge_vertex(const int e_id, const int lv_id) const =0
id of the edge vertex
virtual std::unique_ptr< Mesh > copy() const =0
Create a copy of the mesh.
void append(const std::unique_ptr< Mesh > &mesh)
appends a new mesh to the end of this, utility that takes pointer, calls other one
virtual bool is_boundary_edge(const int edge_global_id) const =0
is edge boundary
bool has_poly() const
checks if the mesh has polytopes
std::vector< int > element_vertices(const int el_id) const
list of vids of an element
const Eigen::VectorXi & in_ordered_vertices() const
Order of the input vertices.
std::vector< int > body_ids_
list of volume labels
static std::unique_ptr< Mesh > create(const std::string &path, const bool non_conforming=false)
factory to build the proper mesh
virtual int get_default_boundary_id(const int primitive) const
Get the default boundary selection of an element (face in 3d, edge in 2d)
int dimension() const
utily for dimension
virtual int n_cells() const =0
number of cells
virtual const std::vector< int > & get_body_ids() const
Get the volume selection of all elements (cells in 3d, faces in 2d)
std::vector< FaceNodes > face_nodes_
high-order nodes associates to faces
virtual bool load(const std::string &path)=0
loads a mesh from the path
virtual int n_faces() const =0
number of faces
const std::vector< ElementType > & elements_tag() const
Returns the elements types.
std::vector< EdgeNodes > edge_nodes_
high-order nodes associates to edges
std::vector< std::vector< int > > faces() const
list of sorted faces.
virtual void attach_higher_order_nodes(const Eigen::MatrixXd &V, const std::vector< std::vector< int > > &nodes)=0
attach high order nodes
int n_boundary_elements() const
utitlity to return the number of boundary elements, faces or edges in 3d and 2d
Eigen::MatrixXi in_ordered_edges_
Order of the input edges.
void set_tag(const int el, const ElementType type)
changes the element type
virtual void append(const Mesh &mesh)
appends a new mesh to the end of this
Mesh(Mesh &&)=default
Construct a new Mesh object.
virtual bool save(const std::string &path) const =0
virtual RowVectorNd cell_barycenter(const int c) const =0
cell barycenter
const Eigen::MatrixXi & in_ordered_faces() const
Order of the input edges.
virtual int n_edges() const =0
number of edges
virtual void set_boundary_ids(const std::vector< int > &boundary_ids)
Set the boundary selection from a vector.
virtual void compute_body_ids(const std::function< int(const size_t, const std::vector< int > &, const RowVectorNd &)> &marker)=0
computes boundary selections based on a function
void edge_barycenters(Eigen::MatrixXd &barycenters) const
all edges barycenters
virtual int cell_vertex(const int f_id, const int lv_id) const =0
id of the vertex of a cell
virtual int n_face_vertices(const int f_id) const =0
number of vertices of a face
virtual void elements_boxes(std::vector< std::array< Eigen::Vector3d, 2 > > &boxes) const =0
constructs a box around every element (3d cell, 2d face)
Eigen::VectorXi in_ordered_vertices_
Order of the input vertices.
virtual bool is_boundary_element(const int element_global_id) const =0
is cell boundary
virtual int n_cell_vertices(const int c_id) const =0
number of vertices of a cell
virtual int get_node_id(const int node_id) const
Get the boundary selection of a node.
virtual ~Mesh()=default
Destroy the Mesh object.
virtual int face_vertex(const int f_id, const int lv_id) const =0
id of the face vertex
Mesh(const Mesh &)=default
Construct a new Mesh object.
int boundary_element_vertex(const int primitive_id, const int lv_id) const
ElementType
Type of Element, check [Poly-Spline Finite Element Method] for a complete description.
@ REGULAR_INTERIOR_CUBE
Triangle/tet element.
@ UNDEFINED
Boundary polytope.
@ REGULAR_BOUNDARY_CUBE
Quad/Hex incident to more than 1 singular vertices (should not happen in 2D)
@ MULTI_SINGULAR_BOUNDARY_CUBE
Quad incident to exactly 1 singular vertex (in 2D); hex incident to exactly 1 singular interior edge,...
@ MULTI_SINGULAR_INTERIOR_CUBE
Quad/hex incident to exactly 1 singular vertex (in 2D) or edge (in 3D)
@ SIMPLE_SINGULAR_INTERIOR_CUBE
Regular quad/hex inside a 3^n patch.
@ INTERFACE_CUBE
Boundary hex that is not regular nor SimpleSingularBoundaryCube.
@ INTERIOR_POLYTOPE
Quad/hex that is at the interface with a polytope (if a cube has both external boundary and and inter...
@ SIMPLE_SINGULAR_BOUNDARY_CUBE
Boundary quad/hex, where all boundary vertices/edges are incident to at most 2 quads/hexes.
@ BOUNDARY_POLYTOPE
Interior polytope.
Eigen::Matrix< double, Eigen::Dynamic, 1, 0, 3, 1 > VectorNd
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor, 3, 3 > MatrixNd
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd