[FEM.HyperElastic] Integration of hyperelasticity from Elasticity plugin to SOFA - #6206
Open
alxbilger wants to merge 8 commits into
Open
[FEM.HyperElastic] Integration of hyperelasticity from Elasticity plugin to SOFA#6206alxbilger wants to merge 8 commits into
alxbilger wants to merge 8 commits into
Conversation
th-skam
requested changes
Aug 10, 2026
th-skam
left a comment
Contributor
There was a problem hiding this comment.
Few comments and porting corrections from SOFA's Ogden.h here.
|
|
||
| find_package(Sofa.Config QUIET REQUIRED) | ||
| sofa_find_package(Sofa.Simulation.Core QUIET REQUIRED) | ||
| sofa_find_package(Sofa.Component.SolidMechanics.FEM.Elastic QUITE REQUIRED) |
Contributor
There was a problem hiding this comment.
Suggested change
| sofa_find_package(Sofa.Component.SolidMechanics.FEM.Elastic QUITE REQUIRED) | |
| sofa_find_package(Sofa.Component.SolidMechanics.FEM.Elastic QUIET REQUIRED) |
| * * | ||
| * Contact information: contact@sofa-framework.org * | ||
| ******************************************************************************/ | ||
| #define ELASTICITY_COMPONENT_PK2HYPERELASTIC_MATERIAL_CPP |
Contributor
There was a problem hiding this comment.
A last pass on the guards with ELASTICITY prefix.
Comment on lines
+135
to
+140
| if (l_material.empty()) | ||
| { | ||
| msg_info() << "Link to a valid material should be set to ensure right behavior. First " | ||
| "material found in current context will be used."; | ||
| l_material.set(this->getContext()->template get<HyperelasticMaterial<DataTypes>>()); | ||
| } |
Contributor
There was a problem hiding this comment.
It's not initialized somewhere so user cannot set it.
Comment on lines
+65
to
+68
| // The SelfAdjointEigenSolver is normally the suitable choice for symmetric matrices | ||
| // However, it has produced wrong results in some previous tests | ||
| // Disable temporarilly until fixed /*Eigen::SelfAdjointEigenSolver<EigenMatrix>*/ | ||
| Eigen::EigenSolver<EigenMatrix> EigenProblemSolver(CEigen, true); |
Contributor
There was a problem hiding this comment.
Suggested change
| // The SelfAdjointEigenSolver is normally the suitable choice for symmetric matrices | |
| // However, it has produced wrong results in some previous tests | |
| // Disable temporarilly until fixed /*Eigen::SelfAdjointEigenSolver<EigenMatrix>*/ | |
| Eigen::EigenSolver<EigenMatrix> EigenProblemSolver(CEigen, true); | |
| Eigen::SelfAdjointEigenSolver<EigenMatrix> EigenProblemSolver(CEigen, Eigen::ComputeEigenvectors); |
Have changed this in old Ogden.
Comment on lines
+134
to
+135
| // Disable temporarilly until fixed /*Eigen::SelfAdjointEigenSolver<EigenMatrix>*/ | ||
| Eigen::EigenSolver<EigenMatrix> EigenProblemSolver(CEigen, true); |
Contributor
There was a problem hiding this comment.
Suggested change
| // Disable temporarilly until fixed /*Eigen::SelfAdjointEigenSolver<EigenMatrix>*/ | |
| Eigen::EigenSolver<EigenMatrix> EigenProblemSolver(CEigen, true); | |
| Eigen::SelfAdjointEigenSolver<EigenMatrix> EigenProblemSolver(CEigen, Eigen::ComputeEigenvectors); |
Comment on lines
+138
to
+139
| const auto eigenvectors = EigenProblemSolver.eigenvectors().real().eval(); | ||
| const auto eigenvalues = EigenProblemSolver.eigenvalues().real().eval(); |
Contributor
There was a problem hiding this comment.
Suggested change
| const auto eigenvectors = EigenProblemSolver.eigenvectors().real().eval(); | |
| const auto eigenvalues = EigenProblemSolver.eigenvalues().real().eval(); | |
| const auto eigenvectors = EigenProblemSolver.eigenvectors(); | |
| const auto eigenvalues = EigenProblemSolver.eigenvalues(); |
These are not needed after the SelfAdjoint change.
Comment on lines
+72
to
+73
| const auto eigenvectors = EigenProblemSolver.eigenvectors().real().eval(); | ||
| const auto eigenvalues = EigenProblemSolver.eigenvalues().real().eval(); |
Contributor
There was a problem hiding this comment.
Suggested change
| const auto eigenvectors = EigenProblemSolver.eigenvectors().real().eval(); | |
| const auto eigenvalues = EigenProblemSolver.eigenvalues().real().eval(); | |
| const auto eigenvectors = EigenProblemSolver.eigenvectors(); | |
| const auto eigenvalues = EigenProblemSolver.eigenvalues(); |
Comment on lines
+187
to
+190
| const Real eigenvalueMultiplier = | ||
| std::fabs(eigenvalues[n] - eigenvalues[m]) < std::numeric_limits<Real>::epsilon() | ||
| ? aBy2Minus1 * eigenvaluePowers2(n) | ||
| : (eigenvaluePowers1(n) - eigenvaluePowers1(m)) / (eigenvalues(n) - eigenvalues(m)); |
Contributor
There was a problem hiding this comment.
Suggested change
| const Real eigenvalueMultiplier = | |
| std::fabs(eigenvalues[n] - eigenvalues[m]) < std::numeric_limits<Real>::epsilon() | |
| ? aBy2Minus1 * eigenvaluePowers2(n) | |
| : (eigenvaluePowers1(n) - eigenvaluePowers1(m)) / (eigenvalues(n) - eigenvalues(m)); | |
| constexpr Real tol = static_cast<Real>(1e-8); | |
| const Real maxEval = std::max(std::fabs(eigenvalues(n)), std::fabs(eigenvalues(m))); | |
| const bool isDegenerate = std::fabs(eigenvalues(n) - eigenvalues(m)) < maxEval * tol; | |
| const Real eigenvalueMultiplier = isDegenerate | |
| ? aBy2Minus1 * eigenvaluePowers2(n) | |
| : (eigenvaluePowers1(n) - eigenvaluePowers1(m)) / (eigenvalues(n) - eigenvalues(m)); |
This is ported from Ogden.h already in SOFA. The eigenvalue difference should be scaled by their magnitudes.
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.
Introduction of hyperelasticity with a few materials, and validation scenes
[with-all-tests]
Note that Ogen was added in alxbilger/Elasticity#6 by @th-skam
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