Hi everyone!
I adapted the Poisson equation with pure Neumann BCs example from legacy fenics to fenicsx (https://fenicsproject.org/olddocs/dolfin/latest/python/demos/neumann-poisson/demo_neumann-poisson.py.html)
The code is quite short:
from mpi4py import MPI
from dolfinx import mesh, fem, io
import ufl
#Create mesh
domain = mesh.create_unit_square(MPI.COMM_WORLD, 10, 10, mesh.CellType.triangle)
#Create function space with Lagrange multiplier
P1 = ufl.FiniteElement("Lagrange",domain.ufl_cell(),1)
R0 = ufl.FiniteElement("Real",domain.ufl_cell(),0)
V = ufl.MixedElement([P1,R0])
ME = fem.FunctionSpace(domain,V)
#Define Equation. Boundary condition is captured within weak form
v,d = ufl.TestFunctions(ME)
u,c = ufl.TrialFunctions(ME)
x = ufl.SpatialCoordinate(domain)
f = 10 * ufl.exp(-((x[0] - 0.5)**2 + (x[1] - 0.5)**2) / 0.02)
g = -ufl.sin(5 * x[0])
a = ufl.inner(ufl.grad(u), ufl.grad(v)) * ufl.dx + ufl.inner(c,v)*ufl.dx + ufl.inner(u,d)*ufl.dx
L = ufl.inner(f, v) * ufl.dx + ufl.inner(g, v) * ufl.ds
#Solve with direct solver
problem = fem.petsc.LinearProblem(a, L, petsc_options={"ksp_type": "preonly",
"pc_type": "lu"
})
uh = problem.solve()
#Output to xdmf
xdmf = io.XDMFFile(domain.comm,"poisson5.xdmf","w")
#Output mesh
xdmf.write_mesh(domain)
#Output solution
u_,c_ = uh.split()
xdmf.write_function(u_)
xdmf.write_function(c_)
When I run it, I get the following error which isnt very helpful
munmap_chunk(): invalid pointer
Aborted (core dumped)
Ive tried sequentially commenting out bits of the code and it seems to be failing at the solve step which possibly indicates something is breaking at the solution level. I previously got the error message " PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range", but have not been able to reproduce that error message. I also reinstalled fenicsx (0.6.0 from conda) to no avail, though the installation works for other demos / codes.
Would be grateful for any advice on this topic! Thanks