-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SofaBaseLinearSolver] FIX breaking condition in CG at first step regarding threshold #556
Conversation
If threshold is met at first step with den=0, break but info msg about the status of the linear system. If threshold is met at first with den!=0, then continue one more iteration and warning about threshold value too large.
[ci-build][with-scene-tests] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me. Basically, apart from issuing a warning, the code should not explicitly handle the case when the residual is below a threshold already in the first iteration, since numerically, it's a correct behavior even if it yields an unwanted result (e.g., an object is not moving despite applied forces). CG is an iterative solver and anyone using it should be well aware of its parameters and their impact on the simulation.
[ci-build][with-scene-tests] |
Your remarks are taken into account @IPeterlik :) |
endcond = "threshold"; | ||
if( verbose ) | ||
{ | ||
sout<<"CGLinearSolver, den = "<<den<<", smallDenominatorThreshold = "<<f_smallDenominatorThreshold.getValue()<<sendl; | ||
msg_info() << "CGLinearSolver, den = " << den <<", smallDenominatorThreshold = " << f_smallDenominatorThreshold.getValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for CGLinearSolver...msg_info add the prefix.
sout<<"den = "<<den<<", alpha = "<<alpha<<sendl; | ||
sout<<"x : "<<x<<sendl; | ||
sout<<"r : "<<r<<sendl; | ||
msg_info() << "den = " << den << ", alpha = " << alpha; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No needs for three messages...one is better (and more efficient)
@@ -63,6 +63,29 @@ CGLinearSolver<TMatrix,TVector>::CGLinearSolver() | |||
f_smallDenominatorThreshold.setRequired(true); | |||
} | |||
|
|||
template<class TMatrix, class TVector> | |||
void CGLinearSolver<TMatrix,TVector>::init() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For usability reason I would recommand to have something like
if(f_verbose.getValue()){
f_printLog.setValue(true);
}
@@ -109,7 +132,7 @@ void CGLinearSolver<TMatrix,TVector>::solve(Matrix& M, Vector& x, Vector& b) | |||
double rho, rho_1=0, alpha, beta; | |||
|
|||
|
|||
msg_info_when(verbose) <<" CGLinearSolver, b = "<< b ; | |||
msg_info_when(verbose) << " CGLinearSolver, b = " << b ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No needs for the 'CGLinearSolver' prefix
Now it is fast merge :) |
is this fine now ? |
For me, when the CI will re-vive and says ok it may go. |
[ci-build] |
[ci-build][with-scene-tests] |
oh dear lord this PR looks fine ! |
[ci-build][with-scene-tests] |
Agreed, let's merge! |
sorry again for the inconvenience of this sexy # in my PR branch name.. |
Fix bug introduced in #521
If threshold is met at first step with den=0, break but info msg
about the status of the linear system.
If threshold is met at first with den!=0, then continue one more iteration
and warning about threshold value too large.
This PR:
Reviewers will merge only if all these checks are true.