Wildmeshing Toolkit
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | List of all members
wmtk::components::simwild::SimWildMesh Class Reference
Inheritance diagram for wmtk::components::simwild::SimWildMesh:
wmtk::TetOptimizerMesh wmtk::TetMesh wmtk::RationalPositions

Classes

struct  SplitTagCache
 
struct  SwapTagCache
 

Public Types

using ExprPtr = expression_parser::ExpressionPtr
 
using TetAttCol = wmtk::AttributeCollection< TetAttributes >
 
- Public Types inherited from wmtk::TetOptimizerMesh
using FaceAttributes = wmtk::SurfaceTagAttributes
 
using VertAttCol = AttributeCollection< VertexAttributes >
 
using FaceAttCol = AttributeCollection< FaceAttributes >
 
using EdgeAttCol = AttributeCollection< FeatureEdgeAttributes >
 
using PositionKey = std::array< std::array< double, 3 >, 3 >
 A tracked face by its corners' positions, sorted.
 
using SurfaceTopoSignature = wmtk::utils::SurfaceTopoSignature
 
using FeaturePointAttCol = AttributeCollection< FeaturePointAttributes >
 
- Public Types inherited from wmtk::TetMesh
enum class  OpKind : int {
  split , collapse , swap_32 , swap_44 ,
  swap_56 , swap_face , COUNT
}
 
enum class  OpEvent : int {
  attempt , before_hook , link_condition , no_return_tet ,
  duplicate_tet , topology , valence , boundary ,
  exists , no_case_allowed , no_better_case , out_of_slots ,
  after_hook , invariants , committed , screened ,
  COUNT
}
 
template<typename T >
using vector = std::vector< T >
 
using VertexMutex = wmtk::threading::VertexMutex
 

Public Member Functions

InputSet face_tag_mask () const
 The face-tag bits of an input set: those below the number of face tags.
 
void init_label_envelopes (double eps, bool exact)
 
std::shared_ptr< Envelope > surface_envelope_for_face (const std::array< size_t, 3 > &vids, const FaceAttributes &attr) const override
 A tracked face's containment: its labels' envelopes if it has any, else m_envelope.
 
std::shared_ptr< Envelope > smoothing_energy_envelope (const size_t vid) const override
 Envelope a vertex is pulled toward while smoothing.
 
 SimWildMesh (Parameters &_m_params, double envelope_eps, int _num_threads=0)
 
double cell_quality (const size_t tid) const override
 The quality of cell tid, and how to write it.
 
void set_cell_quality (const size_t tid, const double q) override
 
bool allow_surface_swap () const override
 
bool check_surface_topology () const override
 
void create_mesh_attributes (const std::vector< VertexAttributes > &_vertex_attribute, const std::vector< TetAttributes > &_tet_attribute)
 
void init_envelope (const MatrixXd &V, const MatrixXi &F)
 
CellTag string_set_to_cell_tag (const std::set< std::string > &str_set)
 
void set_sizing_field (const nlohmann::json &sizing_field_json)
 
void set_quality_field (const nlohmann::json &quality_field_json)
 
double target_quality (const size_t tid) const
 
double target_quality (const Tuple &t) const
 
double quality_rel (const size_t tid) const override
 
double quality_rel (const Tuple &t) const
 
bool check_mesh_quality (double &max_rel_quality, const bool verbose=false) const
 
bool check_interface_faces_tagged (const bool verbose=false) const
 Verify that every interface between unlike tags carries a surface face.
 
void update_attributes () override
 Update the attributes of the mesh after an iteration of operations.
 
std::array< size_t, 3 > orient_tracked_face (const std::array< size_t, 3 > &f, const std::vector< size_t > &tets) const override
 
std::vector< int64_t > tet_tags (size_t tid) const override
 A tet's tags: the regions of a volume history are the tag sets.
 
std::vector< size_t > active_vertices () const override
 
void simplify ()
 
bool all_rounded () const
 Check if all vertices of the mesh are rounded.
 
void init_from_image (const MatrixXr &V, const MatrixXi &T, const MatrixSi &T_tags, const std::vector< std::string > &tag_names, const MatrixXi &F_tagged=MatrixXi(), const MatrixSi &F_tags=MatrixSi(), const std::vector< std::string > &face_tag_names={})
 Init from meshes image.
 
void init_from_image (const MatrixXd &V, const MatrixXi &T, const MatrixSi &T_tags, const std::vector< std::string > &tag_names, const MatrixXi &F_tagged=MatrixXi(), const MatrixSi &F_tags=MatrixSi(), const std::vector< std::string > &face_tag_names={})
 
void init_surfaces_and_boundaries ()
 
void init_face_tags (const MatrixXi &F_tagged, const MatrixSi &F_tags, const std::vector< std::string > &face_tag_names)
 
size_t refine_sizing_around_worst (double max_metric=0.) override
 Escape a stuck max energy by refining the sizing field around the worst elements.
 
void find_order_2_edges ()
 Find open boundary edges of the embedded surface and initialize a BVH for the open boundary.
 
bool is_order_2_edge (const Tuple &e) const
 Checks if an edge COULD be an open boundary edge.
 
bool is_order_2_edge (const std::array< size_t, 2 > &e) const
 
void write_vtu (const std::string &path, MeshMap *output=nullptr)
 
void write_surface (const std::string &path) const
 
void init_vertex_order ()
 Compute the vertex order for every vertex.
 
double tet_volume (const size_t tid) const
 
std::vector< ConnectedComponent > compute_connected_components (const CellTag &tag_in) const
 Find all connected components that contain the tag_in tags.
 
std::vector< ConnectedComponent > compute_connected_components (const ExprPtr &expr) const
 
std::vector< ConnectedComponent > find_holes (const std::vector< CellTag > &tag_in) const
 Find all regions that do not contain the tags from tag_in.
 
void compute_tag_boundary (const CellTag &tag, MatrixXd &V, MatrixXi &F) const
 Compute the boundary of a tag.
 
void keep_largest_connected_component (const std::vector< CellTag > &lcc_tags, const size_t n_lcc=1)
 Keep only the largest connected component for each of the distinct tag_0 values, and engulf all other components.
 
void fill_holes_topo (const std::vector< CellTag > &fill_holes_tags, double threshold=std::numeric_limits< double >::infinity())
 
void seal_connected_components (const std::vector< CellTag > &tag_sets, const std::vector< ConnectedComponent > &components)
 
void tight_seal_topo (const std::vector< std::vector< CellTag > > &tight_seal_tag_sets, double threshold=std::numeric_limits< double >::infinity())
 
void resolve_overlaps (const std::vector< std::array< ExprPtr, 2 > > &intersecting_tags)
 
void replace_tags (const std::vector< CellTag > &tags_in, const std::vector< CellTag > &tags_out)
 
void tag_priority (const std::vector< int64_t > &tags)
 Gives tags priority over others.
 
std::array< size_t, 3 > orient_tracked_face (const std::array< size_t, 3 > &f, const std::vector< size_t > &tets) const override
 
virtual std::array< size_t, 3 > orient_tracked_face (const std::array< size_t, 3 > &f, const std::vector< size_t > &tets) const
 
std::array< size_t, 3 > orient_tracked_face (const std::array< size_t, 3 > &f) const
 
