Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
288 commits
Select commit Hold shift + click to select a range
4bebdc0
remove not implemented function
Huangzizhou Jan 8, 2024
312e774
add print to see dtype
maxpaik16 Jan 8, 2024
45fe368
fix formatting
maxpaik16 Jan 8, 2024
bfab1cf
add more prints
maxpaik16 Jan 8, 2024
b12594e
add printing to smooth builders
maxpaik16 Jan 8, 2024
1d77d9c
add first draft of adaptive eps code
maxpaik16 Jan 8, 2024
81a2dd7
remove semicolon
maxpaik16 Jan 8, 2024
653560d
fix compiler errors
maxpaik16 Jan 8, 2024
d007f5a
fix compiler errors
maxpaik16 Jan 8, 2024
3e4de34
fix compiler errors!
maxpaik16 Jan 8, 2024
c23a48f
add some debug prints
maxpaik16 Jan 8, 2024
a81b76b
typo fix
maxpaik16 Jan 8, 2024
e001348
address seg fault
maxpaik16 Jan 8, 2024
077505f
comment out
maxpaik16 Jan 8, 2024
93f26b2
add more prints
maxpaik16 Jan 8, 2024
f40d0c5
fix typo
maxpaik16 Jan 8, 2024
61cfbe8
fix more typos
maxpaik16 Jan 8, 2024
07bc85c
fix eigen typo
maxpaik16 Jan 8, 2024
1e2fe91
use parens for indexing
maxpaik16 Jan 8, 2024
6f3988a
add new print after loop
maxpaik16 Jan 8, 2024
8df305e
change size to rows
maxpaik16 Jan 8, 2024
7dcbed9
resize config mapping
maxpaik16 Jan 8, 2024
04582ab
add local eps print
maxpaik16 Jan 8, 2024
1a337db
quadrature for point face potential
Huangzizhou Jan 8, 2024
2b4ed80
face vertex potential in 3D, incomplete
Huangzizhou Jan 8, 2024
0880e1e
comment out
maxpaik16 Jan 8, 2024
d13b29f
comment out
maxpaik16 Jan 8, 2024
ed0574c
fix grad/hess bug
maxpaik16 Jan 8, 2024
3304f5d
cleanup code
maxpaik16 Jan 8, 2024
eacfadc
more cleaning
maxpaik16 Jan 8, 2024
ff34c1c
set a to 0
maxpaik16 Jan 8, 2024
4be830b
add distance ratio param
maxpaik16 Jan 9, 2024
88010e6
use simple dist method
maxpaik16 Jan 9, 2024
733f077
fix some sqs, test case, and candidate dhat
maxpaik16 Jan 9, 2024
fd67ace
parallelize init_vertex_contact_distance_map
Huangzizhou Jan 9, 2024
2861e12
make json param dhat max for local dhat
maxpaik16 Jan 9, 2024
e1335be
Merge pull request #2 from geometryprocessing/adaptive-eps
Huangzizhou Jan 9, 2024
4d1a502
make adaptive epsilon optional
maxpaik16 Jan 9, 2024
fdcacdb
Merge pull request #3 from geometryprocessing/main
maxpaik16 Jan 9, 2024
50172fb
add some prints
maxpaik16 Jan 9, 2024
c0fc86e
fix dhat vs dhat**2
maxpaik16 Jan 9, 2024
f0c2e26
remove comments
maxpaik16 Jan 9, 2024
c397561
Merge pull request #4 from geometryprocessing/adaptive-eps
Huangzizhou Jan 9, 2024
5127eb7
point face potential
Huangzizhou Jan 9, 2024
3916061
Merge branch 'main' of https://github.com/geometryprocessing/smooth-ipc
Huangzizhou Jan 9, 2024
b7c5282
fix eps
Huangzizhou Jan 9, 2024
b2163fc
verified 3D vertex-face potential
Huangzizhou Jan 9, 2024
dfdf68e
template dimension in SmoothEdgeEdgeCollision
Huangzizhou Jan 10, 2024
9db82e2
face-face candidate
Huangzizhou Jan 10, 2024
52b7b8c
consider orientation in 2D
Huangzizhou Jan 10, 2024
66d932e
include adjacent edges in edge-edge candidates
Huangzizhou Jan 10, 2024
a90e489
face-face candidate for BVH
Huangzizhou Jan 10, 2024
3d03151
refactor code, 2D validated, 3D buggy
Huangzizhou Jan 11, 2024
f773104
fix bug in 3d face-vertex
Huangzizhou Jan 11, 2024
bf2eb75
reduce template params
Huangzizhou Jan 11, 2024
0d524d7
fix bug in edge-edge potential
Huangzizhou Jan 11, 2024
08db98f
fix artifact in point-edge potential
Huangzizhou Jan 11, 2024
5008192
2D simulation working!
Huangzizhou Jan 11, 2024
b96ad43
fix compile err on mac
Huangzizhou Jan 11, 2024
ea98be7
add back adaptive dhat
Huangzizhou Jan 11, 2024
49f9aaf
test for adaptive barrier
Huangzizhou Jan 11, 2024
d7d203a
remove smooth_point_edge in python
Huangzizhou Jan 12, 2024
d4f8237
add neighboring face-face pairs
Huangzizhou Jan 12, 2024
d5ec4e7
3d edge-edge collision, use the same as IPC for now
Huangzizhou Jan 12, 2024
7454e2d
Merge branch 'main' of https://github.com/geometryprocessing/smooth-ipc
Huangzizhou Jan 12, 2024
83d16b7
use old edge-edge potential for now
Huangzizhou Jan 12, 2024
84a2c4b
reduce face-face candidates
Huangzizhou Jan 12, 2024
b329c67
code refactor
Huangzizhou Jan 13, 2024
ce4770b
fix comment
Huangzizhou Jan 13, 2024
ea98b45
re-organize code for 3d edge-edge collision
Huangzizhou Jan 13, 2024
9802bfc
new edge-edge potential in 3D
Huangzizhou Jan 13, 2024
ae3e8b3
fix bugs in edge-edge potential
Huangzizhou Jan 14, 2024
319163f
add finite difference
Huangzizhou Jan 14, 2024
b66a53b
move distance functions to separate folder
Huangzizhou Jan 14, 2024
c82234e
mollifier for edge-edge potential
Huangzizhou Jan 14, 2024
6a96573
change edge-edge mollification
Huangzizhou Jan 14, 2024
a47399f
fix compile error
Huangzizhou Jan 14, 2024
39f7648
fix compile error
Huangzizhou Jan 14, 2024
f8107d3
accelerate
Huangzizhou Jan 14, 2024
5d7839d
normal penalty in edge-edge potential
Huangzizhou Jan 15, 2024
02215e8
acceleration with more caching
Huangzizhou Jan 15, 2024
d6f56f5
more acceleration
Huangzizhou Jan 15, 2024
81e64d7
acceleration
Huangzizhou Jan 15, 2024
c64a660
fix compute_min_distance
Huangzizhou Jan 15, 2024
f6c6c58
adaptive dhat
Huangzizhou Jan 16, 2024
317ab27
fix bug in edge-edge potential normal term
Huangzizhou Jan 16, 2024
bb0200a
change minimum distance computation
Huangzizhou Jan 16, 2024
c997ce8
point-point potential in 2D
Huangzizhou Jan 16, 2024
214366d
fix bug in edge-edge potential in 3D
Huangzizhou Jan 16, 2024
050d163
point-point potential in 2D
Huangzizhou Jan 16, 2024
92ec656
vertex-vertex potential in 3D
Huangzizhou Jan 16, 2024
58de39a
vertex-vertex potential in 3D
Huangzizhou Jan 16, 2024
bc10ad5
vertex-edge potential in 3D
Huangzizhou Jan 17, 2024
9eab924
fix bug in minimum distance
Huangzizhou Jan 17, 2024
246f893
change virtual function
Huangzizhou Jan 17, 2024
39e4aa6
more meaningful log
Huangzizhou Jan 17, 2024
96f9b99
change hashing
Huangzizhou Jan 17, 2024
372e56b
fix bug in edge-edge 3d
Huangzizhou Jan 17, 2024
d0872f3
fix adaptive dhat
Huangzizhou Jan 17, 2024
b0dcae5
add project_to_psd
Huangzizhou Jan 18, 2024
c9e88a0
2d vertex-edge potential
Huangzizhou Jan 18, 2024
993d47a
edge_mollifier
Huangzizhou Jan 18, 2024
a2abd37
fix bug in edge-vertex potential
Huangzizhou Jan 18, 2024
3dfdc51
simpler mollifier
Huangzizhou Jan 18, 2024
8020b63
change to 3d formulation
Huangzizhou Jan 19, 2024
5a16978
optimize code
Huangzizhou Jan 19, 2024
26952a0
fix wrong type check
Huangzizhou Jan 19, 2024
31edf09
try to fix edge-vertex in 2D
Huangzizhou Jan 19, 2024
d3429f8
change adaptive dhat
Huangzizhou Jan 19, 2024
35b264a
fix discontinuity in energy
Huangzizhou Jan 19, 2024
ae11c38
fix bug in face_vertex
Huangzizhou Jan 20, 2024
b3ad2bb
smoother potential
Huangzizhou Jan 20, 2024
f2cb5a0
fix bug in wrong number of vertices
Huangzizhou Jan 21, 2024
8cda392
fix bug
Huangzizhou Jan 21, 2024
a74b901
fix mollifier, change heaviside
Huangzizhou Jan 22, 2024
6d19d14
better scaled contact weights
Huangzizhou Jan 27, 2024
486aef2
clean code, change eps to dhat
Huangzizhou Jan 27, 2024
a70afad
move files around
Huangzizhou Jan 28, 2024
e52c175
fix bug in triangle area
Huangzizhou Jan 28, 2024
5a11138
add autodiff lib, not used
Huangzizhou Jan 28, 2024
a928856
fixed-size matrix for autodiff
Huangzizhou Jan 28, 2024
0973df9
clean functions
Huangzizhou Jan 28, 2024
668af7c
acceleration of edge-edge by caching
Huangzizhou Jan 28, 2024
9ac3bc8
clean function
Huangzizhou Jan 28, 2024
3979683
make tests pass
Huangzizhou Jan 28, 2024
bc7cd7e
move around files
Huangzizhou Jan 28, 2024
db02e38
rename autodiff type
Huangzizhou Jan 28, 2024
7d6e5c5
remove project PSD; class for each primitive
Huangzizhou Jan 29, 2024
dd77bde
fix bug in unordered_tuple
Huangzizhou Jan 29, 2024
5b46b73
refactor 3D potential for better efficiency
Huangzizhou Feb 1, 2024
b9171fb
change tolerance
Huangzizhou Feb 1, 2024
c8612d4
remove not used files
Huangzizhou Feb 1, 2024
f60395a
add check for number of vertices
Huangzizhou Feb 1, 2024
0bcbb48
put back caching
Huangzizhou Feb 1, 2024
8644b0b
try to reduce cost of point_edge_distance autodiff
Huangzizhou Feb 1, 2024
3c78e26
refactor for better efficiency
Huangzizhou Feb 2, 2024
abf6b11
remove AD for edge-edge mollifier grad
Huangzizhou Feb 2, 2024
19ff37d
remove autodiff in edge mollifier, static size for autodiff
Huangzizhou Feb 2, 2024
81ab0e2
more manual derivatives and tests
Huangzizhou Feb 3, 2024
9744902
remove not used functions
Huangzizhou Feb 3, 2024
25639bd
remove point term autodiff
Huangzizhou Feb 5, 2024
d5f3ca4
remove unused files
Huangzizhou Feb 5, 2024
a8cb493
prepare for point2
Huangzizhou Feb 5, 2024
9984ba5
fix bug in point term
Huangzizhou Feb 5, 2024
f00f984
remove autodiff for edge term gradient
Huangzizhou Feb 5, 2024
b3a8a45
remove AD in point term hessian
Huangzizhou Feb 5, 2024
4ca0667
fix compile error
Huangzizhou Feb 5, 2024
ef7bd14
use indices instead of blocks
Huangzizhou Feb 5, 2024
e73ed0e
format files
Huangzizhou Feb 5, 2024
b07cf48
remove autodiff in edge-edge mollifier
Huangzizhou Feb 6, 2024
66fde95
move around functions
Huangzizhou Feb 6, 2024
fff6888
replace line-line closest direction autodiff
Huangzizhou Feb 7, 2024
9bd7afb
refactor mollifier
Huangzizhou Feb 8, 2024
3c8ca72
more robust
Huangzizhou Feb 8, 2024
66b53f8
remove autodiff for point-face mollifier
Huangzizhou Feb 9, 2024
313ed38
move 2D into the new code structure
Huangzizhou Feb 12, 2024
de10633
faster matrix assembly
Huangzizhou Feb 13, 2024
52a7304
fix nan in energy
Huangzizhou Feb 13, 2024
0bbdb8e
change scaling of mollifiers
Huangzizhou Feb 14, 2024
6fcc3e0
friction
Huangzizhou Feb 14, 2024
b446664
change threshold for mollifier
Huangzizhou Feb 15, 2024
f955b1e
fix bug in edge term
Huangzizhou Feb 21, 2024
de21594
change mollifier threshold
Huangzizhou Feb 21, 2024
b318898
fix bugs in derivatives
Huangzizhou Feb 21, 2024
076a3bf
change barrier power to integer
Huangzizhou Feb 21, 2024
1e2ed31
change alpha to 1 in normal term
Huangzizhou Feb 23, 2024
b59dba2
clean code
Huangzizhou Feb 27, 2024
c609038
clean parallelism code
Huangzizhou Mar 1, 2024
b809f9c
refactor builder
Huangzizhou Mar 1, 2024
e5f79b3
simplify collisions builder
Huangzizhou Mar 1, 2024
4ddced5
clean code
Huangzizhou Mar 2, 2024
cc0347f
make autodiff cmake option
Huangzizhou Mar 11, 2024
90123d2
active min dist
Huangzizhou Mar 21, 2024
d894e33
fix compile error in python addon
Huangzizhou Mar 21, 2024
001ec08
python binding for smooth collisions
Huangzizhou Mar 22, 2024
ff6ceac
new normal term formulation
Huangzizhou Apr 29, 2024
bd3dd26
merge main
Huangzizhou Apr 29, 2024
51e0cf3
fix bug in edge term autodiff
Huangzizhou Apr 29, 2024
1461cd3
enable shape derivatives for new formulation
Huangzizhou May 3, 2024
7431bc7
support collisions deep copy
Huangzizhou May 3, 2024
9504cf5
try to add friction force jacobian, still buggy
Huangzizhou May 8, 2024
6752391
fix small bugs
Huangzizhou May 9, 2024
1ec6e77
fix memory issue
Huangzizhou Aug 28, 2024
557dbb0
fix compile error
Huangzizhou Sep 5, 2024
2c29a4d
fix bug in compute_active_minimum_distance
Huangzizhou Sep 11, 2024
8dda64a
Merge commit '617b80e92eb4310791a722fd1cc20c902b17683f' into fix-bug
Huangzizhou Oct 3, 2024
cbf0f79
fix python binding and compile error
Huangzizhou Mar 26, 2025
3c30dc5
comment huge test
Huangzizhou Mar 26, 2025
beb56c1
increase threshold for failed unit test
Huangzizhou Mar 27, 2025
0c287e1
friction force jacobian
Huangzizhou Mar 28, 2025
5dc2eaa
separate 2d and 3d tests
Huangzizhou Mar 29, 2025
8410ada
2D friction force jacobian tests
Huangzizhou Mar 29, 2025
80e4d59
fix friction force jacobian test
Huangzizhou Mar 29, 2025
ecfebca
force hessian symmetric
Huangzizhou Mar 31, 2025
b9050b3
Update CI
Huangzizhou May 2, 2025
6a78e28
fix cmake
Huangzizhou May 2, 2025
0bfb223
remove autodiff lib
Huangzizhou May 2, 2025
7e3e12a
disable complex tests in debug
Huangzizhou May 2, 2025
3b8e90b
increase tolerance
Huangzizhou May 2, 2025
816307f
Increase FD order
Huangzizhou May 3, 2025
6e96e53
update unit test
Huangzizhou May 5, 2025
20b0617
fix python binding
Huangzizhou May 6, 2025
7fd5787
Fix problems with templated return types.
daniel-zint May 6, 2025
2aded9d
Merge pull request #5 from geometryprocessing/dzint/windows_template_fix
Huangzizhou May 6, 2025
0ba4e7c
fix warning
Huangzizhou May 7, 2025
182eb72
template vector size
Huangzizhou May 7, 2025
059cda0
fix bugs
Huangzizhou May 11, 2025
f90e8c7
fix missing definition
Huangzizhou May 11, 2025
d128e2c
fix compile error
Huangzizhou May 11, 2025
512fda2
deal with codim vert/edge in 2D
Huangzizhou May 11, 2025
1f7c102
3D codimensional edge/face
Huangzizhou Jun 2, 2025
182e09b
try to fix CI
Huangzizhou Jun 2, 2025
82f483d
fix compile error
Huangzizhou Jun 2, 2025
7ee2026
fix wrong derivatives
Huangzizhou Jun 2, 2025
bc3fa7c
fix CI
Huangzizhou Jun 6, 2025
f937e09
fix compile error on windows
Huangzizhou Jun 7, 2025
f73987b
Fix compile error on windows
Huangzizhou Jun 7, 2025
12db2bc
readme
Huangzizhou Jun 9, 2025
6718175
Merge branch 'main' of github.com:geometryprocessing/geometric-contac…
Huangzizhou Jun 9, 2025
9fa2c71
Merge branch 'main' of https://github.com/ipc-sim/ipc-toolkit
Huangzizhou Jun 14, 2025
446c384
clang formatting
Huangzizhou Jun 14, 2025
e0c68dc
fix python compilation
Huangzizhou Jun 15, 2025
c7f8b9d
orientable flag
Huangzizhou Jun 15, 2025
11467a0
remove deprecated flag
Huangzizhou Jun 15, 2025
450a1d5
enum class BroadPhaseMethod
Huangzizhou Jun 16, 2025
e22a89c
remove CollisionBase class
Huangzizhou Jun 18, 2025
9b7650f
get rid off templates
Huangzizhou Jun 26, 2025
ae528e7
fix bug
Huangzizhou Jun 28, 2025
aaf9513
change test param
Huangzizhou Jun 29, 2025
80dda64
fix format
Huangzizhou Jun 29, 2025
3b19523
Merge branch 'main' of https://github.com/ipc-sim/ipc-toolkit into dy…
Huangzizhou Jun 29, 2025
7a1627e
format files
Huangzizhou Jun 29, 2025
a775902
disable pypi workflow
Huangzizhou Jun 29, 2025
44c5e56
format files
Huangzizhou Jun 29, 2025
81c41e3
format file
Huangzizhou Jun 30, 2025
97316fe
remove not used file
Huangzizhou Jun 30, 2025
15f3a13
skip expensive test
Huangzizhou Jun 30, 2025
7185ecd
Merge pull request #6 from geometryprocessing/dynamic
Huangzizhou Jul 1, 2025
8905abe
Merge branch 'main' into gcp
Huangzizhou Sep 26, 2025
21f4a60
revert changes
Huangzizhou Sep 26, 2025
f622856
revert test change
Huangzizhou Sep 26, 2025
6f1d422
Revert changes
Huangzizhou Sep 29, 2025
7951138
clean repo
Huangzizhou Sep 29, 2025
b746117
format doc
Huangzizhou Sep 29, 2025
9f0ed6d
formatting
Huangzizhou Oct 5, 2025
c861e4a
Merge branch 'main' of https://github.com/ipc-sim/ipc-toolkit into gcp
Huangzizhou Oct 5, 2025
3726206
formatting
Huangzizhou Oct 5, 2025
3da47f0
build function for broad phase methods
Huangzizhou Oct 5, 2025
baeed9b
formatting
Huangzizhou Oct 5, 2025
91b840e
formatting
Huangzizhou Oct 5, 2025
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
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ else()
set(IPC_TOOLKIT_BUILD_PYTHON OFF CACHE BOOL "Build Python bindings" FORCE)
endif()

