After a repeated evaluation of a problem PETSc.Options.setValue throws error
Traceback (most recent call last):
File "/root/shared/./test.py", line 45, in <module>
solution = dolfinx.fem.LinearProblem(a_p, L_p,
File "/usr/local/dolfinx-real/lib/python3.8/dist-packages/dolfinx/fem/problem
.py", line 83, in __init__
opts[k] = v
File "PETSc/Options.pyx", line 23, in petsc4py.PETSc.Options.__setitem__
File "PETSc/Options.pyx", line 91, in petsc4py.PETSc.Options.setValue
petsc4py.PETSc.Error: error code 55
In my case error shows after 475 iterations of this MWE (less for a more involved code):
import dolfinx
import dolfinx.io
from mpi4py import MPI
import ufl
from ufl import inner, grad, dx
import numpy as np
def set_bc(V):
u_bc = dolfinx.Function(V)
bc_facets = np.where(
np.array(dolfinx.cpp.mesh.compute_boundary_facets(mesh.topology)) == 1)[0]
bc_dofs = dolfinx.fem.locate_dofs_topological(V,
mesh.topology.dim-1,
bc_facets)
with u_bc.vector.localForm() as loc:
loc.setValues(bc_dofs, np.full(len(bc_dofs), 0))
return dolfinx.DirichletBC(u_bc, bc_dofs)
mesh = dolfinx.UnitSquareMesh(MPI.COMM_WORLD, 100, 100)
mesh.topology.create_connectivity(mesh.topology.dim-1,
mesh.topology.dim)
Hcurl = ufl.FiniteElement("Nedelec 1st kind H(curl)", mesh.ufl_cell(), 1)
H1 = ufl.FiniteElement("Lagrange", mesh.ufl_cell(), 1)
N = 1000
for i in range(N):
print(f"{i+1}/{N}")
V = dolfinx.FunctionSpace(mesh, H1)
u, v = ufl.TrialFunctions(V), ufl.TestFunctions(V)
f = dolfinx.Function(V)
f.interpolate(lambda x: (i+1) * x[0]**2 + 0*x[1])
f.x.scatter_forward()
V = dolfinx.FunctionSpace(mesh, Hcurl)
u, v = ufl.TrialFunction(V), ufl.TestFunction(V)
a_p = inner((i+1)*u, v) * dx
L_p = inner(v, grad(f)) * dx
solution = dolfinx.fem.LinearProblem(a_p, L_p,
petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
u = solution.solve()
Running using the command
docker run -ti -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd):/root/shared -w /root/shared --rm dolfinx/dolfinx python3 ./test.py