Remove NewtonSolver from hyperelasticity demo#3929
Remove NewtonSolver from hyperelasticity demo#3929chrisrichardson wants to merge 10 commits intomainfrom
Conversation
|
On a related note, where are we with providing the things needed to interface with SNES from C++? |
| VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD); | ||
| VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD); | ||
| PetscReal residual = 0; | ||
| VecNorm(r, NORM_2, &residual); |
There was a problem hiding this comment.
Should we use NORM_INFINITY for residual norms instead (as a naive fix)? I always struggle that NORM_2 grows with numbers of elements so for a finer mesh you'll violate atol very soon.
Btw. are C++ demos run in CI? Could not find the job.
There was a problem hiding this comment.
Btw. are C++ demos run in CI? Could not find the job.
https://github.com/FEniCS/dolfinx/blob/main/.github/workflows/ccpp.yml#L230 - CI step has a confusing name.
|
Is the long term plan to remove the DOLFINx C++ Newton solver, in favor of another solver (like SNES)? If we plan to remove it, I think we need to give some deprecation notice to the C++ users + an alternative that is not copying solver logic across multiple user files. |
|
Yes, the plan is to remove NewtonSolver and provide some tooling/examples to help people interface SNES from C++. However, I've never done it myself, so I have no idea where to even begin. |
|
I think that the example here is sufficiently simple that reproducing the logic of NewtonSolver (and simplifying) is OK (only adds 70 lines of code). |
|
Could you add that deprecated message so we can get this merged for 0.10? |
| if (relative_residual < rtol or residual < atol) | ||
| return {residual, true}; | ||
| else | ||
| return {residual, false}; |
There was a problem hiding this comment.
| if (relative_residual < rtol or residual < atol) | |
| return {residual, true}; | |
| else | |
| return {residual, false}; | |
| bool converged = relative_residual < rtol or residual < atol; | |
| return {residual, converged}; |
| if (newton_converged) | ||
| { | ||
| spdlog::info("Newton solver finished in {} iterations and {} linear " | ||
| "solver iterations.", | ||
| iteration, krylov_iterations); | ||
| } | ||
| else | ||
| throw std::runtime_error("Newton solver did not converge."); |
There was a problem hiding this comment.
| if (newton_converged) | |
| { | |
| spdlog::info("Newton solver finished in {} iterations and {} linear " | |
| "solver iterations.", | |
| iteration, krylov_iterations); | |
| } | |
| else | |
| throw std::runtime_error("Newton solver did not converge."); | |
| if (not newton_converged) | |
| throw std::runtime_error("Newton solver did not converge."); | |
| spdlog::info("Newton solver finished in {} iterations and {} linear " | |
| "solver iterations.", | |
| iteration, krylov_iterations); |
No description provided.