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