set(IPC_TOOLKIT_TESTS_GCP_DATA_DIR "${PROJECT_SOURCE_DIR}/tests/gcp-data/" CACHE PATH "")

if(CMAKE_CUDA_COMPILER)
option(IPC_TOOLKIT_WITH_CUDA "Enable CUDA CCD" ON)
else()
Expand All @@ -91,6 +93,7 @@ option(IPC_TOOLKIT_WITH_INEXACT_CCD "Use the original inexact CCD meth
# Advanced options
option(IPC_TOOLKIT_WITH_SIMD "Enable SIMD" OFF)
option(IPC_TOOLKIT_WITH_CODE_COVERAGE "Enable coverage reporting" OFF)
option(IPC_TOOLKIT_WITH_AUTODIFF "Enable AutoDiff for computing derivatives" OFF)

mark_as_advanced(IPC_TOOLKIT_WITH_SIMD) # This does not work reliably
mark_as_advanced(IPC_TOOLKIT_WITH_CODE_COVERAGE) # This is used in GitHub Actions
Expand Down Expand Up @@ -235,6 +238,11 @@ endif()
# Use C++17
target_compile_features(ipc_toolkit PUBLIC cxx_std_17)

if(IPC_TOOLKIT_WITH_AUTODIFF)
target_compile_definitions(ipc_toolkit PUBLIC DERIVATIVES_WITH_AUTODIFF)
endif()
target_compile_definitions(ipc_toolkit PUBLIC IPC_TOOLKIT_WITH_TBB)

################################################################################
# CUDA
################################################################################
Expand Down Expand Up @@ -306,4 +314,4 @@ if (CMAKE_GENERATOR STREQUAL "Xcode")
if(IPC_TOOLKIT_BUILD_PYTHON)
set_target_properties(ipctk PROPERTIES XCODE_GENERATE_SCHEME ON)
endif()
endif()
endif()
16 changes: 16 additions & 0 deletions cmake/recipes/autodiff.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# autodiff (https://github.com/autodiff/autodiff.git)
# BSD license
if(TARGET autodiff::autodiff)
return()
endif()

message(STATUS "Third-party: creating target 'autodiff::autodiff'")

option(AUTODIFF_BUILD_TESTS "Enable the compilation of the test files." OFF)
option(AUTODIFF_BUILD_PYTHON "Enable the compilation of the python bindings." OFF)
option(AUTODIFF_BUILD_EXAMPLES "Enable the compilation of the example files." OFF)
option(AUTODIFF_BUILD_DOCS "Enable the build of the documentation and website." OFF)

include(CPM)
CPMAddPackage("gh:autodiff/[email protected]")
target_link_libraries(ipc_toolkit PRIVATE autodiff::autodiff)
2 changes: 2 additions & 0 deletions python/src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ PYBIND11_MODULE(ipctk, m)
define_smooth_friction_mollifier(m);
define_smooth_mu(m);

define_smooth_potential(m);

// implicits
define_plane_implicit(m);

Expand Down
6 changes: 4 additions & 2 deletions python/src/collision_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ void define_collision_mesh(py::module_& m)
"displacement_map"_a = Eigen::SparseMatrix<double>())
.def(
py::init<
const std::vector<bool>&, Eigen::ConstRef<Eigen::MatrixXd>,
const std::vector<bool>&, const std::vector<bool>&,
Eigen::ConstRef<Eigen::MatrixXd>,
Eigen::ConstRef<Eigen::MatrixXi>,
Eigen::ConstRef<Eigen::MatrixXi>,
const Eigen::SparseMatrix<double>&>(),
Expand All @@ -160,12 +161,13 @@ void define_collision_mesh(py::module_& m)

Parameters:
include_vertex: Vector of bools indicating whether each vertex should be included in the collision mesh.
orient_vertex: Vector of bools indicating whether each vertex is orientable.
full_rest_positions: The vertices of the full mesh at rest (#V × dim).
edges: The edges of the collision mesh indexed into the full mesh vertices (#E × 2).
faces: The faces of the collision mesh indexed into the full mesh vertices (#F × 3).
displacement_map: The displacement mapping from displacements on the full mesh to the collision mesh.
)ipc_Qu8mg5v7",
"include_vertex"_a, "full_rest_positions"_a,
"include_vertex"_a, "orient_vertex"_a, "full_rest_positions"_a,
"edges"_a = Eigen::MatrixXi(), "faces"_a = Eigen::MatrixXi(),
"displacement_map"_a = Eigen::SparseMatrix<double>())
.def_static(
Expand Down
115 changes: 115 additions & 0 deletions python/src/collisions/normal/normal_collisions.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,86 @@
#include <common.hpp>

#include <ipc/collisions/normal/normal_collisions.hpp>
#include <ipc/smooth_contact/smooth_collisions.hpp>

using namespace ipc;

template <typename collision_type, typename parent_type>
void define_SmoothCollisionTemplate(py::module_& m, std::string name)
{
py::class_<collision_type, parent_type>(m, name.c_str())
.def("name", &collision_type::name, "Get the type name of collision")
.def(
"num_vertices", &collision_type::num_vertices,
"Get the number of vertices");
}

void define_SmoothCollisions(py::module_& m, std::string name)
{
py::class_<SmoothCollisions>(m, name.c_str())
.def(py::init())
.def(
"build",
py::overload_cast<
const CollisionMesh&, Eigen::ConstRef<Eigen::MatrixXd>,
const ParameterType, const bool, std::shared_ptr<BroadPhase>>(
&SmoothCollisions::build),
R"ipc_Qu8mg5v7(
Initialize the set of collisions used to compute the barrier potential.

Parameters:
mesh: The collision mesh.
vertices: Vertices of the collision mesh.
param: ParameterType.
use_adaptive_dhat: If the adaptive dhat should be used.
broad_phase: Broad phase method.
)ipc_Qu8mg5v7",
py::arg("mesh"), py::arg("vertices"), py::arg("param"),
py::arg("use_adaptive_dhat") = false,
py::arg("broad_phase") = make_default_broad_phase())
.def(
"compute_minimum_distance",
&SmoothCollisions::compute_minimum_distance,
R"ipc_Qu8mg5v7(
Computes the minimum distance between any non-adjacent elements.

Parameters:
mesh: The collision mesh.
vertices: Vertices of the collision mesh.

Returns:
The minimum distance between any non-adjacent elements.
)ipc_Qu8mg5v7",
py::arg("mesh"), py::arg("vertices"))
.def(
"__len__", &SmoothCollisions::size, "Get the number of collisions.")
.def(
"empty", &SmoothCollisions::empty,
"Get if the collision set is empty.")
.def("clear", &SmoothCollisions::clear, "Clear the collision set.")
.def(
"__getitem__",
[](SmoothCollisions& self, size_t i) ->
typename SmoothCollisions::value_type& { return self[i]; },
py::return_value_policy::reference,
R"ipc_Qu8mg5v7(
Get a reference to collision at index i.

Parameters:
i: The index of the collision.

Returns:
A reference to the collision.
)ipc_Qu8mg5v7",
py::arg("i"))
.def(
"to_string", &SmoothCollisions::to_string, py::arg("mesh"),
py::arg("vertices"), py::arg("param"))
.def(
"n_candidates", &SmoothCollisions::n_candidates,
"Get the number of candidates.");
}

