Skip to content

[FEATURE] Enhance SAP Coupler to support self collision between FEM objects #1375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 54 commits into
base: main
Choose a base branch
from

Conversation

Libero0809
Copy link
Contributor

@Libero0809 Libero0809 commented Jul 8, 2025

Description

  • Add self collision support in SAP Coupler
  • Performance optimization, kernel optimization and early exit when convergence met.
  • Code Refactor: Add classes for Contacts.
  • Exact Line search along with backtracking line search
  • BVH radix sort optimization
  • BUG FIX: PCG solver, typo

Related Issue

Motivation and Context

How Has This Been / Can This Be Tested?

Added a new test.

Screenshots (if appropriate):

test_self.1.mp4
test_self.mp4
test_dragon.mp4

Checklist:

  • I read the CONTRIBUTING document.
  • I followed the Submitting Code Changes section of CONTRIBUTING document.
  • I tagged the title correctly (including BUG FIX/FEATURE/MISC/BREAKING)
  • I updated the documentation accordingly or no change is needed.
  • I tested my changes and added instructions on how to test it for reviewers.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@ti.kernel
def detection(self, f: ti.i32):
fem_solver = self.fem_solver
pairs = ti.static(self.contact_pairs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does static does here? Why not just use self.contact_pairs directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a syntax sugar, make the code shorter

def detection(self, f: ti.i32):
fem_solver = self.fem_solver
pairs = ti.static(self.contact_pairs)
sap_info = ti.static(pairs.sap_info)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

@Libero0809
Copy link
Contributor Author

I have updated the code. Let me know if there's anything else need to be changed. @duburcqa

Libero0809 and others added 5 commits July 11, 2025 11:21
* Delay VTK import to mitigate import failure on Linux w/o X11.
* Fix 'delete_weld_constraint'.
* Fix 'test_convexify'.
* Disable broken 'test_query' unit test.
* Improve BVH query performance.
* Use 'ti.u1' for boolean flags.
* Fix dtype handling.
* Avoid 'numpy.flatten' for efficiency.
* Remove dead code 'RigidGeom.sdf_*' methods.
@Libero0809
Copy link
Contributor Author

I have pushed the lastest version @duburcqa

@duburcqa
Copy link
Collaborator

I will have a look tomorrow morning and merge this PR if all the comments have been addressed.

@Libero0809
Copy link
Contributor Author

Libero0809 commented Jul 11, 2025

Take your time. I think for changes like the self.fem_solver, we should have another PR to make these changes. I have other working branches forked from this one. After I make these changes to this branch, I need to merge this branch into my other working branches which would cause many conflicts. I kind of need to change these multiple times which is quite painful. I think these kind of changes should be done when all my relevant branches are merged then I can only do them in one time. Let me know what you think @duburcqa . For these kind of change, maybe you don't need to mark them and just leave a general note for how to improve them and we can work on that in another PR.

@duburcqa
Copy link
Collaborator

I need to merge this branch into my other working branches which would cause many conflicts. I kind of need to change these multiple times which is quite painful.

First, I think this kind of issues are caused by "weaknesses" in your workflow and the way your organise your branches and PRs. Ideally, your workflow should be more resilient to this kind of requests for changes, especially where it only affects fresh new code that you are pushing yourself. We would discuss this together in a video call if you are interested.

I think these kind of changes should be done when all my relevant branches are merged then I can only do them in one time.

It is a bad engineering practice to merge code that is not up-to-standard under the promise that it will be fixed later on. From my own experience, even without deceptive intend from contributors, such promises tend to never be fulfilled in practice, simply because other tasks come on the way so that addressing requests for changes of some already merged PR is no longer a priority. This practice is only recommended when a repository is in a broken state for some reason and a quick-and-dirty solution must be shipped as soon as possible before anything.

What being said, I'm ok to make a compromise for this time.

@Libero0809
Copy link
Contributor Author

I need to merge this branch into my other working branches which would cause many conflicts. I kind of need to change these multiple times which is quite painful.

First, I think this kind of issues are caused by "weaknesses" in your workflow and the way your organise your branches and PRs. Ideally, your workflow should be more resilient to this kind of requests for changes, especially where it only affects fresh new code that you are pushing yourself. We would discuss this together in a video call if you are interested.

I think these kind of changes should be done when all my relevant branches are merged then I can only do them in one time.

It is a bad engineering practice to merge code that is not up-to-standard under the promise that it will be fixed later on. From my own experience, even without deceptive intend from contributors, such promises tend to never be fulfilled in practice, simply because other tasks come on the way so that addressing requests for changes of some already merged PR is no longer a priority. This practice is only recommended when a repository is in a broken state for some reason and a quick-and-dirty solution must be shipped as soon as possible before anything.

What being said, I'm ok to make a compromise for this time.

I get your idea. I will update them in this PR. For issues like this, maybe only comment once and note that it occurs multiple times in the code instead of trying to exhaust them. As you can see the dialogues are already very lengthy and cumbersome to navigate through.

@Libero0809
Copy link
Contributor Author

Most comments are resolved except for syntax sugar and compute information kernels. Please see the above replies. @duburcqa

@duburcqa
Copy link
Collaborator

duburcqa commented Jul 16, 2025

@Libero0809 I will merge once the CI is passing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants