4#include <Eigen/Geometry>
6#include <wmtk/envelope/Envelope.hpp>
15namespace wmtk::components::topological_offset {
123 const Eigen::MatrixXd& V,
124 const Eigen::MatrixXi& F,
125 const std::vector<int8_t>& face_side,
127 size_t value_slots = 0,
128 std::shared_ptr<const wmtk::Envelope> envelope =
nullptr);
137 int64_t rule_a_pieces = 0;
148 int64_t closed_checked = 0, open_results = 0;
159 int64_t
side_clipped = 0, side_rule_a_split = 0, side_D = 0, side_D_pos = 0;
165 double t_total = 0., t_candidates = 0., t_clip = 0., t_closed = 0., t_series = 0.;
190 double value(
const std::array<Eigen::Vector3d, 4>& t,
double delta,
Stats* stats =
nullptr)
217 std::unique_ptr<Work> m_w;
219 double m_key[12] = {};
223 double value(
const std::array<Eigen::Vector3d, 4>& t,
double delta,
Partition& keep)
const;
254 const std::array<Eigen::Vector3d, 4>& t,
257 Eigen::Vector3d& grad,
258 Eigen::Matrix3d& hess,
259 Stats* stats =
nullptr)
const;
262 const std::array<Eigen::Vector3d, 4>& t,
265 Eigen::Vector3d& grad,
266 Eigen::Matrix3d& hess,
278 const std::array<Eigen::Vector3d, 4>& t,
281 Eigen::Vector3d& grad,
282 Eigen::Matrix3d& hess,
291 int candidates = 0, pieces = 0, rule_a_pieces = 0;
319 double max_distance(
const std::array<Eigen::Vector3d, 3>& f,
MaxInfo* info =
nullptr)
const;
371 std::unique_ptr<FaceWork> m_w;
373 double m_key[9] = {};
396 const std::array<Eigen::Vector3d, 3>& f,
398 FaceParts* keep =
nullptr)
const;
399 void front_face_derivs(
400 const std::array<Eigen::Vector3d, 3>& f,
403 Eigen::Vector3d& grad,
404 Eigen::Matrix3d& hess,
405 FaceParts* keep =
nullptr)
const;
438 const std::array<Eigen::Vector3d, 4>& t,
452 size_t front_flux_polytopes()
const {
return m_ff_boxes.size(); }
480 size_t num_faces()
const {
return m_A.size(); }
489 Eigen::Vector3d p, dir;
490 int h_begin = 0, h_end = 0;
491 Eigen::Vector3d lo,
hi;
502 std::vector<std::pair<Eigen::Vector3d, Eigen::Vector3d>>
m_hs;
503 int m_nF = 0, m_nE = 0;
504 std::vector<Eigen::Vector3d> m_A, m_B,
m_C;
510 std::vector<char> m_side_has;
511 std::vector<Eigen::Vector3d> m_side_n, m_side_q;
516 std::shared_ptr<const wmtk::Envelope>
m_env;
524 Eigen::Vector3d lo, hi;
525 int left = -1, right = -1, begin = 0, end = 0;
542 const std::array<Eigen::Vector3d, 4>& t,
551 const std::array<Eigen::Vector3d, 4>& t,
561 const std::array<Eigen::Vector3d, 4>& t,
564 Eigen::Vector3d& grad,
565 Eigen::Matrix3d& hess,
568 bool want_value)
const;
577 static constexpr size_t kValueStripes = 1024;
578 mutable std::vector<ValueSlot> m_values;
579 mutable std::unique_ptr<std::mutex[]> m_value_locks;
583 double upper_bound(
const Eigen::Vector3d* t,
int n)
const;
588 const std::array<Eigen::Vector3d, 4>& t,
592 double empty_vol)
const;
593 void check_face_pieces(
594 const std::array<Eigen::Vector3d, 3>& f,
596 const char* who)
const;
606 Eigen::Vector3d lo, hi;
607 std::vector<std::pair<Eigen::Vector3d, double>> planes;
609 std::vector<FFBox> m_ff_boxes;
610 std::vector<Node> m_ff_nodes;
611 std::vector<int> m_ff_order;
612 double m_ff_reach = 0.;
613 int build_ff_node(
int begin,
int end);
616 const Eigen::Vector3d& lo,
617 const Eigen::Vector3d& hi,
619 std::vector<int>& out)
const;
One face's labelled parts, kept by the caller between front_face() calls on that face,...
Definition ExactBandIntegral.hpp:362
uint64_t m_owner
the integral's m_id; 0: none
Definition ExactBandIntegral.hpp:372
One cell's partition, kept by the caller between value() and value_grad_hess() of that cell: each par...
Definition ExactBandIntegral.hpp:208
uint64_t m_owner
the integral's m_id; 0: none
Definition ExactBandIntegral.hpp:218
bool m_ok
false: t is flat
Definition ExactBandIntegral.hpp:220
While one is alive on a thread, a curved bisector crossing a piece of a face (front_face(),...
Definition ExactBandIntegral.hpp:415
The band-volume integral of one cell, in closed form:
Definition ExactBandIntegral.hpp:104
bool front_flux_flag(const std::array< Eigen::Vector3d, 4 > &t) const
Whether the cell t can meet a bisector at points with d <= front_flux_reach(): t's box meets a kept p...
Definition ExactBandIntegral.hpp:461
double distance_bound(const std::array< Eigen::Vector3d, 4 > &t) const
Definition ExactBandIntegral.hpp:473
double value_tabled(const std::array< Eigen::Vector3d, 4 > &t, double delta, Partition *keep) const
value(t, delta, stats, keep) through the value table (value()).
Definition ExactBandIntegral.cpp:3732
std::shared_ptr< const wmtk::Envelope > m_env
Definition ExactBandIntegral.hpp:516
void localize(const Eigen::Vector3d *t, int n, Local &w, Stats *stats) const
Definition ExactBandIntegral.cpp:3408
void check_cell_pieces(const std::array< Eigen::Vector3d, 4 > &t, double delta, const Work &w, double vol_sum, double empty_vol) const
Definition ExactBandIntegral.cpp:4631
double distance(const Eigen::Vector3d &x) const
d(x), the distance to the input: min over the triangles of the point-triangle distance.
Definition ExactBandIntegral.hpp:470
void reserve_values(size_t slots) const
Definition ExactBandIntegral.cpp:3724
double front_face(const std::array< Eigen::Vector3d, 3 > &f, double delta, FaceParts *keep=nullptr) const
front_face(): int over the triangle f of G.n dA, n = (f1 - f0) x (f2 - f0) / |.| (f ordered with the ...
Definition ExactBandIntegral.cpp:4872
double bisector_jump(const std::array< Eigen::Vector3d, 4 > &t, double delta, Partition *keep=nullptr) const
D_t = int_t (d - delta) dV - oint_dt G.n dA of the cell t (either orientation): 0 exactly when one fe...
Definition ExactBandIntegral.cpp:4989
std::vector< Eigen::Vector3d > m_C
triangle corners, for d_P
Definition ExactBandIntegral.hpp:504
double front_flux_reach() const
prepare_front_flux()'s R (0 before it), and the number of polytopes it kept.
Definition ExactBandIntegral.hpp:451
double value_grad_hess_impl(const std::array< Eigen::Vector3d, 4 > &t, int kv, double delta, Eigen::Vector3d &grad, Eigen::Matrix3d &hess, Stats *stats, Partition *keep, bool want_value) const
Definition ExactBandIntegral.cpp:4179
double evaluate(const std::array< Eigen::Vector3d, 4 > &t, double delta, Stats *stats, Partition *keep) const
value() without the value table.
Definition ExactBandIntegral.cpp:3765
double m_pad
Definition ExactBandIntegral.hpp:519
void prepare_front_flux(double delta)
Builds, from the input alone, where bisectors can be: for every pair of features g,...
Definition ExactBandIntegral.cpp:5110
void candidates(const Eigen::Vector3d &lo, const Eigen::Vector3d &hi, double r, std::vector< int > &out) const
Feature indices whose box is within r of [lo, hi], ascending.
Definition ExactBandIntegral.cpp:3346
std::vector< std::pair< Eigen::Vector3d, Eigen::Vector3d > > m_hs
Definition ExactBandIntegral.hpp:502
bool partition(const std::array< Eigen::Vector3d, 4 > &t, Work &w, Stats *stats) const
Definition ExactBandIntegral.cpp:3459
double distance_bound(const Eigen::Vector3d *t, const int n) const
The same bound for the n points t; a subset's bound is never larger.
Definition ExactBandIntegral.hpp:478
void tri_partition(const std::array< Eigen::Vector3d, 3 > &f, TriWork &w) const
_tri_partition: the same for the face f, its pieces planar rings.
Definition ExactBandIntegral.cpp:3554
double max_distance(const std::array< Eigen::Vector3d, 3 > &f, MaxInfo *info=nullptr) const
max over the triangle f of d (exact_mesh.max_on_triangle), the settle loop's max test....
Definition ExactBandIntegral.cpp:3621
void label_face(const std::array< Eigen::Vector3d, 3 > &f, FaceWork &fw) const
Definition ExactBandIntegral.cpp:4784
double upper_bound(const Eigen::Vector3d *t, int n) const
U: min over all triangles of max over the n points t of d_P.
Definition ExactBandIntegral.cpp:3319
void grad_hess(const std::array< Eigen::Vector3d, 4 > &t, int kv, double delta, Eigen::Vector3d &grad, Eigen::Matrix3d &hess, Partition &keep) const
value_grad_hess()'s gradient and Hessian alone, t's partition read from or written to keep: J's own i...
Definition ExactBandIntegral.cpp:4168
double value(const std::array< Eigen::Vector3d, 4 > &t, double delta, Stats *stats=nullptr) const
J(t) = int_t (d - delta) dV for the cell with corners t (either orientation), restricted to the offse...
Definition ExactBandIntegral.cpp:3706
std::vector< std::array< int, 6 > > m_face_feats
Definition ExactBandIntegral.hpp:505
std::vector< Feature > m_feat
Definition ExactBandIntegral.hpp:493
double value_grad_hess(const std::array< Eigen::Vector3d, 4 > &t, int kv, double delta, Eigen::Vector3d &grad, Eigen::Matrix3d &hess, Stats *stats=nullptr) const
J and its exact gradient and Hessian with respect to corner kv of t, the other three fixed (exact_mes...
Definition ExactBandIntegral.cpp:4146
int m_sigma
Definition ExactBandIntegral.hpp:509
const FaceWork & face_parts(const std::array< Eigen::Vector3d, 3 > &f, FaceParts *keep) const
f's labelled parts, from keep when it holds f's, else made (into keep, or a scratch).
Definition ExactBandIntegral.cpp:4845
const Work * cell_partition(const std::array< Eigen::Vector3d, 4 > &t, Stats *stats, Work *own, Partition *keep) const
Definition ExactBandIntegral.cpp:3526
ExactBandIntegral(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F)
Definition ExactBandIntegral.hpp:109
uint64_t m_id
Definition ExactBandIntegral.hpp:548
Definition ExactBandIntegral.hpp:605
Definition ExactBandIntegral.cpp:4756
Definition ExactBandIntegral.hpp:487
Eigen::Vector3d hi
bounding box
Definition ExactBandIntegral.hpp:491
Definition ExactBandIntegral.cpp:3378
What max_distance() found besides the max.
Definition ExactBandIntegral.hpp:287
Eigen::Vector3d at
a point of f where the returned max is attained
Definition ExactBandIntegral.hpp:288
double U
min over P of max over f's corners of d_P (the former settle bound)
Definition ExactBandIntegral.hpp:290
bool rule_a
the max came from a rule-(a) piece: an upper bound there
Definition ExactBandIntegral.hpp:289
Definition ExactBandIntegral.hpp:523
Definition ExactBandIntegral.hpp:133
int64_t caps_split
Definition ExactBandIntegral.hpp:144
int64_t point_faces
faces integrated against a point distance
Definition ExactBandIntegral.hpp:149
double empty_vol
volume of pieces with no member (must be rounding)
Definition ExactBandIntegral.hpp:141
double vol
cell volume
Definition ExactBandIntegral.hpp:138
bool check_closed
Definition ExactBandIntegral.hpp:147
int64_t candidates
candidate features
Definition ExactBandIntegral.hpp:135
int64_t side_clipped
Definition ExactBandIntegral.hpp:159
double rule_a_vol
volume of rule-(a) pieces (upper bound)
Definition ExactBandIntegral.hpp:140
int64_t line_faces_series
... near-parallel series
Definition ExactBandIntegral.hpp:152
int64_t pieces
convex pieces of the partition
Definition ExactBandIntegral.hpp:136
int64_t clips_closed_up
cutting clips whose kept faces closed up without a cap
Definition ExactBandIntegral.hpp:143
int64_t series_long
Definition ExactBandIntegral.hpp:155
int64_t series_short
near-parallel edges, Taylor series along the edge
Definition ExactBandIntegral.hpp:154
bool timing
Definition ExactBandIntegral.hpp:164
int64_t clips
half-space clips of a polytope
Definition ExactBandIntegral.hpp:142
int64_t line_faces_radial
... against a line distance, radial closed form
Definition ExactBandIntegral.hpp:150
int64_t cells
value() calls with a non-flat cell
Definition ExactBandIntegral.hpp:134
double exact_vol
volume of pieces integrated exactly
Definition ExactBandIntegral.hpp:139
int64_t closed_edges
polygon edges integrated by a closed form
Definition ExactBandIntegral.hpp:153
int64_t line_faces_parallel
... line exactly parallel to the face
Definition ExactBandIntegral.hpp:151
Definition ExactBandIntegral.cpp:3403
Definition ExactBandIntegral.hpp:572
Definition ExactBandIntegral.cpp:3389