MismatchingDomainErrors can occur when using R spaces with Submesh. Peculiarly, this only started happening once I began using the div operator in my forms. See MFE below. If you comment out the line involving div, the error no longer occurs.
from firedrake import *
# Create the unlabelled mesh
mesh = UnitSquareMesh(4, 4)
x_sc, y_sc = SpatialCoordinate(mesh)
# Create the left-half submesh and measures
DG0 = FunctionSpace(mesh, "DG", 0)
tag_L = Function(DG0).interpolate(conditional(lt(x_sc, 0.5), 1, 0))
label_L = 1
mesh = RelabeledMesh(mesh, [tag_L], [label_L])
mesh_L = Submesh(mesh, 2, label_L)
dx_M = Measure("dx", domain=mesh)
dx_L = Measure("dx", domain=mesh_L, intersect_measures=[dx(domain=mesh)])
# Function spaces
CG_L = FunctionSpace(mesh_L, "CG", 1)
BDM = FunctionSpace(mesh, "BDM", 1)
R = FunctionSpace(mesh, "R", 0)
S = CG_L * BDM * R
# Variational problem
sln = Function(S)
u, tau, l = split(sln)
v, sigma, r = TestFunctions(S)
res = u * v * dx_L \
+ dot(tau, sigma) * dx_M \
+ l * r * dx_M \
+ div(tau) * div(sigma) * dx_M # To make the error go away, comment out this line,
# OR, get rid of the CG space,
# OR, get rid of the R space.
u, tau, l = sln.subfunctions
u.interpolate(1) # Make the residual nonzero so it does a solve
# Below solve fails
NonlinearVariationalSolver(NonlinearVariationalProblem(res, sln)).solve()
Traceback (most recent call last):
File "petsc4py/PETSc/libpetsc4py.pyx", line 1541, in petsc4py.PETSc.PCSetUp_Python
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/preconditioners/base.py", line 214, in setUp
super().setUp(pc)
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/preconditioners/base.py", line 54, in setUp
self.initialize(pc)
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/preconditioners/assembled.py", line 54, in initialize
self.P = form_assembler.allocate()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/assemble.py", line 1382, in allocate
self._make_maps_and_regions())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/assemble.py", line 1415, in _make_maps_and_regions
elif any(local_kernel.indices == (None, None) for assembler in self._all_assemblers for local_kernel, _ in assembler.local_kernels):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/assemble.py", line 1415, in <genexpr>
elif any(local_kernel.indices == (None, None) for assembler in self._all_assemblers for local_kernel, _ in assembler.local_kernels):
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/functools.py", line 995, in __get__
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/assemble.py", line 1110, in local_kernels
kernels = tsfc_interface.compile_form(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "petsc4py/PETSc/Log.pyx", line 250, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 251, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 250, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 251, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/pyop2/caching.py", line 583, in wrapper
value = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "petsc4py/PETSc/Log.pyx", line 250, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 251, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/pyop2/caching.py", line 583, in wrapper
value = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "petsc4py/PETSc/Log.pyx", line 250, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 251, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/tsfc_interface.py", line 251, in compile_form
tsfc_kernel = TSFCKernel(
^^^^^^^^^^^
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/tsfc_interface.py", line 111, in __init__
tree = tsfc_compile_form(form, prefix=name, parameters=parameters,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "petsc4py/PETSc/Log.pyx", line 250, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 251, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/pyop2/caching.py", line 583, in wrapper
value = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "petsc4py/PETSc/Log.pyx", line 250, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 251, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/pyop2/caching.py", line 583, in wrapper
value = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/tsfc/driver.py", line 96, in compile_form
validate_domains(form_data.preprocessed_form)
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/tsfc/driver.py", line 202, in validate_domains
raise MismatchingDomainError("Argument or Coefficient domain not found in integral. "
tsfc.exceptions.MismatchingDomainError: Argument or Coefficient domain not found in integral. Possibly, the form contains coefficients on different meshes and requires measure intersection, for example: Measure("dx", argument_mesh, intersect_measures=[Measure("dx", coefficient_mesh)]).
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/baierreinio/Downloads/test.py", line 43, in <module>
NonlinearVariationalSolver(NonlinearVariationalProblem(res, sln)).solve()
File "petsc4py/PETSc/Log.pyx", line 250, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 251, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/adjoint_utils/variational_solver.py", line 108, in wrapper
out = solve(self, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/scratch/baierreinio/firedrake_dev_aaron_submesh/firedrake/firedrake/variational_solver.py", line 398, in solve
self.snes.solve(None, work)
File "petsc4py/PETSc/SNES.pyx", line 1740, in petsc4py.PETSc.SNES.solve
petsc4py.PETSc.Error: error code 101
[0] SNESSolve() at /scratch/baierreinio/firedrake_dev_aaron_submesh/petsc/src/snes/interface/snes.c:4875
[0] SNESSolve_NEWTONLS() at /scratch/baierreinio/firedrake_dev_aaron_submesh/petsc/src/snes/impls/ls/ls.c:220
[0] KSPSolve() at /scratch/baierreinio/firedrake_dev_aaron_submesh/petsc/src/ksp/ksp/interface/itfunc.c:1092
[0] KSPSolve_Private() at /scratch/baierreinio/firedrake_dev_aaron_submesh/petsc/src/ksp/ksp/interface/itfunc.c:840
[0] KSPSetUpOnBlocks() at /scratch/baierreinio/firedrake_dev_aaron_submesh/petsc/src/ksp/ksp/interface/itfunc.c:219
[0] PCSetUpOnBlocks() at /scratch/baierreinio/firedrake_dev_aaron_submesh/petsc/src/ksp/pc/interface/precon.c:1154
[0] PCSetUpOnBlocks_FieldSplit_Schur() at /scratch/baierreinio/firedrake_dev_aaron_submesh/petsc/src/ksp/pc/impls/fieldsplit/fieldsplit.c:1115
[0] KSPSetUp() at /scratch/baierreinio/firedrake_dev_aaron_submesh/petsc/src/ksp/ksp/interface/itfunc.c:428
[0] PCSetUp() at /scratch/baierreinio/firedrake_dev_aaron_submesh/petsc/src/ksp/pc/interface/precon.c:1117
MismatchingDomainErrors can occur when using R spaces with Submesh. Peculiarly, this only started happening once I began using the
divoperator in my forms. See MFE below. If you comment out the line involvingdiv, the error no longer occurs.This fails with the message: