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

Commit ae528e7

Browse files
committed
fix bug
1 parent 9b7650f commit ae528e7

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

src/ipc/smooth_contact/collisions/smooth_collision.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ SmoothCollisionTemplate<PrimitiveA, PrimitiveB>::type() const
3131
return CollisionType::VertexVertex;
3232
}
3333

34+
Eigen::VectorXd SmoothCollision::dof(Eigen::ConstRef<Eigen::MatrixXd> X) const
35+
{
36+
const int dim = X.cols();
37+
Eigen::VectorXd x(num_vertices() * dim);
38+
if (dim == 2) {
39+
for (int i = 0; i < num_vertices(); i++) {
40+
x.segment<2>(i * 2) = X.row(vertex_ids_[i]);
41+
}
42+
}
43+
else if (dim == 3) {
44+
for (int i = 0; i < num_vertices(); i++) {
45+
x.segment<3>(i * 3) = X.row(vertex_ids_[i]);
46+
}
47+
}
48+
else
49+
throw std::runtime_error("Invalid dimension!");
50+
return x;
51+
}
52+
3453
template <typename PrimitiveA, typename PrimitiveB>
3554
std::string
3655
SmoothCollisionTemplate<PrimitiveA, PrimitiveB>::name() const
@@ -106,10 +125,14 @@ SmoothCollisionTemplate<PrimitiveA, PrimitiveB>::
106125
(d.norm() < Super::dhat()) && pA->is_active() && pB->is_active();
107126

108127
if (d.norm() < 1e-12)
128+
{
109129
logger().warn(
110130
"pair distance {}, id {} and {}, dtype {}, active {}", d.norm(),
111131
primitive0_, primitive1_,
112132
PrimitiveDistType<PrimitiveA, PrimitiveB>::name, Super::is_active_);
133+
134+
logger().warn("value {}", (*this)(this->dof(V), param));
135+
}
113136
}
114137

115138
template <typename PrimitiveA, typename PrimitiveB>
@@ -135,10 +158,13 @@ double SmoothCollisionTemplate<PrimitiveA, PrimitiveB>::operator()(
135158
PrimitiveDistanceTemplate<PrimitiveA, PrimitiveB, double>::mollifier(
136159
x, dist * dist);
137160

161+
if (params.r == 0)
162+
logger().error("Invalid param!");
163+
138164
if (dist < 1e-12)
139165
logger().warn(
140-
"pair distance {:.3e}, barrier {:.3e}, mollifier {:.3e}, orient {:.3e} {:.3e}",
141-
dist, a3, a4, a1, a2);
166+
"pair distance {:.3e}, dhat {:.3e}, r {}, barrier {:.3e}, mollifier {:.3e}, orient {:.3e} {:.3e}",
167+
dist, Super::dhat(), params.r, a3, a4, a1, a2);
142168

143169
return a1 * a2 * a3 * a4;
144170
}

src/ipc/smooth_contact/collisions/smooth_collision.hpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,7 @@ class SmoothCollision {
6969
/// @param X Full matrix of DOF (rowwise).
7070
/// @return This stencil's DOF.
7171
Eigen::VectorXd
72-
dof(Eigen::ConstRef<Eigen::MatrixXd> X) const
73-
{
74-
const int dim = X.cols();
75-
Eigen::VectorXd x(num_vertices() * dim);
76-
for (int i = 0; i < num_vertices(); i++) {
77-
x.segment(i * dim, dim) = X.row(vertex_ids_[i]);
78-
}
79-
return x;
80-
}
72+
dof(Eigen::ConstRef<Eigen::MatrixXd> X) const;
8173

8274
/// @brief Compute the distance of the stencil.
8375
/// @param vertices Collision mesh vertices

src/ipc/smooth_contact/smooth_collisions.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,7 @@ double SmoothCollisions::compute_active_minimum_distance(
306306
double& local_min_dist = storage.local();
307307

308308
for (size_t i = r.begin(); i < r.end(); i++) {
309-
const double dist = collisions[i]->compute_distance(
310-
collisions[i]->dof(vertices));
309+
const double dist = collisions[i]->compute_distance(vertices);
311310

312311
if (collisions[i]->is_active() && dist < local_min_dist) {
313312
local_min_dist = dist;

0 commit comments

Comments
 (0)