PolyFEM
Loading...
Searching...
No Matches
polyfem::mesh::LocalMesh< M > Class Template Reference

#include <LocalMesh.hpp>

Public Member Functions

 LocalMesh (const M &m, const std::vector< Tuple > &element_tuples, const bool include_global_boundary)
 
int num_local_vertices () const
 Number of vertices in the local mesh (not including extra global boundary vertices).
 
int num_vertices () const
 Number of vertices in the local mesh.
 
int num_elements () const
 Number of elements.
 
const Eigen::MatrixXd & rest_positions () const
 Rest positions of the vertices.
 
const Eigen::MatrixXd & positions () const
 Deformed positions of the vertices.
 
Eigen::MatrixXd displacements () const
 Displacements of the vertices.
 
const Eigen::MatrixXd & projection_quantities () const
 Projection quantaties for each vertex.
 
const Eigen::MatrixXi & elements () const
 Elements in the local mesh.
 
const Eigen::MatrixXi & boundary_edges () const
 Edged on the boundary.
 
const Eigen::MatrixXi & boundary_faces () const
 Faces on the boundary (not set for TriMesh).
 
const std::unordered_map< int, int > & global_to_local () const
 Map from global vertex index to local vertex index.
 
const std::vector< int > & local_to_global () const
 Map from local vertex index to global vertex index.
 
const std::vector< int > & fixed_vertices () const
 Fixed vertices.
 
const Remesher::BoundaryMap< int > & boundary_ids () const
 Map from boundary elements (all edges for TriMesh or faces in TetMesh) to their boundary id.
 
const std::vector< int > & body_ids () const
 One body id per element.
 
Eigen::MatrixXi & boundary_facets ()
 Get a reference to the boundary facets (edges in 2D or faces in 3D).
 
const Eigen::MatrixXi & boundary_facets () const
 
std::vector< polyfem::basis::ElementBasesbuild_bases (const std::string &formulation)
 Build the ElementBases for the local mesh.
 
void reorder_vertices (const Eigen::VectorXi &permutation)
 Reorder the vertices of the local mesh.
 
void write_mesh (const std::string &path, const Eigen::MatrixXd &sol) const
 Write the local mesh to a VTU file.
 

Static Public Member Functions

static std::vector< Tuplen_ring (const M &m, const Tuple &center, const int n)
 Construct a local mesh as an n-ring around a vertex.
 
static std::vector< Tuplen_ring (const M &m, const std::vector< Tuple > &one_ring, const int n)
 
static std::vector< Tupleflood_fill_n_ring (const M &m, const Tuple &center, const double area)
 Construct a local mesh as an n-ring around a vertex.
 
static std::vector< Tupleball_selection (const M &m, const VectorNd &center, const double rel_radius, const int n_ring_size)
 

Protected Types

using Tuple = typename M::Tuple
 

Protected Member Functions

void remove_duplicate_fixed_vertices ()
 
void init_local_to_global ()
 
void init_vertex_attributes (const M &m)
 

Protected Attributes

Eigen::MatrixXd m_rest_positions
 Rest positions of the vertices.
 
Eigen::MatrixXd m_positions
 Deformed positions of the vertices.
 
Eigen::MatrixXd m_projection_quantities
 Projection quantaties for each vertex.
 
Eigen::MatrixXi m_elements
 Elements in the local mesh.
 
Eigen::MatrixXi m_boundary_edges
 Edged on the boundary.
 
Eigen::MatrixXi m_boundary_faces
 Faces on the boundary (not set for TriMesh).
 
int m_num_local_vertices
 Number of vertices in the local mesh (not including extra global boundary vertices).
 
std::unordered_map< int, int > m_global_to_local
 Map from global vertex index to local vertex index.
 
std::vector< int > m_local_to_global
 Map from local vertex index to global vertex index.
 
std::vector< int > m_fixed_vertices
 Fixed vertices.
 
