Repository navigation
Conversation
pbrubeck
force-pushed
the
pbrubeck/restricted-equationbc
branch
from
December 3, 2026 10:47
f14a5ce to
cd068c4
Compare
NonlinearVariationalProblem.rediscretise rebuilt each boundary condition in a local function. For an EquationBC it read bc.lhs, which does not exist, and it dropped any EquationBC nested inside another. For a DirichletBC it called as_ufl on the value, which fails for a tuple of numbers. Add rediscretise to DirichletBC, EquationBCSplit and EquationBC, with the same coefficient_mapping, form_transform and homogenize_bcs arguments as the problem. Each class rebuilds itself with its constructor, so reconstruct keeps only its own arguments. The multigrid reconstruction also rebuilds an EquationBC from its F, J and Jp parts, because an EquationBC built from these parts has no equation attribute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the docstring of EquationBC.rediscretise, which repeated BCBase.rediscretise, and reduce the docstring of the multigrid reconstruction of an EquationBCSplit to one line, as for the other reconstruction functions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NonlinearVariationalProblem turned off restrict=True when the boundary conditions contained an EquationBC. Now it restricts the spaces to exclude the nodes of every DirichletBC, also those inside an EquationBC, and rebuilds each boundary condition on the restricted space with rediscretise. The adjoint solves drop the restrict option of the forward solve, because they use an assembled operator. Parametrize the tests over restrict, not pre_apply_bcs, and give the EquationBC test with a DirichletBC a solution that is not constant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pbrubeck
force-pushed
the
pbrubeck/restricted-equationbc
branch
from
December 3, 2026 11:05
cd068c4 to
d9e2943
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI assistance: Claude Code (Claude Opus 5.5) helped to write these changes and this description.
Summary
Stacked on #5185, which is stacked on #5766.
NonlinearVariationalProblemturnedrestrict=Trueoff without a warning when the boundary conditions contained anEquationBC. Now it restricts the spaces to exclude the nodes of everyDirichletBC, including theDirichletBCs inside anEquationBC:A
DirichletBCinside anEquationBCis usually on a corner or an edge, which is the intersection of two facet markers. SoRestrictedFunctionSpacenow accepts intersections:Changes for users
restrict=Truewith anEquationBCRestrictedFunctionSpace(V, boundary_set=[(1, 3)])ValueErrorNonlinearVariationalProblem.rediscretisewith anEquationBCAttributeErroronbc.lhsEquationBCImplementation details
DirichletBC,EquationBCSplitandEquationBChave arediscretisemethod with the arguments ofNonlinearVariationalProblem.rediscretise. Each class rebuilds itself with its constructor. This replaces the local function inNonlinearVariationalProblem.rediscretise, which readbc.lhs(which does not exist), dropped nestedEquationBCs, and failed for aDirichletBCwith a tuple of numbers as its value.EquationBCfrom itsF,JandJpparts, because anEquationBCbuilt from these parts has noequationattribute.restrictoption of the forward solve, because they use an assembled operator.Evidence
test_restricted_solve_corner_bcsolves the Laplace equation withu = 1on the corner(1, 3)andrestrict=True. The exact solution is the constant 1.RestrictedFunctionSpaceraisesValueErrorfor[(1, 3)].errornorm(Constant(1), u) < 1e-12on 1 and 3 processes.test_EquationBC_poisson_matrixandtest_equationbc_with_dirichletbcnow run withrestrict=Trueas well. The restricted cases converge at the rate of the unrestricted ones. Before this change,restrict=Truewas ignored, so these cases did not test a restricted space.test_restricted_function_space.pypasses on 1, 2 and 3 processes,test_equation_bcs.pyon 1 and 3 processes, andadjoint/test_solving.pyandadjoint/test_reduced_functional.pyon 1 process.Merge Danger
Door: two-way
Blast Radius: restricted solves
Solves with
restrict=Trueand anEquationBCnow use a restricted space, so their iteration counts can change.🤖 Generated with Claude Code