- Public Member Functions inherited from wmtk::TetOptimizerMesh
std::vector< std::array< size_t, 3 > > oriented_tracked_faces () const
 The tracked surface as an oriented soup: each tracked face emitted |m_orientation| times, in the orientation the input gave it. Faces whose sheets cancel are left out. Vertex ids index m_vertex_attribute.
 
std::vector< std::pair< std::array< size_t, 2 >, int > > tracked_surface_boundary () const
 Mesh edges where the oriented tracked surface has a boundary.
 
void throw_if_in_operation_pass (const char *call) const
 
void add_edge_attributes (AbstractAttributeContainer *c)
 Register an edge collection with m_edge_attr_group and point p_edge_attrs at the group.
 
void enable_feature_edge_tracking ()
 Turn on feature-edge tracking. The collection joins m_edge_attr_group beside whatever the application registered there.
 
bool vertex_has_feature_edge (size_t vid) const
 
size_t substructure_order_of_edge (const std::array< size_t, 2 > &vids) const override
 The orders substructure_link_condition consults, overridable so an application can widen the 1D substructure beyond what the surface complex derives.
 
size_t substructure_order_of_vertex (size_t vid) const override
 
void substructure_feature_neighbors (size_t vid, std::vector< size_t > &out) const override
 One-ring vertices x of vid where (vid, x) is 1D substructure NOT derivable from the surface complex (feature edges through the interior, for instance). The link condition's order-2 edge collection walks surface faces and would never see them.
 
bool feature_edges_at_vertex_inside (size_t vid) const
 
virtual bool smoothing_position_is_allowed (const size_t vid, const Vector3d &p) const
 
bool is_force_split_edge (const size_t v1, const size_t v2) const
 
bool storage_grows_on_demand () const override
 
bool split_edge_is_due (const Tuple &e) const
 
 TetOptimizerMesh (OptimizerParameters &params, std::shared_ptr< Envelope > env)
 
void compute_vertex_partition ()
 
void compute_vertex_partition_morton ()
 
size_t get_partition_id (const Tuple &loc) const
 
double get_length2 (const Tuple &l) const
 
bool is_inverted (const std::array< size_t, 4 > &vs) const
 
bool is_inverted (const Tuple &loc) const
 
bool is_inverted_f (const Tuple &loc) const
 Inversion check using only the double positions.
 
double get_quality (const std::array< size_t, 4 > &vs) const
 
double get_quality (const Tuple &loc) const
 
std::tuple< double, double > get_max_avg_energy ()
 
void update_attributes_and_history ()
 update_attributes(), then the change it made to the tracked surface, if recording one.
 
void record_surface_history (const std::string &metadata)
 
std::optional< history::SurfaceHistory > finish_surface_history (const history::SurfaceHistory *input=nullptr)
 Bring the recorded surface up to date with the tracked faces, stop recording, log what the history holds and return it, for the application to save (ComponentIO:: save_history). None if not recording.
 
void record_volume_history ()
 
std::optional< std::vector< uint8_t > > finish_volume_history (const std::map< int64_t, std::string > &tag_names={})
 
bool is_tracked_face (size_t tid, int j) const override
 The faces with m_is_surface_fs, for a surface history (TetMesh::start_surface_history).
 
std::array< size_t, 3 > orient_tracked_face (const std::array< size_t, 3 > &f, const std::vector< size_t > &tets) const override
 
std::vector< std::array< size_t, 2 > > tracked_feature_edges () const override
 The tagged feature edges (m_feature_edge_attribute) that are edges of tracked faces.
 
bool checks_tracked_surface () const override
 m_params.check_surface_folds; see there.
 
void tracked_surface_before (const std::vector< size_t > &vs, bool all) override
 
bool tracked_surface_after (const std::vector< size_t > &vs, bool all) override
 
Eigen::Vector3d tracked_area_normal (const std::vector< std::array< size_t, 3 > > &faces) const
 
size_t tracked_not_facing (const std::vector< std::array< size_t, 3 > > &faces, const Eigen::Vector3d &n) const
 
size_t tracked_star_folds (const std::vector< std::array< size_t, 3 > > &faces) const
 
void mesh_improvement (int max_its=80)
 
std::tuple< double, double > local_operations (const std::array< int, 4 > &ops, bool collapse_limit_length=true)
 
bool round (const Tuple &v)
 Round a vertex position to floating point, if that inverts no incident tet.
 
bool is_edge_on_surface (const Tuple &loc)
 
bool is_edge_on_bbox (const Tuple &loc)
 
virtual bool is_open_boundary_edge (const Tuple &e)
 Whether edge e lies on the boundary of the tracked surface.
 
int edge_incident_surface_face_count (const Tuple &e)
 How many of the faces incident to edge e are on the tracked surface.
 
bool surface_triangle_is_outside (const size_t a, const size_t b, const size_t c, const FaceAttributes &attr) const
 
bool vertex_is_on_surface (const size_t vid) const override
 Is a vertex part of the substructure.
 
bool face_is_on_surface (const size_t fid) const override
 Is a face part of the substructure.
 
size_t get_order_of_vertex (const size_t vid) const override
 Get the order of a vertex.
 
std::vector< std::array< size_t, 3 > > get_faces_by_condition (std::function< bool(const FaceAttributes &)> cond) const
 
void output_faces (std::string file, std::function< bool(const FaceAttributes &)> cond)
 
void gradation_smooth_sizing (double grade, const std::vector< size_t > &seeds)
 Grade the refined sizing region into its surroundings (monotone, only lowers).
 
double active_quality_threshold () const
 Cell-quality threshold above which a tet is "active" (worth operating on) for the skip-good-regions filter.
 
void split_all_edges ()
 
bool split_edge_before (const Tuple &t) override
 User specified preparations and desideratas for an edge split before changing the connectivity.
 
bool split_edge_after (const Tuple &loc) override
 This function computes the attributes for the added simplices. User specified modifications and desideratas for after an edge split.
 
void collapse_all_edges (bool is_limit_length=true)
 
bool collapse_edge_before (const Tuple &t) override
 User specified preparations and desideratas for an edge collapse before changing the connectivity.
 
bool collapse_edge_after (const Tuple &t) override
 User specified modifications and desideratas for after an edge collapse.
 
size_t coarsen_mesh ()
 Coarsen the mesh without letting the max energy rise.
 
bool coarsen_collapse_edge (const Tuple &e, std::vector< Tuple > &new_tets)
 One collapse under the coarsening rules, outside a coarsening pass.
 
size_t swap_all_edges_32 ()
 
bool swap_edge_before (const Tuple &t) override
 User specified preparations and desideratas for an 3-2 edge swap before changing the conenctivity.
 
bool swap_edge_after (const Tuple &t) override
 User specified modifications and desideratas for after a 3-2 edge swap.
 
size_t swap_all_edges_44 ()
 
bool swap_edge_44_before (const Tuple &t) override
 User specified preparations and desideratas for an 4-4 edge swap before changing the connectivity.
 
bool swap_edge_44_accept_case (const std::array< size_t, 2 > &new_edge) override
 Filter which of the 4-4 orientations may be chosen.
 
bool swap_edge_44_after (const Tuple &t) override
 User specified modifications and desideratas for after a 4-4 edge swap.
 
size_t swap_all_edges_56 ()
 
bool swap_edge_56_before (const Tuple &t) override
 User specified preparations and desideratas for a 5-6 edge swap before changing the connectivity.
 
