[RodStraightSection] Fix rest shape double-offset for non-first sections#224
Conversation
…ons (sofa-framework#223) x_used is the global curvilinear abscissa; adding x_start again placed the rest node at 2*x_start + local_offset instead of x_used. For wires with two or more RodStraightSections this produced enormous elastic restoring forces at every timestep, causing simulation explosion. Fix: use x_used directly, consistent with RodSpireSection and RodMeshSection.
|
Hi @lkarstensen |
| void RodStraightSection<DataTypes>::getRestTransformOnX(Transform& global_H_local, const Real x_used, const Real x_start) | ||
| { | ||
| global_H_local.set(type::Vec3(x_start + x_used, 0.0, 0.0), Quat()); | ||
| global_H_local.set(type::Vec3(x_used, 0.0, 0.0), Quat()); |
There was a problem hiding this comment.
| global_H_local.set(type::Vec3(x_used, 0.0, 0.0), Quat()); | |
| global_H_local.set(type::Vec3(x_used - x_start, 0.0, 0.0), Quat()); |
Thank you for your contribution, indeed there is an error here the x_start should not be added to the x_used which is already the global curvilinear abscissa. However for me the correct fix is to deduce the x_start as the sections are used in reverse order.
If your tool is composed of 2 straightSection:
section 1: length 400
section 2: length 200
when tool will goes out the method will be called on the section 2 with the values:
x_used -> equal to full length -> 600,
x_start = 400 (length of section 1), therefor the transform will be computed at relative value of 600 - 400 = 200 the last position of this section
Summary
Fixes #223.
RodStraightSection::getRestTransformOnXcomputed the rest position asx_start + x_used, butx_usedis already the global curvilinear abscissa. This placed rest-shape nodes at2 * x_start + local_offsetinstead ofx_usedfor any section that is not the first in thewireMaterialslist.Example (stiff section 420 mm + flex section 30 mm):
The ~420 mm offset between rest shape and mechanical DOFs caused
AdaptiveBeamForceFieldAndMassto generate huge elastic restoring forces every timestep, leading to simulation explosion on any disturbance (e.g. vessel-wall contact).Fix
This matches the pattern already used correctly by
RodSpireSectionandRodMeshSection. Zero effect on single-section wires (x_start = 0).