PolyFEM
Loading...
Searching...
No Matches
polyfem::mesh::Mesh2D Class Referenceabstract

#include <Mesh2D.hpp>

Inheritance diagram for polyfem::mesh::Mesh2D:
[legend]
Collaboration diagram for polyfem::mesh::Mesh2D:
[legend]

Public Member Functions

 Mesh2D ()=default
 
virtual ~Mesh2D ()=default
 
 Mesh2D (Mesh2D &&)=default
 
Mesh2Doperator= (Mesh2D &&)=default
 
 Mesh2D (const Mesh2D &)=default
 
Mesh2Doperator= (const Mesh2D &)=default
 
bool is_volume () const override
 checks if mesh is volume
 
int n_cells () const override
 number of cells
 
int n_cell_vertices (const int c_id) const override
 number of vertices of a cell
 
bool is_boundary_face (const int face_global_id) const override
 is face boundary
 
virtual RowVectorNd edge_node (const Navigation::Index &index, const int n_new_nodes, const int i) const =0
 
virtual RowVectorNd 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
 
void compute_face_jacobian (const int el_id, const Eigen::MatrixXd &reference_map, Eigen::MatrixXd &jacobian) const
 
virtual Navigation::Index get_index_from_face (int f, int lv=0) const =0
 
virtual Navigation::Index switch_vertex (Navigation::Index idx) const =0
 
virtual Navigation::Index switch_edge (Navigation::Index idx) const =0
 
virtual Navigation::Index switch_face (Navigation::Index idx) const =0
 
void barycentric_coords (const RowVectorNd &p, const int el_id, Eigen::MatrixXd &coord) const override
 constructs barycentric coodiantes for a point p.
 
RowVectorNd face_barycenter (const int index) const override
 face barycenter
 
void compute_element_barycenters (Eigen::MatrixXd &barycenters) const override
 utility for 2d/3d.
 
void elements_boxes (std::vector< std::array< Eigen::Vector3d, 2 > > &boxes) const override
 constructs a box around every element (3d cell, 2d face)
 
Navigation::Index next_around_face (Navigation::Index idx) const
 
Navigation::Index next_around_vertex (Navigation::Index idx) const
 
void get_edges (Eigen::MatrixXd &p0, Eigen::MatrixXd &p1) const override
 Get all the edges.
 
void get_edges (Eigen::MatrixXd &p0, Eigen::MatrixXd &p1, const std::vector< bool > &valid_elements) const override
 Get all the edges according to valid_elements selection.
 
- Public Member Functions inherited from polyfem::mesh::Mesh
virtual std::unique_ptr< Meshcopy () const =0
 Create a copy of the mesh.
 
virtual ~Mesh ()=default
 Destroy the Mesh object.
 
 Mesh (Mesh &&)=default
 Construct a new Mesh object.
 
Meshoperator= (Mesh &&)=default
 Copy constructor.
 
 Mesh (const Mesh &)=default
 Construct a new Mesh object.
 
Meshoperator= (const Mesh &)=default
 
virtual void refine (const int n_refinement, const double t)=0
 refine the mesh
 
int dimension () const
 utily for dimension
 
virtual bool is_conforming () const =0
 if the mesh is conforming
 
int n_elements () const
 utitlity to return the number of elements, cells or faces in 3d and 2d
 
int n_boundary_elements () const
 utitlity to return the number of boundary elements, faces or edges in 3d and 2d
 
virtual int n_faces () const =0
 number of faces
 
virtual int n_edges () const =0
 number of edges
 
virtual int n_vertices () const =0
 number of vertices
 
virtual int n_face_vertices (const int f_id) const =0
 number of vertices of a face
 
virtual int edge_vertex (const int e_id, const int lv_id) const =0
 id of the edge vertex
 
virtual int face_vertex (const int f_id, const int lv_id) const =0
 id of the face vertex
 
virtual int cell_vertex (const int f_id, const int lv_id) const =0
 id of the vertex of a cell
 
