-
Notifications
You must be signed in to change notification settings - Fork 489
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
Matrix-free solution using PetscNonlinearSolver #1681
Comments
Yes. If you need the matrix for preconditioning, you need to assemble it. You can setup petsc to compute jacobian-vector products on the fly using finite differences and coloring, but this option is not available in combination with mfem right now. |
Many thanks for your quick reply ! Thanks |
I think snes_mf will use JFNK and it will not use GetGradient() as preconditioner. So for simple problems which has weak nonlinearity, it may be enough. I believe in example 10, the case of rc_ex10p_mf should demonstrate that. In general, you need to provide the preconditioner for JFNK through GetGradient(). You can start with providing a simple approximation to the Jacobian matrix through GetGradient(), like a block diagonal matrix that only keeps the diagonal small matrices. The case of rc_ex10p_mf demonstrates how to use it. Yes, snes_fd can be very slow. The normal way to get it working is through snes_fd_color. But it looks like this option is not available in mfem yet. |
You get the matrix-vector-product of the Jacobian with This works out of the box with MFEM by just setting the option on the command line (e.g. ex10). The gradient that is implemented only uses (if desired) the assembled gradient for the PC. |
The limiting factor in MFEM is that we don't provide a DM object for PETSc from which coloring of matrix could be determined. |
Thanks for the comments. thanks |
We can't answer the the question without knowing the details of the equations you are solving. In coupled equations it might be OK to just provide diagonal blocks for the approximation, although it might not be enough in strongly nonlinear cases. |
@brightzhang91 If you use @jandrej Regarding the coloring: well, the interface from MFEM to PETSc is completely algebraic and specifying mesh information is somewhat out-of-synch with the MFEM approach, since |
This issue has not been active for more than two weeks, so I will close it now. Feel free to reopen if you still have questions. |
Hi :)
I'm building a new NonlinearFormintegrator for nonlinear material modeling. Due to the difficulty in producing the analytical Jacobian, I want to try the PetscNonlinearSolver to perform the matrix-free solution. I had a look at the petsc/ex10p, which can be activated to be matrix-free with -snes_mf or -snes_mf_operator. However, ex10p already has the analytical Jacobian built in the AssembleElementGrad().
By using the matrix-free method, do I still need to explicitly build the GetGradient() of the operator ? How should I construct the AssembleElementGrad() of the new NonlinearFormintegrator, as I try to use the matrix-free Newton-Krylov to avoid deriving the analytical Jacobian ?
Thanks !
Bright
The text was updated successfully, but these errors were encountered: