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) 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);