Remesher::BoundaryMap< int > m_boundary_ids
 Map from boundary elements (all edges for TriMesh or faces in TetMesh) to their boundary id.
 
std::vector< int > m_body_ids
 One body id per element.
 

Detailed Description

template<typename M>
class polyfem::mesh::LocalMesh< M >

Definition at line 12 of file LocalMesh.hpp.

Member Typedef Documentation

◆ Tuple

template<typename M >
using polyfem::mesh::LocalMesh< M >::Tuple = typename M::Tuple
protected

Definition at line 15 of file LocalMesh.hpp.

Constructor & Destructor Documentation

◆ LocalMesh()

template<typename M >
polyfem::mesh::LocalMesh< M >::LocalMesh ( const M &  m,
const std::vector< Tuple > &  element_tuples,
const bool  include_global_boundary 
)

Member Function Documentation

◆ ball_selection()

template<typename M >
std::vector< typename M::Tuple > polyfem::mesh::LocalMesh< M >::ball_selection ( const M &  m,
const VectorNd center,
const double  rel_radius,
const int  n_ring_size 
)
static

Definition at line 331 of file LocalMesh.cpp.

References polyfem::utils::are_aabbs_intersecting(), POLYFEM_REMESHER_SCOPED_TIMER, polyfem::utils::tetrahedron_intersects_ball(), and polyfem::utils::triangle_intersects_disk().

Referenced by polyfem::mesh::PhysicsRemesher< WMTKMesh >::local_mesh_tuples().

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

◆ body_ids()

template<typename M >
const std::vector< int > & polyfem::mesh::LocalMesh< M >::body_ids ( ) const
inline

One body id per element.

Definition at line 83 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_body_ids.

◆ boundary_edges()

template<typename M >
const Eigen::MatrixXi & polyfem::mesh::LocalMesh< M >::boundary_edges ( ) const
inline

Edged on the boundary.

Definition at line 66 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_boundary_edges.

◆ boundary_faces()

template<typename M >
const Eigen::MatrixXi & polyfem::mesh::LocalMesh< M >::boundary_faces ( ) const
inline

Faces on the boundary (not set for TriMesh).

Definition at line 68 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_boundary_faces.

◆ boundary_facets() [1/2]

template<typename M >
Eigen::MatrixXi & polyfem::mesh::LocalMesh< M >::boundary_facets ( )

Get a reference to the boundary facets (edges in 2D or faces in 3D).

Todo:
Make this const.

Definition at line 467 of file LocalMesh.cpp.

◆ boundary_facets() [2/2]

template<typename M >
const Eigen::MatrixXi & polyfem::mesh::LocalMesh< M >::boundary_facets ( ) const

Definition at line 476 of file LocalMesh.cpp.

◆ boundary_ids()

template<typename M >
const Remesher::BoundaryMap< int > & polyfem::mesh::LocalMesh< M >::boundary_ids ( ) const
inline

Map from boundary elements (all edges for TriMesh or faces in TetMesh) to their boundary id.

Definition at line 80 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_boundary_ids.

◆ build_bases()

template<typename M >
std::vector< polyfem::basis::ElementBases > polyfem::mesh::LocalMesh< M >::build_bases ( const std::string &  formulation)

Build the ElementBases for the local mesh.

Note
Reorders the vertices to match the order of the ElementBases.
Parameters
formulationEnergy formulation.
Returns
ElementBases for the local mesh.

Definition at line 573 of file LocalMesh.cpp.

References polyfem::mesh::Remesher::build_bases(), polyfem::mesh::Mesh::create(), and POLYFEM_REMESHER_SCOPED_TIMER.

Here is the call graph for this function:

◆ displacements()

template<typename M >
Eigen::MatrixXd polyfem::mesh::LocalMesh< M >::displacements ( ) const
inline

Displacements of the vertices.

Definition at line 58 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_positions, and polyfem::mesh::LocalMesh< M >::m_rest_positions.

