Wildmeshing Toolkit
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
wmtk::TetMesh Class Reference
Inheritance diagram for wmtk::TetMesh:
app::interior_tet_opt::InteriorTetOpt harmonic_tet::HarmonicTet

Classes

class  SmartTuple
 
class  TetrahedronConnectivity
 
class  Tuple
 a Tuple refers to a global vid and a global tet id, and a local edge id and local face id More...
 
class  VertexConnectivity
 
class  VertexMutex
 

Public Types

template<typename T >
using vector = tbb::concurrent_vector< T >
 

Public Member Functions

size_t vert_capacity () const
 get the current largest global vid
 
size_t tet_capacity () const
 get the current largest global tid
 
size_t vertex_size () const
 get the number of unremoved verticies
 
size_t tet_size () const
 get the number of unremoved tets
 
void init (size_t n_vertices, const std::vector< std::array< size_t, 4 > > &tets)
 
void init_with_isolated_vertices (size_t n_vertices, const std::vector< std::array< size_t, 4 > > &tets)
 
void init (const MatrixXi &T)
 Generate the connectivity of the mesh from an IGL-style T matrix.
 
bool split_edge (const Tuple &t, std::vector< Tuple > &new_tets)
 
virtual bool collapse_edge (const Tuple &t, std::vector< Tuple > &new_tets)
 
bool link_condition (const Tuple &t)
 
bool collapse_edge_conn (const Tuple &loc0, std::vector< Tuple > &new_edges, size_t &v1_id, Tuple &new_loc, std::map< size_t, wmtk::TetMesh::VertexConnectivity > &rollback_vert_conn, std::vector< size_t > &n1_t_ids_copy, std::vector< size_t > &new_tet_id, std::vector< TetrahedronConnectivity > &old_tets)
 
bool collapse_edge_check_topology (const std::vector< size_t > &new_tet_id)
 Check topology after collapse connectivity change. This is a sanity check and should not be necessary.
 
void collapse_edge_rollback (size_t &v1_id, std::map< size_t, wmtk::TetMesh::VertexConnectivity > &rollback_vert_conn, std::vector< size_t > &n1_t_ids, std::vector< size_t > &new_tet_id, std::vector< TetrahedronConnectivity > &old_tets)
 
bool swap_edge_56 (const Tuple &t, std::vector< Tuple > &new_tets)
 
bool swap_edge_44 (const Tuple &t, std::vector< Tuple > &new_tets)
 
bool swap_edge (const Tuple &t, std::vector< Tuple > &new_tets)
 3-2 edge swap
 
bool swap_face (const Tuple &t, std::vector< Tuple > &new_tets)
 2-3 face swap
 
bool smooth_vertex (const Tuple &t)
 
bool split_tet (const Tuple &t, std::vector< Tuple > &new_tets)
 Split a tet in 4 tets.
 
bool split_face (const Tuple &t, std::vector< Tuple > &new_tets)
 Split a face in 3 faces.
 
void triangle_insertion (const std::vector< Tuple > &intersected_tets, const std::vector< Tuple > &intersected_edges, std::vector< size_t > &new_edge_vids, std::vector< size_t > &new_center_vids, std::vector< std::array< size_t, 4 > > &center_split_tets)
 Insert a triangle into a tetmesh, with known intersection information.
 
bool insert_point (const Tuple &t, std::vector< Tuple > &new_tets)
 Insert a point into a tetmesh inside a tet. In general position, this split a tet into 4. In face position, split two tets. In edge position, In point position, do nothing.
 
virtual bool insert_point_before (const Tuple &t)
 
virtual bool insert_point_after (std::vector< Tuple > &new_tets)
 
void consolidate_mesh ()
 cleans up the deleted vertices or tetrahedra, fixes the corresponding indices, and reset the version number. WARNING: it invalidates all tuples!
 
std::vector< Tupleget_edges () const
 
std::vector< Tupleget_faces () const
 
std::vector< Tupleget_vertices () const
 
std::vector< Tupleget_tets () const
 
virtual void for_each_face (const std::function< void(const TetMesh::Tuple &)> &)
 looping through all the unique edges and perform the given function
 
virtual bool invariants (const std::vector< Tuple > &)
 
Tuple tuple_from_edge (size_t tid, int local_eid) const
 get a Tuple from global tetra index and local edge index (from 0-5).
 
Tuple tuple_from_edge (const std::array< size_t, 2 > &vids) const
 get a Tuple from global vids of the 2 end of an edge
 
Tuple tuple_from_face (size_t tid, int local_fid) const
 get a Tuple from global tetra index and local face index (from 0-3).
 
std::tuple< Tuple, size_t > tuple_from_face (const std::array< size_t, 3 > &vids) const
 get a Tuple and the global face index from global vertex index of the face.
 
std::tuple< Tuple, size_t > tuple_from_face (const simplex::Face &f) const
 
Tuple tuple_from_vertex (size_t vid) const
 get a Tuple from global vertex index
 
Tuple tuple_from_tet (size_t tid) const
 get a Tuple from global tetra index
 
Tuple tuple_from_vids (size_t vid0, size_t vid1, size_t vid2, size_t vid3) const
 Get a Tuple from global vertex IDs.
 
simplex::Tet simplex_from_tet (const Tuple &t) const
 
simplex::Tet simplex_from_tet (const size_t tid) const
 
Tuple switch_vertex (const Tuple &t) const
 wrapper function from Tuple::switch_vertex
 
Tuple switch_edge (const Tuple &t) const
 wrapper function from Tuple::switch_edge
 
Tuple switch_face (const Tuple &t) const
 wrapper function from Tuple::switch_face
 
