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

Commit 8410ada

Browse files
committed
2D friction force jacobian tests
1 parent 5dc2eaa commit 8410ada

File tree

2 files changed

+47
-29
lines changed

2 files changed

+47
-29
lines changed

src/ipc/smooth_contact/primitives/point2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Point2::Point2(const long &id,
99
const ParameterType& param)
1010
: Primitive(id, param)
1111
{
12-
_vert_ids.resize(3);
12+
_vert_ids = {{-1, -1, -1}};
1313
_vert_ids[0] = id;
1414

1515
if (mesh.vertex_edge_adjacencies()[id].size() != 2)

tests/src/tests/friction/friction_data_generator.cpp

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ SmoothFrictionData<3> smooth_friction_data_generator_3d()
188188

189189
V1 = V0;
190190
Eigen::Vector3d disp;
191-
disp << 1, 0, 0;
191+
disp << 0.5, 0, 0;
192192
V1.row(0) += disp.transpose();
193193
V1.row(4) += disp.transpose();
194194
V1.row(5) += disp.transpose();
@@ -224,7 +224,7 @@ SmoothFrictionData<3> smooth_friction_data_generator_3d()
224224

225225
V1 = V0;
226226
Eigen::Vector3d disp;
227-
disp << 1.5, 0, 0;
227+
disp << 0.5, 0, 0;
228228
V1.row(0) += disp.transpose();
229229
V1.row(1) += disp.transpose();
230230
V1.row(4) += disp.transpose();
@@ -278,7 +278,7 @@ SmoothFrictionData<3> smooth_friction_data_generator_3d()
278278

279279
V1 = V0;
280280
Eigen::Vector3d disp;
281-
disp << 1, 0, 0;
281+
disp << 0.5, 0, 0;
282282
V1.row(0) += disp.transpose();
283283
V1.row(3) += disp.transpose();
284284
V1.row(4) += disp.transpose();
@@ -325,7 +325,7 @@ SmoothFrictionData<3> smooth_friction_data_generator_3d()
325325

326326
V1 = V0;
327327
Eigen::Vector3d disp;
328-
disp << 1, 0, 0;
328+
disp << 0.5, 0, 0;
329329
V1.row(0) += disp.transpose();
330330
V1.row(2) += disp.transpose();
331331
V1.row(3) += disp.transpose();
@@ -429,13 +429,13 @@ SmoothFrictionData<2> smooth_friction_data_generator_2d()
429429
V0 << d, 0, // point at t=0
430430
0, -1, // edge vertex 0 at t=0
431431
0, 1, // edge vertex 1 at t=0
432-
2*d, -1,
433-
2*d, 1,
432+
1 + d, -1,
433+
1 + d, 1,
434434
-1, 0;
435435

436436
V1 = V0;
437437
Eigen::Vector2d disp;
438-
disp << 0, 1;
438+
disp << 0, 0.5;
439439
V1.row(0) += disp.transpose();
440440
V1.row(3) += disp.transpose();
441441
V1.row(4) += disp.transpose();
@@ -444,34 +444,52 @@ SmoothFrictionData<2> smooth_friction_data_generator_2d()
444444
F << 0, 3, 4,
445445
1, 2, 5;
446446

447-
igl::edges(F, E);
447+
E.resize(6, 2);
448+
E << 0, 3,
449+
3, 4,
450+
4, 0,
451+
1, 2,
452+
2, 5,
453+
5, 1;
454+
// igl::edges(F, E);
448455

449-
int e = 0;
450-
for (; e < E.rows(); e++)
451-
{
452-
if (std::min(E(e, 0), E(e, 1)) == 1 &&
453-
std::max(E(e, 0), E(e, 1)) == 2)
454-
break;
455-
}
456-
assert(e < E.rows());
456+
int e = 3;
457457

458458
CollisionMesh mesh(V0, E, F);
459459
collisions.collisions.push_back(std::make_shared<SmoothCollisionTemplate<max_vert_2d, Edge2, Point2>>(e, 0, PointEdgeDistanceType::AUTO, mesh, param, dhat, V0));
460460
}
461-
// SECTION("point-point 2D")
462-
// {
463-
// V0.resize(2, 2);
464-
// V0.row(0) << -1, d; // point 0 at t=0
465-
// V0.row(1) << 1, d; // point 1 at t=0
461+
SECTION("point-point 2D")
462+
{
463+
V0.resize(6, 2);
464+
V0 << d, 0,
465+
0, 0,
466+
1 + d, -1,
467+
1 + d, 1,
468+
0, -1,
469+
0, 1;
466470

467-
// V1 = V0;
468-
// // double dy = GENERATE(-1, 1, 1e-1);
469-
// V1.row(0) << 0.5, d; // edge a vertex 0 at t=1
470-
// V1.row(1) << -0.5, d; // edge a vertex 1 at t=1
471+
V1 = V0;
472+
Eigen::Vector2d disp;
473+
disp << 0, 0.5;
474+
V1.row(0) += disp.transpose();
475+
V1.row(2) += disp.transpose();
476+
V1.row(3) += disp.transpose();
471477

472-
// collisions.vv_collisions.emplace_back(0, 1);
473-
// collisions.vv_collisions.back().weight_gradient.resize(V0.size());
474-
// }
478+
F.resize(2, 3);
479+
F << 0, 2, 3,
480+
1, 5, 4;
481+
482+
E.resize(6, 2);
483+
E << 0, 2,
484+
2, 3,
485+
3, 0,
486+
1, 5,
487+
5, 4,
488+
4, 1;
489+
490+
CollisionMesh mesh(V0, E, F);
491+
collisions.collisions.push_back(std::make_shared<SmoothCollisionTemplate<max_vert_2d, Point2, Point2>>(0, 1, PointPointDistanceType::AUTO, mesh, param, dhat, V0));
492+
}
475493

476494
return data;
477495
}

0 commit comments

Comments
 (0)