firedrakeproject / firedrake

Firedrake is an automated system for the portable solution of partial differential equations using the finite element method (FEM)
https://firedrakeproject.org
Other
498 stars 157 forks source link

Bug in MeshHierarchy (refining domain tags) #1575

Closed salazardetroya closed 3 years ago

salazardetroya commented 4 years ago

Refining a mesh from gmsh with subdomain tags results in elements with the wrong tags. I believe this bug might actually come from PETSc though. See MWE below:

Mesh

// This code was created by pygmsh v6.0.2.
SetFactory("OpenCASCADE");
Mesh.CharacteristicLengthMin = 0.1;
Mesh.CharacteristicLengthMax = 0.1;
s0 = news;
Rectangle(s0) = {0.0, 0.0, 0.0, 1.2, 1.5};
s1 = news;
Rectangle(s1) = {-0.2, -2.7755575615628914e-17, 0.0, 0.2, 0.2};
bo1[] = BooleanFragments{ Surface{s0}; Delete; } { Surface{s1};Delete;};//+
Physical Surface(0) = {s1};
Physical Surface(1) = {s0};

Plotting the tags (this is the way I came up with)

from firedrake import *

mesh = Mesh("./mwe_mesh.msh")
mh = MeshHierarchy(mesh, 1)
mesh = mh[-1]

DG0 = FunctionSpace(mesh, 'DG', 0)
v = TestFunction(DG0)
h = CellVolume(mesh)
domain0 = assemble(Constant(1.0) / h * v * dx(1))
File("domain0.pvd").write(domain0)

Picture of the domain

Screenshot from 2019-12-29 18-01-02

You can see how some elements in the little rectangle have now a tag number of 1. This does not occur if there is no refinement with MeshHierarchy.

wence- commented 3 years ago

This was fixed a while ago by a9f22c5dde6050dc347a0eba9f7dd24606857b68.