std::optional< Tupleswitch_tetrahedron (const Tuple &t) const
 wrapper function from Tuple::switch_tetrahedron
 
std::vector< Tupleget_one_ring_tets_for_vertex (const Tuple &t) const
 Get the one ring tets for a vertex.
 
std::vector< size_t > get_one_ring_tids_for_vertex (const Tuple &t) const
 Get the one ring tids for vertex.
 
std::vector< size_t > get_one_ring_tids_for_vertex (const size_t vid) const
 
std::vector< Tupleget_one_ring_vertices_for_vertex (const Tuple &t) const
 Get the one ring vertices for a vertex.
 
std::vector< size_t > get_one_ring_vids_for_vertex (size_t vid, std::vector< size_t > &cache)
 Get the one ring vids for vertex.
 
std::vector< size_t > get_one_ring_vids_for_vertex (size_t vid) const
 Get the one ring vids for vertex.
 
std::vector< size_t > get_one_ring_vids_for_vertex_adj (size_t vid) const
 Duplicate of the function TetMesh::get_one_ring_vids_for_vertex.
 
std::vector< size_t > get_one_ring_vids_for_vertex_adj (size_t vid, std::vector< size_t > &cache)
 Duplicate of the function TetMesh::get_one_ring_vids_for_vertex.
 
std::vector< Tupleget_incident_tets_for_edge (const Tuple &t) const
 Get the incident tets for edge.
 
std::vector< Tupleget_incident_tets_for_edge (const size_t vid0, const size_t vid1) const
 
std::vector< size_t > get_incident_tids_for_edge (const Tuple &t) const
 
std::vector< size_t > get_incident_tids_for_edge (const size_t vid0, const size_t vid1) const
 
std::vector< Tupleget_one_ring_tets_for_edge (const Tuple &t) const
 Get the one ring tets for edge.
 
std::vector< std::array< size_t, 3 > > vertex_adjacent_boundary_faces (const Tuple &t) const
 
std::array< Tuple, 4 > oriented_tet_vertices (const Tuple &t) const
 
std::array< size_t, 4 > oriented_tet_vids (const Tuple &t) const
 
std::array< size_t, 4 > oriented_tet_vids (const size_t tid) const
 
std::array< Tuple, 3 > get_face_vertices (const Tuple &t) const
 Get the 3 vertices of a face represented by Tuple.
 
std::array< size_t, 3 > get_face_vids (const Tuple &t) const
 
std::array< Tuple, 6 > tet_edges (const Tuple &t) const
 get the 6 edges of a tet represented by Tuples
 
void check_tuple_validity (const Tuple &t) const
 
bool check_mesh_connectivity_validity () const
 checks the validity of the connectivity of the mesh. Including the validity of each Tuple
 
void remove_tets_by_ids (const std::vector< size_t > &tids)
 remove the tetrahedrons in the mesh that have given tet ids
 
void start_protect_attributes ()
 
void release_protect_attributes ()
 
void rollback_protected_attributes ()
 
int release_vertex_mutex_in_stack ()
 
bool try_set_vertex_mutex_two_ring (const Tuple &v, int threadid)
 try lock the two-ring neighboring traingles' incident vertices
 
bool try_set_vertex_mutex_two_ring_vid (const Tuple &v, int threadid)
 try lock the two-ring neighboring traingles' incident vertices using vids
 
bool try_set_vertex_mutex_two_ring_vid (size_t v, int threadid)
 a duplicate of ConcurrentTetMesh::try_set_vertex_mutex_two_ring_vid that gets vids using the vid of the input Tuple
 
bool try_set_edge_mutex_two_ring (const Tuple &e, int threadid=0)
 try lock the two-ring neighboring triangles' incident vertices for the two ends of an edge
 
bool try_set_face_mutex_two_ring (const Tuple &f, int threadid=0)
 try lock the two-ring neighboring triangles' incident vertices for the 3 vertices of a face
 
bool try_set_face_mutex_two_ring (const Tuple &v1, const Tuple &v2, const Tuple &v3, int threadid=0)
 locking the two-ring neighboring triangles' incident vertices given the 3 vertex Tuples of the face
 
bool try_set_face_mutex_two_ring (size_t v1, size_t v2, size_t v3, int threadid=0)
 a duplicate of ConcurrentTetMesh::try_set_face_mutex_two_ring usign the vids of the 3 vertices of a face
 
bool try_set_vertex_mutex_one_ring (const Tuple &v, int threadid=0)
 try lock the one-ring neighboring traingles' incident vertices
 
void for_each_edge (const std::function< void(const TetMesh::Tuple &)> &)
 perform the given function for each edge
 
void for_each_vertex (const std::function< void(const TetMesh::Tuple &)> &)
 perform the given function for each vertex
 
void for_each_tetra (const std::function< void(const TetMesh::Tuple &)> &)
 perform the given function for each tet
 

Public Attributes

AbstractAttributeContainerp_vertex_attrs = nullptr
 
AbstractAttributeContainerp_edge_attrs = nullptr
 
AbstractAttributeContainerp_face_attrs = nullptr
 
AbstractAttributeContainerp_tet_attrs = nullptr
 
bool m_collapse_check_link_condition = true
 
bool m_collapse_check_topology = false
 
bool m_collapse_check_manifold = true
 
tbb::enumerable_thread_specific< std::vector< size_t > > mutex_release_stack
 
tbb::enumerable_thread_specific< std::vector< size_t > > get_one_ring_cache
 
int NUM_THREADS = 0
 

Protected Member Functions

virtual bool triangle_insertion_before (const std::vector< Tuple > &faces)
 
virtual bool triangle_insertion_after (const std::vector< std::vector< Tuple > > &)
 