int element_vertex (const int el_id, const int lv_id) const
 id of the vertex of a element
 
int boundary_element_vertex (const int primitive_id, const int lv_id) const
 
virtual bool is_boundary_vertex (const int vertex_global_id) const =0
 is vertex boundary
 
virtual bool is_boundary_edge (const int edge_global_id) const =0
 is edge boundary
 
virtual bool is_boundary_element (const int element_global_id) const =0
 is cell boundary
 
virtual bool save (const std::string &path) const =0
 
virtual void attach_higher_order_nodes (const Eigen::MatrixXd &V, const std::vector< std::vector< int > > &nodes)=0
 attach high order nodes
 
const Eigen::MatrixXi & orders () const
 order of each element
 
bool is_rational () const
 check if curved mesh has rational polynomials elements
 
void set_is_rational (const bool in_is_rational)
 Set the is rational object.
 
virtual void normalize ()=0
 normalize the mesh
 
virtual void compute_elements_tag ()=0
 compute element types, see ElementType
 
virtual void update_elements_tag ()
 Update elements types.
 
virtual double edge_length (const int gid) const
 edge length
 
virtual double quad_area (const int gid) const
 area of a quad face of an hex mesh
 
virtual double tri_area (const int gid) const
 area of a tri face of a tet mesh
 
virtual RowVectorNd point (const int global_index) const =0
 point coordinates
 
virtual void set_point (const int global_index, const RowVectorNd &p)=0
 Set the point.
 
virtual RowVectorNd edge_barycenter (const int e) const =0
 edge barycenter
 
void edge_barycenters (Eigen::MatrixXd &barycenters) const
 all edges barycenters
 
void face_barycenters (Eigen::MatrixXd &barycenters) const
 all face barycenters
 
void cell_barycenters (Eigen::MatrixXd &barycenters) const
 all cells barycenters
 
virtual void bounding_box (RowVectorNd &min, RowVectorNd &max) const =0
 computes the bbox of the mesh
 
bool is_spline_compatible (const int el_id) const
 checks if element is spline compatible
 
bool is_cube (const int el_id) const
 checks if element is cube compatible
 
bool is_polytope (const int el_id) const
 checks if element is polygon compatible
 
bool is_simplex (const int el_id) const
 checks if element is simples compatible
 
const std::vector< ElementType > & elements_tag () const
 Returns the elements types.
 
void set_tag (const int el, const ElementType type)
 changes the element type
 
void compute_node_ids (const std::function< int(const size_t, const RowVectorNd &, bool)> &marker)
 computes boundary selections based on a function
 
virtual void load_boundary_ids (const std::string &path)
 loads the boundary selections for a file
 
virtual void compute_boundary_ids (const double eps)=0
 computes the selection based on the bbx of the mesh.
 
virtual void compute_boundary_ids (const std::function< int(const RowVectorNd &)> &marker)=0
 computes boundary selections based on a function
 
virtual void compute_boundary_ids (const std::function< int(const RowVectorNd &, bool)> &marker)=0
 computes boundary selections based on a function
 
virtual void compute_boundary_ids (const std::function< int(const size_t, const RowVectorNd &, bool)> &marker)=0
 computes boundary selections based on a function
 
virtual void compute_boundary_ids (const std::function< int(const std::vector< int > &, bool)> &marker)=0
 computes boundary selections based on a function
 
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 void compute_body_ids (const std::function< int(const size_t, const RowVectorNd &)> &marker)=0
 computes boundary selections based on a function
 
virtual void set_boundary_ids (const std::vector< int > &boundary_ids)
 Set the boundary selection from a vector.
 
virtual void set_body_ids (const std::vector< int > &body_ids)
 Set the volume sections.
 
virtual int get_default_boundary_id (const int primitive) const
 Get the default boundary selection of an element (face in 3d, edge in 2d)
 
virtual int get_boundary_id (const int primitive) const
 Get the boundary selection of an element (face in 3d, edge in 2d)
 
