Skip to content

[IntegrationScheme] Fix propagation of unknown state - #6346

Merged
hugtalbot merged 3 commits into
sofa-framework:masterfrom
bakpaul:26_09_fix_behavior_of_lagrangian_based_scenes_with_mappings
Oct 28, 2026
Merged

hugtalbot merged 3 commits into
sofa-framework:masterfrom
bakpaul:26_09_fix_behavior_of_lagrangian_based_scenes_with_mappings

Conversation

@bakpaul

@bakpaul bakpaul commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

The philosophy of these new class where to use the same VecID as the current state throughout the integration to prepare the work for the Newton. This mean that the current state (position and velocity) is copied into the working state.

The issue is that after this copy, no propagation was performed. Meaning that for lagrangian-based simulation, the free states where updated with the current state but the mapped states kept the old free state. Leading to the forcefield under those mapping computing the forces values at the freestate of the previous timestep.

This PR fixes this behavior.

Some regression might fail as they might have been wrongly interpreted as non-converged CG because of very little behavior differences.

EDIT:
I have pushed another solution that behave more like the old implementation. This for me is broken mechanically speaking, but first let's bring back the old behavior with stable scenes, then we can rediscuss the ways.

[with-all-tests]


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@bakpaul bakpaul added pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request labels Oct 2, 2026
@fredroy

fredroy commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@bakpaul

bakpaul commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Yes it was a quick fix so Eulalie could try it, I'll do it properly. Thx

@bakpaul bakpaul added pr: status wip Development in the pull-request is still in progress and removed pr: status to review To notify reviewers to review this pull-request labels Oct 6, 2026
@bakpaul
bakpaul force-pushed the 26_09_fix_behavior_of_lagrangian_based_scenes_with_mappings branch from a834bcb to 2836ed3 Compare October 6, 2026 09:45
@bakpaul bakpaul added pr: status to review To notify reviewers to review this pull-request and removed pr: status wip Development in the pull-request is still in progress labels Oct 6, 2026
@hugtalbot hugtalbot added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Oct 8, 2026
@fredroy
fredroy force-pushed the 26_09_fix_behavior_of_lagrangian_based_scenes_with_mappings branch from d93c272 to 5fe0263 Compare October 12, 2026 03:46

@fredroy fredroy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude detected some problems, one is especially concerning, as it was copying twice the velocity (copy-paste I suppose)
He (it?) also says that AccelerationBasedImplicitIntegrationScheme having the same problem.

simulation::mechanicalvisitor::MechanicalVOpVisitor copyVelInFreeVel(params, m_vResult, core::vec_id::write_access::velocity);
copyVelInFreeVel.setMapped(true);
copyPoseInFreePose.setMapped(true);
this->getContext()->executeVisitor(&copyPoseInFreePose);

@fredroy fredroy Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

m_vop->v_eq was filtering on the eventual tags apparently, with this->getContext()->executeVisitor the tag filtering is lost. But I dont know it we still really support the tagging system.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The tagging system might be important for some diffusion scenes. Tje v_eq was added by me in my IntegrationScheme PR so I didn't make the use of v_eq because of the tag filtering. In other words, if we don't see any changes in the tests, there is no willingness to keep filtering here.

@fredroy fredroy added pr: status to review To notify reviewers to review this pull-request and removed pr: status ready Approved a pull-request, ready to be squashed labels Oct 12, 2026
@bakpaul

bakpaul commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

That is only half true. I see the copy/paste error, my mistake sorry. Indeed the acceleration-based one suffer the same problem, but this is only an issue when used in a FreeMotionAnimationLoop which is never the case. I'll add it but it will be a bit useless in this case.

@fredroy
fredroy force-pushed the 26_09_fix_behavior_of_lagrangian_based_scenes_with_mappings branch from 25c9188 to 65911d2 Compare October 20, 2026 02:27
@hugtalbot hugtalbot added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Oct 28, 2026
@hugtalbot
hugtalbot merged commit 4e86ecf into sofa-framework:master Oct 28, 2026
12 of 14 checks passed
bakpaul added a commit to bakpaul/sofa that referenced this pull request Oct 29, 2026
…6346)

* Copy local state instead of going through the mappings

* Apply batched suggestions from code review

Co-authored-by: Frederick Roy <fredroy@users.noreply.github.com>

* Add state copy for AccelerationBased too

---------

Co-authored-by: Frederick Roy <fredroy@users.noreply.github.com>
@hugtalbot hugtalbot added this to the v26.12 milestone Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: fix Fix a bug pr: status ready Approved a pull-request, ready to be squashed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants