Open
Description
Describe the bug
I'm comparing some refinement indicators and I ran into this issue where calling
mesh.refine_marked_elements()
multiple times with different indicators fails with an index out of bounds error.
I'm not sure if this is coming from the ngsPETSc or firedrake.
Steps to Reproduce
from firedrake import *
from netgen.geom2d import SplineGeometry
# Generate Netgen Mesh
geo = SplineGeometry()
geo.AddRectangle(p1=(-1, -1),
p2=(1, 1),
bc="rectangle",
leftdomain=1,
rightdomain=0)
ngmsh = geo.GenerateMesh(maxh=0.1)
mesh = Mesh(ngmsh)
# Constructing indicators
DG0 = FunctionSpace(mesh, "DG", 0)
mark1 = Function(DG0).interpolate(Constant(1.0))
mark2 = Function(DG0).interpolate(Constant(1.0))
meshadapt1 = mesh.refine_marked_elements(mark1)
meshadapt2 = mesh.refine_marked_elements(mark2) # <- fails here
Expected behavior
I would expect this method to work the same for both indicator functions.
Error message
Traceback (most recent call last):
File "/home/stefano/FiredrakeAdapt/bugExamples/SameMeshMultipleRefinements.py", line 22, in <module>
meshadapt2 = mesh.refine_marked_elements(mark2)
File "/home/stefano/FiredrakeAdapt/firedrake-dec24/lib/python3.10/site-packages/ngsPETSc/utils/firedrake/meshes.py", line 64, in refineMarkedElements
if mark[getIdx(i)] > 0:
IndexError: index 926 is out of bounds for axis 0 with size 926
Activity