virtual int get_node_id (const int node_id) const
 Get the boundary selection of a node.
 
void update_nodes (const Eigen::VectorXi &in_node_to_node)
 Update the node ids to reorder them.
 
virtual int get_body_id (const int primitive) const
 Get the volume selection of an element (cell in 3d, face in 2d)
 
virtual const std::vector< int > & get_body_ids () const
 Get the volume selection of all elements (cells in 3d, faces in 2d)
 
bool has_node_ids () const
 checks if points selections are available
 
bool has_boundary_ids () const
 checks if surface selections are available
 
virtual bool has_body_ids () const
 checks if volumes selections are available
 
virtual void triangulate_faces (Eigen::MatrixXi &tris, Eigen::MatrixXd &pts, std::vector< int > &ranges) const =0
 generate a triangular representation of every face
 
const std::vector< double > & cell_weights (const int cell_index) const
 weights for rational polynomial meshes
 
void set_cell_weights (const std::vector< std::vector< double > > &in_cell_weights)
 Set the cell weights for rational polynomial meshes.
 
virtual void prepare_mesh ()
 method used to finalize the mesh.
 
bool has_poly () const
 checks if the mesh has polytopes
 
bool is_simplicial () const
 checks if the mesh is simplicial
 
bool is_linear () const
 check if the mesh is linear
 
std::vector< std::pair< int, int > > edges () const
 list of sorted edges.
 
std::vector< std::vector< int > > faces () const
 list of sorted faces.
 
std::unordered_map< std::pair< int, int >, size_t, polyfem::utils::HashPairedges_to_ids () const
 map from edge (pair of v id) to the id of the edge
 
std::unordered_map< std::vector< int >, size_t, polyfem::utils::HashVectorfaces_to_ids () const
 map from face (tuple of v id) to the id of the face
 
const Eigen::VectorXi & in_ordered_vertices () const
 Order of the input vertices.
 
const Eigen::MatrixXi & in_ordered_edges () const
 Order of the input edges.
 
const Eigen::MatrixXi & in_ordered_faces () const
 Order of the input edges.
 
virtual void append (const Mesh &mesh)
 appends a new mesh to the end of this
 
void append (const std::unique_ptr< Mesh > &mesh)
 appends a new mesh to the end of this, utility that takes pointer, calls other one
 
void apply_affine_transformation (const MatrixNd &A, const VectorNd &b)
 Apply an affine transformation \(Ax+b\) to the vertex positions \(x\).
 

Additional Inherited Members

- Static Public Member Functions inherited from polyfem::mesh::Mesh
static std::unique_ptr< Meshcreate (const std::string &path, const bool non_conforming=false)
 factory to build the proper mesh
 
static std::unique_ptr< Meshcreate (GEO::Mesh &M, const bool non_conforming=false)
 factory to build the proper mesh
 
static std::unique_ptr< Meshcreate (const Eigen::MatrixXd &vertices, const Eigen::MatrixXi &cells, const bool non_conforming=false)
 factory to build the proper mesh
 
static std::unique_ptr< Meshcreate (const int dim, const bool non_conforming=false)
 factory to build the proper empty mesh
 
- Protected Member Functions inherited from polyfem::mesh::Mesh
 Mesh ()=default
 Construct a new Mesh object.
 
virtual bool load (const std::string &path)=0
 loads a mesh from the path
 
virtual bool load (const GEO::Mesh &M)=0
 loads a mesh from a geo mesh
 
- Protected Attributes inherited from polyfem::mesh::Mesh
std::vector< ElementTypeelements_tag_
 list of element types
 
std::vector< int > node_ids_
 list of node labels
 
std::vector< int > boundary_ids_
 list of surface labels
 
std::vector< int > body_ids_
 list of volume labels
 
Eigen::MatrixXi orders_
 list of geometry orders, one per cell
 
bool is_rational_ = false
 stores if the mesh is rational
 