virtual bool split_edge_before (const Tuple &t)
 User specified preparations and desideratas for an edge split before changing the connectivity.
 
virtual bool split_edge_after (const Tuple &t)
 This function computes the attributes for the added simplices. User specified modifications and desideratas for after an edge split.
 
virtual bool collapse_edge_before (const Tuple &t)
 User specified preparations and desideratas for an edge collapse before changing the connectivity.
 
virtual bool collapse_edge_after (const Tuple &t)
 User specified modifications and desideratas for after an edge collapse.
 
virtual bool swap_edge_44_before (const Tuple &t)
 User specified preparations and desideratas for an 4-4 edge swap before changing the connectivity.
 
virtual double swap_edge_44_energy (const std::vector< std::array< size_t, 4 > > &tets, const int op_case)
 User specified energy to decide which of the 4 possible orientations should be chosen.
 
virtual bool swap_edge_44_after (const Tuple &t)
 User specified modifications and desideratas for after a 4-4 edge swap.
 
virtual bool swap_edge_56_before (const Tuple &t)
 User specified preparations and desideratas for a 5-6 edge swap before changing the connectivity.
 
virtual double swap_edge_56_energy (const std::vector< std::array< size_t, 4 > > &tets, const int op_case)
 User specified energy to decide which of the 5 possible orientations should be chosen.
 
virtual bool swap_edge_56_after (const Tuple &t)
 User specified modifications and desideratas for after a 5-6 edge swap.
 
virtual bool swap_edge_before (const Tuple &t)
 User specified preparations and desideratas for an 3-2 edge swap before changing the conenctivity.
 
virtual bool swap_edge_after (const Tuple &t)
 User specified modifications and desideratas for after a 3-2 edge swap.
 
virtual bool swap_face_before (const Tuple &t)
 User specified preparations and desideratas for an 2-3 face swap befroe changing the geometry.
 
virtual bool swap_face_after (const Tuple &t)
 User specified modifications and desideratas for after a 2-3 face swap.
 
virtual bool smooth_before (const Tuple &t)
 User specified preparations and desideratas for smoothing a vertex.
 
virtual bool smooth_after (const Tuple &t)
 User specified modifications and desideratas for after smoothing a vertex.
 
virtual bool split_face_before (const Tuple &t)
 User specified preparations and desideratas for a face split before changing the connectivity.
 
virtual bool split_face_after (const Tuple &t)
 Compute the attributes for the added simplices.
 
virtual bool split_tet_before (const Tuple &t)
 User specified preparations and desideratas for a tet split before changing the connectivity.
 
virtual bool split_tet_after (const Tuple &t)
 Compute the attributes for the added simplices.
 
void resize_vertex_mutex (size_t v)
 

Private Member Functions

int get_next_empty_slot_t ()
 
int get_next_empty_slot_v ()
 
void subdivide_tets (const std::vector< size_t > t_ids, const std::vector< bool > &mark_surface, const std::map< std::array< size_t, 2 >, size_t > &map_edge2vid, std::map< std::array< size_t, 3 >, std::vector< std::array< size_t, 5 > > > &new_face_vids, const std::vector< size_t > &new_vids, std::vector< size_t > &new_tids, std::vector< size_t > &new_center_vids, std::vector< std::array< size_t, 4 > > &center_split_tets)
 
void subdivide_a_tet (size_t t_id, const std::array< int, 6 > &new_v_ids, bool mark_surface, std::map< std::array< size_t, 3 >, std::vector< std::array< size_t, 5 > > > &new_face_vids, std::vector< size_t > &new_tids, std::vector< size_t > &new_center_vids, std::vector< std::array< size_t, 4 > > &center_split_tets)
 
std::map< size_t, VertexConnectivityoperation_update_connectivity_impl (std::vector< size_t > &affected_tid, const std::vector< std::array< size_t, 4 > > &new_tet_conn)
 
void operation_failure_rollback_imp (std::map< size_t, VertexConnectivity > &rollback_vert_conn, const std::vector< size_t > &affected, const std::vector< size_t > &new_tet_id, const std::vector< TetrahedronConnectivity > &old_tets)
 
std::map< size_t, VertexConnectivityoperation_update_connectivity_impl (const std::vector< size_t > &remove_id, const std::vector< std::array< size_t, 4 > > &new_tet_conn, std::vector< size_t > &allocate_id)
 
bool try_set_vertex_mutex (const Tuple &v, int threadid)
 
bool try_set_vertex_mutex (size_t vid, int threadid)
 
void unlock_vertex_mutex (const Tuple &v)
 
void unlock_vertex_mutex (size_t vid)
 

Static Private Member Functions

static std::vector< TetrahedronConnectivityrecord_old_tet_connectivity (const TetMesh::vector< TetrahedronConnectivity > &conn, const std::vector< size_t > &tets)
 

Private Attributes

vector< VertexConnectivitym_vertex_connectivity
 
vector< TetrahedronConnectivitym_tet_connectivity
 
std::atomic_long current_vert_size
 
std::atomic_long current_tet_size
 
tbb::spin_mutex vertex_connectivity_lock
 
tbb::spin_mutex tet_connectivity_lock
 
bool vertex_connectivity_synchronizing_flag = false
 
bool tet_connectivity_synchronizing_flag = false
 
int MAX_THREADS = 128
 
int m_t_empty_slot = 0
 
int m_v_empty_slot = 0
 
tbb::concurrent_vector< VertexMutexm_vertex_mutex
 

Static Private Attributes

static constexpr std::array< std::array< int, 2 >, 6 > m_local_edges
 local edges within a tet
 
static constexpr std::array< int, 4 > m_map_vertex2edge = {{0, 0, 1, 3}}
 