bool swap_edge_56_accept_case (const std::array< size_t, 3 > &new_face) override
 Filter which of the 5-6 orientations may be chosen.
 
bool swap_edge_56_after (const Tuple &t) override
 User specified modifications and desideratas for after a 5-6 edge swap.
 
size_t swap_all_faces ()
 
bool swap_face_before (const Tuple &t) override
 User specified preparations and desideratas for an 2-3 face swap befroe changing the geometry.
 
bool swap_face_after (const Tuple &t) override
 User specified modifications and desideratas for after a 2-3 face swap.
 
size_t swap_all_edges_all ()
 
bool prepare_surface_flip (const Tuple &t, const std::vector< size_t > &incident_tets)
 
SurfaceTopoSignature surface_topology_signature () const
 
void warn_if_surface_topology_changed (const SurfaceTopoSignature &before, const char *where) const
 
double swap_edge_44_energy (const std::vector< std::array< size_t, 4 > > &tets, const int op_case) override
 User specified energy to decide which of the 4 possible orientations should be chosen.
 
double swap_edge_56_energy (const std::vector< std::array< size_t, 4 > > &tets, const int op_case) override
 User specified energy to decide which of the 5 possible orientations should be chosen.
 
virtual std::shared_ptr< Envelope > smoothing_containment_envelope (const size_t, const std::array< size_t, 3 > &face, const FaceAttributes &attr) const
 Envelope the smoother checks tracked face face (attributes attr) at the moved vertex vid against; null skips the face.
 
virtual bool boundary_edges_at_vertex_inside (size_t) const
 
virtual std::shared_ptr< polysolve::nonlinear::Problem > smoothing_extra_energy (const size_t) const
 An extra term the application adds to this vertex's smoothing objective, or null.
 
virtual double smoothing_cell_energy (const size_t, const double quality) const
 The number the shared smoother compares for one cell, given the cell's quality (AMIPS^3) at the position being tested. Its quality veto compares the max of this over the ring before and after the move, and the default smoothing_ring_energy() is the same max.
 
virtual double smoothing_ring_energy (const std::vector< Tuple > &ring, const bool stored) const
 The number the shared smoother's projected step compares for a whole one-ring: a vertex held on a surface takes the first projected candidate whose value is strictly below the value before the move.
 
bool smooth_before (const Tuple &t) override
 The smoothing hooks. A derived class overriding them – or invariants(), which a smooth also runs – must read every attribute outside the smoothed vertex's star (other vertices, and the edges, faces and tets not incident to the vertex) through const access, e.g. std::as_const(m_vertex_attribute)[u].
 
bool smooth_after (const Tuple &t) override
 User specified modifications and desideratas for after smoothing a vertex.
 
void smooth_all_vertices (const size_t n_iters=1)
 
bool use_colored_smoothing () const
 Whether this pass smooths by color class (see OptimizerParameters::colored_smoothing).
 
void smooth_vertices_colored (const std::vector< std::pair< std::string, Tuple > > &ops)
 One smoothing sweep over ops (all "vertex_smooth"), one color class at a time.
 
virtual void log_smoothing_pass_accounting ()
 
virtual void smoothing_pass_done ()
 
bool invariants (const std::vector< Tuple > &t) override
 
virtual std::array< size_t, 3 > orient_tracked_face (const std::array< size_t, 3 > &f, const std::vector< size_t > &tets) const
 
std::array< size_t, 3 > orient_tracked_face (const std::array< size_t, 3 > &f) const
 
void enable_feature_point_tracking (const bool preserve)
 Turn on feature-point tracking, and the policy when preserve.
 
bool collapse_breaks_feature_point (const size_t v1_id, const size_t v2_id) const
 
bool feature_point_ball_contains (const size_t vid, const Vector3d &p) const
 
std::pair< size_t, size_t > feature_retention (double *worst_ratio=nullptr) const
 
- Public Member Functions inherited from wmtk::TetMesh
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, 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. It has no surface history hooks, and throws while a surface history is recording.
 
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::shared_ptr< history::TrackedSurfaceRecorder > start_surface_history (std::function< Eigen::Vector3d(size_t)> position)
 Record every change to the tracked surface from now on (see wmtk/history/TrackedRecorder.hpp).
 
void stop_surface_history ()
 Stop recording. The recorder keeps what it has.
 
size_t resync_surface_history ()
 
std::shared_ptr< history::VolumeRecorder > start_volume_history (std::function< Eigen::Vector3d(size_t)> position)
 Record, alongside the surface history, the tets around every operation that changes the tracked surface (wmtk/history/VolumeHistory.hpp): what a map of the volume needs. The surface history must be recording; a volume history is its own choice, since it takes far more room. position(v) is called as start_surface_history()'s is; a tet's region is its tet_tags().
 
void stop_volume_history ()
 Stop recording the volume. The recorder keeps what it has.
 
std::vector< std::array< size_t, 3 > > tracked_faces () const
 Every tracked face, oriented by orient_tracked_face().
 
std::array< size_t, 3 > orient_tracked_face (const std::array< size_t, 3 > &f) const
 orient_tracked_face, finding the face's tets.
 
std::array< size_t, 3 > face_out_of (size_t tid, const std::array< size_t, 3 > &face) const
 The corners of face, a face of tet tid, ordered so that its normal points out of the tet – for a tet the right way round as TetOptimizerMesh has them, with its fourth vertex on the side of the first three's normal (orient3d negative).
 
std::vector< size_t > tets_of_face (const std::array< size_t, 3 > &f) const
 The tets with the face f, sorted: one on the boundary, two inside.
 
std::vector< Tuple > get_edges () const
 
std::vector< Tuple > get_faces () const
 
std::vector< Tuple > get_vertices () const
 
std::vector< Tuple > get_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
 
void set_preallocation_factor (double factor)
 Preallocation factor: init/consolidate reserve capacity = max(floor, ceil(factor * live_count)) so operations can grab fresh slots without resizing the storage. When a pass exhausts the reserved capacity the affected operations fail (and are retried later after a consolidate). Tune per application (e.g. from JSON); values < 1 are clamped to 1.
 
double preallocation_factor () const
 
bool slots_exhausted () const
 
void clear_slots_exhausted ()
 
size_t request_tet_slots (size_t n)
 
size_t request_vert_slots (size_t n)
 
void ensure_free_tet_capacity (size_t extra)
 
void ensure_free_vert_capacity (size_t extra)
 
bool op_refused (const OpKind k, const OpEvent e) const
 op_event() for a refusal, returning false so a site reads return op_refused(...).
 
bool op_screened (const OpKind k) const
 The end of a dry run that would have gone on to change the mesh: true, and counted.
 
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::optional< std::tuple< Tuple, size_t > > try_tuple_from_face (const std::array< size_t, 3 > &vids) const
 tuple_from_face for callers where a missing face is an answer, not a bug.
 
size_t lowest_common_tet (size_t v0_id, size_t v1_id, size_t v2_id) const
 Lowest tet id incident to all three vertices, or size_t(-1) if there is none.
 
size_t vertex_valence (const size_t vid) const
 Number of tets incident to a vertex, in O(1).
 
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
 
simplex::Face simplex_from_face (const Tuple &t) const
 