◆ elements()

template<typename M >
const Eigen::MatrixXi & polyfem::mesh::LocalMesh< M >::elements ( ) const
inline

Elements in the local mesh.

Definition at line 64 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_elements.

◆ fixed_vertices()

template<typename M >
const std::vector< int > & polyfem::mesh::LocalMesh< M >::fixed_vertices ( ) const
inline

Fixed vertices.

Definition at line 77 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_fixed_vertices.

◆ flood_fill_n_ring()

template<typename M >
std::vector< typename M::Tuple > polyfem::mesh::LocalMesh< M >::flood_fill_n_ring ( const M &  m,
const Tuple center,
const double  area 
)
static

Construct a local mesh as an n-ring around a vertex.

Definition at line 279 of file LocalMesh.cpp.

References POLYFEM_REMESHER_SCOPED_TIMER.

◆ global_to_local()

template<typename M >
const std::unordered_map< int, int > & polyfem::mesh::LocalMesh< M >::global_to_local ( ) const
inline

Map from global vertex index to local vertex index.

Definition at line 71 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_global_to_local.

◆ init_local_to_global()

template<typename M >
void polyfem::mesh::LocalMesh< M >::init_local_to_global ( )
protected

Definition at line 493 of file LocalMesh.cpp.

◆ init_vertex_attributes()

template<typename M >
void polyfem::mesh::LocalMesh< M >::init_vertex_attributes ( const M &  m)
protected

Definition at line 504 of file LocalMesh.cpp.

◆ local_to_global()

template<typename M >
const std::vector< int > & polyfem::mesh::LocalMesh< M >::local_to_global ( ) const
inline

Map from local vertex index to global vertex index.

Definition at line 74 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_local_to_global.

◆ n_ring() [1/2]

template<typename M >
std::vector< typename M::Tuple > polyfem::mesh::LocalMesh< M >::n_ring ( const M &  m,
const std::vector< Tuple > &  one_ring,
const int  n 
)
static

Definition at line 230 of file LocalMesh.cpp.

References POLYFEM_REMESHER_SCOPED_TIMER.

◆ n_ring() [2/2]

template<typename M >
std::vector< typename M::Tuple > polyfem::mesh::LocalMesh< M >::n_ring ( const M &  m,
const Tuple center,
const int  n 
)
static

Construct a local mesh as an n-ring around a vertex.

Definition at line 223 of file LocalMesh.cpp.

◆ num_elements()

template<typename M >
int polyfem::mesh::LocalMesh< M >::num_elements ( ) const
inline

Number of elements.

Definition at line 50 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_elements.

◆ num_local_vertices()

template<typename M >
int polyfem::mesh::LocalMesh< M >::num_local_vertices ( ) const
inline

Number of vertices in the local mesh (not including extra global boundary vertices).

Definition at line 46 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_num_local_vertices.

◆ num_vertices()

template<typename M >
int polyfem::mesh::LocalMesh< M >::num_vertices ( ) const
inline

Number of vertices in the local mesh.

Definition at line 48 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_rest_positions.

◆ positions()

template<typename M >
const Eigen::MatrixXd & polyfem::mesh::LocalMesh< M >::positions ( ) const
inline

Deformed positions of the vertices.

Definition at line 55 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_positions.

◆ projection_quantities()

template<typename M >
const Eigen::MatrixXd & polyfem::mesh::LocalMesh< M >::projection_quantities ( ) const
inline

Projection quantaties for each vertex.

Definition at line 61 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_projection_quantities.

◆ remove_duplicate_fixed_vertices()

template<typename M >
void polyfem::mesh::LocalMesh< M >::remove_duplicate_fixed_vertices ( )
protected

Definition at line 485 of file LocalMesh.cpp.

◆ reorder_vertices()

template<typename M >
void polyfem::mesh::LocalMesh< M >::reorder_vertices ( const Eigen::VectorXi &  permutation)