void define_normal_collisions(py::module_& m)
{
py::class_<NormalCollisions>(m, "NormalCollisions")
Expand Down Expand Up @@ -159,4 +236,42 @@ void define_normal_collisions(py::module_& m)
.def_readwrite("ee_collisions", &NormalCollisions::ee_collisions)
.def_readwrite("fv_collisions", &NormalCollisions::fv_collisions)
.def_readwrite("pv_collisions", &NormalCollisions::pv_collisions);

py::class_<SmoothCollision>(m, "SmoothCollision2")
.def("n_dofs", &SmoothCollision::n_dofs, "Get the degree of freedom")
.def(
"__call__", &SmoothCollision::operator(),
R"ipc_Qu8mg5v7(
Compute the potential.

Parameters:
positions: The vertex positions.
params: The parameters.

Returns:
The potential (not scaled by the barrier stiffness) of this collision pair.
)ipc_Qu8mg5v7",
py::arg("positions"), py::arg("params"))
.def(
"__getitem__",
[](SmoothCollision& self, size_t i) -> long { return self[i]; },
R"ipc_Qu8mg5v7(
Get primitive id.

Parameters:
i: 0 or 1.

Returns:
The index of the primitive.
)ipc_Qu8mg5v7",
py::arg("i"));

define_SmoothCollisionTemplate<
SmoothCollisionTemplate<Edge2, Point2>, SmoothCollision>(
m, "Edge2Point2Collision");
define_SmoothCollisionTemplate<
SmoothCollisionTemplate<Point2, Point2>, SmoothCollision>(
m, "Point2Point2Collision");

