Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 7ee2026

Browse files
committed
fix wrong derivatives
1 parent 82f483d commit 7ee2026

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/ipc/smooth_contact/primitives/point3.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Point3::Point3(
1111
const ParameterType& param)
1212
: Primitive(id, param)
1313
{
14-
orientable =
15-
!mesh.is_codim_vertex(id) && mesh.vertices_to_faces()[id].size() > 0;
14+
orientable = !mesh.is_codim_vertex(id) && mesh.vertices_to_faces()[id].size() > 0;
1615

1716
// Build index mapping from all vertices to one-ring neighbors
1817
{
@@ -258,6 +257,35 @@ GradType<-1> Point3::smooth_point3_term_normal_gradient(
258257
}
259258
}
260259

260+
// autodiff
261+
// TODO: replace with efficient code
262+
// double normal_term = 0;
263+
// {
264+
// using T = ADGrad<-1>;
265+
// Eigen::VectorXd tmp(direc.size() + tangents.size());
266+
// tmp.head<3>() = direc;
267+
// for (int i = 0; i < tangents.rows(); i++)
268+
// tmp.segment<3>(3 * i + 3) = tangents.row(i);
269+
270+
// DiffScalarBase::setVariableCount(tmp.size());
271+
// const Eigen::Matrix<T, -1, dim> X = slice_positions<T, -1, dim>(tmp);
272+
273+
// T normal_term_ad(0.);
274+
// for (int a = 0; a < faces.rows(); a++) {
275+
// if (_otypes.normal_type(a) == HEAVISIDE_TYPE::VARIANT)
276+
// normal_term_ad =
277+
// normal_term_ad
278+
// + Math<T>::smooth_heaviside(
279+
// -X.row(0).dot(X.row(faces(a, 1))
280+
// .cross(X.row(faces(a, 2)))
281+
// .normalized()),
282+
// _param.alpha_n, _param.beta_n);
283+
// }
284+
285+
// normal_term = normal_term_ad.getValue();
286+
// grad = normal_term_ad.getGradient();
287+
// }
288+
261289
const double val = Math<double>::smooth_heaviside(normal_term - 1, 1., 0);
262290
const double grad_val =
263291
Math<double>::smooth_heaviside_grad(normal_term - 1, 1., 0);
@@ -554,7 +582,7 @@ scalar Point3::smooth_point3_term(
554582
X.row(faces(a, 2)) - X.row(faces(a, 0));
555583
normal_term = normal_term
556584
+ Math<scalar>::smooth_heaviside(
557-
-dn.dot(t1.cross(t2).normalized()),
585+
dn.dot(t1.cross(t2).normalized()),
558586
_param.alpha_n, _param.beta_n);
559587
}
560588
normal_term = Math<scalar>::smooth_heaviside(normal_term - 1, 1., 0);

0 commit comments

Comments
 (0)