Skip to content

Commit

Permalink
fixing and adding unit tests for tuple_from_id unit etsts
Browse files Browse the repository at this point in the history
  • Loading branch information
mtao committed Dec 5, 2024
1 parent 25fd711 commit c7cfccf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

namespace wmtk::autogen::edge_mesh {

inline Tuple get_tuple_from_simplex_local_vertex_id(int8_t local_id, int64_t global_id = -1)
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 = -1)
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);
Expand Down
10 changes: 5 additions & 5 deletions src/wmtk/autogen/tet_mesh/get_tuple_from_simplex_local_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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 = -1)
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);
Expand All @@ -28,7 +28,7 @@ return tuple;
} // namespace
*/

inline Tuple get_tuple_from_simplex_local_vertex_id(int8_t local_id, int64_t global_id = -1)
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];
const auto& [lvid, leid, lfid] = arr;
Expand All @@ -43,7 +43,7 @@ inline Tuple get_tuple_from_simplex_local_vertex_id(int8_t local_id, int64_t glo
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 = -1)
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;
Expand All @@ -58,7 +58,7 @@ inline Tuple get_tuple_from_simplex_local_edge_id(int8_t local_id, int64_t globa
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 = -1)
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;
Expand All @@ -74,7 +74,7 @@ inline Tuple get_tuple_from_simplex_local_face_id(int8_t local_id, int64_t globa
return tuple;
}
inline Tuple
get_tuple_from_simplex_local_id(PrimitiveType pt, int8_t local_id, int64_t global_fid = -1)
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);
Expand Down
6 changes: 3 additions & 3 deletions src/wmtk/autogen/tri_mesh/get_tuple_from_simplex_local_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#endif

namespace wmtk::autogen::tri_mesh {
inline Tuple get_tuple_from_simplex_local_vertex_id(int8_t local_id, int64_t global_fid = -1) {
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];
Expand All @@ -16,7 +16,7 @@ namespace wmtk::autogen::tri_mesh {
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 = -1) {
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];

Expand All @@ -25,7 +25,7 @@ namespace wmtk::autogen::tri_mesh {
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 = -1) {
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);
Expand Down
9 changes: 5 additions & 4 deletions tests/autogen/tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ TEST_CASE("tuple_autogen_from_id_is_ccw", "[tuple]")
Tuple t2 = wmtk::autogen::edge_mesh::get_tuple_from_simplex_local_id(PrimitiveType::Vertex, i);
CHECK(t == t2);
CHECK(edge_mesh::tuple_is_valid_for_ccw(t));
CHECK(edge_mesh::is_ccw(t));
// edge mesh does not always have a ccw tuple for every simplex
CHECK(edge_mesh::is_ccw(t) == (i == 0));
}
for(int i = 0; i < 3; ++i) {
Tuple t = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_vertex_id(i);
Expand All @@ -284,7 +285,7 @@ TEST_CASE("tuple_autogen_from_id_is_ccw", "[tuple]")
CHECK(tri_mesh::is_ccw(t));
}
for(int i = 0; i < 3; ++i) {
Tuple t = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_vertex_id(i);
Tuple t = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_edge_id(i);
Tuple t2 = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_id(PrimitiveType::Edge, i);
CHECK(t == t2);
CHECK(tri_mesh::tuple_is_valid_for_ccw(t));
Expand All @@ -299,14 +300,14 @@ TEST_CASE("tuple_autogen_from_id_is_ccw", "[tuple]")
CHECK(tet_mesh::is_ccw(t));
}
for(int i = 0; i < 6; ++i) {
Tuple t = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_vertex_id(i);
Tuple t = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_edge_id(i);
Tuple t2 = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id(PrimitiveType::Edge, i);
CHECK(t == t2);
CHECK(tet_mesh::tuple_is_valid_for_ccw(t));
CHECK(tet_mesh::is_ccw(t));
}
for(int i = 0; i < 4; ++i) {
Tuple t = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_vertex_id(i);
Tuple t = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_face_id(i);
Tuple t2 = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id(PrimitiveType::Triangle, i);
CHECK(t == t2);
CHECK(tet_mesh::tuple_is_valid_for_ccw(t));
Expand Down

0 comments on commit c7cfccf

Please sign in to comment.