define_SmoothCollisions(m, "SmoothCollisions");
}
151 changes: 151 additions & 0 deletions python/src/potentials/barrier_potential.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <common.hpp>

#include <ipc/potentials/barrier_potential.hpp>
#include <ipc/smooth_contact/smooth_contact_potential.hpp>

using namespace ipc;

Expand Down Expand Up @@ -37,3 +38,153 @@ void define_barrier_potential(py::module_& m)
&BarrierPotential::set_barrier,
"Barrier function used to compute the potential.");
}

void define_smooth_potential(py::module_& m)
{
py::class_<ParameterType>(m, "ParameterType")
.def(
py::init<
const double&, const double&, const double&, const double&,
const double&, const int&>(),
R"ipc_Qu8mg5v7(
Construct parameter set for smooth contact.

Parameters:
dhat, alpha_t, beta_t, alpha_n, beta_n, r
)ipc_Qu8mg5v7",
py::arg("dhat"), py::arg("alpha_t"), py::arg("beta_t"),
py::arg("alpha_n"), py::arg("beta_n"), py::arg("r"))
.def(
py::init<const double&, const double&, const double&, const int&>(),
R"ipc_Qu8mg5v7(
Construct parameter set for smooth contact.

Parameters:
dhat, alpha_t, beta_t, r
)ipc_Qu8mg5v7",
py::arg("dhat"), py::arg("alpha_t"), py::arg("beta_t"),
py::arg("r"))
.def_readonly("dhat", &ParameterType::dhat)
.def_readonly("alpha_t", &ParameterType::alpha_t)
.def_readonly("beta_t", &ParameterType::beta_t)
.def_readonly("alpha_n", &ParameterType::alpha_n)
.def_readonly("beta_n", &ParameterType::beta_n)
.def_readonly("r", &ParameterType::r);