std::vector< EdgeNodesedge_nodes_
 high-order nodes associates to edges
 
std::vector< FaceNodesface_nodes_
 high-order nodes associates to faces
 
std::vector< CellNodescell_nodes_
 high-order nodes associates to cells
 
std::vector< std::vector< double > > cell_weights_
 weights associates to cells for rational polynomail meshes
 
Eigen::VectorXi in_ordered_vertices_
 Order of the input vertices.
 
Eigen::MatrixXi in_ordered_edges_
 Order of the input edges.
 
Eigen::MatrixXi in_ordered_faces_
 Order of the input faces, TODO: change to std::vector of Eigen::Vector.
 

Detailed Description

Definition at line 15 of file Mesh2D.hpp.

Constructor & Destructor Documentation

◆ Mesh2D() [1/3]

polyfem::mesh::Mesh2D::Mesh2D ( )
default

◆ ~Mesh2D()

virtual polyfem::mesh::Mesh2D::~Mesh2D ( )
virtualdefault

◆ Mesh2D() [2/3]

polyfem::mesh::Mesh2D::Mesh2D ( Mesh2D &&  )
default

◆ Mesh2D() [3/3]

polyfem::mesh::Mesh2D::Mesh2D ( const Mesh2D )
default

Member Function Documentation

◆ barycentric_coords()

void polyfem::mesh::Mesh2D::barycentric_coords ( const RowVectorNd p,
const int  el_id,
Eigen::MatrixXd &  coord 
) const
overridevirtual

constructs barycentric coodiantes for a point p.

WARNING works only for simplices

Parameters
[in]pquery point
[in]el_idelement id
[out]coordmatrix containing the barycentric coodinates

Implements polyfem::mesh::Mesh.

Definition at line 85 of file Mesh2D.cpp.

References get_index_from_face(), polyfem::mesh::Mesh::is_simplex(), next_around_face(), and polyfem::mesh::Mesh::point().

Here is the call graph for this function:

◆ cell_barycenter()

RowVectorNd polyfem::mesh::Mesh2D::cell_barycenter ( const int  c) const
inlineoverridevirtual

cell barycenter

Parameters
[in]cglobal cell index
Returns
cell barycenter

Implements polyfem::mesh::Mesh.

Definition at line 39 of file Mesh2D.hpp.

◆ compute_element_barycenters()

void polyfem::mesh::Mesh2D::compute_element_barycenters ( Eigen::MatrixXd &  barycenters) const
inlineoverridevirtual

utility for 2d/3d.

In 2d it returns face_barycenters, in 3d it returns cell_barycenters

Parameters
[out]barycentersthe barycenters

Implements polyfem::mesh::Mesh.

Definition at line 57 of file Mesh2D.hpp.

References polyfem::mesh::Mesh::face_barycenters().

Here is the call graph for this function:

◆ compute_face_jacobian()

void polyfem::mesh::Mesh2D::compute_face_jacobian ( const int  el_id,
const Eigen::MatrixXd &  reference_map,
Eigen::MatrixXd &  jacobian 
) const

Definition at line 101 of file Mesh2D.cpp.

References get_index_from_face(), polyfem::mesh::Mesh::is_simplex(), next_around_face(), and polyfem::mesh::Mesh::point().

Referenced by polyfem::solver::AMIPSForm::AMIPSForm(), and polyfem::State::set_materials().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ edge_node()

virtual RowVectorNd polyfem::mesh::Mesh2D::edge_node ( const Navigation::Index index,
const int  n_new_nodes,
const int  i 
) const
pure virtual

Implemented in polyfem::mesh::CMesh2D, and polyfem::mesh::NCMesh2D.

Referenced by polyfem::mesh::MeshNodes::node_ids_from_edge().

Here is the caller graph for this function:

◆ elements_boxes()

void polyfem::mesh::Mesh2D::elements_boxes ( std::vector< std::array< Eigen::Vector3d, 2 > > &  boxes) const
overridevirtual

constructs a box around every element (3d cell, 2d face)