simplex::Edge simplex_from_edge (const Tuple &t) 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< Tuple > switch_tetrahedron (const Tuple &t) const
 wrapper function from Tuple::switch_tetrahedron
 
std::vector< Tuple > get_one_ring_tets_for_vertex (const Tuple &t) const
 Get the one ring tets for a vertex.
 
const std::vector< size_t > & get_one_ring_tids_for_vertex (const Tuple &t) const
 Get the one ring tids for vertex.
 
const std::vector< size_t > & get_one_ring_tids_for_vertex (const size_t vid) const
 
std::vector< Tuple > get_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< Tuple > get_incident_tets_for_edge (const Tuple &t) const
 Get the incident tets for edge.
 
std::vector< Tuple > get_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< Tuple > get_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 ()
 
int release_vertex_mutex_to (size_t mark)
 Release the mutexes taken since the release stack held mark entries.
 
bool try_set_vertex_mutex_n_ring (const Tuple &v, int threadid, int n)
 Lock every vertex within graph distance n of v, the seed included.
 
bool try_set_vertex_mutex_n_ring (size_t vid, int threadid, int n)
 
bool try_set_edge_mutex_n_ring (const Tuple &e, int threadid, int n)
 try_set_vertex_mutex_n_ring seeded from both ends of an edge.
 
bool try_set_face_mutex_n_ring (size_t v1, size_t v2, size_t v3, int threadid, int n)
 try_set_vertex_mutex_n_ring seeded from the three vertices of a face.
 
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
 
simplex::SimplexCollection get_surface_faces_for_vertex (const size_t vid) const
 Get all faces on the surface that are incident to vid.
 
simplex::SimplexCollection get_surface_faces_for_edge (const std::array< size_t, 2 > &vids) const
 Get all faces on the surface that are incident to the edge.
 
size_t get_num_surface_faces_for_edge (const std::array< size_t, 2 > &vids) const
 Get the number of surface faces incident to the edge.
 
size_t compute_vertex_order (const size_t vid) const
 Compute the vertex order for a single vertex.
 
size_t get_order_of_edge (const std::array< size_t, 2 > &vids) const
 Compute the order of an edge.
 
bool substructure_link_condition (const Tuple &e_tuple) const
 Link condition that also considers substructures.
 
size_t tet_storage_capacity () const
 
size_t vert_storage_capacity () const
 
bool try_set_vertex_mutex_two_ring (const Tuple &v, int threadid)
 Lock v's one-ring and, partially, its two-ring. See the note above.
 
bool try_set_vertex_mutex_two_ring_vid (const Tuple &v, int threadid)
 try_set_vertex_mutex_two_ring reached through vids rather than Tuples.
 
bool try_set_vertex_mutex_two_ring_vid (size_t v, int threadid)
 try_set_vertex_mutex_two_ring reached through vids rather than Tuples.
 
bool try_set_edge_mutex_two_ring (const Tuple &e, int threadid=0)
 Lock the edge's one-ring and, partially, its two-ring. See the note above.
 
bool try_set_face_mutex_two_ring (const Tuple &f, int threadid=0)
 Lock the face's one-ring and, partially, its two-ring. See the note above.
 
bool try_set_face_mutex_two_ring (const Tuple &v1, const Tuple &v2, const Tuple &v3, int threadid=0)
 Lock the face's one-ring and, partially, its two-ring. See the note above.
 
bool try_set_face_mutex_two_ring (size_t v1, size_t v2, size_t v3, int threadid=0)
 Lock the face's one-ring and, partially, its two-ring. See the note above.
 
bool try_set_vertex_mutex_one_ring (const Tuple &v, int threadid=0)
 Lock v and its one-ring. Complete, unlike the two-ring family.
 
size_t cell_capacity () const
 
size_t cell_storage_capacity () const
 
Tuple tuple_from_cell (size_t cid) const
 
size_t cell_slot_bound (const Tuple &t) const
 
void reserve_free_slots (size_t cells, size_t verts)
 
- Public Member Functions inherited from wmtk::RationalPositions
size_t round_all_vertices ()
 Try to round every un-rounded vertex; returns the number reclaimed.
 
bool round_and_check_all_rounded ()
 Run the sweep, then report whether the mesh is now fully rounded.
 

Public Attributes

size_t m_tags_count = 0
 
std::map< int64_t, std::string > m_tag_id_to_name
 
std::map< std::string, int64_t > m_tag_name_to_id
 
std::vector< std::string > m_face_tag_names
 Names of the face tags: bit i of a face's input set is m_face_tag_names[i].
 
wmtk::InputEnvelopes m_input_envelopes
 One envelope per label, and each surface face held by those of the labels it lies on: bit i < F of a face's input set is face tag i (m_face_tag_names, F of them), bit F + j the boundary of tet tag j's region. A border between tet tag sets S and S' carries the bits of the tags in one and not the other; ambient is the empty set, so a border of region X with ambient is held by X's envelope, one between X and Y by both. As tetwild holds a tracked face to its inputs' envelopes, and topological_offset's 2D mesh a region boundary to its tags'.
 
std::vector< InputSet > m_F_envelope_labels
 
Parameters & m_sim_params
 
std::vector< Vector3d > m_V_envelope
 
std::vector< Vector3i > m_F_envelope
 
double m_envelope_eps = -1
 
std::vector< std::tuple< ExprPtr, double > > m_sizing_field
 
std::vector< std::tuple< ExprPtr, double > > m_quality_field
 
bool m_collapse_check_quality = true
 
std::shared_ptr< Envelope > m_order_2_edge_envelope
 Follows m_envelope's use_exact; see where it is built in VolumemesherInsertion.cpp.
 
std::function< double(const Vector3d &)> m_voronoi_split_fn = nullptr
 
TetAttCol m_tet_attribute
 
std::atomic< int > cnt_split = 0
 
std::atomic< int > cnt_collapse = 0
 
- Public Attributes inherited from wmtk::TetOptimizerMesh
VertAttCol m_vertex_attribute
 
FaceAttCol m_face_attribute
 
bool m_tracks_orientation = false
 The application set FaceAttributes::m_orientation at insertion, so the tracked surface carries the input's orientation and the operations keep it.
 
std::atomic< size_t > m_inconsistent_orientation_flips = 0
 Surface flips that joined two faces not oriented alike (a fold of the tracked surface, or unequal multiplicities).
 
AttributeContainerGroup m_vertex_attr_group
 What p_vertex_attrs points at, so a derived class can register more.
 
AttributeContainerGroup m_face_attr_group
 What p_face_attrs points at, so a derived class can register more.
 
AttributeContainerGroup m_edge_attr_group
 What p_edge_attrs points at, once a collection is registered with it.
 
bool m_in_operation_pass = false
 True while a pass of the shared operations runs.
 
EdgeAttCol m_feature_edge_attribute
 Sized, protected and rolled back only once enable_feature_edge_tracking() ran.
 
bool m_track_feature_edges = false
 Whether the shared operations maintain m_feature_edge_attribute.
 
std::shared_ptr< Envelope > m_feature_envelope
 Envelope around the input feature curves: the tube a tagged edge must stay in.
 
OptimizerParameters & m_params
 
std::shared_ptr< Envelope > m_envelope
 Surface envelope: what a surface vertex is pulled toward and checked against.
 
double m_s_amips = 1.
 
double m_s_envelope = -1.
 
double time_env = 0.0
 
igl::Timer isout_timer
 
wmtk::threading::enumerable_thread_specific< std::unique_ptr< polysolve::nonlinear::Solver > > m_solver
 Per-thread Newton solver for smoothing; created on first use.
 
optimization::SmoothRejectCounters m_smooth_rejects
 Why smoothing attempts were refused, reported once per pass.
 
optimization::NewtonCounters m_newton
 
bool m_collapse_limit_length = true
 
std::set< simplex::Edge > m_force_split_edges
 
size_t m_force_split_count = 0
 Force-splits taken in the current split pass. Diagnostic only.
 
std::unique_ptr< std::atomic< int >[]> m_high_valence_claim
 Per-pass claims for the shared high-valence split gate.
 
size_t m_high_valence_claim_size = 0
 
std::atomic< size_t > m_high_valence_rejects = 0
 
size_t m_split_order_waits = 0
 The current split pass's ExecutePass::waits() and wait_defects().
 
size_t m_split_order_wait_defects = 0
 
std::vector< std::pair< PositionKey, std::vector< uint32_t > > > m_insertion_sources
 
std::shared_ptr< history::VolumeRecorder > m_recorded_volume
 
uint64_t m_surface_edit_offset = 0
 
std::optional< history::SurfaceKey > m_finished_surface
 
std::atomic< size_t > m_surface_fold_refusals = 0
 The operations check_surface_folds refused.
 
int m_iterations_used = 0
 Shared TetWild/SimWild outer optimization schedule.
 
std::shared_ptr< history::TrackedSurfaceRecorder > m_recorded_surface
 
wmtk::threading::enumerable_thread_specific< SurfaceFolds > m_surface_folds_before
 
std::vector< std::vector< uint64_t > > m_recorded_sources
 The input triangles each face of the recorded surface's first state lies on.
 
int m_debug_print_counter = 0
 
std::string m_debug_pass_name
 
CoarsenStats m_coarsen_stats
 
std::atomic< int > cnt_swap = 0
 
std::atomic< int > cnt_surface_swap = 0
 
std::atomic< int > cnt_surface_swap_32 = 0
 
std::atomic< int > cnt_surface_swap_44 = 0
 
std::atomic< int > cnt_surface_swap_56 = 0
 
FeaturePointAttCol m_feature_point_attribute
 Registered with m_vertex_attr_group only once enable_feature_point_tracking() ran.
 
std::vector< Vector3d > m_feature_points
 
double m_feature_eps = -1
 
bool m_track_feature_points = false
 Whether the shared operations maintain the ids (enable_feature_point_tracking()).
 
bool m_preserve_feature_points = false
 Whether the collapse and smoothing policy is on (its preserve argument).
 
- Public Attributes inherited from wmtk::TetMesh
bool m_check_smoothing_stays_in_star = false
 While true, smooth_vertex() checks that the smooth recorded nothing outside the vertex's star – the vertex itself and the edges, faces and cells incident to it – and throws if it did.
 
AbstractAttributeContainer * p_vertex_attrs = nullptr
 
AbstractAttributeContainer * p_edge_attrs = nullptr
 
AbstractAttributeContainer * p_face_attrs = nullptr
 
AbstractAttributeContainer * p_tet_attrs = nullptr
 
bool m_collapse_check_link_condition = true
 
bool m_collapse_check_topology = false
 
bool m_collapse_check_manifold = true
 
wmtk::threading::enumerable_thread_specific< std::vector< size_t > > mutex_release_stack
 
wmtk::threading::enumerable_thread_specific< std::vector< size_t > > get_one_ring_cache
 
int NUM_THREADS = 0
 

Protected Member Functions

std::tuple< double, double > optimization_quality_stats () override
 
double optimization_stop_metric () const override
 
bool optimization_stop_at_float () const override
 
void write_optimization_debug_output (const std::string &path) override
 
bool collapse_before_vertex (size_t v1, size_t v2, double edge_length) override
 
bool collapse_quality_allowed (size_t v1, double quality, double ring_max) const override
 
bool collapse_is_order_2_edge (const std::array< size_t, 2 > &e) override
 
bool collapse_after_connectivity (size_t v1, size_t v2, const std::vector< std::array< size_t, 2 > > &boundary_edges) override
 
bool split_before_cells (const Tuple &edge, const std::vector< Tuple > &parents) override
 Cache application cell data before a split. TetWild needs none; SimWild caches tags.
 
bool split_after_cells (size_t v1, size_t v2, size_t v_new, const std::vector< Tuple > &children) override
 Restore application cell data on the children made by a split.
 
bool split_adjust_position (size_t v_new, const std::vector< Tuple > &children) override
 
bool swap_before_interior (const std::vector< size_t > &tids) override
 Application data attached to the old cells. TetWild has none; SimWild caches tags.
 
bool swap_before_surface (const std::vector< size_t > &tids, size_t a, size_t b, size_t c, size_t d) override
 
bool swap_after_cells (const std::vector< size_t > &tids, bool is_surface_flip) override
 Propagate application data to the cells made by a successful topological swap.
 
- Protected Member Functions inherited from wmtk::TetOptimizerMesh
void on_slot_storage_grown () override
 
std::vector< size_t > all_vertex_ids () const override
 Every live vertex, in the mesh's own iteration order.
 
bool vertex_is_rounded (const size_t vid) const override
 Whether this vertex's double position is currently trusted.
 
bool round_vertex (const size_t vid) override
 
virtual bool optimization_bare_coarsen_passes () const
 Whether the loop opens with an UNLIMITED-LENGTH collapse pass.
 
virtual void optimization_iteration_done (int)
 
virtual void optimization_sanity_checks_extra ()
 
virtual bool optimization_stalled (double prev, double cur)
 Whether an iteration that moved the metric from prev to cur is stalled, and the sizing refinement should therefore fire.
 
virtual void collapse_after_vertex (size_t, size_t)
 
virtual void collapse_after_features (size_t, size_t)
 
virtual void split_after_vertex (size_t, bool)
 Application metadata not represented by the shared vertex attributes.
 
bool swap_reject (SwapReject r) const
 
bool swap_reject_kind_only (SwapReject r) const
 
void swap_stage (SwapStage s) const
 
void swap_counters_reset ()
 
std::string swap_reject_report () const
 One line per nonzero counter, for a per-turn log. Does not reset.
 
bool collapse_reject (CollapseReject r) const
 
void op_event (OpKind k, OpEvent e) const override
 
std::string op_accounting_report (OpKind k) const
 
bool op_accounting_unexplained (OpKind k) const
 True when the report for k has a nonzero remainder: a refusal no counter named.
 
void op_accounting_reset ()
 
OpHookReasons op_hook_reasons (OpKind k) const
 
long op_event_count (const OpKind k, const OpEvent e) const
 
long op_unaccounted (OpKind k) const
 Attempts minus every outcome: 0 unless an exit of the TetMesh operation reports nothing.
 
virtual bool swap_quality_allowed (double after, double before, bool) const
 
void feature_edges_cache (const std::vector< size_t > &tids, std::map< std::array< size_t, 2 >, bool > &cache)
 Cache the feature tag of every edge of every tet in tids.
 
void feature_edges_restore_region (const std::vector< Tuple > &tets, const std::map< std::array< size_t, 2 >, bool > &cache)
 Write back tags over every edge of every tet in tets (created regions).
 
void feature_edges_restore_region (const std::vector< size_t > &tids, const std::map< std::array< size_t, 2 >, bool > &cache)
 
bool feature_edges_restore_remap (const std::map< std::array< size_t, 2 >, bool > &cache, size_t v_old, size_t v_new)
 Write back tags for every cached edge, with v_old renamed to v_new (collapse).
 
virtual void split_after_vertex_feature (size_t, bool)
 
- Protected Member Functions inherited from wmtk::TetMesh
std::vector< std::array< size_t, 3 > > tracked_faces_around (const std::vector< size_t > &vs, bool all) const
 
std::vector< VertexFace > faces_at_vertex (size_t v) const
 The faces with v as a corner, found from v's tets alone.
 
size_t face_id_in (const std::array< size_t, 3 > &f, size_t tid) const
 The face id (Tuple::fid) of f, a face of tet tid, its lowest; from tid alone.
 
virtual bool triangle_insertion_before (const std::vector< Tuple > &faces)
 
virtual bool triangle_insertion_after (const std::vector< std::vector< Tuple > > &)
 
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 Attributes

wmtk::threading::enumerable_thread_specific< SplitTagCache > split_tag_cache
 
wmtk::threading::enumerable_thread_specific< SwapTagCache > swap_tag_cache
 

Additional Inherited Members

- Static Public Member Functions inherited from wmtk::TetOptimizerMesh
static PositionKey position_key (const Vector3d &a, const Vector3d &b, const Vector3d &c)
 
- Static Public Member Functions inherited from wmtk::TetMesh
static bool dry_run ()
 Whether operations on this thread are dry runs (see wmtk/OperationDryRun.hpp).
 
static SlotUsage slot_usage_of_this_thread ()
 
- Static Public Attributes inherited from wmtk::TetOptimizerMesh
static constexpr double MAX_ENERGY = 1e50
 The sentinel get_quality returns for an element AMIPS cannot score.
 
static constexpr size_t NO_FEATURE_POINT = std::numeric_limits<size_t>::max()
 A vertex that stands for no feature point. See FeaturePointAttributes.
 
- Static Public Attributes inherited from wmtk::TetMesh
static constexpr int EDGES_PER_CELL = 6
 
static constexpr int FACES_PER_CELL = 4
 
- Protected Types inherited from wmtk::TetOptimizerMesh
enum class  SwapReject : int {
  base_before , base_after , valence , bbox ,
  surface_not_allowed , feature_edge , prepare_flip , interior_hook ,
  flip_open_boundary , flip_not_two_surf , flip_nonmanifold_edge , flip_cd_nonmanifold ,
  flip_new_face_surface , flip_app_refused , flip_wrong_case , app_capture_label ,
  app_capture_tag , app_fid_missing , app_class_mismatch , app_mask_mismatch ,
  app_sag_raised , after_inverted , after_quality , after_cells ,
  app_after_side_conflict , app_after_no_side , after_envelope , face_tracked_surface ,
  face_tracked_bbox , face_inverted , face_not_better , COUNT
}
 
enum class  SwapStage : int {
  attempt , surface_attempt , before_pass , after_enter ,
  accepted , screened , COUNT
}
 
enum class  CollapseReject : int {
  coarsen_length , bbox , surface_leaves_envelope , inverted ,
  quality , substructure_link , feature_leaves_tube , feature_point ,
  app_both_surfaces , app_front_unlimited , app_leaves_input , app_leaves_offset ,
  app_leaves_region , app_order2 , app_substructure_link , app_ops_guard ,
  after_base , after_connectivity , after_envelope , after_face_attribute ,
  after_order2_chord , after_feature_edge , after_coarsen_region , COUNT
}
 
enum class  SwapRejectRole { before_leaf , after_leaf , wrapper , per_case }
 
- Static Protected Member Functions inherited from wmtk::TetOptimizerMesh
static const char * swap_reject_name (SwapReject r)
 
static const char * swap_stage_name (SwapStage s)
 
static const char * collapse_reject_name (CollapseReject r)
 
static OpKind & current_op_kind ()
 
static const char * op_kind_name (OpKind k)
 
static const char * op_event_name (OpEvent e)
 
static SwapRejectRole swap_reject_role (SwapReject r)
 
- Protected Attributes inherited from wmtk::TetOptimizerMesh
uint32_t m_op_epoch = 0
 
std::array< std::atomic< long >, size_t(SwapReject::COUNT)> m_swap_reject {}
 
std::array< std::atomic< long >, size_t(SwapStage::COUNT)> m_swap_stage {}
 
std::array< std::atomic< long >, size_t(CollapseReject::COUNT)> m_collapse_reject {}
 
std::array< std::array< std::atomic< long >, size_t(OpEvent::COUNT)>, size_t(OpKind::COUNT)> m_op_events {}
 
std::array< std::array< std::atomic< long >, size_t(SwapReject::COUNT)>, size_t(OpKind::COUNT)+1 > m_swap_reject_by_kind {}
 
wmtk::threading::enumerable_thread_specific< SwapInfoCache > swap_cache
 
wmtk::threading::enumerable_thread_specific< SplitInfoCache > split_cache
 
wmtk::threading::enumerable_thread_specific< CollapseInfoCache > collapse_cache
 
bool m_coarsen_mode = false
 Set for the duration of coarsen_mesh(); read-only while a pass is running.
 
- Protected Attributes inherited from wmtk::RationalPositions
std::atomic< bool > m_all_rounded = false
 True when every vertex is known to be rounded.
 
- Static Protected Attributes inherited from wmtk::TetMesh
static constexpr std::array< std::array< int, 2 >, 6 > m_local_edges
 local edges within a tet
 

Member Function Documentation

◆ active_vertices()

std::vector< size_t > wmtk::components::simwild::SimWildMesh::active_vertices ( ) const
overridevirtual

vids of the vertices incident to at least one "active" cell, for the skip-good-regions filter.

Reimplemented from wmtk::TetOptimizerMesh.

◆ allow_surface_swap()

bool wmtk::components::simwild::SimWildMesh::allow_surface_swap ( ) const
inlineoverridevirtual

◆ cell_quality()

double wmtk::components::simwild::SimWildMesh::cell_quality ( const size_t  tid) const
inlineoverridevirtual

The quality of cell tid, and how to write it.

The cell attribute types differ between the applications, so the base reaches the one field it shares through these. Both are AMIPS^3; see MAX_ENERGY. Topological operations and smoothing use the accessors so the shared algorithms remain independent of each application's cell-attribute type.

Implements wmtk::TetOptimizerMesh.

◆ check_interface_faces_tagged()

bool wmtk::components::simwild::SimWildMesh::check_interface_faces_tagged ( const bool  verbose = false) const

Verify that every interface between unlike tags carries a surface face.

Checks that direction only: an interface face that is not tagged is a violation, while a tagged face between like-tagged tets is not reported here.

Parameters
verboseLog a summary line, and the first few offending faces.
Returns
true if every interface face is tagged.

◆ check_surface_topology()

bool wmtk::components::simwild::SimWildMesh::check_surface_topology ( ) const
inlineoverridevirtual

◆ collapse_after_connectivity()

bool wmtk::components::simwild::SimWildMesh::collapse_after_connectivity ( size_t  v1,
size_t  v2,
const std::vector< std::array< size_t, 2 > > &  boundary_edges 
)
overrideprotectedvirtual

