6 June 2020 at 1 h 49 min #16569
I have been looking for preconditioners in SOFA but I havent been able to found any way to use them. Is there anyway to use a preconditioner or implement our own to use with the CG solver?11 June 2020 at 16 h 38 min #16595
Good question! You can see in the modules SofaPreconditioner (SOFA/modules/SofaPreconditioner) some precond are available. See especially the ShewchukPCGLinearSolver. It has to be used with a linear solver to compute this preconditioner with the CG.
Hugo11 June 2020 at 23 h 59 min #16606
So ShewchukPCGSolver is a preconditioned conjugate gradient implementation. Why is not the default CG implementation? Seems like it is a bit hidden…
If I understand correctly, I just need to provide an implementation of my preconditioner, deriving it from
sofa::core::behavior::LinearSolverand link it to the preconditioners property, right?15 June 2020 at 11 h 27 min #16626
For the inheritance, I cannot answer myself since I am not one of the author.
Regarding the fact that it is hidden, I guess it also comes from the fact that no online documentation is available on this component. With the ShewchukPCGSolver, you need to specify the data “preconditioners” with a path towards a (direct) linear solver indeed.
This preconditioner can be refreshed every update_step.
Or it can be computed only once if build_precond is false.
Hugo15 June 2020 at 12 h 49 min #16633
I just shortly added a page on the documentation. Do not hesitate to review it 😉
Hugo15 June 2020 at 22 h 37 min #16639
Thanks Hugo. I have read the document you proposed and I think that this:
The ShewchukPCGLinearSolver allows to choose the preconditioner of our choice based on an external direct linear solver: LULinearSolver, SparseLDLSolver, etcIs not exactly correct.
From reading the source code, I think any linear solver can be used, not only direct linear solver. This also includes user defined implementations.
Maybe at some point SOFA will be interested in deprecating CGLinearSolver in favour of Shewchuk?16 June 2020 at 12 h 47 min #16647
Yes the C++ code could have a pointer to any linear solver. But I think it makes more sense to use direct solvers since they really build the full A matrix. Iterative approaches in SOFA are unbuilt.
Before deprecating, we would need to compare both codes, namely to check whether both CG present similar performances (without precond). But it’s a good point.
Hugo16 June 2020 at 12 h 57 min #16649
Well, that depends on your preconditioner. For my particular use case, the preconditioned can be represented as a matrix, but its easier to represent it as some functions, kind of matrix-free preconditioner. I think saying that a its based on a external linear direct solver may arise to some misconceptions later. Better to just say that is has to be a linear solver, and maybe then cite a few and add “or any user implementation” or something like that.
Ill close the question and mark it as solved, as the original question is solved.
- You must be logged in to reply to this topic.