3#include <wmtk/TetMesh.h>
4#include <wmtk/AttributeCollection.hpp>
7#include <wmtk/utils/DisableWarnings.hpp>
8#include <tbb/enumerable_thread_specific.h>
9#include <wmtk/utils/EnableWarnings.hpp>
12#include <wmtk/utils/partition_utils.hpp>
13#include "wmtk/utils/Logger.hpp"
19namespace harmonic_tet {
27 size_t partition_id = 0;
37 const std::vector<Eigen::Vector3d>& _vertex_attribute,
38 const std::vector<std::array<size_t, 4>>& tets,
41 p_vertex_attrs = &vertex_attrs;
42 p_tet_attrs = &tet_attrs;
44 vertex_attrs.resize(_vertex_attribute.size());
46 NUM_THREADS = num_threads;
47 init(_vertex_attribute.size(), tets);
50 auto i = v.vid(*
this);
51 vertex_attrs[i].pos = _vertex_attribute[i];
54 auto i = t.tid(*
this);
55 tet_attrs[i].quality = get_quality(t);
58 compute_vertex_partition_morton();
65 void compute_vertex_partition_morton()
67 if (NUM_THREADS == 0)
return;
68 wmtk::logger().info(
"Number of parts: {} by morton", NUM_THREADS);
69 std::vector<size_t> par;
70 wmtk::partition_vertex_morton(
72 [&](
auto vid) {
return vertex_attrs[vid].pos; },
76 auto vid = v.vid(*
this);
77 vertex_attrs[vid].partition_id = par[vid];
81 void output_mesh(std::string file)
const;
83 size_t get_partition_id(
const Tuple& loc)
const
85 return vertex_attrs[loc.vid(*
this)].partition_id;
93 double total_energy = 0.;
95 tbb::enumerable_thread_specific<SwapInfoCache> edgeswap_cache, faceswap_cache;
97 void smooth_all_vertices(
bool interior_only =
false);
100 void swap_all_edges(
bool parallel =
false);
105 void swap_all_faces(
bool parallel =
false);
109 bool is_inverted(
const Tuple& loc);
110 double get_quality(
const Tuple& loc)
const;
111 double get_quality(
const std::array<size_t, 4>& vids)
const;
113 bool invariants(
const std::vector<Tuple>&)
override;
Definition HarmonicTet.hpp:22
bool swap_face_after(const Tuple &t) override
User specified modifications and desideratas for after a 2-3 face swap.
Definition HarmonicTet.cpp:138
bool swap_face_before(const Tuple &t) override
User specified preparations and desideratas for an 2-3 face swap befroe changing the geometry.
Definition HarmonicTet.cpp:206
bool swap_edge_after(const Tuple &t) override
User specified modifications and desideratas for after a 3-2 edge swap.
Definition HarmonicTet.cpp:118
bool swap_edge_before(const Tuple &t) override
User specified preparations and desideratas for an 3-2 edge swap before changing the conenctivity.
Definition HarmonicTet.cpp:105
bool smooth_after(const Tuple &t) override
User specified modifications and desideratas for after smoothing a vertex.
Definition HarmonicTet.cpp:53
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
size_t vert_capacity() const
get the current largest global vid
Definition TetMesh.h:355
void for_each_vertex(const std::function< void(const TetMesh::Tuple &)> &)
perform the given function for each vertex
Definition TetMesh.cpp:1355
void init(size_t n_vertices, const std::vector< std::array< size_t, 4 > > &tets)
Definition TetMesh.cpp:77
void for_each_tetra(const std::function< void(const TetMesh::Tuple &)> &)
perform the given function for each tet
Definition TetMesh.cpp:1327
Definition HarmonicTet.hpp:92
Definition HarmonicTet.hpp:30
Definition HarmonicTet.hpp:25
Definition AttributeCollection.hpp:37