Reimplemented from wmtk::TetOptimizerMesh.

◆ collapse_before_vertex()

bool wmtk::components::simwild::SimWildMesh::collapse_before_vertex ( size_t  ,
size_t  ,
double   
)
overrideprotectedvirtual

Non-const: an override may cache what it measured before the collapse so its after counterpart can tell a regression from a defect that was already there.

Reimplemented from wmtk::TetOptimizerMesh.

◆ collapse_is_order_2_edge()

bool wmtk::components::simwild::SimWildMesh::collapse_is_order_2_edge ( const std::array< size_t, 2 > &  e)
overrideprotectedvirtual

Reimplemented from wmtk::TetOptimizerMesh.

◆ collapse_quality_allowed()

bool wmtk::components::simwild::SimWildMesh::collapse_quality_allowed ( size_t  v1,
double  quality,
double  ring_max 
) const
overrideprotectedvirtual

Reimplemented from wmtk::TetOptimizerMesh.

◆ compute_tag_boundary()

void wmtk::components::simwild::SimWildMesh::compute_tag_boundary ( const CellTag &  tag,
MatrixXd &  V,
MatrixXi &  F 
) const

Compute the boundary of a tag.

Parameters
tagA set of tags that must be present in a tet for being considered as tagged.
VVertices of the tag boundary.
FFaces of the tag boundary.

◆ find_holes()

std::vector< ConnectedComponent > wmtk::components::simwild::SimWildMesh::find_holes ( const std::vector< CellTag > &  tag_in) const

Find all regions that do not contain the tags from tag_in.

The tag_in vector represents a list of tag intersections. Example: tag_in = {{1,2},{3}} A face will be considered as a hole if its tags neither include {1,2} or {3}. The following would be holes: {} {1,4} The following would be NOT holes: {1,2,4} <- contains 1 and 2 {3} <- contains 3 {1,3} <- contains 3

The returned vector also contains "holes" that touch the boundary. They should be ommitted in hole filling.

◆ find_order_2_edges()

void wmtk::components::simwild::SimWildMesh::find_order_2_edges ( )

Find open boundary edges of the embedded surface and initialize a BVH for the open boundary.

The envelope for the open boundary uses a hack: A boundary edge is represented as a degenerate triangle, e.g., (v0,v1,v0). That way, the standard triangle envelope code can be used.

◆ init_face_tags()

void wmtk::components::simwild::SimWildMesh::init_face_tags ( const MatrixXi &  F_tagged,
const MatrixSi &  F_tags,
const std::vector< std::string > &  face_tag_names 
)