static constexpr std::array< int, 4 > m_map_vertex2oppo_face = {{3, 1, 2, 0}}
 
static constexpr std::array< int, 6 > m_map_edge2face = {{0, 0, 0, 1, 2, 1}}
 
static constexpr std::array< std::array< int, 3 >, 4 > m_local_faces
 
static constexpr std::array< std::array< int, 3 >, 4 > m_local_edges_in_a_face
 

Member Function Documentation

◆ check_mesh_connectivity_validity()

bool wmtk::TetMesh::check_mesh_connectivity_validity ( ) const

checks the validity of the connectivity of the mesh. Including the validity of each Tuple

Returns
true if the mesh is valid

◆ check_tuple_validity()

void wmtk::TetMesh::check_tuple_validity ( const Tuple t) const
inline

wrapper function for Tuple::check_validity

◆ collapse_edge()

bool wmtk::TetMesh::collapse_edge ( const Tuple t,
std::vector< Tuple > &  new_tets 
)
virtual

Collapse an edge

Parameters
tInput Tuple for the edge to collapse.
[out]new_tetsa vector of Tuples for all the newly introduced tetra.
Returns
if collapse succeed

◆ collapse_edge_after()

virtual bool wmtk::TetMesh::collapse_edge_after ( const Tuple t)
inlineprotectedvirtual

User specified modifications and desideratas for after an edge collapse.

Parameters
tedge Tuple that's collapsed
Returns
true if the modification succeed

Reimplemented in app::interior_tet_opt::InteriorTetOpt.

◆ collapse_edge_before()

virtual bool wmtk::TetMesh::collapse_edge_before ( const Tuple t)
inlineprotectedvirtual

User specified preparations and desideratas for an edge collapse before changing the connectivity.

Parameters
tedge Tuple to be collapsed
Returns
true is the preparation succeed

Reimplemented in app::interior_tet_opt::InteriorTetOpt.

◆ collapse_edge_check_topology()

bool wmtk::TetMesh::collapse_edge_check_topology ( const std::vector< size_t > &  new_tet_id)

Check topology after collapse connectivity change. This is a sanity check and should not be necessary.

Parameters
new_tet_idnew tet ids added to v2
Returns
if true the topology is valid

◆ collapse_edge_conn()

bool wmtk::TetMesh::collapse_edge_conn ( const Tuple loc0,
std::vector< Tuple > &  new_edges,
size_t &  v1_id,
Tuple new_loc,
std::map< size_t, wmtk::TetMesh::VertexConnectivity > &  rollback_vert_conn,
std::vector< size_t > &  n1_t_ids_copy,
std::vector< size_t > &  new_tet_id,
std::vector< TetrahedronConnectivity > &  old_tets 
)

Collapse edge connectivity change part. Constains a link condition check and the connecticity update

Parameters
loc0Input Tuple for the edge to collapse
[out]new_tetsa vector of Tuples for all the newly introduced tetra.
[out]v1_idvertex id of the input tuple
[out]new_locresult vertex tuple
[out]rollback_vert_connvertex connectivity got changed and will be involed in rollback
[out]n1_t_ids_copyorigninal (before collape) one ring tet ids connected to the input vertex
[out]new_tet_idnew tet ids added to v2
[out]old_tetstets tv connectivities in n1_t_ids_copy
Returns
if true collapse pass link condition check

backup of everything

◆ collapse_edge_rollback()

void wmtk::TetMesh::collapse_edge_rollback ( size_t &  v1_id,
std::map< size_t, wmtk::TetMesh::VertexConnectivity > &  rollback_vert_conn,
std::vector< size_t > &  n1_t_ids,
std::vector< size_t > &  new_tet_id,
std::vector< TetrahedronConnectivity > &  old_tets 
)

rollback function for collapse edges

Parameters
[out]v1_idvertex id of the input tuple
[out]rollback_vert_connvertex connectivity got changed and will be involed in rollback
[out]n1_t_idsorigninal (before collape) one ring tet ids connected to the input vertex
[out]new_tet_idnew tet ids added to v2
[out]old_tetstets tv connectivities in n1_t_ids

◆ for_each_face()

void wmtk::TetMesh::for_each_face ( const std::function< void(const TetMesh::Tuple &)> &  func)
virtual

looping through all the unique edges and perform the given function

looping through all the unique faces and perform the given function

◆ get_edges()

std::vector< TetMesh::Tuple > wmtk::TetMesh::get_edges ( ) const

Get all unique undirected edges in the mesh.

Returns
std::vector<Tuple> each Tuple owns a distinct edge.

◆ get_face_vertices()

std::array< TetMesh::Tuple, 3 > wmtk::TetMesh::get_face_vertices ( const Tuple t) const

Get the 3 vertices of a face represented by Tuple.

Parameters
t
Returns
std::array<Tuple, 3> an array of 3 Tuple points to the 3 vertices of a face

◆ get_faces()

std::vector< TetMesh::Tuple > wmtk::TetMesh::get_faces ( ) const

Get all unique faces in the mesh.

Returns
std::vector<Tuple> each Tuple owns a distinct face.

◆ get_incident_tets_for_edge()

std::vector< TetMesh::Tuple > wmtk::TetMesh::get_incident_tets_for_edge ( const Tuple t) const

Get the incident tets for edge.

Parameters
ttuple pointing to an edge
Returns
incident tets

◆ get_one_ring_tets_for_edge()

std::vector< TetMesh::Tuple > wmtk::TetMesh::get_one_ring_tets_for_edge ( const Tuple t) const

Get the one ring tets for edge.

Parameters
ttuple pointing to an edge
Returns
one ring