py::class_<SmoothContactPotential>(m, "SmoothPotential")
.def(
py::init<const ParameterType&>(),
R"ipc_Qu8mg5v7(
Construct a smooth barrier potential.

Parameters:
param: A set of parameters.
)ipc_Qu8mg5v7",
py::arg("param"))
.def(
"__call__",
py::overload_cast<
const SmoothCollisions&, const CollisionMesh&,
Eigen::ConstRef<Eigen::MatrixXd>>(
&ipc::SmoothContactPotential::operator(), py::const_),
R"ipc_Qu8mg5v7(
Compute the barrier potential for a set of collisions.

Parameters:
collisions: The set of collisions.
mesh: The collision mesh.
vertices: Vertices of the collision mesh.

Returns:
The sum of all barrier potentials (not scaled by the barrier stiffness).
)ipc_Qu8mg5v7",
py::arg("collisions"), py::arg("mesh"), py::arg("vertices"))
.def(
"gradient",
py::overload_cast<
const SmoothCollisions&, const CollisionMesh&,
Eigen::ConstRef<Eigen::MatrixXd>>(
&ipc::SmoothContactPotential::gradient, py::const_),
R"ipc_Qu8mg5v7(
Compute the gradient of the barrier potential.

Parameters:
collisions: The set of collisions.
mesh: The collision mesh.
vertices: Vertices of the collision mesh.

Returns:
The gradient of all barrier potentials (not scaled by the barrier stiffness). This will have a size of |vertices|.
)ipc_Qu8mg5v7",
py::arg("collisions"), py::arg("mesh"), py::arg("vertices"))
.def(
"hessian",
py::overload_cast<
const SmoothCollisions&, const CollisionMesh&,
Eigen::ConstRef<Eigen::MatrixXd>, const PSDProjectionMethod>(
&ipc::SmoothContactPotential::hessian, py::const_),
R"ipc_Qu8mg5v7(
Compute the hessian of the barrier potential.

Parameters:
collisions: The set of collisions.
mesh: The collision mesh.
vertices: Vertices of the collision mesh.
project_hessian_to_psd: Make sure the hessian is positive semi-definite.

Returns:
The hessian of all barrier potentials (not scaled by the barrier stiffness). This will have a size of |vertices|x|vertices|.
)ipc_Qu8mg5v7",
py::arg("collisions"), py::arg("mesh"), py::arg("vertices"),
py::arg("project_hessian_to_psd") = PSDProjectionMethod::NONE)
.def(
"__call__",
py::overload_cast<
const SmoothCollision&, Eigen::ConstRef<Eigen::VectorXd>>(
&ipc::SmoothContactPotential::operator(), py::const_),
R"ipc_Qu8mg5v7(
Compute the potential for a single collision.

Parameters:
collision: The collision.
x: The collision stencil's degrees of freedom.

Returns:
The potential.
)ipc_Qu8mg5v7",
py::arg("collision"), py::arg("x"))
.def(
"gradient",
py::overload_cast<
const SmoothCollision&, Eigen::ConstRef<Eigen::VectorXd>>(
&SmoothContactPotential::gradient, py::const_),
R"ipc_Qu8mg5v7(
Compute the gradient of the potential for a single collision.

Parameters:
collision: The collision.
x: The collision stencil's degrees of freedom.

Returns:
The gradient of the potential.
)ipc_Qu8mg5v7",
py::arg("collision"), py::arg("x"))
.def(
"hessian",
py::overload_cast<
const SmoothCollision&, Eigen::ConstRef<Eigen::VectorXd>,
const PSDProjectionMethod>(
&SmoothContactPotential::hessian, py::const_),
R"ipc_Qu8mg5v7(
Compute the hessian of the potential for a single collision.

Parameters:
collision: The collision.
x: The collision stencil's degrees of freedom.

Returns:
The hessian of the potential.
)ipc_Qu8mg5v7",
py::arg("collision"), py::arg("x"),
py::arg("project_hessian_to_psd") = PSDProjectionMethod::NONE);
}
1 change: 1 addition & 0 deletions python/src/potentials/bindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <pybind11/pybind11.h>

void define_barrier_potential(py::module_& m);
void define_smooth_potential(py::module_& m);
void define_friction_potential(py::module_& m);
void define_normal_adhesion_potential(py::module_& m);
void define_normal_potential(py::module_& m);
Expand Down
3 changes: 2 additions & 1 deletion src/ipc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ add_subdirectory(friction)
add_subdirectory(implicits)
add_subdirectory(potentials)
add_subdirectory(tangent)
add_subdirectory(utils)
add_subdirectory(utils)
add_subdirectory(smooth_contact)
Loading
Loading