Tracks the faces F_tagged (rows of T's vertices, as read_mesh_data gives them) as surface, with input set bit j where F_tags has a 1 in column j. Throws on a row that is no face.

◆ init_from_image()

void wmtk::components::simwild::SimWildMesh::init_from_image ( const MatrixXr &  V,
const MatrixXi &  T,
const MatrixSi &  T_tags,
const std::vector< std::string > &  tag_names,
const MatrixXi &  F_tagged = MatrixXi(),
const MatrixSi &  F_tags = MatrixSi(),
const std::vector< std::string > &  face_tag_names = {} 
)

Init from meshes image.

Parameters
VVx3 vertices of the tet mesh
TTx4 vertex IDs for all tets
T_tagsTx1 image data represented by the individual tets

◆ init_label_envelopes()

void wmtk::components::simwild::SimWildMesh::init_label_envelopes ( double  eps,
bool  exact 
)

(Re)build m_input_envelopes at eps, around the same surface as m_envelope: each label's rows of m_F_envelope when m_F_envelope_labels says which, else the mesh's faces carrying the label. The input triangles are far fewer than the faces embedded on them.

◆ is_order_2_edge()

bool wmtk::components::simwild::SimWildMesh::is_order_2_edge ( const Tuple &  e) const

Checks if an edge COULD be an open boundary edge.

The method performs two checks. First, it checks if the two vertices are marked as on the open boundary. Second, it checks if the edge is within the open boundary envelope. Note that these checks are not sufficient to guarantee that an edge is actually on the open boundary! For example, an almost degenerate triangle with two edges on the open boundary could cause a false positive result.

◆ keep_largest_connected_component()

void wmtk::components::simwild::SimWildMesh::keep_largest_connected_component ( const std::vector< CellTag > &  lcc_tags,
const size_t  n_lcc = 1 
)

Keep only the largest connected component for each of the distinct tag_0 values, and engulf all other components.

Parameters
lcc_tags
n_lccThe number of largest components that should be kept.

◆ optimization_quality_stats()

std::tuple< double, double > wmtk::components::simwild::SimWildMesh::optimization_quality_stats ( )
overrideprotectedvirtual

Quality metric used by the driver. TetWild uses absolute AMIPS; SimWild overrides this with quality normalized by each cell's tag-dependent target.

Reimplemented from wmtk::TetOptimizerMesh.

◆ optimization_stop_at_float()

bool wmtk::components::simwild::SimWildMesh::optimization_stop_at_float ( ) const
inlineoverrideprotectedvirtual

Reimplemented from wmtk::TetOptimizerMesh.

◆ optimization_stop_metric()

double wmtk::components::simwild::SimWildMesh::optimization_stop_metric ( ) const
inlineoverrideprotectedvirtual

Reimplemented from wmtk::TetOptimizerMesh.

◆ orient_tracked_face() [1/4]

std::array< size_t, 3 > wmtk::TetMesh::orient_tracked_face ( const std::array< size_t, 3 > &  f) const
inline

Out of the tet whose tags come first (std::set order) into the other: a sheet between two tag sets is oriented the same way all over, from the tags alone.

◆ orient_tracked_face() [2/4]

virtual std::array< size_t, 3 > wmtk::TetMesh::orient_tracked_face ( const std::array< size_t, 3 > &  f,
const std::vector< size_t > &  tets 
) const
inlinevirtual

Out of the tet whose tags come first (std::set order) into the other: a sheet between two tag sets is oriented the same way all over, from the tags alone.

Reimplemented from wmtk::TetMesh.

◆ orient_tracked_face() [3/4]

std::array< size_t, 3 > wmtk::TetOptimizerMesh::orient_tracked_face ( const std::array< size_t, 3 > &  f,
const std::vector< size_t > &  tets 
) const
overridevirtual

Out of the tet whose tags come first (std::set order) into the other: a sheet between two tag sets is oriented the same way all over, from the tags alone.

Reimplemented from wmtk::TetMesh.

◆ orient_tracked_face() [4/4]

std::array< size_t, 3 > wmtk::components::simwild::SimWildMesh::orient_tracked_face ( const std::array< size_t, 3 > &  f,
const std::vector< size_t > &  tets 
) const
overridevirtual

A tracked face's corners in the order that orients it, for a surface history, given the face's tets (tets_of_face). As given, unless an application says otherwise. The tets are passed in so that a caller holding one corner can find them from its tets alone (faces_at_vertex).

Reimplemented from wmtk::TetMesh.

◆ quality_rel()

double wmtk::components::simwild::SimWildMesh::quality_rel ( const size_t  tid) const
overridevirtual

SimWild's target is per tag, so this normalizes each cell by its own before the shared optimizer compares one cell against another. See TetOptimizerMesh::quality_rel.

Reimplemented from wmtk::TetOptimizerMesh.

◆ refine_sizing_around_worst()

size_t wmtk::components::simwild::SimWildMesh::refine_sizing_around_worst ( double  max_metric = 0.)
overridevirtual

Escape a stuck max energy by refining the sizing field around the worst elements.

Finds the m_params.stuck_refine_num_worst tets with the highest energy, gathers all vertices within m_params.stuck_refine_rings graph rings of them, and multiplies each such vertex's m_sizing_scalar by m_params.stuck_refine_factor (clamped at m_params.stuck_refine_min_scalar). Then runs gradation_smooth_sizing so the refined region blends smoothly into the surrounding resolution. Replaces the old global adjust_sizing_field mechanism. Returns the number of vertices refined.

Implements wmtk::TetOptimizerMesh.

◆ set_cell_quality()

void wmtk::components::simwild::SimWildMesh::set_cell_quality ( const size_t  tid,
const double  q 
)
inlineoverridevirtual

◆ simplify()

void wmtk::components::simwild::SimWildMesh::simplify ( )

Not checking the quality here can lead to horrible elements that take forever to fix in the optimization stage. The quality check reduces the amount of simplification, but the overall convergence is faster because the optimizer does not have to fix the mess.

◆ smoothing_energy_envelope()

std::shared_ptr< Envelope > wmtk::components::simwild::SimWildMesh::smoothing_energy_envelope ( const size_t  vid) const
overridevirtual

Envelope a vertex is pulled toward while smoothing.

Implements wmtk::TetOptimizerMesh.

◆ split_adjust_position()

bool wmtk::components::simwild::SimWildMesh::split_adjust_position ( size_t  ,
const std::vector< Tuple > &   
)
overrideprotectedvirtual

Optional annotation-only adjustment of the midpoint. Ordinary optimization returns true without changing the shared TetWild position.

Reimplemented from wmtk::TetOptimizerMesh.

◆ split_after_cells()

bool wmtk::components::simwild::SimWildMesh::split_after_cells ( size_t  ,
size_t  ,
size_t  ,
const std::vector< Tuple > &   
)
overrideprotectedvirtual

Restore application cell data on the children made by a split.

Reimplemented from wmtk::TetOptimizerMesh.

◆ split_before_cells()

bool wmtk::components::simwild::SimWildMesh::split_before_cells ( const Tuple &  ,
const std::vector< Tuple > &   
)
overrideprotectedvirtual

Cache application cell data before a split. TetWild needs none; SimWild caches tags.

Reimplemented from wmtk::TetOptimizerMesh.

◆ surface_envelope_for_face()

std::shared_ptr< Envelope > wmtk::components::simwild::SimWildMesh::surface_envelope_for_face ( const std::array< size_t, 3 > &  vids,
const FaceAttributes &  attr 
) const
inlineoverridevirtual

A tracked face's containment: its labels' envelopes if it has any, else m_envelope.

Reimplemented from wmtk::TetOptimizerMesh.

◆ swap_after_cells()

bool wmtk::components::simwild::SimWildMesh::swap_after_cells ( const std::vector< size_t > &  ,
bool   
)
overrideprotectedvirtual

Propagate application data to the cells made by a successful topological swap.

Reimplemented from wmtk::TetOptimizerMesh.

◆ swap_before_interior()

bool wmtk::components::simwild::SimWildMesh::swap_before_interior ( const std::vector< size_t > &  )
overrideprotectedvirtual

Application data attached to the old cells. TetWild has none; SimWild caches tags.

Reimplemented from wmtk::TetOptimizerMesh.

◆ swap_before_surface()

bool wmtk::components::simwild::SimWildMesh::swap_before_surface ( const std::vector< size_t > &  tids,
size_t  a,
size_t  b,
size_t  c,
size_t  d 
)
overrideprotectedvirtual

Reimplemented from wmtk::TetOptimizerMesh.

◆ tag_priority()

void wmtk::components::simwild::SimWildMesh::tag_priority ( const std::vector< int64_t > &  tags)

Gives tags priority over others.

If a tet has multiple tags, only the one with the highest priority will be kept. The priority is determined by the order of the tags in the input vector, e.g., if tag A is before tag B in the vector, then A has higher priority than B.

Parameters
tagsA vector of tags, where the order determines the priority.

◆ tet_tags()

std::vector< int64_t > wmtk::components::simwild::SimWildMesh::tet_tags ( size_t  tid) const
overridevirtual

A tet's tags: the regions of a volume history are the tag sets.

Reimplemented from wmtk::TetMesh.

◆ update_attributes()

void wmtk::components::simwild::SimWildMesh::update_attributes ( )
overridevirtual

Update the attributes of the mesh after an iteration of operations.

Re-derives the surface from the tet tags over the whole mesh: a face is a surface face exactly when it separates two differently tagged tets, and a vertex is on the surface exactly when it belongs to such a face. This is the global form of what the operations used to attempt incrementally; doing it here, between passes and single-threaded, avoids both the stale flags that OR-merging leaves behind and the neighbourhood reads that are unsafe inside a parallel operation.

See also
check_interface_faces_tagged, which verifies the post-condition in both directions.

Reimplemented from wmtk::TetOptimizerMesh.

◆ write_optimization_debug_output()

void wmtk::components::simwild::SimWildMesh::write_optimization_debug_output ( const std::string &  path)
inlineoverrideprotectedvirtual

Member Data Documentation

◆ m_F_envelope_labels

std::vector<InputSet> wmtk::components::simwild::SimWildMesh::m_F_envelope_labels

Per row of m_F_envelope: its label bits, when m_F_envelope is the inputs' triangles (InputData::F_envelope_labels); empty once m_F_envelope is rebuilt from the mesh.

◆ m_input_envelopes

wmtk::InputEnvelopes wmtk::components::simwild::SimWildMesh::m_input_envelopes

One envelope per label, and each surface face held by those of the labels it lies on: bit i < F of a face's input set is face tag i (m_face_tag_names, F of them), bit F + j the boundary of tet tag j's region. A border between tet tag sets S and S' carries the bits of the tags in one and not the other; ambient is the empty set, so a border of region X with ambient is held by X's envelope, one between X and Y by both. As tetwild holds a tracked face to its inputs' envelopes, and topological_offset's 2D mesh a region boundary to its tags'.

Member b is built around the same surface as m_envelope, restricted to label b – the input triangles of that label in generation, else the mesh's faces carrying it – at the eps and with the predicate m_envelope has at the time (init_label_envelopes()), and follows it: at eps_simplify while the simplification runs, around the simplified surface after. Built around the faces embedded on the inputs instead, the members cost +33 to +70% time; around the input triangles, +2 to +6%. m_envelope stays the union, for the engine's direct uses of it and for a surface face carrying no label.

With one union envelope a collapse by the seam of two sheets side by side moved a face of one 0.125 off it (eps 0.029), within eps of the other. Two volumes a fraction of eps apart did not drift so with it (each region's boundary stayed within 0.7 eps of its own box, the tets between them in the way); their labels' envelopes make that hold by construction.

◆ m_sim_params

Parameters& wmtk::components::simwild::SimWildMesh::m_sim_params

The base holds only wmtk::OptimizerParameters; this is the same object, typed, for the simwild-only fields (tags, quality/sizing fields, the operation name).


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