mark_entities does not refresh the cached unique_markers of facet sets

オープン
#5,482 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@pbrubeck がすでに取り組んでいます。

2026年9月23日 から。

評価

この issue はまだ評価されていません。

説明

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.

主要言語
Python
スター
684
フォーク
204
平均マージ
4日 14時間
マージ済み PR(30日)
46

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

firedrakeproject/firedrake のほかの issue

firedrakeproject/firedrake の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。