◆ get_one_ring_tets_for_vertex()

std::vector< TetMesh::Tuple > wmtk::TetMesh::get_one_ring_tets_for_vertex ( const Tuple t) const

Get the one ring tets for a vertex.

Parameters
ttuple pointing to a vertex
Returns
one-ring

◆ get_one_ring_tids_for_vertex()

std::vector< size_t > wmtk::TetMesh::get_one_ring_tids_for_vertex ( const Tuple t) const

Get the one ring tids for vertex.

Parameters
ta Tuple that refers to a vertex
Returns
std::vector<size_t> a vector of vids

◆ get_one_ring_vertices_for_vertex()

std::vector< TetMesh::Tuple > wmtk::TetMesh::get_one_ring_vertices_for_vertex ( const Tuple t) const

Get the one ring vertices for a vertex.

Parameters
ttuple pointing to a vertex
Returns
a vector of Tupels that refers to the one-ring vertices

◆ get_one_ring_vids_for_vertex() [1/2]

std::vector< size_t > wmtk::TetMesh::get_one_ring_vids_for_vertex ( size_t  vid) const

Get the one ring vids for vertex.

Parameters
vidsize_t type vertex id
Returns
std::vector<size_t> a vecotr of unique one-ring vids

◆ get_one_ring_vids_for_vertex() [2/2]

std::vector< size_t > wmtk::TetMesh::get_one_ring_vids_for_vertex ( size_t  vid,
std::vector< size_t > &  cache 
)

Get the one ring vids for vertex.

Parameters
vidsize_t type vertex id
[output]cache stores a verctor of vids with duplicate
Returns
std::vector<size_t> vectotr of one-ring vids

◆ get_tets()

std::vector< TetMesh::Tuple > wmtk::TetMesh::get_tets ( ) const

Get all unique tet in the mesh.

Returns
std::vector<Tuple> each Tuple owns a distinct tet

◆ get_vertices()

std::vector< TetMesh::Tuple > wmtk::TetMesh::get_vertices ( ) const

Get all unique vertices in the mesh.

Returns
std::vector<Tuple> each Tuple owns a distinct vertex

◆ init() [1/2]

void wmtk::TetMesh::init ( const MatrixXi &  T)

Generate the connectivity of the mesh from an IGL-style T matrix.

Parameters
Tby 4 list of vertex indices.

◆ init() [2/2]

void wmtk::TetMesh::init ( size_t  n_vertices,
const std::vector< std::array< size_t, 4 > > &  tets 
)

Initialize TetMesh data structure

Parameters
n_verticesnumber of vertices
tetsvector of array. Each element represents one tet, which is defined by four vertices.
Note
Assuming oriented and manifold, but no embedding. The maximum index in tets should not exceed n_vertices

◆ insert_point()

bool wmtk::TetMesh::insert_point ( const Tuple t,
std::vector< Tuple > &  new_tets 
)

Insert a point into a tetmesh inside a tet. In general position, this split a tet into 4. In face position, split two tets. In edge position, In point position, do nothing.

Returns
true
false

◆ link_condition()

bool wmtk::TetMesh::link_condition ( const Tuple t)

Compute the link of a given simplex Return a tuple of sets for 1. vertices, 2. edges, and 3. faces.

◆ operation_update_connectivity_impl()

std::map< size_t, TetMesh::VertexConnectivity > wmtk::TetMesh::operation_update_connectivity_impl ( std::vector< size_t > &  remove_id,
const std::vector< std::array< size_t, 4 > > &  new_tet_conn 
)
private
Parameters
tet_conn
vert_conn
remove_idthis will be modified as new_tet_id, useful for rollback etc.
new_tet_conn
Returns
std::map<size_t, wmtk::TetMesh::VertexConnectivity>

◆ oriented_tet_vertices()

std::array< TetMesh::Tuple, 4 > wmtk::TetMesh::oriented_tet_vertices ( const Tuple t) const

Positively oriented 4 vertices (represented by Tuples) in a tetra.

Returns
std::array<Tuple, 4> each tuple owns a different vertex.

◆ oriented_tet_vids()

std::array< size_t, 4 > wmtk::TetMesh::oriented_tet_vids ( const Tuple t) const

Positively oriented 4 vertices ids in a tetra.

Returns
std::array<size_t, 4> of the vertex ids.

◆ remove_tets_by_ids()

void wmtk::TetMesh::remove_tets_by_ids ( const std::vector< size_t > &  tids)
inline

remove the tetrahedrons in the mesh that have given tet ids

Parameters
tids

◆ smooth_after()

virtual bool wmtk::TetMesh::smooth_after ( const Tuple t)
inlineprotectedvirtual

User specified modifications and desideratas for after smoothing a vertex.

Parameters
tTuple refering to a vertex
Returns
true if the preparation succeed

Reimplemented in harmonic_tet::HarmonicTet, and app::interior_tet_opt::InteriorTetOpt.

◆ smooth_before()

virtual bool wmtk::TetMesh::smooth_before ( const Tuple t)
inlineprotectedvirtual

User specified preparations and desideratas for smoothing a vertex.

Parameters
tTuple refering to a vertex Tuple
Returns
true if the preparation succeed

Reimplemented in app::interior_tet_opt::InteriorTetOpt.

◆ smooth_vertex()

bool wmtk::TetMesh::smooth_vertex ( const Tuple t)

Smooth a vertex

Parameters
tInput Tuple for the vertex
Note
no geometry changed here
Returns
if smooth succeed

◆ split_edge()

bool wmtk::TetMesh::split_edge ( const Tuple t,
std::vector< Tuple > &  new_tets 
)

Split an edge

