Home › Forum › SOFA › Using SOFA › [SOLVED] Preconditioner for an iterative solver
Tagged: 64_bits, cg, Linux_ubuntu, preconditioner, SOFA_2006, Solver
- This topic has 7 replies, 2 voices, and was last updated 4 years, 6 months ago by jjcasmar.
-
AuthorPosts
-
6 June 2020 at 01:49 #16569jjcasmarBlocked
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:38 #16595HugoKeymasterHi @jjcasmar
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.
Best
Hugo
11 June 2020 at 23:59 #16606jjcasmarBlockedSo 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::LinearSolver
and link it to the preconditioners property, right?15 June 2020 at 11:27 #16626HugoKeymasterHi @jjcasmar
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.Hugo
15 June 2020 at 12:49 #16633HugoKeymasterI just shortly added a page on the documentation. Do not hesitate to review it 😉
https://www.sofa-framework.org/community/doc/components/linearsolver/preconditioned-cg/
Hugo
15 June 2020 at 22:37 #16639jjcasmarBlockedThanks 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, etc
Is 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:47 #16647HugoKeymasterHi @jjcasmar
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.
Hugo
16 June 2020 at 12:57 #16649jjcasmarBlockedWell, 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.
Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.