[Core] Fix projection direction in NewtonRaphsonCurve to improve robustness#13564
Merged
juancamarotti merged 6 commits intomasterfrom Jun 27, 2025
Merged
[Core] Fix projection direction in NewtonRaphsonCurve to improve robustness#13564juancamarotti merged 6 commits intomasterfrom
NewtonRaphsonCurve to improve robustness#13564juancamarotti merged 6 commits intomasterfrom
Conversation
Contributor
|
We need a test for this, especially a case when the existing implementation fails. |
…reme of the curve. This was failing before
Contributor
Author
Done @rickyaristio |
Contributor
Author
|
It's ready @rickyaristio, could you check it ? |
rickyaristio
previously approved these changes
Jun 26, 2025
Contributor
Author
|
@sunethwarna could you take a look at this PR? Thanks |
sunethwarna
previously approved these changes
Jun 27, 2025
Member
sunethwarna
left a comment
There was a problem hiding this comment.
Thanks @juancamarotti .... I checked the technical stuff, I'll leave the algorithmic and formulation stuff approval to @rickyaristio.
kratos/tests/cpp_tests/geometries/test_projection_nurbs_geometry.cpp
Outdated
Show resolved
Hide resolved
kratos/tests/cpp_tests/geometries/test_projection_nurbs_geometry.cpp
Outdated
Show resolved
Hide resolved
|
|
||
| KRATOS_EXPECT_NEAR(parameter_extreme[0], -1.0, TOLERANCE); | ||
|
|
||
| std::vector<double> projected_point_extreme1 = {-9.0, -2.0, 0.0}; |
Co-authored-by: Suneth Warnakulasuriya <7856520+sunethwarna@users.noreply.github.com>
472c521
Co-authored-by: Suneth Warnakulasuriya <7856520+sunethwarna@users.noreply.github.com>
rickyaristio
approved these changes
Jun 27, 2025
Contributor
no more comments from my side |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Fix: Improve Direction Handling in
NewtonRaphsonCurveProjection✨ What’s new
This PR enhances the robustness of the
NewtonRaphsonCurvefunction inProjectionNurbsGeometryUtilitiesby correcting the direction of the parametric update using geometric information.🧠 Why
When projecting points far from the curve or close to the curve extremes, the Newton-Raphson update can mistakenly move in the wrong direction along the curve due to poor alignment with the tangent. This may lead to:
Divergence or overshooting,
Fallback to endpoints,
Incorrect projections.
📐 How it works
We compute the global-space update vector:
update_vector = delta_t * tangent;Then compare it with the distance vector:
If
alignment > 0.0, we reversedelta_tto ensure the update moves toward the projection target.