Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Calling .refine_marked_elements() multiple times on the same mesh is broken. #4007

Open
StefanoFochesatto opened this issue Feb 3, 2025 · 0 comments
Assignees
Labels

Comments

@StefanoFochesatto
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants