File: snes_set_from_options_with_empty_matrix.patch

package info (click to toggle)
dolfin 2019.2.0~legacy20240219.1c52e83-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 31,968 kB
  • sloc: xml: 104,040; cpp: 102,227; python: 24,356; sh: 460; makefile: 330; javascript: 226
file content (15 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (2)
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()