Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
acf31ce
Introduce base integration schemes + acceleration based and velocity …
bakpaul Apr 29, 2026
4232dc8
Remove ODESolvers
bakpaul Apr 29, 2026
e812c6f
Fix last remnence of ODE + add BDF that doesn't work
bakpaul Apr 29, 2026
a15f5c3
Fix EulerImplicit + partially fix BDF, at least it matches Alex implem
bakpaul May 7, 2026
5e8fa65
Update BDFIntegrationScheme.cpp
bakpaul May 7, 2026
b7f6573
Added one more level of inheritance whith implicit/explicit integrati…
bakpaul May 12, 2026
396a7c4
Add Static solver
bakpaul May 12, 2026
61063f0
Add linear ùmultistep methods
bakpaul May 13, 2026
c628027
Bring back forward solvers
bakpaul May 13, 2026
eb17c0d
Add explicit solvers
bakpaul May 19, 2026
a44d9ab
Rename implicit solvers using IntegrationScheme
bakpaul May 20, 2026
d7f6465
Fix part of instability in freemotion + remove unnecessary clear
bakpaul May 22, 2026
d5a7200
Better usage of vop and mop
bakpaul May 26, 2026
6d3d136
Clean and add comments
bakpaul May 26, 2026
92b1e55
Fix instability by computing RHS before LHS
bakpaul May 27, 2026
5c00cb0
Add first order capability to velocity-based IS
bakpaul May 27, 2026
93f373e
changed iteration parameter into a bool instead of a number
bakpaul May 27, 2026
1ad5fcc
Fix condition for rayleigh damping in the RHS
bakpaul May 27, 2026
96a4805
Implement the trapezoid scheme
bakpaul May 27, 2026
5f90479
Refactor IS order getter to explicit the time characteristic
bakpaul May 27, 2026
c83d0ed
Use right mop and vop in static solver
bakpaul May 27, 2026
d85b59e
Rename residue estimation method
bakpaul May 28, 2026
5c21557
Fix compilation
bakpaul Jun 10, 2026
7c5b078
Add Newton solver to StaticEquilibriumIS
bakpaul Jun 10, 2026
834293e
fix typo in comment
bakpaul Jun 10, 2026
af86493
Fix scenes
bakpaul Jun 10, 2026
a239ece
Apply changes from #6087
bakpaul Jun 10, 2026
a34abb6
Fix compilation
bakpaul Jun 10, 2026
a2f5759
fix more scenes
bakpaul Jun 11, 2026
49e14bc
Fix compilation
bakpaul Jun 11, 2026
66e22f6
Fix requiredPlugins
bakpaul Jun 11, 2026
53c92f5
Change base class name according to review
bakpaul Jun 16, 2026
eca80c9
Add compat layer for both C++ and CMake
bakpaul Jun 17, 2026
eb0824f
Remove s from IntegrationSchemeS
bakpaul Jun 17, 2026
3bf43db
Sort compat file more properly
bakpaul Jun 17, 2026
b3433e2
Add new feature to alway move forward in newton + fir one unit test
bakpaul Jun 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SOFA_HEADER_DEPRECATED_NOT_REPLACED("v26.06", "v26.12")
#include <sofa/core/MultiVecId.h>
#include <sofa/core/VecId.h>
#include <sofa/core/behavior/BaseConstraintCorrection.h>
#include <sofa/core/behavior/OdeSolver.h>
#include <sofa/core/behavior/BaseIntegrationScheme.h>
#include <sofa/core/ConstraintParams.h>
#include <sofa/core/fwd.h>

Expand Down
2 changes: 1 addition & 1 deletion Sofa/Component/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ set(SOFACOMPONENT_SOURCE_DIR "src/sofa/component")

sofa_add_subdirectory_modules(SOFACOMPONENT_TARGETS
DIRECTORIES
ODESolver
IO
Playback
SceneUtility
Topology
Visual
LinearSystem
IntegrationScheme
LinearSolver
Mass
Diffusion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ set(SOURCE_FILES
sofa_find_package(Sofa.Simulation.Core REQUIRED)
sofa_find_package(Sofa.Component.Mass REQUIRED) # UncoupledCC needs UniformMass
sofa_find_package(Sofa.Component.LinearSolver.Iterative REQUIRED) # PrecomputedCC needs CGLinearSolver
sofa_find_package(Sofa.Component.ODESolver.Backward REQUIRED) # PrecomputedCC needs EulerSolver
sofa_find_package(Sofa.Component.IntegrationScheme.Backward REQUIRED) # PrecomputedCC needs EulerSolver

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Core)
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.Mass)
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.LinearSolver.Iterative)
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.ODESolver.Backward)
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.IntegrationScheme.Backward)

sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ find_package(Sofa.Config QUIET REQUIRED)
sofa_find_package(Sofa.Simulation.Core QUIET REQUIRED)
sofa_find_package(Sofa.Component.Mass QUIET REQUIRED)
sofa_find_package(Sofa.Component.LinearSolver.Iterative QUIET REQUIRED)
sofa_find_package(Sofa.Component.ODESolver.Backward QUIET REQUIRED)
sofa_find_package(Sofa.Component.IntegrationScheme.Backward QUIET REQUIRED)

if(NOT TARGET @PROJECT_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <sofa/component/constraint/lagrangian/correction/GenericConstraintCorrection.h>
#include <sofa/simulation/mechanicalvisitor/MechanicalIntegrateConstraintVisitor.h>
#include <sofa/core/behavior/OdeSolver.h>
#include <sofa/core/behavior/BaseIntegrationScheme.h>
#include <sofa/core/ObjectFactory.h>
#include <sofa/core/behavior/ConstraintSolver.h>
#include <sofa/core/behavior/LinearSolver.h>
Expand Down Expand Up @@ -94,10 +94,10 @@ void GenericConstraintCorrection::init()
{
msg_info() << "Link \"ODESolver\" to the desired ODE solver should be set to ensure right behavior." << msgendl
<< "First ODESolver found in current context will be used.";
l_ODESolver.set( context->get<sofa::core::behavior::OdeSolver>(BaseContext::Local) );
l_ODESolver.set( context->get< sofa::core::behavior::BaseIntegrationScheme>(BaseContext::Local) );
if (l_ODESolver.get() == nullptr)
{
l_ODESolver.set( context->get<sofa::core::behavior::OdeSolver>(BaseContext::SearchRoot) );
l_ODESolver.set( context->get< sofa::core::behavior::BaseIntegrationScheme>(BaseContext::SearchRoot) );
}
}

Expand Down Expand Up @@ -138,7 +138,7 @@ void GenericConstraintCorrection::addComplianceInConstraintSpace(const Constrain
if (!l_ODESolver.get()) return;
const SReal complianceFactor = d_complianceFactor.getValue();

// use the OdeSolver to get the integration factor
// use the IntegrationScheme to get the integration factor
SReal factor = BaseConstraintCorrection::correctionFactor(l_ODESolver.get(), cparams->constOrder());
factor *= complianceFactor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API GenericConstraintCorre
void resetContactForce() override;

SingleLink<GenericConstraintCorrection, sofa::core::behavior::LinearSolver, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_linearSolver; ///< Link towards the linear solver used to compute the compliance matrix, requiring the inverse of the linear system matrix
SingleLink<GenericConstraintCorrection, sofa::core::behavior::OdeSolver, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_ODESolver; ///< Link towards the ODE solver used to recover the integration factors
SingleLink<GenericConstraintCorrection, sofa::core::behavior::BaseIntegrationScheme, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_ODESolver; ///< Link towards the ODE solver used to recover the integration factors
Data< SReal > d_complianceFactor; ///< Factor applied to the position factor and velocity factor used to calculate compliance matrix
Data< SReal > d_regularizationTerm; ///< add regularizationTerm*Id to W when solving for constraints

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <sofa/core/behavior/ConstraintCorrection.h>

#include <sofa/core/behavior/OdeSolver.h>
#include <sofa/core/behavior/BaseIntegrationScheme.h>
#include <sofa/core/behavior/LinearSolver.h>

#include <sofa/type/Mat.h>
Expand Down Expand Up @@ -95,7 +95,7 @@ class LinearSolverConstraintCorrection : public sofa::core::behavior::Constraint
Data< bool > wire_optimization; ///< constraints are reordered along a wire-like topology (from tip to base)
Data< SReal > d_regularizationTerm; ///< add regularization*Id to W when solving for constraints
SingleLink<LinearSolverConstraintCorrection, sofa::core::behavior::LinearSolver, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_linearSolver; ///< Link towards the linear solver used to compute the compliance matrix, requiring the inverse of the linear system matrix
SingleLink<LinearSolverConstraintCorrection, sofa::core::behavior::OdeSolver, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_ODESolver; ///< Link towards the ODE solver used to recover the integration factors
SingleLink<LinearSolverConstraintCorrection, sofa::core::behavior::BaseIntegrationScheme, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_ODESolver; ///< Link towards the ODE solver used to recover the integration factors

void verify_constraints();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ void LinearSolverConstraintCorrection<DataTypes>::init()
{
msg_info() << "Link \"ODESolver\" to the desired ODE solver should be set to ensure right behavior." << msgendl
<< "First ODESolver found in current context will be used.";
l_ODESolver.set( context->get<sofa::core::behavior::OdeSolver>(sofa::core::objectmodel::BaseContext::Local) );
l_ODESolver.set( context->get< sofa::core::behavior::BaseIntegrationScheme>(sofa::core::objectmodel::BaseContext::Local) );
if (l_ODESolver.get() == nullptr)
{
l_ODESolver.set( context->get<sofa::core::behavior::OdeSolver>(sofa::core::objectmodel::BaseContext::SearchRoot) );
l_ODESolver.set( context->get< sofa::core::behavior::BaseIntegrationScheme>(sofa::core::objectmodel::BaseContext::SearchRoot) );
}
}

Expand Down Expand Up @@ -192,7 +192,7 @@ void LinearSolverConstraintCorrection<DataTypes>::addComplianceInConstraintSpace
if(d_componentState.getValue() != ComponentState::Valid)
return ;

// use the OdeSolver to get the position integration factor
// use the IntegrationScheme to get the position integration factor
const SReal factor = core::behavior::BaseConstraintCorrection::correctionFactor(l_ODESolver.get(), cparams->constOrder());

// J is read from the mechanical state and converted to m_constraintJacobian
Expand Down Expand Up @@ -373,10 +373,10 @@ void LinearSolverConstraintCorrection<DataTypes>::applyContactForce(const linear

//TODO: tell the solver not to recompute the matrix

// use the OdeSolver to get the position integration factor
// use the IntegrationScheme to get the position integration factor
const SReal positionFactor = l_ODESolver.get()->getPositionIntegrationFactor();

// use the OdeSolver to get the position integration factor
// use the IntegrationScheme to get the position integration factor
const SReal velocityFactor = l_ODESolver.get()->getVelocityIntegrationFactor();

Data<VecCoord>& xData = *mstate->write(core::vec_id::write_access::position);
Expand Down Expand Up @@ -689,7 +689,7 @@ void LinearSolverConstraintCorrection<DataTypes>::getBlockDiagonalCompliance(lin
if(d_componentState.getValue() != ComponentState::Valid)
return ;

// use the OdeSolver to get the position integration factor
// use the IntegrationScheme to get the position integration factor
const SReal factor = l_ODESolver.get()->getPositionIntegrationFactor(); //*m_ODESolver->getPositionIntegrationFactor(); // dt*dt

const unsigned int numDOFs = mstate->getSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <sofa/simulation/Node.h>
#include <sofa/simulation/MechanicalVisitor.h>

#include <sofa/component/odesolver/backward/EulerImplicitSolver.h>
#include <sofa/component/integrationscheme/backward/EulerImplicitIntegrationScheme.h>

#include <sofa/linearalgebra/SparseMatrix.h>
#include <sofa/component/linearsolver/iterative/CGLinearSolver.h>
Expand Down Expand Up @@ -287,7 +287,7 @@ void PrecomputedConstraintCorrection<DataTypes>::bwdInit()
static constexpr sofa::type::Vec3 gravity_zero(0_sreal, 0_sreal, 0_sreal);
this->getContext()->setGravity(gravity_zero);

sofa::component::odesolver::backward::EulerImplicitSolver* eulerSolver;
sofa::component::integrationscheme::backward::EulerImplicitIntegrationScheme* eulerSolver;
sofa::component::linearsolver::iterative::CGLinearSolver< sofa::component::linearsolver::GraphScatteredMatrix, sofa::component::linearsolver::GraphScatteredVector >* cgLinearSolver;
core::behavior::LinearSolver* linearSolver;

Expand All @@ -297,19 +297,19 @@ void PrecomputedConstraintCorrection<DataTypes>::bwdInit()

if (eulerSolver && cgLinearSolver)
{
msg_info() << "use EulerImplicitSolver & CGLinearSolver" ;
msg_info() << "use EulerImplicitIntegrationScheme & CGLinearSolver" ;
}
else if (eulerSolver && linearSolver)
{
msg_info() << "use EulerImplicitSolver & LinearSolver";
msg_info() << "use EulerImplicitIntegrationScheme & LinearSolver";
}
else if(eulerSolver)
{
msg_info() << "use EulerImplicitSolver";
msg_info() << "use EulerImplicitIntegrationScheme";
}
else
{
msg_error() << "PrecomputedContactCorrection must be associated with EulerImplicitSolver+LinearSolver for the precomputation\nNo Precomputation" ;
msg_error() << "PrecomputedContactCorrection must be associated with EulerImplicitIntegrationScheme+LinearSolver for the precomputation\nNo Precomputation" ;
return;
}

Expand Down Expand Up @@ -345,7 +345,7 @@ void PrecomputedConstraintCorrection<DataTypes>::bwdInit()
/// (avoid to have a line of 0 at the top of the matrix)
if (eulerSolver)
{
eulerSolver->solve(core::execparams::defaultInstance(), dt, core::vec_id::write_access::position, core::vec_id::write_access::velocity);
eulerSolver->integrate(core::execparams::defaultInstance(), dt, core::vec_id::write_access::position, core::vec_id::write_access::velocity);
}

Deriv unitary_force;
Expand Down Expand Up @@ -380,7 +380,7 @@ void PrecomputedConstraintCorrection<DataTypes>::bwdInit()
{
fact *= eulerSolver->getPositionIntegrationFactor(); // here, we compute a compliance

eulerSolver->solve(core::execparams::defaultInstance(), dt, core::vec_id::write_access::position, core::vec_id::write_access::velocity);
eulerSolver->integrate(core::execparams::defaultInstance(), dt, core::vec_id::write_access::position, core::vec_id::write_access::velocity);
}

for (unsigned int v = 0; v < nbNodes; v++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API void UncoupledConstraintCorr

double odeFactor = 1.0;

this->getContext()->get(m_pOdeSolver);
if (!m_pOdeSolver)
this->getContext()->get(m_pIntegrationScheme);
if (!m_pIntegrationScheme)
{
if (d_useOdeSolverIntegrationFactors.getValue() == true)
if (d_useIntegrationSchemeIntegrationFactors.getValue() == true)
{
msg_error() << "Can't find any odeSolver";
d_useOdeSolverIntegrationFactors.setValue(false);
d_useIntegrationSchemeIntegrationFactors.setValue(false);
}
d_useOdeSolverIntegrationFactors.setReadOnly(true);
d_useIntegrationSchemeIntegrationFactors.setReadOnly(true);
}
else
{
if( !d_useOdeSolverIntegrationFactors.getValue() )
if( !d_useIntegrationSchemeIntegrationFactors.getValue() )
{
const double dt = this->getContext()->getDt();
odeFactor = dt*dt; // W = h^2 * JMinvJt : only correct when solving in constraint equation in position. Must be deprecated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
#include <sofa/component/constraint/lagrangian/correction/config.h>

#include <sofa/core/behavior/ConstraintCorrection.h>
#include <sofa/core/behavior/OdeSolver.h>
#include <sofa/core/behavior/BaseIntegrationScheme.h>
#include <sofa/core/topology/TopologyData.h>
#include <sofa/core/objectmodel/lifecycle/RenamedData.h>

namespace sofa::component::constraint::lagrangian::correction
{
Expand Down Expand Up @@ -116,7 +117,8 @@ class UncoupledConstraintCorrection : public sofa::core::behavior::ConstraintCor
Data<bool> d_verbose; ///< Dump the constraint matrix at each iteration
Data< Real > d_correctionVelocityFactor; ///< Factor applied to the constraint forces when correcting the velocities
Data< Real > d_correctionPositionFactor; ///< Factor applied to the constraint forces when correcting the positions
Data < bool > d_useOdeSolverIntegrationFactors; ///< Use odeSolver integration factors instead of correctionVelocityFactor and correctionPositionFactor
Data < bool > d_useIntegrationSchemeIntegrationFactors; ///< Use odeSolver integration factors instead of correctionVelocityFactor and correctionPositionFactor
sofa::core::objectmodel::lifecycle::RenamedData<bool> d_useOdeSolverIntegrationFactors;

/// Link to be set to the topology container in the component graph.
SingleLink<UncoupledConstraintCorrection<DataTypes>, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology;
Expand All @@ -128,7 +130,7 @@ class UncoupledConstraintCorrection : public sofa::core::behavior::ConstraintCor

protected:

sofa::core::behavior::OdeSolver* m_pOdeSolver;
sofa::core::behavior::BaseIntegrationScheme* m_pIntegrationScheme;

/**
* @brief Compute dx correction from motion space force vector.
Expand Down
Loading
Loading