Parameters
tInput Tuple for the edge to split.
[out]new_tetsa vector of Tuples for all the newly introduced tetra.
Returns
if split succeed

update connectivity

◆ split_edge_after()

virtual bool wmtk::TetMesh::split_edge_after ( const Tuple t)
inlineprotectedvirtual

This function computes the attributes for the added simplices. User specified modifications and desideratas for after an edge split.

Parameters
theedge Tuple to be split
Returns
true if the modification succeed

Reimplemented in app::interior_tet_opt::InteriorTetOpt.

◆ split_edge_before()

virtual bool wmtk::TetMesh::split_edge_before ( const Tuple t)
inlineprotectedvirtual

User specified preparations and desideratas for an edge split before changing the connectivity.

Parameters
theedge Tuple to be split
Returns
true if the preparation succeed

Reimplemented in app::interior_tet_opt::InteriorTetOpt.

◆ split_face()

bool wmtk::TetMesh::split_face ( const Tuple t,
std::vector< Tuple > &  new_tets 
)

Split a face in 3 faces.

The TetMesh is assumed to be face manifold, i.e., a face has at most two incident tets.

Parameters
tInput tuple for the face to split.
[out]new_tA vector of Tuples refering to the tets incident to the new vertex. introduced
Returns
true, if split succeed
   v2
   /|\
  / | \
 /  |  \
/t1 ^ t0\

/ / \ \ // t2 \ v0 --------— v1

◆ split_face_after()

virtual bool wmtk::TetMesh::split_face_after ( const Tuple t)
inlineprotectedvirtual

Compute the attributes for the added simplices.

User specified modifications and desideratas for after a face split

Parameters
tThe face tuple to be split.
Returns
true if the modification succeed

◆ split_face_before()

virtual bool wmtk::TetMesh::split_face_before ( const Tuple t)
inlineprotectedvirtual

User specified preparations and desideratas for a face split before changing the connectivity.

Parameters
tThe face tuple to be split.
Returns
true if the preparation succeed.

◆ split_tet()

bool wmtk::TetMesh::split_tet ( const Tuple t,
std::vector< Tuple > &  new_tets 
)

Split a tet in 4 tets.

Parameters
tInput tuple for the tet to split.
[out]new_tA vector of Tuples refering to the tets incident to the new vertex. introduced
Returns
true, if split succeed
    v2
    /|\
   / | \
  /  |  \
 /t1 X t0\
/ /(t3)\  \

// t2 \ v0 --------— v1

  • X is the new vertex
  • v3 is above X (not displayed)
  • t3 is below the new vertex

New tet vertex connectivity: t0: (X,1,2,3) <- modified old tet t1: (0,X,2,3) t2: (0,1,X,3) t3: (0,1,2,X)

◆ split_tet_after()

virtual bool wmtk::TetMesh::split_tet_after ( const Tuple t)
inlineprotectedvirtual

Compute the attributes for the added simplices.

User specified modifications and desideratas for after a tet split

Parameters
tThe tet tuple to be split.
Returns
true if the modification succeed

◆ split_tet_before()

virtual bool wmtk::TetMesh::split_tet_before ( const Tuple t)
inlineprotectedvirtual

User specified preparations and desideratas for a tet split before changing the connectivity.

Parameters
tThe tet tuple to be split.
Returns
true if the preparation succeed.

◆ subdivide_a_tet()

void wmtk::TetMesh::subdivide_a_tet ( size_t  t_id,
const std::array< int, 6 > &  new_v_ids,
bool  mark_surface,
std::map< std::array< size_t, 3 >, std::vector< std::array< size_t, 5 > > > &  new_face_vids,
std::vector< size_t > &  new_tids,
std::vector< size_t > &  new_center_vids,
std::vector< std::array< size_t, 4 > > &  center_split_tets 
)
private

track surface

◆ subdivide_tets()

void wmtk::TetMesh::subdivide_tets ( const std::vector< size_t >  t_ids,
const std::vector< bool > &  mark_surface,
const std::map< std::array< size_t, 2 >, size_t > &  map_edge2vid,
std::map< std::array< size_t, 3 >, std::vector< std::array< size_t, 5 > > > &  new_face_vids,
const std::vector< size_t > &  new_vids,
std::vector< size_t > &  new_tids,
std::vector< size_t > &  new_center_vids,
std::vector< std::array< size_t, 4 > > &  center_split_tets 
)
private

insert new vertices

record infos

insert new tets

update conn_tets

◆ swap_edge()

bool wmtk::TetMesh::swap_edge ( const Tuple t,
std::vector< Tuple > &  new_tets 
)

3-2 edge swap

Note
only swap internal edges, not on boundary.
Parameters
tInput Tuple for the edge to swap.
new_tetsa vector of Tuples for all the newly introduced tetra.
Returns
true if swap succeed

◆ swap_edge_44()

bool wmtk::TetMesh::swap_edge_44 ( const Tuple t,
std::vector< Tuple > &  new_tets 
)

Perform 4-4 swap between 2 tets

Parameters
tInput Tuple for the edge to swap.
[out]new_tetsa vector of Tuples for all the newly introduced tetra.
Returns
if swap succeed
Note
only happens on internal edges

◆ swap_edge_44_after()

virtual bool wmtk::TetMesh::swap_edge_44_after ( const Tuple t)
inlineprotectedvirtual

User specified modifications and desideratas for after a 4-4 edge swap.

Parameters
tedge Tuple that's swaped
Returns
true if the modification succeed

Reimplemented in app::interior_tet_opt::InteriorTetOpt.

◆ swap_edge_44_before()

virtual bool wmtk::TetMesh::swap_edge_44_before ( const Tuple t)
inlineprotectedvirtual

User specified preparations and desideratas for an 4-4 edge swap before changing the connectivity.

Parameters
tedge Tuple to be swaped
Returns
true if the preparation succeed

Reimplemented in app::interior_tet_opt::InteriorTetOpt.

◆ swap_edge_44_energy()

virtual double wmtk::TetMesh::swap_edge_44_energy ( const std::vector< std::array< size_t, 4 > > &  tets,
const int  op_case 
)
inlineprotectedvirtual

User specified energy to decide which of the 4 possible orientations should be chosen.

Accepts the last shown orientation if not overridden.

Parameters
tetsNew tets after performing a 4-4 swap.
op_caseThe operation case, where 0 are the tets before swap.
Returns
energy The swap giving the tets with the lowest energy are chosen.

◆ swap_edge_56()

bool wmtk::TetMesh::swap_edge_56 ( const Tuple t,
std::vector< Tuple > &  new_tets 
)

Perform 5-6 swap

Parameters
tInput Tuple for the edge to swap.
[out]new_tetsa vector of Tuples for all the newly introduced tetra.
Returns
true if swap succeed
Note
only happens on internal edges

◆ swap_edge_56_after()

virtual bool wmtk::TetMesh::swap_edge_56_after ( const Tuple t)
inlineprotectedvirtual

User specified modifications and desideratas for after a 5-6 edge swap.

Parameters
tedge Tuple that's swaped
Returns
true if the modification succeed

◆ swap_edge_56_before()

virtual bool wmtk::TetMesh::swap_edge_56_before ( const Tuple t)
inlineprotectedvirtual

User specified preparations and desideratas for a 5-6 edge swap before changing the connectivity.

Parameters
tedge Tuple to be swaped
Returns
true if the preparation succeed

◆ swap_edge_56_energy()

virtual double wmtk::TetMesh::swap_edge_56_energy ( const std::vector< std::array< size_t, 4 > > &  tets,
const int  op_case 
)
inlineprotectedvirtual

User specified energy to decide which of the 5 possible orientations should be chosen.

Accepts the last shown orientation if not overridden.

Parameters
tetsNew tets after performing a 5-6 swap.
op_caseThe operation case, where 0 are the tets before swap.
Returns
energy The swap giving the tets with the lowest energy are chosen.

◆ swap_edge_after()

virtual bool wmtk::TetMesh::swap_edge_after ( const Tuple t)
inlineprotectedvirtual

User specified modifications and desideratas for after a 3-2 edge swap.

Parameters
tedge Tuple that's swaped
Returns
true if the modification succeed

Reimplemented in harmonic_tet::HarmonicTet, and app::interior_tet_opt::InteriorTetOpt.

◆ swap_edge_before()

virtual bool wmtk::TetMesh::swap_edge_before ( const Tuple t)
inlineprotectedvirtual

User specified preparations and desideratas for an 3-2 edge swap before changing the conenctivity.

Parameters
tedge Tuple to be swaped
Returns
true if the preparation succeed

Reimplemented in harmonic_tet::HarmonicTet, and app::interior_tet_opt::InteriorTetOpt.

◆ swap_face()

bool wmtk::TetMesh::swap_face ( const Tuple t,
std::vector< Tuple > &  new_tets 
)

2-3 face swap

Parameters
tInput Tuple for the edge to swap.
new_tetsa vector of Tuples for all the newly introduced tetra.
Returns
true if swap succeed

◆ swap_face_after()

virtual bool wmtk::TetMesh::swap_face_after ( const Tuple t)
inlineprotectedvirtual

User specified modifications and desideratas for after a 2-3 face swap.

Parameters
tedge Tuple that's swaped
Returns
true if the modification succeed

Reimplemented in harmonic_tet::HarmonicTet, and app::interior_tet_opt::InteriorTetOpt.

◆ swap_face_before()

virtual bool wmtk::TetMesh::swap_face_before ( const Tuple t)
inlineprotectedvirtual

User specified preparations and desideratas for an 2-3 face swap befroe changing the geometry.

Parameters
tedge Tuple to be swaped
Returns
true if the preparation succeed

Reimplemented in harmonic_tet::HarmonicTet, and app::interior_tet_opt::InteriorTetOpt.

◆ tet_capacity()

size_t wmtk::TetMesh::tet_capacity ( ) const
inline

get the current largest global tid

Returns
size_t

◆ tet_edges()

std::array< TetMesh::Tuple, 6 > wmtk::TetMesh::tet_edges ( const Tuple t) const

get the 6 edges of a tet represented by Tuples

Parameters
t
Returns
std::array<Tuple, 6> an array of 6 Tuples pointing to the 6 edges of a tet that share the same tid

◆ triangle_insertion()

void wmtk::TetMesh::triangle_insertion ( const std::vector< Tuple > &  intersected_tets,
const std::vector< Tuple > &  intersected_edges,
std::vector< size_t > &  new_edge_vids,
std::vector< size_t > &  new_center_vids,
std::vector< std::array< size_t, 4 > > &  center_split_tets 
)

Insert a triangle into a tetmesh, with known intersection information.

Parameters
intersected_tetsthe tet to split
intersected_edgesthe edges where new points are assigned to
new_edge_vidsnew vertices correspond to each cut-edge

get all tets

track surface before

subdivide

track surface after

◆ try_set_edge_mutex_two_ring()

bool wmtk::TetMesh::try_set_edge_mutex_two_ring ( const Tuple e,
int  threadid = 0 
)

try lock the two-ring neighboring triangles' incident vertices for the two ends of an edge

Parameters
eTuple refers to the edge
threadid
Returns
true if all locked successfully

◆ try_set_face_mutex_two_ring() [1/3]

bool wmtk::TetMesh::try_set_face_mutex_two_ring ( const Tuple f,
int  threadid = 0 
)

try lock the two-ring neighboring triangles' incident vertices for the 3 vertices of a face

Parameters
fTuple refers to the face
threadid
Returns
true if all locked successfully

◆ try_set_face_mutex_two_ring() [2/3]

bool wmtk::TetMesh::try_set_face_mutex_two_ring ( const Tuple v1,
const Tuple v2,
const Tuple v3,
int  threadid = 0 
)

locking the two-ring neighboring triangles' incident vertices given the 3 vertex Tuples of the face

Parameters
v1a Tuple refering to one vertex of the face
v2a Tuple refering to one vertex of the face
v3a Tuple refering to one vertex of the face
threadid
Returns
true if all locked successfully

◆ try_set_face_mutex_two_ring() [3/3]

bool wmtk::TetMesh::try_set_face_mutex_two_ring ( size_t  v1,
size_t  v2,
size_t  v3,
int  threadid = 0 
)

a duplicate of ConcurrentTetMesh::try_set_face_mutex_two_ring usign the vids of the 3 vertices of a face

Parameters
v1the vid of one vertex of the face
v2the vid of one vertex of the face
v3the vid of one vertex of the face
threadid
Returns
true if all locked successfully

◆ try_set_vertex_mutex_one_ring()

bool wmtk::TetMesh::try_set_vertex_mutex_one_ring ( const Tuple v,
int  threadid = 0 
)

try lock the one-ring neighboring traingles' incident vertices

Parameters
vTuple refers to the vertex
threadid
Returns
true if all locked successfully

◆ try_set_vertex_mutex_two_ring()

bool wmtk::TetMesh::try_set_vertex_mutex_two_ring ( const Tuple v,
int  threadid 
)

try lock the two-ring neighboring traingles' incident vertices

Parameters
vTuple refers to the vertex
threadid
Returns
true if all locked successfully

◆ try_set_vertex_mutex_two_ring_vid() [1/2]

bool wmtk::TetMesh::try_set_vertex_mutex_two_ring_vid ( const Tuple v,
int  threadid 
)

try lock the two-ring neighboring traingles' incident vertices using vids

Parameters
vTuple refers to the vertex
threadid
Returns
true if all locked successfully

◆ try_set_vertex_mutex_two_ring_vid() [2/2]

bool wmtk::TetMesh::try_set_vertex_mutex_two_ring_vid ( size_t  v,
int  threadid 
)

a duplicate of ConcurrentTetMesh::try_set_vertex_mutex_two_ring_vid that gets vids using the vid of the input Tuple

Parameters
vTuple refers to the vertex
threadid
Returns
true if all locked successfully

◆ tuple_from_edge() [1/2]

TetMesh::Tuple wmtk::TetMesh::tuple_from_edge ( const std::array< size_t, 2 > &  vids) const

get a Tuple from global vids of the 2 end of an edge

Parameters
vidsan array of the 2 vertex id of the edge

◆ tuple_from_edge() [2/2]

TetMesh::Tuple wmtk::TetMesh::tuple_from_edge ( size_t  tid,
int  local_eid 
) const

get a Tuple from global tetra index and local edge index (from 0-5).

Parameters
tidGlobal tetra index
local_eidlocal edge index

◆ tuple_from_face() [1/2]

std::tuple< TetMesh::Tuple, size_t > wmtk::TetMesh::tuple_from_face ( const std::array< size_t, 3 > &  vids) const

get a Tuple and the global face index from global vertex index of the face.

Parameters
vidsGlobal vertex index of the face

◆ tuple_from_face() [2/2]

TetMesh::Tuple wmtk::TetMesh::tuple_from_face ( size_t  tid,
int  local_fid 
) const

get a Tuple from global tetra index and local face index (from 0-3).

Parameters
tidGlobal tetra index
local_fidlocal face index

◆ tuple_from_tet()

TetMesh::Tuple wmtk::TetMesh::tuple_from_tet ( size_t  tid) const

get a Tuple from global tetra index

Parameters
tidGlobal tetra index

◆ tuple_from_vertex()

TetMesh::Tuple wmtk::TetMesh::tuple_from_vertex ( size_t  vid) const

get a Tuple from global vertex index

Parameters
vidGlobal vertex index

◆ vert_capacity()

size_t wmtk::TetMesh::vert_capacity ( ) const
inline

get the current largest global vid

Returns
size_t

◆ vertex_adjacent_boundary_faces()

std::vector< std::array< size_t, 3 > > wmtk::TetMesh::vertex_adjacent_boundary_faces ( const Tuple t) const
Parameters
m
Returns
std::vector<std::array<size_t,3>>

Member Data Documentation

◆ m_local_edges

constexpr std::array<std::array<int, 2>, 6> wmtk::TetMesh::m_local_edges
staticconstexprprivate
Initial value:
= {
{{{0, 1}}, {{1, 2}}, {{0, 2}}, {{0, 3}}, {{1, 3}}, {{2, 3}}}}

local edges within a tet

◆ m_local_edges_in_a_face

constexpr std::array<std::array<int, 3>, 4> wmtk::TetMesh::m_local_edges_in_a_face
staticconstexprprivate
Initial value:
= {
{{{0, 1, 2}}, {{2, 5, 3}}, {{3, 4, 0}}, {{5, 1, 4}}}}

◆ m_local_faces

constexpr std::array<std::array<int, 3>, 4> wmtk::TetMesh::m_local_faces
staticconstexprprivate
Initial value:
= {
{{{0, 1, 2}}, {{0, 2, 3}}, {{0, 1, 3}}, {{1, 2, 3}}}}

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