Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/ipc/smooth_contact/primitives/edge3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<index_t, 4> neighbors { { -1, -1, -1, -1 } };
{
Expand Down Expand Up @@ -448,20 +448,25 @@ 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<Eigen::Vector3d> d, Eigen::ConstRef<Vector12d> x) const
Eigen::ConstRef<Eigen::Vector3d> d, Eigen::ConstRef<VectorMax12d> x) const
{
#ifdef IPC_TOOLKIT_DEBUG_AUTODIFF
return smooth_edge3_term_template<double>(
Expand All @@ -475,7 +480,7 @@ double Edge3::potential(
}

Vector15d Edge3::grad(
Eigen::ConstRef<Eigen::Vector3d> d, Eigen::ConstRef<Vector12d> x) const
Eigen::ConstRef<Eigen::Vector3d> d, Eigen::ConstRef<VectorMax12d> x) const
{
#ifdef IPC_TOOLKIT_DEBUG_AUTODIFF
Vector15d tmp;
Expand All @@ -495,7 +500,7 @@ Vector15d Edge3::grad(
}

Matrix15d Edge3::hessian(
Eigen::ConstRef<Eigen::Vector3d> d, Eigen::ConstRef<Vector12d> x) const
Eigen::ConstRef<Eigen::Vector3d> d, Eigen::ConstRef<VectorMax12d> x) const
{
#ifdef IPC_TOOLKIT_DEBUG_AUTODIFF
Vector15d tmp;
Expand Down
9 changes: 6 additions & 3 deletions src/ipc/smooth_contact/primitives/edge3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ class Edge3 : public Primitive {
int n_dofs() const override { return n_vertices() * DIM; }

double potential(
Eigen::ConstRef<Eigen::Vector3d> d, Eigen::ConstRef<Vector12d> x) const;
Eigen::ConstRef<Eigen::Vector3d> d,
Eigen::ConstRef<VectorMax12d> x) const;
Vector15d grad(
Eigen::ConstRef<Eigen::Vector3d> d, Eigen::ConstRef<Vector12d> x) const;
Eigen::ConstRef<Eigen::Vector3d> d,
Eigen::ConstRef<VectorMax12d> x) const;
Matrix15d hessian(
Eigen::ConstRef<Eigen::Vector3d> d, Eigen::ConstRef<Vector12d> x) const;
Eigen::ConstRef<Eigen::Vector3d> d,
Eigen::ConstRef<VectorMax12d> x) const;

private:
OrientationTypes otypes;
Expand Down