Please help to understand and resolve this error message:
RuntimeError: Cannot compute interior facet integral over interprocess facet. Please use ghost mode shared facet when creating the mesh
The error
- arises when running the code in parallel
- does not arise when running on one processor, including refinement, BUT compromises the solution - as can be seen on nicely tiled nonphysical contours drawn by matplotlib
- does not arise when commenting out the refinement (both serial and parallel runs)
I may be missing some communication on mesh after refining.
Please see the MWE:
(weak form reduced into very basic linear and nonphysical but working equation just to reproduce the error)
import numpy as np
from mpi4py import MPI
from petsc4py import PETSc
from ufl import TestFunction, TrialFunction, dx, ds, dS, inner, grad, jump, avg
import dolfinx
from dolfinx.fem import functionspace, Function
from dolfinx.fem.petsc import LinearProblem
from dolfinx.mesh import create_unit_square, refine, compute_incident_entities
comm = MPI.COMM_WORLD
################
### MESH
################
Nx, Ny = 12, 12 # Mesh size
mesh = create_unit_square(comm, Nx, Ny, ghost_mode = dolfinx.cpp.mesh.GhostMode.shared_facet)
################
### REFINE
################
mesh.topology.create_entities(1)
#mark cells
cells = np.arange(mesh.topology.index_map(mesh.topology.dim).size_local, dtype=np.int32) # all cells
edges = compute_incident_entities(mesh.topology, cells, 2, 1)
mesh, _, _ = refine(mesh, edges)
#mesh, _, _ = refine(mesh) # all cells as well
################
V = functionspace(mesh, ("Lagrange", 1))
#V = functionspace(mesh, ("DG", 1))
u = TrialFunction(V)
v = TestFunction(V)
################
### WEAK FORM
################
a = u*v*dx
L = avg(v)*dS
problem = LinearProblem(a, L)
uh = problem.solve()
##########
#u.x.scatter_forward()
#
## Add values from ghost regions and accumulate them on the owning process
#u.x.scatter_reverse(dolfinx.la.InsertMode.add)
and the actual error message:
mpirun -n 2 python MWE.py
File "/data/FEM/fenics/dolfinx_0.10.0/MPI/refine_dS/MWE.py", line 40, in <module>
problem = LinearProblem(a, L)
File "/home/jnk/.local/lib/python3.13/site-packages/dolfinx/fem/petsc.py", line 839, in __init__
self._L = _create_form(
~~~~~~~~~~~~^
L,
^^
...<2 lines>...
jit_options=jit_options,
^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/jnk/.local/lib/python3.13/site-packages/dolfinx/fem/forms.py", line 335, in form
return _create_form(form)
File "/home/jnk/.local/lib/python3.13/site-packages/dolfinx/fem/forms.py", line 329, in _create_form
return _form(form)
File "/home/jnk/.local/lib/python3.13/site-packages/dolfinx/fem/forms.py", line 304, in _form
f = ftype(
module.ffi.cast("uintptr_t", module.ffi.addressof(ufcx_form)),
...<5 lines>...
mesh,
)
RuntimeError: Cannot compute interior facet integral over interprocess facet. Please use ghost mode shared facet when creating the mesh
Exception ignored in: <function LinearProblem.__del__ at 0x74cbf5522d40>
Traceback (most recent call last):
File "/home/jnk/.local/lib/python3.13/site-packages/dolfinx/fem/petsc.py", line 881, in __del__
Exception ignored in: <function LinearProblem.__del__ at 0x7036448d6d40>
Traceback (most recent call last):
File "/home/jnk/.local/lib/python3.13/site-packages/dolfinx/fem/petsc.py", line 881, in __del__
self._solver.destroy()
AttributeError: 'LinearProblem' object has no attribute '_solver'
self._solver.destroy()
AttributeError: 'LinearProblem' object has no attribute '_solver'
--------------------------------------------------------------------------
prterun detected that one or more processes exited with non-zero status,
thus causing the job to be terminated. The first process to do so was:
Process name: [prterun-archlinux-595914@1,0]
Exit code: 1
--------------------------------------------------------------------------
Dolfinx version is 0.10.0
Thank you!