BUG: Parallel assembly of expressions involving SpatialCoordinates, on submeshes, can give the wrong answer

Abierto
#5,207 1 comentario 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
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
python

Línea de trabajo

Comienza con el MFE de Python inline del issue y ejecútalo en serie y con 8 núcleos para reproducir los distintos valores de qty_1 y qty_2. Traza el ensamblaje paralelo de submallas para formas usando las SpatialCoordinates del parent frente a las del submesh; se considera terminado cuando ambas cantidades coincidan en paralelo, como lo hacen en serie. En el informe no se nombran archivos del repositorio ni tests.

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

Descripción

bug

There seems to be a bug where submesh assembly is not done correctly in parallel. See the MFE below.

I compute two quantities, qty_1 and qty_2, by assembling two UFL forms over the submesh. The UFL forms are the same, but for qty_1 it uses the parent SpatialCoordinates, and for qty_2 the submesh SpatialCoordinates.

In serial this gives the same answer, the script output is: qty_1 is 2.83297e+00, qty_2 is 2.83297e+00
In parallel (8 cores) it gives: qty_1 is 2.61235e+00, qty_2 is 2.83297e+00

So it seems that assembling parent mesh SpatialCoordinates may be bugged in parallel.

MFE:

from firedrake import *

# Create the unlabelled mesh (unit square)
mesh = UnitSquareMesh(4, 4)
x_sc, y_sc = SpatialCoordinate(mesh)

# Label the mesh, creating the left-half, right-half and interface
DG0 = FunctionSpace(mesh, "DG", 0)
DGT0 = FunctionSpace(mesh, "DGT", 0)

tag_L = Function(DG0).interpolate(conditional(lt(x_sc, 0.5), 1, 0))                     # Left-half, of dimension 2
tag_R = Function(DG0).interpolate(conditional(gt(x_sc, 0.5), 1, 0))                     # Right-half, of dimension 2
tag_G = Function(DGT0).interpolate(conditional(lt(abs(x_sc - 0.5), 1.0e-8), 1, 0))      # Interface, of dimension 1

label_L = 1
label_R = 2
label_G = 3

mesh = RelabeledMesh(mesh, [tag_L, tag_R, tag_G], [label_L, label_R, label_G])
x_sc, y_sc = SpatialCoordinate(mesh)

# Create the submeshes
mesh_L = Submesh(mesh, 2, label_L)      # Left-half mesh, of dimension 2
mesh_R = Submesh(mesh, 2, label_R)      # Right-half mesh, of dimension 2
mesh_G = Submesh(mesh, 1, label_G)      # Interface mesh, of dimension 1

# Create the measure on the interface
metadata = {"quadrature_degree": 15}
ds_G = Measure("dx", domain=mesh_G, intersect_measures=[ds(mesh_L), ds(mesh_R), dx(domain=mesh)], metadata=metadata)

# Create a UFL expression using the parent SpatialCoordinates
ufl_expr_1 = exp(x_sc + y_sc)

# Same expression, replacing the parent SpatialCoordinates with the interface SpatialCoordinates
ufl_expr_2 = replace(ufl_expr_1, {SpatialCoordinate(mesh) : SpatialCoordinate(mesh_G)})

# Integrate over the interface, and print the result
qty_1 = assemble(ufl_expr_1 * ds_G)
qty_2 = assemble(ufl_expr_2 * ds_G)

PETSc.Sys.Print("qty_1 is %.5e, qty_2 is %.5e" % (qty_1, qty_2))

# Running in parallel (8 cores) gives:  qty_1 is 2.61235e+00, qty_2 is 2.83297e+00
# Running in serial gives:              qty_1 is 2.83297e+00, qty_2 is 2.83297e+00
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.