BUG: MismatchingDomainErrors can occur when using R spaces with Submesh

Abierto
#5,212 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
42/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Tranquilo
Stack tecnológico
python

Línea de trabajo

Ejecuta el ejemplo mínimo del issue para reproducir el fallo. Empieza siguiendo firedrake/assemble.py a través de firedrake/tsfc_interface.py hasta tsfc/driver.py, especialmente validate_domains en el traceback. Se considera terminado cuando la R-space, Submesh y la forma div se ensamblan y resuelven sin MismatchingDomainError, con una prueba de regresión que cubra el ejemplo.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

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()

This fails with the message:


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
Lenguaje dominante
Python
Estrellas
684
Forks
204
Merge medio
4 d 14 h
PR fusionados (30 d)
46

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de firedrakeproject/firedrake

Todos los issues de firedrakeproject/firedrake

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.