-
Notifications
You must be signed in to change notification settings - Fork 21
Testing tuple_from_id #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
08b183f
25fd711
c7cfccf
405b32c
13cb315
b8f0df8
b1dc298
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #pragma once | ||
| #include <cassert> | ||
| #include <wmtk/Tuple.hpp> | ||
| #include "autogenerated_tables.hpp" | ||
| #if !defined(_NDEBUG) | ||
| #include "is_ccw.hpp" | ||
| #endif | ||
|
|
||
| namespace wmtk::autogen::edge_mesh { | ||
|
|
||
| inline Tuple get_tuple_from_simplex_local_vertex_id(int8_t local_id, int64_t global_id = 0) | ||
| { | ||
| assert(local_id >= 0); | ||
| assert(local_id < 2); | ||
| return Tuple(local_id, -1, -1, global_id); | ||
| } | ||
| inline Tuple | ||
| get_tuple_from_simplex_local_id(PrimitiveType pt, int8_t local_id, int64_t global_fid = 0) | ||
| { | ||
| switch (pt) { | ||
| case PrimitiveType::Vertex: return get_tuple_from_simplex_local_vertex_id(local_id, global_fid); | ||
| case PrimitiveType::Edge: | ||
| case PrimitiveType::Triangle: | ||
| default: | ||
| case PrimitiveType::Tetrahedron: assert(false); return {}; | ||
| } | ||
| } | ||
| } // namespace wmtk::autogen::edge_mesh | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| #pragma once | ||
| #include <cassert> | ||
| #include <wmtk/Tuple.hpp> | ||
| #include "autogenerated_tables.hpp" | ||
| #if !defined(_NDEBUG) | ||
| #include "is_ccw.hpp" | ||
| #endif | ||
|
|
||
| namespace wmtk::autogen::tet_mesh { | ||
| /* | ||
| namespace { | ||
| template <size_t Dim> | ||
| inline Tuple get_tuple_from_simplex_local_id_T(int8_t local_id, int64_t global_id = 0) | ||
|
||
| { | ||
| const auto& arr = autogen::tet_mesh::auto_3d_table_complete_edge[local_id]; | ||
| assert(arr[Dim] == local_id); | ||
| const auto& [lvid, leid, lfid] = arr; | ||
|
|
||
|
|
||
| if (lvid < 0 || leid < 0 || lfid < 0) { | ||
| throw std::runtime_error("tuple_from_id failed"); | ||
| } | ||
| Tuple tuple = Tuple(lvid, leid, lfid, global_id); | ||
| // accessor as parameter | ||
| assert(is_ccw(tuple)); // is_ccw also checks for validity | ||
| return tuple; | ||
| } | ||
| } // namespace | ||
| */ | ||
|
|
||
| inline Tuple get_tuple_from_simplex_local_vertex_id(int8_t local_id, int64_t global_id = 0) | ||
| { | ||
| const auto& arr = autogen::tet_mesh::auto_3d_table_complete_vertex[local_id]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An assert for |
||
| const auto& [lvid, leid, lfid] = arr; | ||
| assert(lvid == local_id); | ||
|
|
||
|
|
||
| if (lvid < 0 || leid < 0 || lfid < 0) { | ||
|
||
| throw std::runtime_error("tuple_from_vertex_id failed"); | ||
| } | ||
| Tuple tuple = Tuple(lvid, leid, lfid, global_id); | ||
| // accessor as parameter | ||
| assert(is_ccw(tuple)); // is_ccw also checks for validity | ||
| return tuple; | ||
| } | ||
| inline Tuple get_tuple_from_simplex_local_edge_id(int8_t local_id, int64_t global_id = 0) | ||
| { | ||
| const auto& arr = autogen::tet_mesh::auto_3d_table_complete_edge[local_id]; | ||
| const auto& [lvid, leid, lfid] = arr; | ||
| assert(leid == local_id); | ||
|
|
||
|
|
||
| if (lvid < 0 || leid < 0 || lfid < 0) { | ||
| throw std::runtime_error("tuple_from_edge_id failed"); | ||
| } | ||
| Tuple tuple = Tuple(lvid, leid, lfid, global_id); | ||
| // accessor as parameter | ||
| assert(is_ccw(tuple)); // is_ccw also checks for validity | ||
| return tuple; | ||
| } | ||
| inline Tuple get_tuple_from_simplex_local_face_id(int8_t local_id, int64_t global_id = 0) | ||
| { | ||
| const auto& arr = autogen::tet_mesh::auto_3d_table_complete_face[local_id]; | ||
| const auto& [lvid, leid, lfid] = arr; | ||
| assert(lfid == local_id); | ||
|
|
||
|
|
||
| if (lvid < 0 || leid < 0 || lfid < 0) { | ||
| throw std::runtime_error("tuple_from_face_id failed"); | ||
| } | ||
| Tuple tuple = Tuple(lvid, leid, lfid, global_id); | ||
| // accessor as parameter | ||
| assert(is_ccw(tuple)); // is_ccw also checks for validity | ||
| return tuple; | ||
| } | ||
| inline Tuple | ||
| get_tuple_from_simplex_local_id(PrimitiveType pt, int8_t local_id, int64_t global_fid = 0) | ||
| { | ||
| switch (pt) { | ||
| case PrimitiveType::Vertex: return get_tuple_from_simplex_local_vertex_id(local_id, global_fid); | ||
| case PrimitiveType::Edge: return get_tuple_from_simplex_local_edge_id(local_id, global_fid); | ||
| case PrimitiveType::Triangle: return get_tuple_from_simplex_local_face_id(local_id, global_fid); | ||
| default: | ||
| case PrimitiveType::Tetrahedron: assert(false); return {}; | ||
| } | ||
| } | ||
| } // namespace wmtk::autogen::tet_mesh | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #pragma once | ||
| #include "autogenerated_tables.hpp" | ||
| #include <wmtk/Tuple.hpp> | ||
| #include <cassert> | ||
| #if !defined(_NDEBUG) | ||
| #include "is_ccw.hpp" | ||
| #endif | ||
|
|
||
| namespace wmtk::autogen::tri_mesh { | ||
| inline Tuple get_tuple_from_simplex_local_vertex_id(int8_t local_id, int64_t global_fid = 0) { | ||
|
|
||
| assert(autogen::tri_mesh::auto_2d_table_complete_vertex[local_id][0] == local_id); | ||
| const int64_t leid = autogen::tri_mesh::auto_2d_table_complete_vertex[local_id][1]; | ||
| Tuple v_tuple = Tuple(local_id, leid, -1, global_fid); | ||
| // accessor as parameter | ||
| assert(is_ccw(v_tuple)); // is_ccw also checks for validity | ||
| return v_tuple; | ||
| } | ||
| inline Tuple get_tuple_from_simplex_local_edge_id(int8_t local_id, int64_t global_fid = 0) { | ||
| assert(autogen::tri_mesh::auto_2d_table_complete_edge[local_id][1] == local_id); | ||
| const int64_t lvid = autogen::tri_mesh::auto_2d_table_complete_edge[local_id][0]; | ||
|
|
||
|
|
||
| Tuple e_tuple = Tuple(lvid, local_id, -1, global_fid); | ||
| assert(is_ccw(e_tuple)); | ||
| return e_tuple; | ||
| } | ||
| inline Tuple get_tuple_from_simplex_local_id(PrimitiveType pt, int8_t local_id, int64_t global_fid = 0) { | ||
| switch(pt) { | ||
| case PrimitiveType::Vertex: return get_tuple_from_simplex_local_vertex_id(local_id, global_fid); | ||
| case PrimitiveType::Edge: return get_tuple_from_simplex_local_edge_id(local_id, global_fid); | ||
| default: | ||
| case PrimitiveType::Triangle: | ||
| case PrimitiveType::Tetrahedron: | ||
| assert(false); | ||
| return {}; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,6 @@ | |
| set(TEST_SOURCES | ||
| dart.cpp | ||
| actions.cpp | ||
| tables.cpp | ||
| ) | ||
| target_sources(wmtk_tests PRIVATE ${TEST_SOURCES}) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it reasonable to have the global_id default to 0? I feel like having no default value makes more sense.