PolyFEM
Loading...
Searching...
No Matches
NCMesh3D.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <set>
5#include <tuple>
7
8namespace polyfem
9{
10 namespace mesh
11 {
33 class NCMesh3D : public Mesh3D
34 {
35 public:
37 {
38 int id;
39 double p1, p2;
40
41 follower_edge(int id_, double p1_, double p2_)
42 {
43 id = id_;
44 p1 = p1_;
45 p2 = p2_;
46 }
47 };
48
50 {
51 int id;
52 Eigen::Vector2d p1, p2, p3;
53
54 follower_face(int id_, Eigen::Vector2d p1_, Eigen::Vector2d p2_, Eigen::Vector2d p3_)
55 {
56 id = id_;
57 p1 = p1_;
58 p2 = p2_;
59 p3 = p3_;
60 }
61 };
62
63 struct ncVert
64 {
65 ncVert(const Eigen::VectorXd &pos_) : pos(pos_) {};
66
67 int n_elem() const
68 {
69 return elem_list.size();
70 }
71
72 void add_element(const int e)
73 {
75 };
76
77 void remove_element(const int e)
78 {
79 int num = elem_list.erase(e);
80 assert(num == 1);
81 }
82
83 SortedIds elem_list; // elements that contain this edge/face
84
86 bool isboundary = false;
87
88 int edge = -1; // only used if the vertex is on the interior of an edge
89 int face = -1; // only used if the vertex is on the interior of an face
90
91 double weight = -1.; // only 2d, the local position of this vertex on the edge
92 };
93
95 {
96 ncBoundary(const Eigen::VectorXi &vert) : vertices(vert)
97 {
98 weights.setConstant(-1);
99 };
100
101 int n_elem() const
102 {
103 return elem_list.size();
104 }
105
106 void add_element(const int e)
107 {
108 elem_list.insert(e);
109 };
110
111 void remove_element(const int e)
112 {
113 int num = elem_list.erase(e);
114 assert(num == 1);
115 }
116
117 int get_element() const
118 {
119 assert(n_elem() > 0);
120 auto it = elem_list.cbegin();
121 return *it;
122 }
123
124 int find_opposite_element(int e) const
125 {
126 assert(n_elem() == 2);
127 bool exist = false;
128 int oppo = -1;
129 for (int elem : elem_list)
130 if (elem == e)
131 exist = true;
132 else
133 oppo = elem;
134
135 assert(oppo >= 0);
136 assert(exist);
137 return oppo;
138 }
139
140 SortedIds elem_list; // elements that contain this edge/face
142
143 bool isboundary = false; // valid only after calling mark_boundary()
144 int boundary_id = -1;
145
146 int leader = -1; // if this edge/face lies on a larger edge/face
147 std::vector<int> followers; // followers of this edge/face
148
149 int leader_face = -1; // if this edge lies in the interior of a face
150
151 std::vector<int> global_ids; // only used for building basis
152
153 // the following only used if it's an edge
154 Eigen::Vector2d weights; // position of this edge on its leader edge
155 };
156
157 struct ncElem
158 {
159 ncElem(const int dim_, const Eigen::VectorXi &vertices_, const int level_, const int parent_) : dim(dim_), level(level_), parent(parent_), geom_vertices(vertices_)
160 {
162
163 assert(geom_vertices.size() == dim + 1);
164 edges.setConstant(3 * (dim - 1), 1, -1);
165 faces.setConstant(4 * (dim - 2), 1, -1);
166 children.setConstant(std::round(pow(2, dim)), 1, -1);
167 };
168
169 bool is_valid() const
170 {
171 return (!is_ghost) && (!is_refined);
172 };
173
174 bool is_not_valid() const
175 {
176 return is_ghost || is_refined;
177 };
178
179 int dim;
180 int level; // level of refinement
183
184 InlineVector<int, 4> vertices; // geom_vertices with a different order that used in polyfem
185
189
190 int body_id = 0;
191
192 bool is_refined = false;
193 bool is_ghost = false;
194 };
195
196 NCMesh3D() = default;
197 virtual ~NCMesh3D() = default;
198 NCMesh3D(NCMesh3D &&) = default;
200 NCMesh3D(const NCMesh3D &) = default;
201 NCMesh3D &operator=(const NCMesh3D &) = default;
202
203 void refine(const int n_refinement, const double t) override;
204
205 bool is_conforming() const override { return false; }
206
207 int n_cells() const override { return n_elements; }
208 // The valid counts are the sizes of the valid -> all id maps while they
209 // are up to date (O(1)); otherwise they are counted (O(n)).
210 int n_faces() const override
211 {
212 if (index_prepared)
213 return valid_to_all_faceMap.size();
214 int n = 0;
215 for (const auto &face : faces)
216 if (face.n_elem())
217 n++;
218 return n;
219 }
220 int n_edges() const override
221 {
222 if (index_prepared)
223 return valid_to_all_edgeMap.size();
224 int n = 0;
225 for (const auto &edge : edges)
226 if (edge.n_elem())
227 n++;
228 return n;
229 }
230 int n_vertices() const override
231 {
232 if (index_prepared)
233 return valid_to_all_vertexMap.size();
234 int n = 0;
235 for (const auto &vert : vertices)
236 if (vert.n_elem())
237 n++;
238 return n;
239 }
240
241 int n_face_vertices(const int f_id) const override { return 3; }
242 int n_face_cells(const int f_id) const { return faces[valid_to_all_face(f_id)].n_elem(); }
243 int n_edge_cells(const int e_id) const { return edges[valid_to_all_edge(e_id)].n_elem(); }
244 int n_cell_vertices(const int c_id) const override { return 4; }
245 int n_cell_edges(const int c_id) const override { return 6; }
246 int n_cell_faces(const int c_id) const override { return 4; }
247 int cell_vertex(const int f_id, const int lv_id) const override { return all_to_valid_vertex(elements[valid_to_all_elem(f_id)].vertices(lv_id)); }
248 int cell_face(const int c_id, const int lf_id) const override { return all_to_valid_face(elements[valid_to_all_elem(c_id)].faces(lf_id)); }
249 int cell_face_orientation(const int, const int) const override { return 1; }
250 int cell_edge(const int c_id, const int le_id) const override { return all_to_valid_edge(elements[valid_to_all_elem(c_id)].edges(le_id)); }
251 int face_vertex(const int f_id, const int lv_id) const override { return all_to_valid_vertex(faces[valid_to_all_face(f_id)].vertices(lv_id)); }
252 int face_edge(const int f_id, const int le_id) const;
253 int edge_vertex(const int e_id, const int lv_id) const override { return all_to_valid_vertex(edges[valid_to_all_edge(e_id)].vertices(lv_id)); }
254
255 inline int cell_ref_level(const int c_id) const { return elements[valid_to_all_elem(c_id)].level; }
256
257 bool is_boundary_vertex(const int vertex_global_id) const override { return vertices[valid_to_all_vertex(vertex_global_id)].isboundary; }
258 bool is_boundary_edge(const int edge_global_id) const override { return edges[valid_to_all_edge(edge_global_id)].isboundary; }
259 bool is_boundary_face(const int face_global_id) const override { return faces[valid_to_all_face(face_global_id)].isboundary; }
260 bool is_boundary_element(const int element_global_id) const override;
261
262 bool build_topology(const MeshData &data) override;
263
264 void attach_higher_order_nodes(const Eigen::MatrixXd &V, const std::vector<std::vector<int>> &nodes) override;
265
266 void normalize() override;
267
268 void compute_elements_tag() override;
269 void update_elements_tag() override;
270
271 double edge_length(const int gid) const override;
272
273 RowVectorNd point(const int global_index) const override;
274 void set_point(const int global_index, const RowVectorNd &p) override;
275 RowVectorNd edge_barycenter(const int e) const override;
276 RowVectorNd face_barycenter(const int f) const override;
277 RowVectorNd cell_barycenter(const int c) const override;
278
279 void bounding_box(RowVectorNd &min, RowVectorNd &max) const override;
280
281 void compute_boundary_ids(const std::function<int(const size_t, const std::vector<int> &, const RowVectorNd &, bool)> &marker) override;
282
283 void compute_body_ids(const std::function<int(const size_t, const std::vector<int> &, const RowVectorNd &)> &marker) override;
284 void set_boundary_ids(const std::vector<int> &boundary_ids) override;
285 void set_body_ids(const std::vector<int> &body_ids) override;
286
287 int get_boundary_id(const int primitive) const override
288 {
289 // Without boundary ids, use the Mesh defaults (boundary: max int, interior: -1).
290 return has_boundary_ids() ? faces[valid_to_all_face(primitive)].boundary_id : get_default_boundary_id(primitive);
291 };
292 int get_body_id(const int primitive) const override { return elements[valid_to_all_elem(primitive)].body_id; };
293
294 // void triangulate_faces(Eigen::MatrixXi &tris, Eigen::MatrixXd &pts, std::vector<int> &ranges) const override;
295
296 RowVectorNd kernel(const int cell_id) const override;
297 // navigation wrapper
298 Navigation3D::Index get_index_from_element(int hi, int lf, int lv) const override;
299 Navigation3D::Index get_index_from_element(int hi) const override;
300
301 Navigation3D::Index get_index_from_element_edge(int hi, int v0, int v1) const override;
302 Navigation3D::Index get_index_from_element_face(int hi, int v0, int v1, int v2) const override;
303
304 std::vector<uint32_t> vertex_neighs(const int v_gid) const override;
305 std::vector<uint32_t> edge_neighs(const int e_gid) const override;
306
307 int leader_edge_of_vertex(const int v_id) const
308 {
309 if (!adj_prepared)
311 return (vertices[valid_to_all_vertex(v_id)].edge < 0) ? -1 : all_to_valid_edge(vertices[valid_to_all_vertex(v_id)].edge);
312 }
313 int leader_edge_of_edge(const int e_id) const
314 {
315 if (!adj_prepared)
317 return (edges[valid_to_all_edge(e_id)].leader < 0) ? -1 : all_to_valid_edge(edges[valid_to_all_edge(e_id)].leader);
318 }
319
320 int leader_face_of_vertex(const int v_id) const
321 {
322 if (!adj_prepared)
324 int id_full = vertices[valid_to_all_vertex(v_id)].face;
325 return (id_full < 0) ? -1 : all_to_valid_face(id_full);
326 }
327 int leader_face_of_edge(const int e_id) const
328 {
329 if (!adj_prepared)
331 int id_full = edges[valid_to_all_edge(e_id)].leader_face;
332 return (id_full < 0) ? -1 : all_to_valid_face(id_full);
333 }
334 int leader_face_of_face(const int f_id) const
335 {
336 if (!adj_prepared)
338 int id_full = faces[valid_to_all_face(f_id)].leader;
339 return (id_full < 0) ? -1 : all_to_valid_face(id_full);
340 }
341
342 // number of follower edges of a leader edge
343 int n_follower_edges(const int e_id) const
344 {
345 if (!adj_prepared)
347 return edges[valid_to_all_edge(e_id)].followers.size();
348 }
349 int n_follower_faces(const int e_id) const
350 {
351 if (!adj_prepared)
353 return faces[valid_to_all_face(e_id)].followers.size();
354 }
355
356 // Navigation in a surface mesh
361
362 // Iterate in a mesh
365
366 void get_vertex_elements_neighs(const int v_id, std::vector<int> &ids) const override;
367 void get_edge_elements_neighs(const int e_id, std::vector<int> &ids) const override;
368 void get_face_elements_neighs(const int f_id, std::vector<int> &ids) const;
369
370 void refine_element(int id_full);
371 void refine_elements(const std::vector<int> &ids);
372
373 void coarsen_element(int id_full);
374
375 void mark_boundary();
376
387
388 void build_index_mapping();
389
390 std::array<int, 4> get_ordered_vertices_from_tet(const int element_index) const override;
391
392 void append(const Mesh &mesh) override;
393
394 std::unique_ptr<Mesh> copy() const override;
395
396 private:
398 {
399 long operator()(const Eigen::Vector2i &a) const
400 {
401 return (long)((long)984120265 * a[0] + (long)125965121 * a[1]);
402 }
403 };
404
406 {
407 long operator()(const Eigen::Vector3i &a) const
408 {
409 return (long)((long)984120265 * a[0] + (long)125965121 * a[1] + (long)495698413 * a[2]);
410 }
411 };
412
413 protected:
414 void remove_elements(const std::vector<bool> &keep) override;
415
416 // Maps between the valid ids and the full ids (see the class comment).
417 // They are up to date only after prepare_mesh().
418 inline int all_to_valid_vertex(const int id) const { return map_id(all_to_valid_vertexMap, id); }
419 inline int valid_to_all_vertex(const int id) const { return map_id(valid_to_all_vertexMap, id); }
420 inline int all_to_valid_edge(const int id) const { return map_id(all_to_valid_edgeMap, id); }
421 inline int valid_to_all_edge(const int id) const { return map_id(valid_to_all_edgeMap, id); }
422 inline int all_to_valid_face(const int id) const { return map_id(all_to_valid_faceMap, id); }
423 inline int valid_to_all_face(const int id) const { return map_id(valid_to_all_faceMap, id); }
424 inline int all_to_valid_elem(const int id) const { return map_id(all_to_valid_elemMap, id); }
425 inline int valid_to_all_elem(const int id) const { return map_id(valid_to_all_elemMap, id); }
426 int map_id(const std::vector<int> &map, const int id) const
427 {
428 if (!index_prepared)
430 assert(id >= 0 && id < int(map.size()));
431 return map[id];
432 }
433
434 // find the mid-point of edge v[0]v[1], return -1 if not exists
435 int find_vertex(Eigen::Vector2i v) const;
436 int find_vertex(const int v1, const int v2) const { return find_vertex(Eigen::Vector2i(v1, v2)); };
437
438 // find the mid-point of edge v[0]v[1], create one if not exists
439 int get_vertex(Eigen::Vector2i v);
440
441 // find the edge v[0]v[1], return -1 if not exists
442 int find_edge(Eigen::Vector2i v) const;
443 int find_edge(const int v1, const int v2) const { return find_edge(Eigen::Vector2i(v1, v2)); };
444
445 // find the edge v[0]v[1], create one if not exists
446 int get_edge(Eigen::Vector2i v);
447 int get_edge(const int v1, const int v2) { return get_edge(Eigen::Vector2i(v1, v2)); };
448
449 // find the face, return -1 if not exists
450 int find_face(Eigen::Vector3i v) const;
451 int find_face(const int v1, const int v2, const int v3) const { return find_face(Eigen::Vector3i(v1, v2, v3)); };
452 // find the face, create one if not exists
453 int get_face(Eigen::Vector3i v);
454 int get_face(const int v1, const int v2, const int v3) { return get_face(Eigen::Vector3i(v1, v2, v3)); };
455
456 void traverse_edge(Eigen::Vector2i v, double p1, double p2, int depth, std::vector<follower_edge> &list) const;
458
459 void traverse_face(int v1, int v2, int v3, Eigen::Vector2d p1, Eigen::Vector2d p2, Eigen::Vector2d p3, int depth, std::vector<follower_face> &face_list, std::vector<int> &edge_list) const;
461
463
464 int add_element(Eigen::Vector4i v, int parent = -1);
465
466 int n_elements = 0;
467
471 bool index_prepared = false;
472 bool adj_prepared = false;
473
475 [[noreturn]] void stale_index_error() const;
480
481 std::vector<ncElem> elements;
482 std::vector<ncVert> vertices;
483 std::vector<ncBoundary> edges;
484 std::vector<ncBoundary> faces;
485
486 std::unordered_map<Eigen::Vector2i, int, ArrayHasher2D> midpointMap;
487 std::unordered_map<Eigen::Vector2i, int, ArrayHasher2D> edgeMap;
488 std::unordered_map<Eigen::Vector3i, int, ArrayHasher3D> faceMap;
489
494
495 std::vector<int> refineHistory;
496
497 // elementAdj(i, j) = 1 iff element i touches element j
498 Eigen::SparseMatrix<bool, Eigen::RowMajor> elementAdj;
499 };
500 } // namespace mesh
501} // namespace polyfem
int V
Eigen::RowVectorXd point
3D mesh interface: the elements are the cells (tetrahedra, hexahedra, prisms, pyramids or general pol...
Definition Mesh3D.hpp:22
Format-independent input used to construct a runtime Mesh.
Definition MeshData.hpp:12
Abstract mesh class to capture 2d/3d conforming and non-conforming meshes.
Definition Mesh.hpp:77
bool has_boundary_ids() const
checks if surface selections are available
Definition Mesh.hpp:557
virtual int get_default_boundary_id(const int primitive) const
Get the default boundary selection of an element (face in 3d, edge in 2d)
Definition Mesh.hpp:487
Non-conforming 3D tetrahedral mesh with hanging nodes, for adaptive h-refinement: refine_element() sp...
Definition NCMesh3D.hpp:34
int all_to_valid_vertex(const int id) const
Definition NCMesh3D.hpp:418
void remove_elements(const std::vector< bool > &keep) override
Remove all top-dimensional elements whose mask entry is false.
Definition NCMesh3D.cpp:17
int find_vertex(Eigen::Vector2i v) const
Definition NCMesh3D.cpp:994
bool is_boundary_element(const int element_global_id) const override
is cell boundary
Definition NCMesh3D.cpp:119
void compute_body_ids(const std::function< int(const size_t, const std::vector< int > &, const RowVectorNd &)> &marker) override
computes boundary selections based on a function
Definition NCMesh3D.cpp:269
void update_labels_after_refinement()
After a refinement: rebuild the body/boundary id arrays from the per-entity labels (inherited by the ...
Definition NCMesh3D.cpp:96
std::vector< int > all_to_valid_elemMap
Definition NCMesh3D.hpp:490
int leader_face_of_vertex(const int v_id) const
Definition NCMesh3D.hpp:320
int find_edge(const int v1, const int v2) const
Definition NCMesh3D.hpp:443
int cell_ref_level(const int c_id) const
Definition NCMesh3D.hpp:255
int n_faces() const override
number of faces
Definition NCMesh3D.hpp:210
int n_cell_vertices(const int c_id) const override
number of vertices of a cell
Definition NCMesh3D.hpp:244
NCMesh3D & operator=(const NCMesh3D &)=default
int valid_to_all_edge(const int id) const
Definition NCMesh3D.hpp:421
Navigation3D::Index next_around_edge(Navigation3D::Index idx) const override
Definition NCMesh3D.cpp:600
int face_edge(const int f_id, const int le_id) const
Definition NCMesh3D.cpp:66
void stale_index_error() const
Throws: the id maps are stale (prepare_mesh() was not called after editing the mesh).
Definition NCMesh3D.cpp:114
int n_cell_faces(const int c_id) const override
Definition NCMesh3D.hpp:246
void traverse_edge(Eigen::Vector2i v, double p1, double p2, int depth, std::vector< follower_edge > &list) const
int n_edge_cells(const int e_id) const
Definition NCMesh3D.hpp:243
int get_boundary_id(const int primitive) const override
Get the boundary selection of an element (face in 3d, edge in 2d)
Definition NCMesh3D.hpp:287
std::unordered_map< Eigen::Vector2i, int, ArrayHasher2D > midpointMap
Definition NCMesh3D.hpp:486
int n_cells() const override
number of cells
Definition NCMesh3D.hpp:207
void build_element_vertex_adjacency()
void prepare_mesh() override
method used to finalize the mesh.
Definition NCMesh3D.hpp:377
int n_follower_faces(const int e_id) const
Definition NCMesh3D.hpp:349
std::vector< ncBoundary > edges
Definition NCMesh3D.hpp:483
int valid_to_all_face(const int id) const
Definition NCMesh3D.hpp:423
void bounding_box(RowVectorNd &min, RowVectorNd &max) const override
computes the bbox of the mesh
Definition NCMesh3D.cpp:231
void append(const Mesh &mesh) override
appends a new mesh to the end of this
Definition NCMesh3D.cpp:888
std::vector< int > refineHistory
Definition NCMesh3D.hpp:495
double edge_length(const int gid) const override
edge length
Definition NCMesh3D.cpp:190
int n_edges() const override
number of edges
Definition NCMesh3D.hpp:220
void compute_boundary_ids(const std::function< int(const size_t, const std::vector< int > &, const RowVectorNd &, bool)> &marker) override
computes boundary selections based on a function
Definition NCMesh3D.cpp:248
int n_follower_edges(const int e_id) const
Definition NCMesh3D.hpp:343
int get_edge(Eigen::Vector2i v)
void set_point(const int global_index, const RowVectorNd &p) override
Set the point.
Definition NCMesh3D.cpp:203
int add_element(Eigen::Vector4i v, int parent=-1)
int get_face(Eigen::Vector3i v)
void attach_higher_order_nodes(const Eigen::MatrixXd &V, const std::vector< std::vector< int > > &nodes) override
attach high order nodes
Definition NCMesh3D.cpp:163
int n_face_vertices(const int f_id) const override
number of vertices of a face
Definition NCMesh3D.hpp:241
int leader_edge_of_vertex(const int v_id) const
Definition NCMesh3D.hpp:307
bool index_prepared
Whether the valid <-> all id maps match the current topology.
Definition NCMesh3D.hpp:471
RowVectorNd cell_barycenter(const int c) const override
cell barycenter
Definition NCMesh3D.cpp:223
std::vector< uint32_t > edge_neighs(const int e_gid) const override
Definition NCMesh3D.cpp:530
int all_to_valid_elem(const int id) const
Definition NCMesh3D.hpp:424
int n_vertices() const override
number of vertices
Definition NCMesh3D.hpp:230
int find_face(const int v1, const int v2, const int v3) const
Definition NCMesh3D.hpp:451
std::vector< ncVert > vertices
Definition NCMesh3D.hpp:482
Navigation3D::Index get_index_from_element_edge(int hi, int v0, int v1) const override
Definition NCMesh3D.cpp:441
std::unordered_map< Eigen::Vector2i, int, ArrayHasher2D > edgeMap
Definition NCMesh3D.hpp:487
void traverse_face(int v1, int v2, int v3, Eigen::Vector2d p1, Eigen::Vector2d p2, Eigen::Vector2d p3, int depth, std::vector< follower_face > &face_list, std::vector< int > &edge_list) const
int find_vertex(const int v1, const int v2) const
Definition NCMesh3D.hpp:436
virtual ~NCMesh3D()=default
void refine(const int n_refinement, const double t) override
refine the mesh
Definition NCMesh3D.cpp:74
void normalize() override
normalize the mesh
Definition NCMesh3D.cpp:170
std::vector< int > all_to_valid_vertexMap
Definition NCMesh3D.hpp:491
int all_to_valid_edge(const int id) const
Definition NCMesh3D.hpp:420
bool build_topology(const MeshData &data) override
Construct only the dimension-specific topology.
Definition NCMesh3D.cpp:129
void get_face_elements_neighs(const int f_id, std::vector< int > &ids) const
Definition NCMesh3D.cpp:621
std::unique_ptr< Mesh > copy() const override
Create a copy of the mesh.
Definition NCMesh3D.cpp:989
int valid_to_all_elem(const int id) const
Definition NCMesh3D.hpp:425
void refine_element(int id_full)
Definition NCMesh3D.cpp:628
Navigation3D::Index switch_vertex(Navigation3D::Index idx) const override
Definition NCMesh3D.cpp:539
int leader_face_of_edge(const int e_id) const
Definition NCMesh3D.hpp:327
RowVectorNd kernel(const int cell_id) const override
Definition NCMesh3D.cpp:404
bool is_boundary_vertex(const int vertex_global_id) const override
is vertex boundary
Definition NCMesh3D.hpp:257
int cell_face(const int c_id, const int lf_id) const override
Definition NCMesh3D.hpp:248
void compute_elements_tag() override
compute element types, see ElementType
Definition NCMesh3D.cpp:182
NCMesh3D & operator=(NCMesh3D &&)=default
std::vector< int > all_to_valid_edgeMap
Definition NCMesh3D.hpp:492
int find_edge(Eigen::Vector2i v) const
Navigation3D::Index get_index_from_element(int hi, int lf, int lv) const override
Definition NCMesh3D.cpp:409
int get_face(const int v1, const int v2, const int v3)
Definition NCMesh3D.hpp:454
bool is_boundary_face(const int face_global_id) const override
is face boundary
Definition NCMesh3D.hpp:259
int cell_vertex(const int f_id, const int lv_id) const override
id of the vertex of a cell
Definition NCMesh3D.hpp:247
std::vector< int > all_to_valid_faceMap
Definition NCMesh3D.hpp:493
void coarsen_element(int id_full)
Definition NCMesh3D.cpp:746
int leader_edge_of_edge(const int e_id) const
Definition NCMesh3D.hpp:313
Navigation3D::Index next_around_face(Navigation3D::Index idx) const override
Definition NCMesh3D.cpp:604
std::vector< int > valid_to_all_elemMap
Definition NCMesh3D.hpp:490
std::vector< int > valid_to_all_edgeMap
Definition NCMesh3D.hpp:492
RowVectorNd face_barycenter(const int f) const override
face barycenter
Definition NCMesh3D.cpp:215
int n_cell_edges(const int c_id) const override
Definition NCMesh3D.hpp:245
int get_body_id(const int primitive) const override
Get the volume selection of an element (cell in 3d, face in 2d)
Definition NCMesh3D.hpp:292
bool is_boundary_edge(const int edge_global_id) const override
is edge boundary
Definition NCMesh3D.hpp:258
Navigation3D::Index switch_element(Navigation3D::Index idx) const override
Definition NCMesh3D.cpp:581
void get_vertex_elements_neighs(const int v_id, std::vector< int > &ids) const override
Definition NCMesh3D.cpp:609
NCMesh3D(const NCMesh3D &)=default
std::vector< ncElem > elements
Definition NCMesh3D.hpp:481
std::unordered_map< Eigen::Vector3i, int, ArrayHasher3D > faceMap
Definition NCMesh3D.hpp:488
RowVectorNd edge_barycenter(const int e) const override
edge barycenter
Definition NCMesh3D.cpp:208
std::vector< int > valid_to_all_faceMap
Definition NCMesh3D.hpp:493
std::vector< uint32_t > vertex_neighs(const int v_gid) const override
Definition NCMesh3D.cpp:522
std::vector< int > valid_to_all_vertexMap
Definition NCMesh3D.hpp:491
std::array< int, 4 > get_ordered_vertices_from_tet(const int element_index) const override
void update_elements_tag() override
Update elements types.
Definition NCMesh3D.cpp:186
int get_edge(const int v1, const int v2)
Definition NCMesh3D.hpp:447
int valid_to_all_vertex(const int id) const
Definition NCMesh3D.hpp:419
int edge_vertex(const int e_id, const int lv_id) const override
id of the edge vertex
Definition NCMesh3D.hpp:253
void refine_elements(const std::vector< int > &ids)
Definition NCMesh3D.cpp:733
int get_vertex(Eigen::Vector2i v)
int find_face(Eigen::Vector3i v) const
void get_edge_elements_neighs(const int e_id, std::vector< int > &ids) const override
Definition NCMesh3D.cpp:615
int cell_edge(const int c_id, const int le_id) const override
Definition NCMesh3D.hpp:250
Navigation3D::Index switch_face(Navigation3D::Index idx) const override
Definition NCMesh3D.cpp:560
int leader_face_of_face(const int f_id) const
Definition NCMesh3D.hpp:334
Eigen::SparseMatrix< bool, Eigen::RowMajor > elementAdj
Definition NCMesh3D.hpp:498
bool is_conforming() const override
if the mesh is conforming
Definition NCMesh3D.hpp:205
int face_vertex(const int f_id, const int lv_id) const override
id of the face vertex
Definition NCMesh3D.hpp:251
int map_id(const std::vector< int > &map, const int id) const
Definition NCMesh3D.hpp:426
int cell_face_orientation(const int, const int) const override
Definition NCMesh3D.hpp:249
int all_to_valid_face(const int id) const
Definition NCMesh3D.hpp:422
int n_face_cells(const int f_id) const
Definition NCMesh3D.hpp:242
Navigation3D::Index get_index_from_element_face(int hi, int v0, int v1, int v2) const override
Definition NCMesh3D.cpp:474
void set_body_ids(const std::vector< int > &body_ids) override
Set the volume sections.
Definition NCMesh3D.cpp:290
void set_boundary_ids(const std::vector< int > &boundary_ids) override
Set the boundary selection from a vector.
Definition NCMesh3D.cpp:281
NCMesh3D(NCMesh3D &&)=default
std::vector< ncBoundary > faces
Definition NCMesh3D.hpp:484
Navigation3D::Index switch_edge(Navigation3D::Index idx) const override
Definition NCMesh3D.cpp:552
Set of ids stored as a sorted vector: iterates in increasing order like std::set<int>,...
void insert(const int id)
const_iterator cbegin() const
size_t erase(const int id)
Removes id; returns the number of removed ids (0 or 1).
Eigen::Matrix< T, Eigen::Dynamic, 1, Eigen::ColMajor, MaxSize, 1 > InlineVector
Small vector stored inline (no heap allocation), with the VectorXi / VectorXd API; used for the per-e...
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
Definition Types.hpp:13
long operator()(const Eigen::Vector2i &a) const
Definition NCMesh3D.hpp:399
long operator()(const Eigen::Vector3i &a) const
Definition NCMesh3D.hpp:407
follower_edge(int id_, double p1_, double p2_)
Definition NCMesh3D.hpp:41
follower_face(int id_, Eigen::Vector2d p1_, Eigen::Vector2d p2_, Eigen::Vector2d p3_)
Definition NCMesh3D.hpp:54
ncBoundary(const Eigen::VectorXi &vert)
Definition NCMesh3D.hpp:96
InlineVector< int, 3 > vertices
Definition NCMesh3D.hpp:141
InlineVector< int, 6 > edges
Definition NCMesh3D.hpp:186
InlineVector< int, 4 > geom_vertices
Definition NCMesh3D.hpp:182
ncElem(const int dim_, const Eigen::VectorXi &vertices_, const int level_, const int parent_)
Definition NCMesh3D.hpp:159
InlineVector< int, 4 > vertices
Definition NCMesh3D.hpp:184
InlineVector< int, 8 > children
Definition NCMesh3D.hpp:188
InlineVector< int, 4 > faces
Definition NCMesh3D.hpp:187
void remove_element(const int e)
Definition NCMesh3D.hpp:77
ncVert(const Eigen::VectorXd &pos_)
Definition NCMesh3D.hpp:65
InlineVector< double, 3 > pos
Definition NCMesh3D.hpp:85
void add_element(const int e)
Definition NCMesh3D.hpp:72