15#include <wmtk/TetMesh.h>
16#include <wmtk/TetOptimizerMesh.h>
17#include <wmtk/envelope/Envelope.hpp>
18#include <wmtk/optimization/EnergySum.hpp>
19#include <wmtk/optimization/solver.hpp>
20#include <wmtk/simplex/Simplex.hpp>
21#include <wmtk/threading/enumerable_thread_specific.hpp>
22#include "OffsetPotential.hpp"
23#include "Parameters.h"
24#include "SimplicialComplexBVH.hpp"
25#include "TagEnvelopes.hpp"
28#include <wmtk/utils/DisableWarnings.hpp>
29#include <wmtk/utils/EnableWarnings.hpp>
32using CellTag = std::set<int64_t>;
35namespace wmtk::components::topological_offset {
37const int64_t TEMP_OFFSET_TET_TAG = -1;
38const CellTag TEMP_OFFSET_TET_TAG_SET{TEMP_OFFSET_TET_TAG};
57 size_t component_id = 0;
58 bool m_is_on_input =
false;
59 bool m_is_on_offset =
false;
60 bool m_is_on_region =
false;
64 bool m_turn_start_valid =
false;
110 double m_quality = 0;
118 std::array<Vector3d, 4> rest_pos;
138 enum class EdgeSplitMode {
147 std::array<size_t, 4> m_init_counts = {{0, 0, 0, 0}};
224 void init_region_potentials(
double delta,
double effective_factor);
230 int vertex_region(
const size_t vid)
const
234 int edge_region(
const size_t va,
const size_t vb)
const
236 const int a = vertex_region(va), b = vertex_region(vb);
237 return (a >= 0 && a == b) ? a : -1;
239 const OffsetPotential3D& potential_for_region(
const int region)
const
245 const OffsetPotential3D& potential_for(
const size_t vid)
const
247 return potential_for_region(vertex_region(vid));
253 const int r = vertex_region(vid);
257 const OffsetPotential3D& potential_for_edge(
const size_t va,
const size_t vb)
const
259 return potential_for_region(edge_region(va, vb));
285 mutable std::mutex m_isect_mutex;
305 std::shared_ptr<SampleEnvelope>
containment_for(uint64_t region_mask,
bool on_offset)
const;
401 EdgeSplitMode m_edge_split_mode = EdgeSplitMode::Midpoint;
404 std::map<std::string, int64_t> m_tag_name_to_id;
405 std::map<int64_t, std::string> m_tag_id_to_name;
406 CellTag m_offset_output_tag_ids;
409 bool m_singlebody =
false;
410 int64_t m_single_tag;
413 bool m_has_envelope =
false;
414 MatrixXd m_V_envelope;
415 MatrixXi m_F_envelope;
418 double m_envelope_eps = -1;
430 static constexpr int OFFSET_SURFACE_CLASS = 1;
450 NUM_THREADS = _num_threads;
455 p_edge_attrs = &m_edge_attribute;
456 p_tet_attrs = &m_tet_attribute;
458 m_collapse_check_link_condition =
false;
459 m_collapse_check_manifold =
false;
463 optimization::deactivate_opt_logger();
470 double cell_quality(
const size_t tid)
const override {
return m_tet_attribute[tid].m_quality; }
471 void set_cell_quality(
const size_t tid,
const double q)
override
473 m_tet_attribute[tid].m_quality = q;
485 m_vertex_attribute[vid].m_posf = p;
486 m_vertex_attribute[vid].m_pos = to_rational(p);
487 m_vertex_attribute[vid].m_is_rounded =
true;
495 return m_face_attribute[fid].m_is_surface_fs &&
496 m_face_attribute[fid].m_surface_class == OFFSET_SURFACE_CLASS;
498 bool face_is_region(
const size_t fid)
const
500 return m_face_attribute[fid].m_is_surface_fs &&
501 m_face_attribute[fid].m_surface_class != OFFSET_SURFACE_CLASS;
517 return FaceSnapshot{m_face_attribute[fid], m_face_extra[fid]};
519 void restore_face(
const size_t fid,
const FaceSnapshot& s)
521 m_face_attribute[fid] = s.tags;
522 m_face_extra[fid] = s.extra;
539 const int l = m_tet_attribute[tid].label;
540 return l == 1 || l == 2;
561 void log_worst_dist_vertex()
const;
678 mutable std::map<std::string, std::vector<size_t>> m_debug_pvd_series;
687 mutable int m_debug_last_round = -1;
688 mutable char m_debug_last_phase =
'?';
699 double m_quality_max_amips = 0.;
704 std::atomic<int> iter_cnt_recollapsed{0};
705 std::atomic<int> iter_cnt_recollapsed_same_pass{0};
706 std::atomic<int> iter_cnt_split = 0, iter_cnt_collapse = 0, iter_cnt_swap = 0;
707 std::atomic<int> iter_cnt_collapse_offset_removed{0};
710 std::atomic<int> iter_cnt_swap_offset_reject{0};
714 std::atomic<int> iter_cnt_swap_guard_reject{0};
733 void flip_trace_record(
double before,
double after);
765 mutable std::atomic<long long> funnel_case_not_better{0};
766 mutable std::atomic<long long> funnel_case_better{0};
767 mutable std::atomic<long long> funnel_quality{0};
768 mutable std::atomic<long long> funnel_quality_ok{0};
769 mutable std::atomic<long long> funnel_committed{0};
770 std::string flip_funnel_report()
const;
771 void flip_funnel_reset();
774 std::atomic<int> iter_cnt_split_offset{0};
779 mutable std::atomic<long> m_split_off_longest{0};
784 static thread_local bool off =
false;
787 void op_event(OpKind k, OpEvent e)
const override;
796 bool is_edge_on_region =
false;
797 bool is_edge_on_offset =
false;
798 std::map<simplex::Edge, TetAttributes> tets;
808 bool marching_split_edge_before(
const Tuple& t);
825 const Vector3d& p_in,
826 const Vector3d& p_out,
828 size_t& steps)
const;
833 size_t m_marching_trace_steps = 0, m_marching_trace_steps_max = 0;
847 bool collapse_after_connectivity(
850 const std::vector<std::array<size_t, 2>>& boundary_edges)
override;
851 bool collapse_is_order_2_edge(
const std::array<size_t, 2>& e)
override
853 return is_order_2_edge(e);
855 void collapse_after_vertex(
size_t v1,
size_t v2)
override;
863 bool swap_before_surface(
864 const std::vector<size_t>& tids,
869 bool swap_after_cells(
const std::vector<size_t>& tids,
bool is_surface_flip)
override;
875 bool split_before_cells(
const Tuple& edge,
const std::vector<Tuple>& parents)
override;
876 bool split_after_cells(
size_t v1,
size_t v2,
size_t v_new,
const std::vector<Tuple>& children)
898 return !m_vertex_attribute[vid].on_bbox_faces.empty();
900 bool face_is_on_domain_boundary(
const size_t fid)
const
902 return m_face_attribute[fid].m_is_bbox_fs >= 0;
919 bool is_edge_on_offset(
const Tuple& loc);
953 std::atomic<long long> res_after_nano{0};
954 std::atomic<long long> res_max_before_nano{0};
955 std::atomic<long long> res_max_after_nano{0};
959 for (std::atomic<int>* c :
972 for (std::atomic<long long>* c :
973 {&
res_before_nano, &res_after_nano, &res_max_before_nano, &res_max_after_nano}) {
978 SmoothTrace m_smooth_trace;
994 mutable std::atomic<size_t> m_needle_smooth_offered{0};
995 mutable std::atomic<size_t> m_needle_smooth_reached{0};
996 mutable std::atomic<size_t> m_needle_smooth_fixed{0};
997 mutable std::atomic<size_t> m_needle_smooth_stationary{0};
998 mutable std::atomic<size_t> m_needle_smooth_reports{0};
1019 void record_flatness(
const char* op,
double parent_flat,
size_t child_tid)
const;
1020 mutable std::atomic<size_t> m_flat_created_split{0};
1021 mutable std::atomic<size_t> m_flat_created_collapse{0};
1022 mutable std::atomic<size_t> m_flat_worsened_split{0};
1023 mutable std::atomic<size_t> m_flat_genesis_reports{0};
1024 static constexpr double kFlatThreshold = 1e-3;
1056 const std::vector<std::array<size_t, 3>>& before,
1057 const std::vector<std::array<size_t, 3>>& after,
1058 size_t removed)
const;
1077 void log_smooth_trace()
const;
1104 return m_vertex_extra[vid].m_is_on_region || !m_vertex_attribute[vid].on_bbox_faces.empty();
1111 for (
const int64_t t : tags) {
1113 if (it !=
m_tag_bit.end()) bits |= (uint64_t(1) << it->second);
1142 return tag_bits(m_tet_attribute[f.
tid(*
this)].tag);
1144 const auto& t0 = m_tet_attribute[f.
tid(*
this)].tag;
1145 const auto& t1 = m_tet_attribute[opp->tid(*
this)].tag;
1147 std::set_symmetric_difference(
1152 std::inserter(diff, diff.begin()));
1171 const std::array<size_t, 3>& vids)
const override
1174 bool all_offset =
true;
1175 for (
const size_t v : vids) {
1176 all_offset = all_offset && m_vertex_extra[v].m_is_on_offset;
1184 if (mask != 0 && all_offset) {
1186 const size_t fid = std::get<1>(*found);
1187 if (m_face_attribute[fid].m_is_surface_fs) {
1196 const std::shared_ptr<SampleEnvelope> base =
containment_for(mask, all_offset);
1225 const bool ok = after < before;
1226 if (is_surface_flip &&
m_swap_sides.local().worthwhile) {
1228 if (ok) ++funnel_quality_ok;
1246 double swap_edge_44_energy(
const std::vector<std::array<size_t, 4>>& tets,
const int op_case)
1248 double swap_edge_56_energy(
const std::vector<std::array<size_t, 4>>& tets,
const int op_case)
1250 bool check_surface_topology()
const override {
return m_offset_params.perform_sanity_checks; }
1268 std::shared_ptr<SampleEnvelope> best;
1269 double worst_d2 = -1.;
1272 if (it ==
m_tag_bit.end() || !(mask & (uint64_t(1) << it->second)))
continue;
1275 if ((mask & (mask - 1)) == 0)
break;
1276 worst_d2 = env->squared_distance(m_vertex_attribute[vid].m_posf);
1279 const double d2 = env->squared_distance(m_vertex_attribute[vid].m_posf);
1280 if (d2 > worst_d2) {
1355 return std::isfinite(ratio) && ratio <= 1.;
1373 static_cast<size_t>(-1);
1380 const Vector3d& x)
const;
1385 const size_t vid)
const override
1387 std::shared_ptr<polysolve::nonlinear::Problem> front;
1393 if (!front)
return rest;
1394 if (!rest)
return front;
1395 auto sum = std::make_shared<optimization::EnergySum>();
1396 sum->add_energy(front);
1397 sum->add_energy(rest);
1413 mutable std::atomic<bool> m_released_tube_dirty{
false};
1414 mutable std::mutex m_released_mutex;
1429 bool cell_is_plastic(
size_t tid)
const
1456 const std::shared_ptr<const OffsetPotential3D>& pot)
const;
1467 return m_phase != OptPhase::B ? wmtk::TetOptimizerMesh::optimization_stop_metric() : 1.;
1478 if (k < 0)
return 0;
1479 if (k == 0)
return 3;
1480 const int n = 1 << (k - 1);
1481 return (n + 1) * (n + 2) / 2 + n * n;
1512 double max_reachable = 0., avg_reachable = 0.;
1513 double max_pinned = 0.;
1514 size_t n_reachable = 0, n_pinned = 0;
1515 double max_at_vertex = 0., max_in_face = 0.;
1516 size_t n_outside_support = 0;
1517 size_t worst_outside_vid =
static_cast<size_t>(-1);
1518 double worst_outside_dist = 0.;
1559 template <
typename Visit>
1564 Visit&& visit)
const
1569 const auto emit = [&](
const double wa,
const double wb,
const double wc) {
1570 visit(Vector3d(wa * p0 + wb * p1 + wc * p2), wa, wb, wc);
1584 const int n = 1 << (k - 1);
1585 const double dn = double(n);
1586 for (
int i = n; i >= 0; --i) {
1587 for (
int j = n - i; j >= 0; --j) {
1588 emit(
double(i) / dn,
double(j) / dn,
double(n - i - j) / dn);
1595 const double d3n = 3. * dn;
1596 for (
int i = n - 1; i >= 0; --i) {
1597 for (
int j = n - 1 - i; j >= 0; --j) {
1598 const int l = n - 1 - i - j;
1599 emit((3. * i + 1.) / d3n, (3. * j + 1.) / d3n, (3. * l + 1.) / d3n);
1602 for (
int i = n - 2; i >= 0; --i) {
1603 for (
int j = n - 2 - i; j >= 0; --j) {
1604 const int l = n - 2 - i - j;
1605 emit((3. * i + 2.) / d3n, (3. * j + 2.) / d3n, (3. * l + 2.) / d3n);
1611 template <
typename Visit>
1614 const auto vs = get_face_vids(f);
1616 m_vertex_attribute[vs[0]].m_posf,
1617 m_vertex_attribute[vs[1]].m_posf,
1618 m_vertex_attribute[vs[2]].m_posf,
1619 std::forward<Visit>(visit));
1634 double max_reachable = 0., avg_reachable = 0.;
1635 double max_pinned = 0.;
1636 size_t n_reachable = 0, n_pinned = 0;
1637 double max_at_vertex = 0., max_in_face = 0.;
1638 double max_in_face_pinned = 0.;
1639 double max_normal_aligned = 0.;
1640 size_t n_face_samples = 0;
1641 size_t n_skipped_inverted = 0, n_skipped_unrounded = 0;
1642 size_t worst_vid =
static_cast<size_t>(-1);
1659 size_t n_vertices = 0, n_faces = 0, n_unmeasurable = 0;
1660 size_t worst_vid =
static_cast<size_t>(-1);
1661 Vector3d worst_face_centroid = Vector3d::Zero();
1669 double max_face_placed = 0.;
1670 Vector3d worst_placed_centroid = Vector3d::Zero();
1679 Vector3d worst_at_floor_centroid = Vector3d::Zero();
1687 Vector3d worst_corners_at_floor_centroid = Vector3d::Zero();
1690 bool floor_from_min_edge_length =
false;
1702 double measure, len;
1704 std::vector<Refinable> refinable;
1727 static const char* ring_name() {
return "area-weighted ring measure"; }
1729 size_t n_rings = 0, n_rings_unmeasurable = 0;
1730 size_t worst_ring_vid =
static_cast<size_t>(-1);
1739 Vector3d worst_ring_at_floor_pos = Vector3d::Zero();
1740 bool rings_ok()
const {
return max_ring <= bar; }
1741 double avg_ring()
const {
return n_rings ?
sum_ring / double(n_rings) : 0.; }
1747 bool faces_ok()
const {
return max_face <= bar; }
1775 return (
ring_exit ? rings_ok() : faces_ok()) && n_unmeasurable == 0;
1783 double ratio()
const {
return bar > 0. ? std::max(max_vertex,
max_face) / bar : 0.; }
1786 double avg_face()
const {
return n_faces ? sum_face / double(n_faces) : 0.; }
1788 EnergyCriterion energy_criterion();
1795 double front_chord_target(
size_t va,
size_t vb,
double len,
double sag,
double tube)
const;
1811 void grade_sizing(
double grade,
const std::vector<size_t>& seeds);
1826 size_t front_worst_vid =
static_cast<size_t>(-1);
1833 size_t background_worst_vid =
static_cast<size_t>(-1);
1834 size_t n_background = 0;
1878 mutable std::atomic<size_t> m_deg_split_created{0};
1879 mutable std::atomic<size_t> m_deg_collapse_offered{0};
1880 mutable std::atomic<size_t> m_deg_collapse_allowed{0};
1881 mutable std::atomic<size_t> m_deg_collapse_by_ringmax{0};
1882 mutable std::atomic<size_t> m_deg_collapse_by_stop{0};
1883 mutable std::atomic<size_t> m_deg_collapse_by_unrounded{0};
1884 std::array<size_t, 6> m_deg_prev_counts{{0, 0, 0, 0, 0, 0}};
1887 void report_needle(
const char* op,
size_t tid,
double parent_q)
const;
1888 static constexpr size_t kNeedleReports = 12;
1891 mutable std::atomic<size_t> m_needle_reports{0};
1899 size_t m_stuck_calls = 0;
1921 const char ph = (
m_phase == OptPhase::A) ?
'A' : (
m_phase == OptPhase::B ?
'B' :
'S');
1922 if (
m_ab_round != m_debug_last_round || ph != m_debug_last_phase) {
1924 m_debug_last_phase = ph;
1927 std::string label = path;
1928 if (path.rfind(
"debug_", 0) == 0) {
1929 label = fmt::format(
1935 }
else if (path.rfind(
"phase_", 0) == 0) {
1936 label = fmt::format(
"r{}{}_end",
m_ab_round, ph);
1964 const MatrixSi& T_tags,
1965 const MatrixXd& V_env,
1966 const MatrixXi F_env,
1967 const std::vector<std::string>& tag_names,
1968 const std::string& sheet_name =
"");
1995 std::vector<int> m_phi_P;
2000 std::vector<std::array<size_t, 3>> get_faces_by_condition(
2010 bool invariants(
const std::vector<Tuple>& tets)
override;
2026 bool is_simplicially_embedded()
const;
2027 bool tet_is_simp_emb(
const Tuple& t)
const;
2028 void simplicial_embedding();
2042 void write_input_complex(
const std::string& path);
2043 void write_vtu(
const std::string& path);
2044 void write_msh_groups(
const std::string& file);
2060 bool is_edge_on_region =
false;
2061 bool is_edge_on_offset =
false;
2062 bool is_edge_open_boundary =
false;
2064 std::vector<std::pair<FaceAttributes, std::array<size_t, 3>>> changed_faces;
2068 std::map<size_t, EdgeAttributes> internal_e;
2069 std::map<simplex::Edge, EdgeAttributes> external_e;
2070 std::map<simplex::Edge, EdgeAttributes> link_e;
2073 std::map<size_t, FaceSnapshot> split_f;
2074 std::map<simplex::Edge, FaceSnapshot> internal_f;
2075 std::map<std::pair<simplex::Edge, size_t>,
FaceSnapshot>
2079 std::map<simplex::Edge, TetAttributes> tets;
2088 std::map<simplex::Edge, EdgeAttributes> existing_e;
2089 std::map<simplex::Face, FaceSnapshot> existing_f;
2091 std::map<size_t, TetAttributes> tets;
2097 std::array<size_t, 4> v_ids;
2098 std::map<simplex::Edge, EdgeAttributes> existing_e;
2099 std::map<simplex::Face, FaceSnapshot> existing_f;
2133 std::map<size_t, std::pair<CellTag, int>> by_vertex;
2144 double sag_before = 0.0;
2145 double sag_after = 0.0;
2160 bool swap_capture_surface_sides(
2161 const std::vector<size_t>& tids,
2173 bool is_order_2_edge(
const Tuple& e)
const;
2174 bool is_order_2_edge(
const std::array<size_t, 2>& e)
const;
2192 return tag1.empty();
2198 for (
const int64_t& i : tag1) {
2199 if (tag2.find(i) != tag2.end()) {
2213 double len1 = (m_vertex_attribute[e1.vertices()[0]].m_posf -
2214 m_vertex_attribute[e1.vertices()[1]].m_posf)
2216 double len2 = (m_vertex_attribute[e2.vertices()[0]].m_posf -
2217 m_vertex_attribute[e2.vertices()[1]].m_posf)
2227 size_t get_partition_id(
const Tuple& loc)
const
2229 return m_vertex_attribute[loc.vid(*
this)].partition_id;
2236 std::vector<size_t> ret_v_ids;
2237 for (
const size_t& other_v_id : onering_v_ids) {
2239 if (m_edge_attribute[e_id].label != 0) {
2240 ret_v_ids.push_back(other_v_id);
2250 for (
const Tuple& v : verts) {
2251 size_t v_id = v.vid(*
this);
2252 m_vertex_extra[v_id].component_id = 0;
Whether a codimension-1 simplex is tracked surface, and which bbox side it lies on.
Definition SurfaceTagAttributes.h:15
a Tuple refers to a global vid and a global tet id, and a local edge id and local face id
Definition TetMesh.h:50
std::optional< Tuple > switch_tetrahedron(const TetMesh &m) const
Definition TetMeshTuple.cpp:304
size_t tid(const TetMesh &m) const
Definition TetMeshTuple.cpp:250
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.
Definition TetMesh.cpp:430
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.
Definition TetMesh.cpp:800
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).
Definition TetMesh.cpp:342
std::vector< Tuple > get_vertices() const
Definition TetMesh.cpp:311
What tetwild and simwild's 3D mesh share.
Definition TetOptimizerMesh.h:46
AttributeContainerGroup m_vertex_attr_group
What p_vertex_attrs points at, so a derived class can register more.
Definition TetOptimizerMesh.h:93
std::string m_debug_pass_name
Definition TetOptimizerMesh.h:247
AttributeContainerGroup m_face_attr_group
What p_face_attrs points at, so a derived class can register more.
Definition TetOptimizerMesh.h:108
Definition TopoOffsetTetMesh.h:85
The offset potential: the scalar field on space whose level set the front is placed on.
Definition OffsetPotential.hpp:37
Definition TopoOffsetTetMesh.h:106
bool rest_valid
Definition TopoOffsetTetMesh.h:117
The offset's tet mesh, on the shared 3D optimizer.
Definition TopoOffsetTetMesh.h:136
void stamp_plastic_rests()
Stamp rest := current for every plastic cell; called before every operation group.
Definition Optimize3d.cpp:564
double ring_face_area(size_t a, size_t b, size_t c) const
Definition Optimize3d.cpp:1060
wmtk::threading::enumerable_thread_specific< double > m_collapse_parent_flatness
The flattest tet in the collapse's ring before it ran, for record_flatness().
Definition TopoOffsetTetMesh.h:1026
std::vector< std::array< int, 3 > > churn_counts
Definition TopoOffsetTetMesh.h:666
EnvelopeSetup
Which boundaries the region-class envelopes hold, and how they are built.
Definition TopoOffsetTetMesh.h:355
int64_t m_sheet_tag
Definition TopoOffsetTetMesh.h:153
double front_chord_target(size_t va, size_t vb, double len, double sag, double tube) const
Definition Optimize3d.cpp:3329
std::atomic< int > iter_cnt_split_born
Definition TopoOffsetTetMesh.h:703
double vertex_ring_measure(const std::vector< std::array< size_t, 3 > > &ring) const
Definition Optimize3d.cpp:1068
int stencil_points_per_face() const
Definition TopoOffsetTetMesh.h:1475
bool vertex_is_on_domain_boundary(const size_t vid) const
Identification only – no operation refuses the domain wall through these.
Definition TopoOffsetTetMesh.h:896
bool split_edge_after(const Tuple &t) override
This function computes the attributes for the added simplices. User specified modifications and desid...
Definition EdgeSplittingTet.cpp:238
void report_offset_face_lookup_misses(const char *when) const
Definition Optimize3d.cpp:4081
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.
Definition Optimize3d.cpp:713
OptPhase m_phase
Which phase is running. Read by every hook that differs between them; see OptPhase.
Definition TopoOffsetTetMesh.h:332
std::set< int64_t > m_source_tags
Definition TopoOffsetTetMesh.h:1407
std::atomic< int > iter_cnt_collapse_offset_reject
Operations refused because they would have left an offset-surface face over tolerance.
Definition TopoOffsetTetMesh.h:709
MatrixXd m_phi_V
Definition TopoOffsetTetMesh.h:1992
size_t m_worst_dist_vid
Definition TopoOffsetTetMesh.h:560
bool smooth_plastic_vertex(const Tuple &t)
The plastic vertex's smoothing: rest-shape AMIPS over its ring, nothing else.
Definition Optimize3d.cpp:579
size_t grade_sizing_by_distance(const std::vector< size_t > &seeds)
Definition Optimize3d.cpp:3497
wmtk::threading::enumerable_thread_specific< SwapSurfaceSides > m_swap_sides
Definition TopoOffsetTetMesh.h:2168
double optimization_stop_metric() const override
stop_energy outside Phase B, 1.0 in it – in the same units as the line above.
Definition TopoOffsetTetMesh.h:1465
std::shared_ptr< const OffsetPotential3D > potential_ptr_for(const size_t vid) const
Definition TopoOffsetTetMesh.h:251
std::tuple< double, double > optimization_quality_stats() override
The loop's quality metric: TetWild's own outside Phase B, the max of AMIPS and the Phi residual (each...
Definition Optimize3d.cpp:3674
uint64_t face_boundary_bits(const Tuple &f) const
Definition TopoOffsetTetMesh.h:1138
int m_debug_pass
Definition TopoOffsetTetMesh.h:686
std::optional< EnergyCriterion > m_energy_verdict
Definition TopoOffsetTetMesh.h:1846
void record_flatness(const char *op, double parent_flat, size_t child_tid) const
Genesis: flatness transitions recorded at the operation hooks. {op, parent, child}.
Definition Optimize3d.cpp:2436
std::atomic< long long > funnel_cases
Definition TopoOffsetTetMesh.h:758
FaceSamples offset_face_samples(const Tuple &f) const
Definition Optimize3d.cpp:2620
bool cell_is_offset_band(const size_t tid) const
Whether tet tid is part of the offset BAND (as opposed to the input complex).
Definition TopoOffsetTetMesh.h:545
std::atomic< long long > flip_trace_bar
Definition TopoOffsetTetMesh.h:729
void report_outside_support(const char *when, const DistanceSplit &s) const
Turn a residual_split()'s outside-support tally into the hard error.
Definition Optimize3d.cpp:3607
wmtk::threading::enumerable_thread_specific< double > m_collapse_survivor_sizing
Definition TopoOffsetTetMesh.h:1029
void sort_edges_by_length(std::vector< simplex::Edge > &edges)
sort edge simplices in place by decreasing edge length
Definition TopoOffsetTetMesh.h:2207
wmtk::threading::enumerable_thread_specific< int > m_swap_label
The construction label shared by every cell of an interior swap's ring, captured alongside.
Definition TopoOffsetTetMesh.h:2118
std::map< uint64_t, std::shared_ptr< SampleEnvelope > > m_offset_isect_cache
Memoized "region tubes AND the offset envelope", keyed by the region mask.
Definition TopoOffsetTetMesh.h:294
std::shared_ptr< SampleEnvelope > smoothing_energy_envelope(const size_t vid) const override
The offset surface is the one tracked surface with no envelope, in either role.
Definition TopoOffsetTetMesh.h:1259
void write_debug_frame(const std::string &label)
One frame of the run's single debug timeline: <output>_NNNNN.vtu with the next sequence number,...
Definition Optimize3d.cpp:4397
std::atomic< int > m_placement_tangential
Definition TopoOffsetTetMesh.h:1096
std::vector< int > m_cell_region
per tet: band's region, -1 none, -2 reached from two
Definition TopoOffsetTetMesh.h:222
uint64_t face_mask(const std::array< size_t, 3 > &vids) const
Definition TopoOffsetTetMesh.h:1129
std::string envelope_key_name(int64_t tag) const
The name a tag or pseudo-tag prints under.
Definition TopoOffsetTetMesh.cpp:271
void for_each_offset_face_sample(const Tuple &f, Visit &&visit) const
The same lattice over a face the mesh carries. Visitor signature as above.
Definition TopoOffsetTetMesh.h:1612
std::vector< std::array< size_t, 2 > > offset_surface_edges() const
Definition Optimize3d.cpp:3962
void build_boundary_envelopes(const char *when, EnvelopeSetup setup)
Definition TopoOffsetTetMesh.cpp:291
std::vector< char > offset_surface_foldover_labels() const
Per-vertex 0/1: is this vertex an endpoint of a COLLAPSED (folded-over) offset surface edge?...
Definition Optimize3d.cpp:4105
void release_deformable_regions()
Definition Optimize3d.cpp:632
double edge_conv_ratio(size_t a, size_t b) const
Definition Optimize3d.cpp:3106
size_t get_order_of_vertex(const size_t vid) const override
Get the order of a vertex.
Definition TopoOffsetTetMesh.cpp:1172
void reset_connected_components()
reset connected component assignments.
Definition TopoOffsetTetMesh.h:2247
bool front_vertex_placed(size_t vid) const
THE definition of "placed" for a vertex on the offset surface.
Definition Optimize3d.cpp:3099
size_t flood_fill()
label connected simplicial complex components (simplices labelled 1 or 2)
Definition TopoOffsetTetMesh.cpp:1116
void grade_sizing(double grade, const std::vector< size_t > &seeds)
Definition Optimize3d.cpp:3487
std::vector< int64_t > m_phi_vert_region
per m_phi_V row: region index
Definition TopoOffsetTetMesh.h:218
void write_debug_pvd() const
Definition Optimize3d.cpp:4421
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.
Definition EdgeSplittingTet.cpp:636
std::vector< bool > band_vertex_mask() const
Which vertices lie on the band's outer surface. Shared by every measurement.
Definition Optimize3d.cpp:2599
std::shared_ptr< SampleEnvelope > envelope_for_mask(uint64_t mask) const
Definition Optimize3d.cpp:424
bool cell_is_deformable(size_t tid) const
Under deform_others the same set as cell_is_plastic(): every cell outside the band.
Definition Optimize3d.cpp:532
void label_offset_boundary()
Tag the two tracked surfaces for the optimization phase.
Definition Optimize3d.cpp:155
std::array< std::atomic< long long >, 3 > funnel_kind
offered, split by swap kind: [0] = 3-2, [1] = 4-4, [2] = 5-6.
Definition TopoOffsetTetMesh.h:755
double offset_gradient_tolerance() const
Definition TopoOffsetTetMesh.h:1496
bool cell_in_region(const size_t tid) const
Definition TopoOffsetTetMesh.h:537
bool collapse_edge_before(const Tuple &t) override
Reject any collapse that violates the substructure link condition, and remember the survivor's sizing...
Definition Optimize3d.cpp:882
static bool & split_off_longest()
Definition TopoOffsetTetMesh.h:782
void marching_tets()
Definition TopoOffsetTetMesh.cpp:1444
static constexpr long long kFlipTraceEvery
Definition TopoOffsetTetMesh.h:725
bool smooth_before(const Tuple &t) override
User specified preparations and desideratas for smoothing a vertex.
Definition Optimize3d.cpp:1276
bool split_edge_before(const Tuple &t) override
User specified preparations and desideratas for an edge split before changing the connectivity.
Definition EdgeSplittingTet.cpp:12
std::shared_ptr< OffsetPotential3D > m_offset_potential
The smooth offset potential, and with it the definition of the offset itself.
Definition TopoOffsetTetMesh.h:189
void init_offset_potential()
Build the smooth offset potential from the extraction init_input_complex_bvh() kept.
Definition TopoOffsetTetMesh.cpp:990
void set_offset_tet_tags()
update 'tags' data for tets in the offset region (tets labelled 2)
Definition TopoOffsetTetMesh.cpp:1583
bool split_tet_after(const Tuple &t) override
Compute the attributes for the added simplices.
Definition EdgeSplittingTet.cpp:542
std::shared_ptr< SimplicialComplexBVH > m_input_complex_bvh
The input complex as loaded. Built once, never rebuilt.
Definition TopoOffsetTetMesh.h:179
std::shared_ptr< polysolve::nonlinear::Problem > phase_b_front_objective(size_t vid, const Vector3d &x) const
Definition FrontSmooth3d.cpp:434
bool face_is_on_surface(const size_t fid) const override
Is a face part of the substructure.
Definition Optimize3d.cpp:150
bool ambient_assert()
check that the ambient tag does not overlap with any other tags
Definition TopoOffsetTetMesh.cpp:403
void log_front_profile(size_t vid)
Diagnostic: the front objective of one vertex along its normal, offset term vs total.
Definition Optimize3d.cpp:3290
std::atomic< long long > flip_trace_nonmono
fall < 0 (a rise): MUST stay 0, the rule forbids it
Definition TopoOffsetTetMesh.h:727
std::vector< Tuple > offset_surface_faces_live_at(size_t vid) const
The live offset-surface faces incident to vid.
Definition Optimize3d.cpp:3990
MatrixXd m_sheet_V
The surface group as loaded, kept because the classification below is redone on demand.
Definition TopoOffsetTetMesh.h:155
std::shared_ptr< SampleEnvelope > m_input_complex_envelope
The exact-kind envelope of the input complex, built only for offset_field "euclidean"....
Definition TopoOffsetTetMesh.h:200
static constexpr int64_t m_complex_tag
Definition TopoOffsetTetMesh.h:361
void compute_vertex_partition()
assign each vertex a partition id (by spatial Morton order). A no-op if NUM_THREADS == 0.
Definition TopoOffsetTetMesh.cpp:1191
Vector3d offset_vertex_normal(const size_t vid) const
Definition Optimize3d.cpp:1395
double face_conv_ratio(size_t a, size_t b, size_t c) const
Definition Optimize3d.cpp:3126
double amips_rel_at_face(const Tuple &f) const
... and the worst of the (up to two) cells a face separates.
Definition Optimize3d.cpp:3703
double max_band_vertex_distance() const
Definition TopoOffsetTetMesh.cpp:1225
std::vector< std::string > m_debug_frame_labels
Definition TopoOffsetTetMesh.h:677
double offset_residual_tolerance() const
Definition TopoOffsetTetMesh.h:1486
void mark_input_complex_vertices()
Definition TopoOffsetTetMesh.cpp:388
std::atomic< int > iter_cnt_split_offset_before
Splits of an offset-surface edge: offered, accepted.
Definition TopoOffsetTetMesh.h:773
static constexpr int INPUT_SURFACE_CLASS
SurfaceTagAttributes::m_surface_class: which of the two tracked surfaces a face belongs to....
Definition TopoOffsetTetMesh.h:429
bool cell_is_input_complex(const size_t tid) const
Whether tet tid is part of the INPUT complex the band wraps.
Definition TopoOffsetTetMesh.h:543
wmtk::threading::enumerable_thread_specific< std::vector< size_t > > m_collapse_edge_link
The link of the collapsed edge, captured in collapse_before_vertex().
Definition TopoOffsetTetMesh.h:1042
void check_offset_membership(const char *when) const
Definition Optimize3d.cpp:4060
bool face_borders_released_boundary(const Tuple &f) const
Definition Optimize3d.cpp:4224
wmtk::threading::enumerable_thread_specific< std::pair< double, Vector3d > > m_needle_pre
Why smoothing does not repair a sliver in its one-ring. Same counters as 2D: offered / reached / fixe...
Definition TopoOffsetTetMesh.h:993
std::shared_ptr< SampleEnvelope > smoothing_containment_envelope(const size_t vid) const override
Definition TopoOffsetTetMesh.h:1290
bool marching_split_edge_after(const Tuple &t)
Definition EdgeSplittingTet.cpp:251
double gradient_reference() const
The scale offset_gradient_tolerance() is a fraction of; 0 on the single-phase path.
Definition TopoOffsetTetMesh.h:1502
bool vertex_has_live_offset_face(size_t vid) const
Definition Optimize3d.cpp:4014
bool face_is_offset(const size_t fid) const
Definition TopoOffsetTetMesh.h:493
std::atomic< int > m_placement_projected
Definition TopoOffsetTetMesh.h:1093
bool split_face_before(const Tuple &t) override
User specified preparations and desideratas for a face split before changing the connectivity.
Definition EdgeSplittingTet.cpp:344
const OffsetPotential3D & potential_for_face(const Tuple &f) const
The field of the band cell a live offset face belongs to.
Definition Optimize3d.cpp:4173
std::vector< std::shared_ptr< SimplicialComplexBVH > > m_region_bvhs
Definition TopoOffsetTetMesh.h:217
Parameters & m_offset_params
The base holds only wmtk::OptimizerParameters; this is the same object, typed.
Definition TopoOffsetTetMesh.h:433
bool m_quality_converged
Definition TopoOffsetTetMesh.h:698
void init_from_image(const MatrixXd &V, const MatrixXi &T, const MatrixSi &T_tags, const MatrixXd &V_env, const MatrixXi F_env, const std::vector< std::string > &tag_names, const std::string &sheet_name="")
initialize TetMesh from vertex, tet, and tag data
Definition TopoOffsetTetMesh.cpp:73
std::shared_ptr< SampleEnvelope > containment_for(uint64_t region_mask, bool on_offset) const
The containment a simplex with this region mask, on/off the offset surface, must satisfy – the inters...
Definition Optimize3d.cpp:463
bool offset_is_manifold()
verify that the closed offset region (simplices labelled 1 or 2) form a manifold region.
Definition TopoOffsetTetMesh.cpp:1617
void audit_surface_containment(const std::string &when) const
Definition Optimize3d.cpp:1422
double front_vertex_conv_ratio(size_t vid) const
Definition Optimize3d.cpp:3076
static constexpr int64_t m_wall_tag
pseudo-tag: the domain wall's tube
Definition TopoOffsetTetMesh.h:360
void log_refine_block_census(const std::string &when, double filter_energy) const
Definition Optimize3d.cpp:1896
uint64_t vertex_boundary_mask(const size_t vid) const
Definition TopoOffsetTetMesh.h:1122
void write_optimization_debug_output(const std::string &path) override
Put the optimization's frames on the run's single debug timeline (see write_debug_frame()),...
Definition TopoOffsetTetMesh.h:1919
void init_vertex_order()
Compute the vertex order for every vertex.
Definition TopoOffsetTetMesh.cpp:1177
void needle_forensics() const
The full post-mortem on why nothing removes the flat cells; see the 2D twin.
Definition Optimize3d.cpp:2486
void append_frame_label(size_t idx, const std::string &label) const
One line of <output>_frames.txt; truncates the file on the first frame.
Definition Optimize3d.cpp:4389
double band_vertex_distance_error(const size_t vid) const
|dist(vid, input complex) - target_distance|. Diagnostic: the Euclidean offset.
Definition Optimize3d.cpp:2609
std::atomic< long long > funnel_offered
[flip funnel]: of the flips of the offset surface that passed the sag rule, how many survive each lat...
Definition TopoOffsetTetMesh.h:753
void execute_offset(const std::filesystem::path &output_file)
Definition TopoOffsetTetMesh.cpp:1245
bool any_tag_present(const CellTag &tag1, const CellTag &tag2)
determine if any tag from tag1 is also present in tag2.
Definition TopoOffsetTetMesh.h:2189
std::atomic< long > m_split_order_waits
Definition TopoOffsetTetMesh.h:778
bool is_edge_on_region(const Tuple &loc)
Definition Optimize3d.cpp:89
double tet_amips(const size_t tid) const
AMIPS of one tet, the cube root of cell_quality(); the number every log line reports.
Definition TopoOffsetTetMesh.h:1004
bool project_into_containment(size_t vid, Vector3d &x) const
Move x back inside every region tube this vertex lies on. True if it ended up inside all of them....
Definition Optimize3d.cpp:492
bool band_vertex_is_reachable(const size_t vid) const
Definition TopoOffsetTetMesh.h:1858
std::pair< double, double > ops_guard_measures(const std::vector< std::array< size_t, 3 > > &before, const std::vector< std::array< size_t, 3 > > &after, size_t removed) const
Definition Optimize3d.cpp:997
std::vector< std::shared_ptr< OffsetPotential3D > > m_region_potentials
Definition TopoOffsetTetMesh.h:213
std::shared_ptr< SampleEnvelope > m_offset_envelope
The tube the offset surface may not leave during the operation passes, of half-width offset_envelope....
Definition TopoOffsetTetMesh.h:381
size_t m_front_gradient_worst_vid
Definition TopoOffsetTetMesh.h:1372
void set_vertex_position(const size_t vid, const Vector3d &p)
Place a vertex, keeping its exact and rounded coordinates in step.
Definition TopoOffsetTetMesh.h:483
std::shared_ptr< polysolve::nonlinear::Problem > smoothing_extra_energy(const size_t vid) const override
Definition TopoOffsetTetMesh.h:1384
std::vector< size_t > connected_components_helper(const size_t &v_id)
all one-ring vertices through input simplices (labelled 1 or 2)
Definition TopoOffsetTetMesh.h:2233
std::atomic< int > m_placement_env_entry_outside
Definition TopoOffsetTetMesh.h:1090
std::map< int64_t, std::shared_ptr< SampleEnvelope > > m_tag_envelopes
One containment envelope per input tag, ambient included. Both phases.
Definition TopoOffsetTetMesh.h:276
std::set< int64_t > m_deform_tags
The released tags. Filled by release_deformable_regions(); empty = feature inactive.
Definition TopoOffsetTetMesh.h:1404
bool collapse_before_vertex(size_t v1, size_t v2, double edge_length) override
Definition Optimize3d.cpp:1091
uint64_t tag_bits(const CellTag &tags) const
The three helpers of the per-tag envelope dispatch.
Definition TopoOffsetTetMesh.h:1108
std::vector< int > m_vertex_region
per vertex: region of its band cells, -1 / -2 as above
Definition TopoOffsetTetMesh.h:223
std::shared_ptr< polysolve::nonlinear::Problem > phase_b_front_energy(size_t vid, const std::shared_ptr< const OffsetPotential3D > &pot) const
Definition FrontSmooth3d.cpp:489
bool front_vertex_alignment_traps_1d_solve(size_t vid) const
Definition FrontSmooth3d.cpp:398
Vector3d front_vertex_move_direction(size_t vid) const
Definition FrontSmooth3d.cpp:331
void log_smoothing_pass_accounting() override
Definition Optimize3d.cpp:1836
void warn_if_offset_reaches_domain_boundary() const
Warn if the offset band has grown into the domain boundary.
Definition Optimize3d.cpp:391
std::shared_ptr< SampleEnvelope > released_envelope() const
Definition Optimize3d.cpp:4247
void stamp_rest_cell(size_t tid)
Definition Optimize3d.cpp:555
double edge_interpolation_residual(size_t a, size_t b) const
The interpolation residual of front edge (a, b), see EnergyCriterion. -1 unmeasurable.
Definition Optimize3d.cpp:2776
bool m_freeze_front
The final Phase A: front vertices are not smoothed (see smooth_before()).
Definition TopoOffsetTetMesh.h:335
double band_vertex_residual(const size_t vid) const
How far vid is from the level set Phi = c, as a length.
Definition Optimize3d.cpp:2615
std::set< std::tuple< long, long, long > > m_stuck_prev_cells
Definition TopoOffsetTetMesh.h:1898
std::pair< size_t, size_t > offset_membership_mismatches() const
Definition Optimize3d.cpp:4047
void refresh_offset_membership(size_t vid)
Re-derive m_is_on_offset for one vertex from the cell labels, exactly.
Definition Optimize3d.cpp:4042
bool optimization_bare_coarsen_passes() const override
Definition TopoOffsetTetMesh.h:1904
void assign_band_regions(bool log=true)
Definition Optimize3d.cpp:3191
std::vector< int64_t > m_phi_seg_region
per m_phi_E row: region index, -1 unknown
Definition TopoOffsetTetMesh.h:219
double front_move_alignment(size_t vid) const
Definition FrontSmooth3d.cpp:317
void init_input_complex_bvh()
Build the input complex's BVH and keep the extraction the potential needs, and number the complex's c...
Definition TopoOffsetTetMesh.cpp:715
std::atomic< int > iter_cnt_collapse_guard_reject
Definition TopoOffsetTetMesh.h:713
double phase_b_front_gradient_linf()
Definition Optimize3d.cpp:3056
std::shared_ptr< SampleEnvelope > surface_envelope_for_face(const std::array< size_t, 3 > &vids) const override
Class-0 faces – every region boundary, the input complex and the domain wall included – carry a conta...
Definition TopoOffsetTetMesh.h:1170
double swap_edge_44_energy(const std::vector< std::array< size_t, 4 > > &tets, const int op_case) override
Counting only: the scored cases of a 4-4 / 5-6 flip of the offset surface, for [flip funnel]....
Definition Optimize3d.cpp:685
bool allow_surface_swap() const override
Definition TopoOffsetTetMesh.h:1211
bool is_open_boundary_edge(const Tuple &e) override
Definition TopoOffsetTetMesh.h:883
bool swap_before_interior(const std::vector< size_t > &tids) override
Which tag the tets a swap creates should carry, and the topology half of the surface-flip refusal (cl...
Definition Optimize3d.cpp:270
bool front_placed_by_ratio(const double ratio) const
Definition TopoOffsetTetMesh.h:1353
void label_input_complex()
label input simplicial complex simplices, as defined in m_offset_params.offset_selection
Definition TopoOffsetTetMesh.cpp:460
void smooth_group_to_convergence(const char *group_name)
Definition Optimize3d.cpp:3440
std::pair< double, double > compute_distance_deviation() const
How far the offset surface is from where it should be: {max, avg} over vertices.
Definition Optimize3d.cpp:3628
bool collapse_quality_allowed(size_t v1, double q, double ring_max) const override
Instrumentation only: which operation manufactures the MAX_ENERGY needles.
Definition Optimize3d.cpp:2283
void split_after_vertex(size_t v_new, bool is_edge_open_boundary) override
Application metadata not represented by the shared vertex attributes.
Definition Optimize3d.cpp:1232
void rebuild_offset_envelope()
Definition Optimize3d.cpp:4283
void for_each_face_sample(const Vector3d &p0, const Vector3d &p1, const Vector3d &p2, Visit &&visit) const
The interior lattice a triangle is sampled on, handed to visit one point at a time as (point,...
Definition TopoOffsetTetMesh.h:1560
std::map< uint64_t, std::shared_ptr< SampleEnvelope > > m_isect_cache
Definition TopoOffsetTetMesh.h:284
std::vector< std::array< int, 3 > > op_counts
{splits, collapses, swaps} per turn, as deltas rather than running totals.
Definition TopoOffsetTetMesh.h:668
static constexpr double kNeedleQuality
What counts as a needle for the tripwire, in AMIPS – deliberately far below MAX_ENERGY.
Definition TopoOffsetTetMesh.h:1890
bool m_converged
Definition TopoOffsetTetMesh.h:694
size_t refine_front_by_halving(const std::vector< EnergyCriterion::Refinable > &faces)
Definition Optimize3d.cpp:3363
double face_resolution_or_inf(size_t a, size_t b, size_t c) const
Definition Optimize3d.cpp:914
bool smooth_front_vertex_phase_b(const Tuple &t)
Phase B placement of a front vertex: the shared smoother with the offset's options,...
Definition FrontSmooth3d.cpp:199
GradientSplit gradient_split(bool include_face_samples=true) const
Definition Optimize3d.cpp:2683
bool edge_is_offset_surface_live(size_t a, size_t b) const
Whether edge (a, b) lies on the band's outer surface: some incident face does.
Definition Optimize3d.cpp:3949
bool swap_capture_tag(const std::vector< size_t > &tids)
Definition Optimize3d.cpp:236
bool swap_quality_allowed(const double after, const double before, const bool is_surface_flip) const override
Definition TopoOffsetTetMesh.h:1222
SmoothingProgress smoothing_progress(const std::vector< Vector3d > &before)
Measure a pass: before holds every live vertex's position before it, indexed by vid.
Definition Optimize3d.cpp:3398
std::array< std::atomic< long long >, 8 > flip_trace_dec
Definition TopoOffsetTetMesh.h:732
bool face_is_complex_boundary(const Tuple &f) const
Definition TopoOffsetTetMesh.cpp:279
DistanceSplit residual_split() const
The same split over the quantity the loop converges on: the Phi residual, as a length.
Definition Optimize3d.cpp:2637
bool collapse_edge_after(const Tuple &t) override
The coarsening bar, the sizing restore and the rest re-stamp, after the base accepted.
Definition Optimize3d.cpp:862
std::map< int64_t, int > m_tag_bit
Definition TopoOffsetTetMesh.h:280
bool split_tet_before(const Tuple &t) override
User specified preparations and desideratas for a tet split before changing the connectivity.
Definition EdgeSplittingTet.cpp:506
int stencil_order() const
Samples per offset face; see offset_face_samples().
Definition TopoOffsetTetMesh.h:1471
std::vector< std::array< size_t, 3 > > offset_surface_faces() const
Every live offset-surface face as a sorted vertex triple.
Definition Optimize3d.cpp:3977
bool edge_split_sphere_trace(const Vector3d &p_in, const Vector3d &p_out, Vector3d &p_new, size_t &steps) const
Construction placement under sphere_trace_initialization: sphere tracing along the edge from p_in (th...
Definition EdgeSplittingTet.cpp:204
bool phase_places_front() const
Definition TopoOffsetTetMesh.h:329
std::array< size_t, 3 > face_vids(const Tuple &f) const
The three corner ids of a face tuple.
Definition Optimize3d.cpp:908
void optimize_offset(const std::filesystem::path &output_file)
The 3D optimization phase: split / collapse / swap / smooth on the shared driver.
Definition Optimize3d.cpp:4874
bool vertex_is_on_region(const size_t vid) const
Definition TopoOffsetTetMesh.h:1102
bool cell_is_released_band(size_t tid) const
Definition Optimize3d.cpp:539
bool ops_guard_refuses_collapse(size_t v1, size_t v2) const
Definition Optimize3d.cpp:926
double tet_flatness(size_t tid) const
Scale-invariant flatness: 6 * volume / longest_edge^3.
Definition Optimize3d.cpp:2418
void log_stuck_refine_census(double max_metric, double filter_energy)
Definition Optimize3d.cpp:2087
std::shared_ptr< polysolve::nonlinear::Problem > rest_energy_for_vertex(size_t vid) const
Definition Optimize3d.cpp:665
std::shared_ptr< SampleEnvelope > m_released_envelope
Definition TopoOffsetTetMesh.h:1412
bool split_before_cells(const Tuple &edge, const std::vector< Tuple > &parents) override
Split policy that is the offset's own: which region tag the two child tets inherit,...
Definition EdgeSplittingTet.cpp:607
bool vertex_is_on_surface(const size_t vid) const override
Is a vertex part of the substructure.
Definition Optimize3d.cpp:143
std::atomic< long long > m_offset_face_lookup_misses
Faces that vertex_has_live_offset_face() / offset_surface_faces_live_at() asked for and the connectiv...
Definition TopoOffsetTetMesh.h:630
double front_vertex_normal_gradient(size_t vid) const
Definition Optimize3d.cpp:1409
bool empty_input_complex()
check if the input complex is empty. Only valid after calling init_from_image(...).
Definition TopoOffsetTetMesh.cpp:703
double ring_max_quality(size_t vid) const
Definition Optimize3d.cpp:2409
void needle_scan(const char *when) const
Population scan at a named moment. Reports the count and the worst few.
Definition Optimize3d.cpp:2360
double m_front_gradient_reference
Definition TopoOffsetTetMesh.h:399
bool split_face_after(const Tuple &t) override
Compute the attributes for the added simplices.
Definition EdgeSplittingTet.cpp:417
double face_criterion_rel(const Tuple &f) const
Definition Optimize3d.cpp:3712
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.
Definition Optimize3d.cpp:812
std::vector< int64_t > m_phi_face_region
per m_phi_F row: region index, -1 unknown
Definition TopoOffsetTetMesh.h:220
void log_region_face_mask_health(const std::string &when) const
Definition Optimize3d.cpp:1691
std::vector< std::array< double, 8 > > optimization_metrics
Definition TopoOffsetTetMesh.h:663
bool split_edge_is_due(const Tuple &e) const
Definition EdgeSplittingTet.cpp:58
double cell_quality_rel(const size_t tid) const
AMIPS of a cell over stop_energy – the 3D twin of TriOptimizerMesh::quality_rel().
Definition Optimize3d.cpp:3696
size_t m_marching_root_splits
Definition TopoOffsetTetMesh.h:832
size_t m_debug_seq
Monotonic frame counter for the debug timeline.
Definition TopoOffsetTetMesh.h:673
size_t refine_sizing_around_worst(double max_metric) override
TetWild's stall-driven sizing refinement, verbatim; Phase A only. See the 2D twin.
Definition Optimize3d.cpp:3727
void check_offset_within_support(const char *when) const
Definition Optimize3d.cpp:3602
bool split_adjust_position(size_t v_new, const std::vector< Tuple > &children) override
Definition Optimize3d.cpp:1262
std::atomic< long long > flip_trace_n
accepted offset-surface flips
Definition TopoOffsetTetMesh.h:726
OptPhase
Which mode the hooks are running in. The 3D copy of TopoOffsetTriMesh::OptPhase.
Definition TopoOffsetTetMesh.h:325
bool face_is_offset_surface_live(const Tuple &f) const
The band's outer surface, recomputed live rather than read from the cached class.
Definition Optimize3d.cpp:3923
void optimize_offset_single_phase()
TetWild's loop, the front placed inside its smoothing passes.
Definition Optimize3d.cpp:4459
wmtk::threading::enumerable_thread_specific< CellTag > m_swap_tag
The tag swap_after_cells writes onto the tets an INTERIOR swap created, chosen in before.
Definition TopoOffsetTetMesh.h:2116
int m_ab_round
Definition TopoOffsetTetMesh.h:671
void init_surfaces_and_boundaries()
Classify every region boundary, build the per-tag containment envelopes, and tag the domain wall – on...
Definition TopoOffsetTetMesh.cpp:198
Vector3d front_vertex_normal(size_t vid) const
The field's unit direction at front vertex vid (zero where grad Phi vanishes).
Definition FrontSmooth3d.cpp:391
double cell_quality(const size_t tid) const override
The quality of cell tid, and how to write it.
Definition TopoOffsetTetMesh.h:470
void classify_sheet_faces()
Mark the mesh faces that lie on the input's envelope surface group (FaceExtra::on_sheet).
Definition TopoOffsetTetMesh.cpp:421
std::atomic< long long > funnel_case_inverted
Definition TopoOffsetTetMesh.h:764
void report_needle(const char *op, size_t tid, double parent_q) const
Where the first needles come from – a tripwire, capped at kNeedleReports.
Definition Optimize3d.cpp:2306
int m_n_regions
One field per connected piece of the input complex, and which one each band vertex is placed on....
Definition TopoOffsetTetMesh.h:212
std::atomic< long long > m_offset_face_invalid_tuple
Definition TopoOffsetTetMesh.h:634
optimization::NewtonCounters m_newton_front
Definition TopoOffsetTetMesh.h:985
bool m_plastic_active
set in optimize_offset() when deform_others
Definition TopoOffsetTetMesh.h:1428
void write_phi_grid(const std::string &path, int n) const
Definition TopoOffsetTetMesh.cpp:2071
bool smooth_after(const Tuple &t) override
User specified modifications and desideratas for after smoothing a vertex.
Definition Optimize3d.cpp:1306
std::vector< int64_t > m_phi_point_region
per m_phi_P entry: region index, -1 unknown
Definition TopoOffsetTetMesh.h:221
void check_no_vertex_on_both_surfaces(const char *when) const
Definition Optimize3d.cpp:4183
double m_gradient_reference
See offset_gradient_tolerance(). Nothing sets it on the single-phase path; it stays 0.
Definition TopoOffsetTetMesh.h:690
Definition Simplex.hpp:46
Definition enumerable_thread_specific.hpp:26
What the offset needs on top of the parameters every wmtk optimizer shares.
Definition Parameters.h:24
double front_conv_frac() const
Definition Parameters.h:81
bool deform_others
Definition Parameters.h:114
Definition TopoOffsetTetMesh.h:1511
Definition TopoOffsetTetMesh.h:2054
Definition TopoOffsetTetMesh.h:1700
The "energy_gradient" criterion: the front's Newton-step ratios and the refinable faces....
Definition TopoOffsetTetMesh.h:1652
double worst_face_len
Definition TopoOffsetTetMesh.h:1662
size_t n_unplaced
Definition TopoOffsetTetMesh.h:1691
bool ring_exit
front_measure "vertex_ring"
Definition TopoOffsetTetMesh.h:1726
std::vector< size_t > refinable_vertices
Definition TopoOffsetTetMesh.h:1734
double max_ring_at_floor
the worst of them, as a ratio to the bar
Definition TopoOffsetTetMesh.h:1738
std::string sizing_floor_fact() const
Definition Optimize3d.cpp:3002
double max_face
Definition TopoOffsetTetMesh.h:1653
size_t n_corners_at_floor
Definition TopoOffsetTetMesh.h:1685
size_t n_rings_over
Definition TopoOffsetTetMesh.h:1731
size_t n_rings_at_floor
Definition TopoOffsetTetMesh.h:1737
size_t n_at_floor
Definition TopoOffsetTetMesh.h:1677
double worst_at_floor_scalar
Definition TopoOffsetTetMesh.h:1680
double sum_vertex
Definition TopoOffsetTetMesh.h:1657
double floor_scalar
The floor, max(min_sizing_scalar, min_edge_length / l), and which of the two it is.
Definition TopoOffsetTetMesh.h:1689
size_t n_faces_over
Definition TopoOffsetTetMesh.h:1668
double sum_ring
ratios to the bar (1 = bar)
Definition TopoOffsetTetMesh.h:1728
bool vertices_ok() const
Definition TopoOffsetTetMesh.h:1746
double avg_vertex() const
Means over the measurable front vertices / offset faces; 0 when there are none.
Definition TopoOffsetTetMesh.h:1785
double max_face_corners_at_floor
the worst of them, as a ratio to the bar
Definition TopoOffsetTetMesh.h:1686
double max_face_at_floor
the worst of them, as a ratio to the bar
Definition TopoOffsetTetMesh.h:1678
bool converged() const
Definition TopoOffsetTetMesh.h:1773
A quantity sampled at points INSIDE an offset-surface face.
Definition TopoOffsetTetMesh.h:1538
A face's shared surface tags together with the offset's own label.
Definition TopoOffsetTetMesh.h:511
Definition TopoOffsetTetMesh.h:2084
The convergence criterion's own split: ||grad (Phi - c)^2|| at band vertices plus the face-interior c...
Definition TopoOffsetTetMesh.h:1633
Definition TopoOffsetTetMesh.h:795
double parent_flatness
Definition TopoOffsetTetMesh.h:804
double parent_q_max
Definition TopoOffsetTetMesh.h:801
What smoothing did with each class of vertex, per pass. Same fields as 2D.
Definition TopoOffsetTetMesh.h:938
std::atomic< int > before_bbox
base smooth_before said no: on the bounding box
Definition TopoOffsetTetMesh.h:940
std::atomic< int > before_unrounded
base smooth_before said no: could not round
Definition TopoOffsetTetMesh.h:941
std::atomic< int > interior_attempted
reached it without one
Definition TopoOffsetTetMesh.h:948
std::atomic< long long > res_before_nano
Definition TopoOffsetTetMesh.h:952
std::atomic< int > attempted
smooth_before() entered
Definition TopoOffsetTetMesh.h:939
std::atomic< int > before_phase_b_not_offset
Phase B: on an input surface, neither placed nor relaxed.
Definition TopoOffsetTetMesh.h:942
std::atomic< int > before_phase_b_enveloped_background
Phase B: envelope-held.
Definition TopoOffsetTetMesh.h:944
std::atomic< int > offset_accepted
... and the smoother kept the new position
Definition TopoOffsetTetMesh.h:947
std::atomic< int > before_phase_b_enveloped_offset
Phase B: on-offset AND held.
Definition TopoOffsetTetMesh.h:945
std::atomic< int > region_attempted
Definition TopoOffsetTetMesh.h:949
std::atomic< int > offset_attempted
reached the smoother with the offset term
Definition TopoOffsetTetMesh.h:946
Definition TopoOffsetTetMesh.h:1822
size_t n_front_unmeasurable
ratio not finite: left out of the max
Definition TopoOffsetTetMesh.h:1828
double front_max_step
Definition TopoOffsetTetMesh.h:1829
double background_max_step
Definition TopoOffsetTetMesh.h:1832
size_t n_front
front vertices the max was taken over
Definition TopoOffsetTetMesh.h:1827
double front_max_ratio
Definition TopoOffsetTetMesh.h:1825
Definition TopoOffsetTetMesh.h:2132
bool saw_case
Definition TopoOffsetTetMesh.h:2156
bool worthwhile
Definition TopoOffsetTetMesh.h:2148
int kind
tids.size() as swap_before_surface() saw it: 3, 4 or 5, i.e. which swap this is.
Definition TopoOffsetTetMesh.h:2158
bool sag_measured
Definition TopoOffsetTetMesh.h:2143
std::array< size_t, 4 > abcd
Definition TopoOffsetTetMesh.h:2137
double case0_energy
Definition TopoOffsetTetMesh.h:2151
Definition TopoOffsetTetMesh.h:2096
How the vertex solves of a smoothing pass ended: Newton iterations taken and the status polysolve sto...
Definition SmoothVertex.hpp:75