From 225c7cd368f0afbcb768be96b8dea7f68364b6fc Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Wed, 30 Apr 2025 07:45:51 +0900 Subject: [PATCH 1/2] fix of the btdlinear partial_solve crash with unbuilt/GenericConstraint (tentative...) --- .../src/sofa/component/linearsolver/direct/BTDLinearSolver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/BTDLinearSolver.h b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/BTDLinearSolver.h index 6c66bd9b86e..19734a7a1e7 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/BTDLinearSolver.h +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/BTDLinearSolver.h @@ -148,9 +148,9 @@ class BTDLinearSolver : public sofa::component::linearsolver::MatrixLinearSolver private: - Index _indMaxNonNullForce; // point with non null force which index is the greatest and for which globalAccumulate was not proceed + Index _indMaxNonNullForce{0}; // point with non null force which index is the greatest and for which globalAccumulate was not proceed - Index _indMaxFwdLHComputed; // indice of node from which bwdLH is accurate + Index _indMaxFwdLHComputed{0}; // indice of node from which bwdLH is accurate /// private functions for partial solve /// step1=> accumulate RH locally for the InBloc (only if a new force is detected on RH) From 9175e9cd2adcdf4940f70736bfe0c3a8307770cc Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Thu, 13 Aug 2026 10:13:12 +0900 Subject: [PATCH 2/2] reset _indMaxNonNullForce and _indMaxFwdLHComputed in init_partial_solve too --- .../sofa/component/linearsolver/direct/BTDLinearSolver.inl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/BTDLinearSolver.inl b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/BTDLinearSolver.inl index ee609309bcf..e0665c9cb60 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/BTDLinearSolver.inl +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/BTDLinearSolver.inl @@ -412,6 +412,11 @@ void BTDLinearSolver::init_partial_solve() // Block that is currently being proceed => start from the end (so that we use step2 bwdAccumulateLHGlobal and accumulate potential initial forces) current_bloc = nb-1; + // no force accumulated yet, and no LH computed during forward: + // both must be reset along with current_bloc, otherwise a value from the previous + // time step (or an out of range one if nb has decreased) is used in partial_solve + _indMaxNonNullForce = 0; + _indMaxFwdLHComputed = 0; // DF represents the variation of the right hand side of the equation (Force in mechanics) Vec_dRH.resize(nb);