Reorder the vertices of the local mesh.

Parameters
permutationMap from old vertex index to new vertex index.

Definition at line 523 of file LocalMesh.cpp.

References polyfem::utils::map_index_matrix(), and polyfem::utils::reorder_matrix().

Here is the call graph for this function:

◆ rest_positions()

template<typename M >
const Eigen::MatrixXd & polyfem::mesh::LocalMesh< M >::rest_positions ( ) const
inline

Rest positions of the vertices.

Definition at line 53 of file LocalMesh.hpp.

References polyfem::mesh::LocalMesh< M >::m_rest_positions.

◆ write_mesh()

template<typename M >
void polyfem::mesh::LocalMesh< M >::write_mesh ( const std::string &  path,
const Eigen::MatrixXd &  sol 
) const

Write the local mesh to a VTU file.

Parameters
pathFilename to write to.
solSolution to write to the file.

Definition at line 607 of file LocalMesh.cpp.

References polyfem::utils::unflatten().

Here is the call graph for this function:

Member Data Documentation

◆ m_body_ids

template<typename M >
std::vector<int> polyfem::mesh::LocalMesh< M >::m_body_ids
protected

One body id per element.

Definition at line 144 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::body_ids().

◆ m_boundary_edges

template<typename M >
Eigen::MatrixXi polyfem::mesh::LocalMesh< M >::m_boundary_edges
protected

Edged on the boundary.

Definition at line 123 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::boundary_edges().

◆ m_boundary_faces

template<typename M >
Eigen::MatrixXi polyfem::mesh::LocalMesh< M >::m_boundary_faces
protected

Faces on the boundary (not set for TriMesh).

Definition at line 126 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::boundary_faces().

◆ m_boundary_ids

template<typename M >
Remesher::BoundaryMap<int> polyfem::mesh::LocalMesh< M >::m_boundary_ids
protected

Map from boundary elements (all edges for TriMesh or faces in TetMesh) to their boundary id.

Definition at line 141 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::boundary_ids().

◆ m_elements

template<typename M >
Eigen::MatrixXi polyfem::mesh::LocalMesh< M >::m_elements
protected

Elements in the local mesh.

Definition at line 120 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::elements(), and polyfem::mesh::LocalMesh< M >::num_elements().

◆ m_fixed_vertices

template<typename M >
std::vector<int> polyfem::mesh::LocalMesh< M >::m_fixed_vertices
protected

Fixed vertices.

Definition at line 138 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::fixed_vertices().

◆ m_global_to_local

template<typename M >
std::unordered_map<int, int> polyfem::mesh::LocalMesh< M >::m_global_to_local
protected

Map from global vertex index to local vertex index.

Definition at line 132 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::global_to_local().

◆ m_local_to_global

template<typename M >
std::vector<int> polyfem::mesh::LocalMesh< M >::m_local_to_global
protected

Map from local vertex index to global vertex index.

Definition at line 135 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::local_to_global().

◆ m_num_local_vertices

template<typename M >
int polyfem::mesh::LocalMesh< M >::m_num_local_vertices
protected

Number of vertices in the local mesh (not including extra global boundary vertices).

Definition at line 129 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::num_local_vertices().

◆ m_positions

template<typename M >
Eigen::MatrixXd polyfem::mesh::LocalMesh< M >::m_positions
protected

Deformed positions of the vertices.

Definition at line 114 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::displacements(), and polyfem::mesh::LocalMesh< M >::positions().

◆ m_projection_quantities

template<typename M >
Eigen::MatrixXd polyfem::mesh::LocalMesh< M >::m_projection_quantities
protected

Projection quantaties for each vertex.

Definition at line 117 of file LocalMesh.hpp.

Referenced by polyfem::mesh::LocalMesh< M >::projection_quantities().

◆ m_rest_positions

template<typename M >
Eigen::MatrixXd polyfem::mesh::LocalMesh< M >::m_rest_positions
protected

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