mark_entities does not refresh the cached unique_markers of facet sets

Đang mở
#5,482 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@pbrubeck đang làm issue này rồi.

Từ ngày 23/9/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

Describe the bug

MeshTopology.mark_entities writes new values into the Face Sets label of the plex, but measures on the mesh do not see them. interior_facets and exterior_facets are cached_propertys, and MeshTopology._facets reads unique_markers from the Face Sets label only once, when the property is first accessed. Anything that builds the facet data before the call to mark_entities (for example, interpolating the HDiv Trace marker function that mark_entities requires) leaves unique_markers stale. A later dS(new_id) or ds(new_id) then raises LookupError, although the plex label contains new_id.

Steps to Reproduce

from firedrake import *

mesh = UnitSquareMesh(2, 2)
x, y = SpatialCoordinate(mesh)
marker = Function(FunctionSpace(mesh, "HDiv Trace", 0))
marker.interpolate(conditional(lt(abs(y - 0.5), 1e-12), 1, 0))
mesh.mark_entities(marker.topological, 99)
print("plex label values:", mesh.topology_dm.getLabelIdIS("Face Sets").indices)
print("interior markers:", mesh.interior_facets.unique_markers)
print(assemble(Constant(1) * dS(99, domain=mesh)))

Expected behavior

The script prints the length of the line y = 1/2, which is 1.0.

Error message

plex label values: [ 3  2  4  1 99]
interior markers: [1 2 3 4]
...
  File ".../firedrake/mesh.py", line 265, in subset
    raise LookupError("{0} are not a valid markers (not in {1})".format(invalid, self.unique_markers))
LookupError: {99} are not a valid markers (not in [1 2 3 4])

Environment

Firedrake main at 065b77334. The facet-marker code path in firedrake/mesh.py is the same on main and on the branch where this was found.

Additional Info

RelabeledMesh(mesh, [marker], [99]) does not have this problem, because it creates a new mesh whose facet data is built after the label is set. Possible fixes are to invalidate the cached interior_facets/exterior_facets (and their marker subsets) inside mark_entities, or to compute unique_markers from the label each time it is needed.


This issue was written by Claude (Claude Code) on behalf of @pbrubeck.

Ngôn ngữ chính
Python
Star
684
Fork
204
Merge trung bình
4 ngày 14 giờ
Pull request đã merge (30 ngày)
46

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của firedrakeproject/firedrake

Tất cả issue của firedrakeproject/firedrake

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.