Hi everyone,
I am trying to solve the Poisson problem with pure Neumann boundary conditions in FEniCS 2019.1.
I looked at the example here:
My code is mostly copied from there, but I made a few changes:
from dolfin import *
# Create mesh
#mesh = UnitSquareMesh.create(64, 64, CellType.Type.quadrilateral)
mesh = UnitSquareMesh(64,64)
# Build function space with Lagrange multiplier
P1 = FiniteElement("Lagrange", mesh.ufl_cell(), 1)
R = FiniteElement("Real", mesh.ufl_cell(), 0)
W = FunctionSpace(mesh, P1 * R)
# Define variational problem
#s1 = Function(W)
#u, c = split(s1)
(u, c) = Function(W)
(v, d) = TestFunctions(W)
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)
u_mean = Constant(0.32)
a = (inner(grad(u), grad(v)) + c*v + u*d)*dx
L = f*v*dx + u_mean*d*dx
F = a - L
# Compute solution
w = Function(W)
solve(F == 0, w)#, solver_parameters={"newton_solver":{"relative_tolerance":1e-6}})
(u, c) = w.split()
# Save solution in VTK format
file = File("neumann_poisson_mod_NL.pvd")
u.rename("f","f")
file << u
Unfortunately the program fails during the first newton iteration with the following error:
Newton iteration 0: r (abs) = 3.212e-01 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
Traceback (most recent call last):
File "/home/pbi/CASES/tutorials/onlyNeumannMod_NL/onlyNeumannMod_NL.py", line 26, in <module>
solve(F == 0, w)#, solver_parameters={"newton_solver":{"relative_tolerance":1e-6}})
^^^^^^^^^^^^^^^^
File "/home/pbi/miniconda3/envs/t02/lib/python3.11/site-packages/dolfin/fem/solving.py", line 220, in solve
_solve_varproblem(*args, **kwargs)
File "/home/pbi/miniconda3/envs/t02/lib/python3.11/site-packages/dolfin/fem/solving.py", line 266, in _solve_varproblem
solver.solve()
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to successfully call PETSc function 'MatSetValuesLocal'.
*** Reason: PETSc error code is: 63 (Argument out of range).
*** Where: This error was encountered inside /home/conda/feedstock_root/build_artifacts/fenics-pkgs_1668433332839/work/dolfin/dolfin/la/PETScMatrix.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 3ea2183fbfe7277de9f16cbe1a9ffaab133ba1fa
*** -------------------------------------------------------------------------
I also looked this “PETSc error code is: 63 (Argument out of range).” up in this forum and tried a few solutions (like using the split(…) function), but nothing helped so far. Does someone know a solution to this problem?