Parameters
[out]boxesaxis aligned bounding boxes

Implements polyfem::mesh::Mesh.

Definition at line 121 of file Mesh2D.cpp.

References get_index_from_face(), polyfem::mesh::Mesh::n_elements(), polyfem::mesh::Mesh::n_face_vertices(), next_around_face(), and polyfem::mesh::Mesh::point().

Here is the call graph for this function:

◆ face_barycenter()

RowVectorNd polyfem::mesh::Mesh2D::face_barycenter ( const int  f) const
overridevirtual

face barycenter

Parameters
[in]fglobal face index
Returns
face barycenter

Implements polyfem::mesh::Mesh.

Definition at line 69 of file Mesh2D.cpp.

References get_index_from_face(), polyfem::mesh::Mesh::n_face_vertices(), polyfem::mesh::Mesh::n_vertices(), next_around_face(), polyfem::mesh::Mesh::point(), and polyfem::mesh::Navigation::Index::vertex.

Referenced by polyfem::mesh::CMesh2D::compute_body_ids(), polyfem::mesh::NCMesh2D::compute_body_ids(), and polyfem::solver::ElasticVariableToSimulation::inverse_eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ face_node()

virtual RowVectorNd polyfem::mesh::Mesh2D::face_node ( const Navigation::Index index,
const int  n_new_nodes,
const int  i,
const int  j 
) const
pure virtual

Implemented in polyfem::mesh::CMesh2D, and polyfem::mesh::NCMesh2D.

Referenced by polyfem::mesh::MeshNodes::node_ids_from_face().

Here is the caller graph for this function:

◆ get_edges() [1/2]

void polyfem::mesh::Mesh2D::get_edges ( Eigen::MatrixXd &  p0,
Eigen::MatrixXd &  p1 
) const
overridevirtual

Get all the edges.

Parameters
[out]p0edge first vertex
[out]p1edge second vertex

Implements polyfem::mesh::Mesh.

Definition at line 21 of file Mesh2D.cpp.

References polyfem::mesh::Mesh::edge_vertex(), polyfem::mesh::Mesh::n_edges(), and polyfem::mesh::Mesh::point().

Referenced by polyfem::mesh::CMesh2D::normalize(), and polyfem::refinement::APriori::p_refine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_edges() [2/2]

void polyfem::mesh::Mesh2D::get_edges ( Eigen::MatrixXd &  p0,
Eigen::MatrixXd &  p1,
const std::vector< bool > &  valid_elements 
) const
overridevirtual

Get all the edges according to valid_elements selection.

Parameters
[out]p0edge first vertex
[out]p1edge second vertex
[in]valid_elementsflag to compute the edge

Implements polyfem::mesh::Mesh.

Definition at line 36 of file Mesh2D.cpp.

References get_index_from_face(), polyfem::mesh::Mesh::n_face_vertices(), next_around_face(), polyfem::mesh::Mesh::point(), and switch_vertex().

Here is the call graph for this function:

◆ get_index_from_face()

virtual Navigation::Index polyfem::mesh::Mesh2D::get_index_from_face ( int  f,
int  lv = 0 
) const
pure virtual

Implemented in polyfem::mesh::CMesh2D, and polyfem::mesh::NCMesh2D.

Referenced by barycentric_coords(), polyfem::basis::SplineBasis2d::build_bases(), polyfem::basis::BarycentricBasis2d::build_bases(), polyfem::basis::compute_epsilon(), compute_face_jacobian(), elements_boxes(), face_barycenter(), get_edges(), and polyfem::refinement::APriori::p_refine().

Here is the caller graph for this function:

◆ is_boundary_face()

bool polyfem::mesh::Mesh2D::is_boundary_face ( const int  face_global_id) const
inlineoverridevirtual

is face boundary

Parameters
[in]face_global_idglobal face id
Returns
is face boundary

Implements polyfem::mesh::Mesh.

Definition at line 30 of file Mesh2D.hpp.

◆ is_volume()

bool polyfem::mesh::Mesh2D::is_volume ( ) const
inlineoverridevirtual

checks if mesh is volume

Returns
if mesh is volumetric

Implements polyfem::mesh::Mesh.

Definition at line 25 of file Mesh2D.hpp.

Referenced by polyfem::basis::PolygonalBasis2d::build_bases(), polyfem::basis::SplineBasis2d::build_bases(), polyfem::basis::BarycentricBasis2d::build_bases(), and polyfem::basis::PolygonalBasis2d::compute_integral_constraints().

Here is the caller graph for this function:

◆ n_cell_vertices()

int polyfem::mesh::Mesh2D::n_cell_vertices ( const int  c_id) const
inlineoverridevirtual

number of vertices of a cell

Parameters
[in]c_idglobal cell id (face for 2d meshes)
Returns
number of vertices

Implements polyfem::mesh::Mesh.

Definition at line 28 of file Mesh2D.hpp.

References polyfem::mesh::Mesh::n_face_vertices().

Here is the call graph for this function:

◆ n_cells()

int polyfem::mesh::Mesh2D::n_cells ( ) const
inlineoverridevirtual

number of cells

Returns
number of cells

Implements polyfem::mesh::Mesh.

Definition at line 27 of file Mesh2D.hpp.

◆ next_around_face()

Navigation::Index polyfem::mesh::Mesh2D::next_around_face ( Navigation::Index  idx) const
inline

Definition at line 61 of file Mesh2D.hpp.

References switch_edge(), and switch_vertex().

Referenced by polyfem::mesh::CMesh2D::attach_higher_order_nodes(), barycentric_coords(), polyfem::basis::compute_epsilon(), compute_face_jacobian(), elements_boxes(), face_barycenter(), get_edges(), polyfem::mesh::CMesh2D::is_boundary_element(), polyfem::utils::BoundarySampler::normal_for_polygon_edge(), polyfem::refinement::APriori::p_refine(), polyfem::utils::BoundarySampler::quadrature_for_polygon_edge(), and polyfem::utils::BoundarySampler::sample_polygon_edge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ next_around_vertex()

Navigation::Index polyfem::mesh::Mesh2D::next_around_vertex ( Navigation::Index  idx) const
inline

Definition at line 62 of file Mesh2D.hpp.

References switch_edge(), and switch_face().

Here is the call graph for this function:

◆ operator=() [1/2]

Mesh2D & polyfem::mesh::Mesh2D::operator= ( const Mesh2D )
default

◆ operator=() [2/2]

Mesh2D & polyfem::mesh::Mesh2D::operator= ( Mesh2D &&  )
default

◆ switch_edge()

virtual Navigation::Index polyfem::mesh::Mesh2D::switch_edge ( Navigation::Index  idx) const
pure virtual

Implemented in polyfem::mesh::CMesh2D, and polyfem::mesh::NCMesh2D.

Referenced by next_around_face(), and next_around_vertex().

Here is the caller graph for this function:

◆ switch_face()

virtual Navigation::Index polyfem::mesh::Mesh2D::switch_face ( Navigation::Index  idx) const
pure virtual

Implemented in polyfem::mesh::CMesh2D, and polyfem::mesh::NCMesh2D.

Referenced by next_around_vertex(), polyfem::mesh::MeshNodes::node_ids_from_edge(), and polyfem::refinement::APriori::p_refine().

Here is the caller graph for this function:

◆ switch_vertex()

virtual Navigation::Index polyfem::mesh::Mesh2D::switch_vertex ( Navigation::Index  idx) const
pure virtual

Implemented in polyfem::mesh::CMesh2D, and polyfem::mesh::NCMesh2D.

Referenced by polyfem::basis::compute_epsilon(), get_edges(), next_around_face(), polyfem::basis::LagrangeBasis2d::quad_edge_local_nodes(), and polyfem::basis::LagrangeBasis2d::tri_edge_local_nodes().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: