Matrix-free `getDiagonal` returns 1 on EquationBC rows
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 62/100
Hướng nghiên cứu
The bug is in ImplicitMatrixContext.getDiagonal, which calls bc.set(diagonal, 1) for every bc, including EquationBCSplit. Run the reproduction script in the issue and compare the matfree and aij diagonals on ebc.nodes. Then read how the aij path handles EquationBC rows and check tests/firedrake/multigrid/test_equation_bc.py. Done when the matfree diagonal matches aij on EquationBC rows and the nested test takes 8 and 9 iterations with matfree.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
For an operator with an EquationBC, getDiagonal of the matrix-free operator returns 1 on every EquationBC row that is not a nested DirichletBC row. The aij matrix has the diagonal of the EquationBC form on these rows. All other rows agree, also the rows of a DirichletBC nested in the EquationBC.
from firedrake import *
mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, "CG", 2)
u, v = TrialFunction(V), TestFunction(V)
a = inner(grad(u), grad(v)) * dx
e2 = as_vector([0, 1])
a1 = (-inner(dot(grad(u), e2), dot(e2, grad(v))) + 4 * pi**2 * inner(u, v)) * ds(1)
corners = DirichletBC(V, 0, ((1, 3), (1, 4)))
for nested in ([], [corners]):
ebc = EquationBC(a1 == inner(Constant(0), v) * ds(1), Function(V), 1, bcs=nested).extract_form("J")
A = assemble(a, bcs=[ebc], mat_type="aij").petscmat
M = assemble(a, bcs=[ebc], mat_type="matfree").petscmat
dA, dM = A.getDiagonal(), M.getDiagonal()
print("aij", dA.array[ebc.nodes[:4]], "matfree", dM.array[ebc.nodes[:4]])
prints
aij [-40.03477216 -36.01738608 -18.00869304 -40.03477216] matfree [1. 1. 1. 1.]
aij [-40.03477216 -36.01738608 1. -40.03477216] matfree [1. 1. 1. 1.]
ImplicitMatrixContext.getDiagonal assembles the diagonal of the form without the bcs and then calls bc.set(diagonal, 1) for every bc, also for an EquationBCSplit.
This changes the convergence of Jacobi with a matrix-free preconditioning matrix. The converged solution is the same. For example, test_nested_equation_bc in tests/firedrake/multigrid/test_equation_bc.py with mat_type: matfree and the coarse level through AssembledPC takes 22 Krylov iterations instead of 8 in 2D and 15 instead of 9 in 3D. With pmat_type: aij it takes 8 and 9 again.
I see this on release and on main. getDiagonal has been like this since it was added in 2019. An LLM (Claude Code) found this while I was digging into #5609 and the redesign discussion on #5620. G-ADOPT does not use this path but I am flagging it anyway.
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firedrakeproject/firedrake
-
BUG: NonlinearVariationalSolver errors with adj_kwargsCó thể đã có người làm @dham đã nhận 151 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
firedrakeproject/firedrake#5186 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
firedrakeproject/firedrake#5091 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
firedrakeproject/firedrake#3556 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
firedrakeproject/firedrake#5644 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Function.assign on a subset fails with a Constant, a Real Function or abs in the expressionCó thể đã có người làm @connorjward đã nhận 2 ngày trước. Đang mở
firedrakeproject/firedrake#5643 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của firedrakeproject/firedrake
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
datamodel-code-generator/datamodel-code-generator#6906 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
UKGovernmentBEIS/optstop#12 ·
-
bug good first issue severity: low
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
TMHSDigital/Awesome-Ads#37 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
smokin-salmon/smoked-salmon#1095 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Sienna-Platform/SiennaSchemas#130 ·
Maintainer thường phản hồi trong vòng 3 ngày