From ec2ec42f4df151724b3ac9b46ca51a47a5e0be68 Mon Sep 17 00:00:00 2001 From: Zizhou Huang Date: Wed, 22 Oct 2025 21:53:40 -0700 Subject: [PATCH 1/2] raise error on codim edges --- src/ipc/smooth_contact/primitives/edge3.cpp | 26 ++++++++++++--------- src/ipc/smooth_contact/primitives/edge3.hpp | 6 ++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/ipc/smooth_contact/primitives/edge3.cpp b/src/ipc/smooth_contact/primitives/edge3.cpp index 53c20974f..0b6be84be 100644 --- a/src/ipc/smooth_contact/primitives/edge3.cpp +++ b/src/ipc/smooth_contact/primitives/edge3.cpp @@ -388,7 +388,7 @@ Edge3::Edge3( { orientable = (mesh.is_orient_vertex(mesh.edges()(id, 0)) - && mesh.is_orient_vertex(mesh.edges()(id, 0))); + && mesh.is_orient_vertex(mesh.edges()(id, 1))); std::array neighbors { { -1, -1, -1, -1 } }; { @@ -448,20 +448,24 @@ Edge3::Edge3( d.normalized(), vertices.row(m_vertex_ids[0]), vertices.row(m_vertex_ids[1]), vertices.row(m_vertex_ids[2]), vertices.row(m_vertex_ids[3]), params, otypes, orientable); - } else if (has_neighbor_1 || has_neighbor_2) { - m_vertex_ids = { { neighbors[0], neighbors[1], - has_neighbor_1 ? neighbors[2] : neighbors[3] } }; - } else { - m_vertex_ids = { { neighbors[0], neighbors[1] } }; - m_is_active = true; + log_and_throw_error("Codimensional objects in 3D are not supported yet!"); + + if (has_neighbor_1 || has_neighbor_2) { + m_vertex_ids = { { neighbors[0], neighbors[1], + has_neighbor_1 ? neighbors[2] : neighbors[3] } }; + + } else { + m_vertex_ids = { { neighbors[0], neighbors[1] } }; + m_is_active = true; + } } } -int Edge3::n_vertices() const { return N_EDGE_NEIGHBORS_3D; } +int Edge3::n_vertices() const { return m_vertex_ids.size(); } double Edge3::potential( - Eigen::ConstRef d, Eigen::ConstRef x) const + Eigen::ConstRef d, Eigen::ConstRef x) const { #ifdef IPC_TOOLKIT_DEBUG_AUTODIFF return smooth_edge3_term_template( @@ -475,7 +479,7 @@ double Edge3::potential( } Vector15d Edge3::grad( - Eigen::ConstRef d, Eigen::ConstRef x) const + Eigen::ConstRef d, Eigen::ConstRef x) const { #ifdef IPC_TOOLKIT_DEBUG_AUTODIFF Vector15d tmp; @@ -495,7 +499,7 @@ Vector15d Edge3::grad( } Matrix15d Edge3::hessian( - Eigen::ConstRef d, Eigen::ConstRef x) const + Eigen::ConstRef d, Eigen::ConstRef x) const { #ifdef IPC_TOOLKIT_DEBUG_AUTODIFF Vector15d tmp; diff --git a/src/ipc/smooth_contact/primitives/edge3.hpp b/src/ipc/smooth_contact/primitives/edge3.hpp index c57ddfc30..d517d37ec 100644 --- a/src/ipc/smooth_contact/primitives/edge3.hpp +++ b/src/ipc/smooth_contact/primitives/edge3.hpp @@ -22,11 +22,11 @@ class Edge3 : public Primitive { int n_dofs() const override { return n_vertices() * DIM; } double potential( - Eigen::ConstRef d, Eigen::ConstRef x) const; + Eigen::ConstRef d, Eigen::ConstRef x) const; Vector15d grad( - Eigen::ConstRef d, Eigen::ConstRef x) const; + Eigen::ConstRef d, Eigen::ConstRef x) const; Matrix15d hessian( - Eigen::ConstRef d, Eigen::ConstRef x) const; + Eigen::ConstRef d, Eigen::ConstRef x) const; private: OrientationTypes otypes; From 3988fb54906e5a5dc1fe03fb337389e8a6f29ff9 Mon Sep 17 00:00:00 2001 From: Zizhou Huang Date: Mon, 27 Oct 2025 17:05:02 -0700 Subject: [PATCH 2/2] fix clang --- src/ipc/smooth_contact/primitives/edge3.cpp | 3 ++- src/ipc/smooth_contact/primitives/edge3.hpp | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ipc/smooth_contact/primitives/edge3.cpp b/src/ipc/smooth_contact/primitives/edge3.cpp index 0b6be84be..aa8c43ae6 100644 --- a/src/ipc/smooth_contact/primitives/edge3.cpp +++ b/src/ipc/smooth_contact/primitives/edge3.cpp @@ -449,7 +449,8 @@ Edge3::Edge3( vertices.row(m_vertex_ids[1]), vertices.row(m_vertex_ids[2]), vertices.row(m_vertex_ids[3]), params, otypes, orientable); } else { - log_and_throw_error("Codimensional objects in 3D are not supported yet!"); + log_and_throw_error( + "Codimensional objects in 3D are not supported yet!"); if (has_neighbor_1 || has_neighbor_2) { m_vertex_ids = { { neighbors[0], neighbors[1], diff --git a/src/ipc/smooth_contact/primitives/edge3.hpp b/src/ipc/smooth_contact/primitives/edge3.hpp index d517d37ec..6fbff3b25 100644 --- a/src/ipc/smooth_contact/primitives/edge3.hpp +++ b/src/ipc/smooth_contact/primitives/edge3.hpp @@ -22,11 +22,14 @@ class Edge3 : public Primitive { int n_dofs() const override { return n_vertices() * DIM; } double potential( - Eigen::ConstRef d, Eigen::ConstRef x) const; + Eigen::ConstRef d, + Eigen::ConstRef x) const; Vector15d grad( - Eigen::ConstRef d, Eigen::ConstRef x) const; + Eigen::ConstRef d, + Eigen::ConstRef x) const; Matrix15d hessian( - Eigen::ConstRef d, Eigen::ConstRef x) const; + Eigen::ConstRef d, + Eigen::ConstRef x) const; private: OrientationTypes otypes;