Skip to content

Adding overload for DirichletBC#49

Open
finsberg wants to merge 6 commits into
mainfrom
finsberg/dirichlet-bc
Open

Adding overload for DirichletBC#49
finsberg wants to merge 6 commits into
mainfrom
finsberg/dirichlet-bc

Conversation

@finsberg

@finsberg finsberg commented Jun 11, 2026

Copy link
Copy Markdown
Member

This PR introduces the overloaded DirichletBC type and its corresponding PyAdjoint block (DirichletBCBlock) to dolfinx-adjoint. This enables the tracing and optimization of boundary conditions that depend on control parameters, such as time-varying boundary values or boundary control problems.

Key Changes:

  • Added DirichletBC overload (src/dolfinx_adjoint/types/dirichletbc.py): Wraps dolfinx.fem.DirichletBC as a FloatingType and eagerly annotates it to the working tape.

  • Added DirichletBCBlock (src/dolfinx_adjoint/blocks/dirichletbc.py): A PyAdjoint block that registers the underlying FEniCSx Function or Constant as a dependency and handles the forward recomputation.

  • In-place Tape Replay (src/dolfinx_adjoint/blocks/function_assigner.py): Updated FunctionAssignBlock to update the FEniCSx function arrays in-place during recompute_component().

  • Solver Dependency Tracking (src/dolfinx_adjoint/blocks/solvers.py): Updated LinearProblemBlock to correctly detect and register dependencies from provided boundary conditions.

  • Testing (tests/test_dirichlet_bc.py): Added test coverage for tape recording, the annotate=False bypass, block recomputations, and a full time-dependent PDE tape replay.

@finsberg finsberg force-pushed the finsberg/dirichlet-bc branch from 46020b5 to 9db8d73 Compare June 11, 2026 19:16
@finsberg finsberg changed the title Finsberg/dirichlet bc Adding overload for DirichletBC Jun 16, 2026
@finsberg finsberg marked this pull request as ready for review June 16, 2026 16:26
@finsberg finsberg requested a review from jorgensd June 16, 2026 16:26
@finsberg finsberg force-pushed the finsberg/dirichlet-bc branch from 71ad414 to b438d67 Compare June 16, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant