BUG: Are facet normals correct for periodic rectangle meshes of width 1 or 2?
メンテナーはふだん 1 日以内に返信
@connorjward がすでに取り組んでいます。
2026年7月21日 から。
評価
この issue はまだ評価されていません。
説明
One of the Gusto "case study" tests seems to have been failing since we picked up the Firedrake 2026.04.1 release. The Skamarock-Klemp hydrostatic gravity wave uses a PeriodicRectangleMesh which is 1 cell wide in the y-direction.
The pressure gradient is calculated via a term which includes cp*avg(exner)*jump(theta*w, n)*dS_v, where:
cp is the specific heat capacity at constant pressure, exner is the "Exner" pressure, theta is the potential temperature, w is the velocity test function and n is the FacetNormal. In our test, the pressure gradient in the y-direction should be essentially zero, but this term now seems to be enormous and causes the model to blown up in the first timestep.
I think the issue is that there has been a change in behaviour for FacetNormal on the PeriodicRectangleMesh, specifically when the mesh is only 1 or 2 cells wide.
To investigate this, I checked whether n takes equal but opposite values on the '+' and '-' sides of each facet. It seems that for the PeriodicRectangleMesh it now doesn't when the mesh is 1 or 2 cells wide.
I wonder if this was a side effect of #4836?
If I change the Gusto test to use a width of 3, it runs successfully.
Here is an MFE:
"""
Minimum failing example demonstrating that facet normals are not computed
correctly on periodic meshes of widths 1 or 2.
Facet normals on the '+' and '-' sides of a facet should sum to zero, as they
should be of equal size but opposite direction.
At the time of writing, this test passes for a width of 3 or more but fails
for a width
of 1 or 2.
"""
from firedrake import (
PeriodicRectangleMesh, FunctionSpace, Function, FacetNormal,
TestFunction, TrialFunction, inner, dS,
LinearVariationalProblem, LinearVariationalSolver, VTKFile
)
import numpy as np
to_output = False
mesh_widths = [4, 3, 2, 1] # Number of cells in y-direction
for width in mesh_widths:
# Periodic rectangle mesh
mesh = PeriodicRectangleMesh(5, width, 10.0, 10.0/width, quadrilateral=True)
# RTCF1 has one degree of freedom per facet
HDiv = FunctionSpace(mesh, "RTCF", 1)
n = FacetNormal(mesh)
psi = TestFunction(HDiv)
p = TrialFunction(HDiv)
n_plus = Function(HDiv, name='n_plus') # Takes value of n on + side
n_minus = Function(HDiv, name='n_minus') # Takes value of n on - side
n_sum = Function(HDiv, name='n_sum') # Sum of n+ and n-
# Project the facet normals onto the HDiv space
# As psi and p are continuous, their label on the facet doesn't matter
a = inner(p('+'), psi('+'))*dS
L_plus = inner(n('+'), psi('+'))*dS
L_minus = inner(n('-'), psi('+'))*dS
problem_plus = LinearVariationalProblem(a, L_plus, n_plus)
problem_minus = LinearVariationalProblem(a, L_minus, n_minus)
solver_plus = LinearVariationalSolver(problem_plus)
solver_minus = LinearVariationalSolver(problem_minus)
solver_plus.solve()
solver_minus.solve()
n_sum.project(n_plus + n_minus)
if to_output:
output = VTKFile(f"facet_normals_{width}.pvd")
output.write(n_plus, n_minus, n_sum)
assert np.allclose(n_sum.dat.data_ro, 0.0, 1e-16), \
f"Facet normals do not sum to zero for mesh width {width}"
- 主要言語
- Python
- スター
- 684
- フォーク
- 204
- 平均マージ
- 4日 14時間
- マージ済み PR(30日)
- 46
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
firedrakeproject/firedrake のほかの issue
-
BUG: NonlinearVariationalSolver errors with adj_kwargs対応中かも @dham が 151 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
firedrakeproject/firedrake#5186 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
firedrakeproject/firedrake#5091 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
firedrakeproject/firedrake#3556 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
firedrakeproject/firedrake#5644 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Function.assign on a subset fails with a Constant, a Real Function or abs in the expression対応中かも @connorjward が 2 日前に担当しました。 オープン
firedrakeproject/firedrake#5643 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
firedrakeproject/firedrake の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
alltheplaces/alltheplaces#20570 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
area:ci bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
catincloud-labs/dagster-dex#206 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
number_to_words raises ValueError with threshold= for ordinals ("12th") and comma-grouped strings ("1,000")対応中かも @hemtilva が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
providers security
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
agentbreeder/agentbreeder#1031 ·
メンテナーはふだん 1 日以内に返信