| 1 |
--- a/python/test/unit/nls/test_PETScSNES_solver.py |
| 2 |
+++ b/python/test/unit/nls/test_PETScSNES_solver.py |
| 3 |
@@ -268,5 +268,12 @@ |
| 4 |
@skip_if_not_PETSc |
| 5 |
def test_snes_set_from_options(): |
| 6 |
solver = PETScSNESSolver() |
| 7 |
+ # The default constructor of PETScSNESSolver initializes an empty jacobian matrix, as well as its preconditioner |
| 8 |
+ # (when running in serial). Instead, PETSc >= 3.19 requires them to be non empty upon setting from options. |
| 9 |
+ # We thus fetch them and set a mock size. Note that this will not be a problem in practice for users because |
| 10 |
+ # PETScSNESSolver::init does allocate the matrix before setting from options. |
| 11 |
+ (A, J, _) = solver.snes().getJacobian() |
| 12 |
+ A.setSizes(1, 1) |
| 13 |
+ J.setSizes(1, 1) |
| 14 |
PETScOptions.set("snes_atol", 1e-12) |
| 15 |
solver.set_from_options() |