Skip to content

Commit 66792ae

Browse files
committed
Include review comment + fix algorithm from a Gauss-seidel to a real JAcobi
1 parent 625f215 commit 66792ae

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/ImprovedJacobiConstraintSolver.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace sofa::component::constraint::lagrangian::solver
3232

3333
void ImprovedJacobiConstraintSolver::doSolve( SReal timeout)
3434
{
35-
SCOPED_TIMER_VARNAME(gaussSeidelTimer, "ConstraintsGaussSeidel");
35+
SCOPED_TIMER_VARNAME(gaussSeidelTimer, "ImprovedJacobiConstraintSolver");
3636

3737

3838
const int dimension = current_cp->getDimension();
@@ -119,6 +119,14 @@ void ImprovedJacobiConstraintSolver::doSolve( SReal timeout)
119119
}
120120
correctedD[l] = rho * d[l] ;
121121
}
122+
j += nb;
123+
}
124+
125+
for(int j=0; j<dimension; ) // increment of j realized at the end of the loop
126+
{
127+
// 1. nbLines provide the dimension of the constraint
128+
const unsigned int nb = current_cp->constraintsResolutions[j]->getNbLines();
129+
122130
current_cp->constraintsResolutions[j]->resolution(j,w,correctedD.data(), force, dfree);
123131
for(unsigned l=j; l<j+nb; ++l )
124132
{
@@ -127,7 +135,7 @@ void ImprovedJacobiConstraintSolver::doSolve( SReal timeout)
127135
lastF[l] = force[l];
128136
}
129137

130-
double cstError = 0.0;
138+
SReal cstError = 0.0;
131139
for(unsigned l=j; l<j+nb; ++l )
132140
{
133141
for(unsigned k=0; k<dimension; ++k)
@@ -166,7 +174,7 @@ void ImprovedJacobiConstraintSolver::doSolve( SReal timeout)
166174

167175
void registerImprovedJacobiConstraintSolver(sofa::core::ObjectFactory* factory)
168176
{
169-
factory->registerObjects(core::ObjectRegistrationData("A Constraint Solver using the Linear Complementarity Problem formulation to solve Constraint based components using a Projected Gauss-Seidel iterative method")
177+
factory->registerObjects(core::ObjectRegistrationData("A Constraint Solver using the Linear Complementarity Problem formulation to solve Constraint based components using a Projected Jacobi iterative method")
170178
.add< ImprovedJacobiConstraintSolver >());
171179
}
172180

0 commit comments

Comments
 (0)