3#include <wmtk/TetMesh.h>
7namespace app::interior_tet_opt {
12 size_t partition_id = 0;
13 double m_sizing_scalar = 1.;
26 double target_l = 5e-2;
27 double m_splitting_l2 = -1.;
28 double m_collapsing_l2 = -1.;
29 void initialize(
const std::vector<Eigen::Vector3d>&,
const std::vector<std::array<size_t, 4>>&);
34 bool is_inverted(
const Tuple&)
const;
35 double get_quality(
const Tuple&)
const;
36 double get_length2(
const Tuple&)
const;
37 bool invariants(
const std::vector<Tuple>& t)
override;
38 void final_output_mesh(std::string);
45 double max_quality = -1.;
47 tbb::enumerable_thread_specific<SplitInfoCache> split_cache;
57 std::vector<std::array<size_t, 3>> surface_faces;
58 std::vector<size_t> changed_tids;
60 std::vector<std::array<size_t, 2>> failed_edges;
62 tbb::enumerable_thread_specific<CollapseInfoCache> collapse_cache;
70 size_t v1_id = loc.vid(*
this);
72 if (m_vertex_attribute[v1_id].freeze)
return false;
75 size_t v2_id = loc1.vid(*
this);
80 std::map<size_t, double> qs;
81 for (
auto& l : n1_locs) {
82 qs[l.tid(*
this)] = m_tet_attribute[l.tid(*
this)].quality;
84 for (
auto& l : n12_locs) {
85 qs.erase(l.tid(*
this));
88 collapse_cache.local().max_energy = 0;
90 if (q.second > collapse_cache.local().max_energy)
91 collapse_cache.local().max_energy = q.second;
93 collapse_cache.local().changed_tids.push_back(q.first);
102 for (
auto& loc : locs) {
103 if (is_inverted(loc)) {
108 for (
size_t tid : collapse_cache.local().changed_tids) {
110 if (!tet.is_valid(*
this))
continue;
111 if (is_inverted(tet))
return false;
112 double q = get_quality(tet);
113 if (q > collapse_cache.local().max_energy) {
116 m_tet_attribute[tid].quality = q;
125 tbb::enumerable_thread_specific<SwapInfoCache> swap_cache;
135 void split_all_edges();
136 void smooth_all_vertices();
137 void collapse_all_edges(
bool is_limit_length =
true);
138 void swap_all_edges_44();
139 void swap_all_edges();
140 void swap_all_faces();
143 size_t get_partition_id(
const Tuple& loc)
const
145 return m_vertex_attribute[loc.vid(*
this)].partition_id;
147 std::tuple<double, double> get_max_avg_energy()
149 double max_energy = -1.;
150 double avg_energy = 0;
153 TetMesh::for_each_tetra([&](
auto& t) {
154 auto& q = m_tet_attribute[t.tid(*
this)].quality;
155 if (q < 0) q = get_quality(t);
157 if (q > max_energy) max_energy = q;
159 avg_energy += std::cbrt(q);
165 return std::make_tuple(std::cbrt(max_energy), avg_energy);
a Tuple refers to a global vid and a global tet id, and a local edge id and local face id
Definition TetMesh.h:49
Tuple tuple_from_tet(size_t tid) const
get a Tuple from global tetra index
Definition TetMesh.cpp:580
std::vector< Tuple > get_incident_tets_for_edge(const Tuple &t) const
Get the incident tets for edge.
Definition TetMesh.cpp:781
Tuple switch_vertex(const Tuple &t) const
wrapper function from Tuple::switch_vertex
Definition TetMesh.h:921
std::vector< Tuple > get_one_ring_tets_for_vertex(const Tuple &t) const
Get the one ring tets for a vertex.
Definition TetMesh.cpp:701
bool collapse_edge_before(const Tuple &loc) override
User specified preparations and desideratas for an edge collapse before changing the connectivity.
Definition Mesh.hpp:68
bool swap_edge_44_after(const Tuple &t) override
User specified modifications and desideratas for after a 4-4 edge swap.
Definition Mesh.cpp:205
bool swap_edge_before(const Tuple &t) override
User specified preparations and desideratas for an 3-2 edge swap before changing the conenctivity.
Definition Mesh.cpp:113
bool swap_face_after(const Tuple &t) override
User specified modifications and desideratas for after a 2-3 face swap.
Definition Mesh.cpp:167
bool smooth_after(const Tuple &t) override
User specified modifications and desideratas for after smoothing a vertex.
Definition Mesh.cpp:232
bool split_edge_after(const Tuple &loc) override
This function computes the attributes for the added simplices. User specified modifications and desid...
Definition Mesh.cpp:71
bool swap_edge_after(const Tuple &t) override
User specified modifications and desideratas for after a 3-2 edge swap.
Definition Mesh.cpp:129
bool swap_face_before(const Tuple &t) override
User specified preparations and desideratas for an 2-3 face swap befroe changing the geometry.
Definition Mesh.cpp:153
bool split_edge_before(const Tuple &loc0) override
User specified preparations and desideratas for an edge split before changing the connectivity.
Definition Mesh.cpp:54
bool swap_edge_44_before(const Tuple &t) override
User specified preparations and desideratas for an 4-4 edge swap before changing the connectivity.
Definition Mesh.cpp:192
bool smooth_before(const Tuple &t) override
User specified preparations and desideratas for smoothing a vertex.
Definition Mesh.cpp:226
bool collapse_edge_after(const Tuple &t) override
User specified modifications and desideratas for after an edge collapse.
Definition Mesh.hpp:98
Definition AttributeCollection.hpp:37