Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEniCS-style bcs #3995

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

FEniCS-style bcs #3995

wants to merge 2 commits into from

Conversation

pbrubeck
Copy link
Contributor

@pbrubeck pbrubeck commented Jan 27, 2025

Description

With the default DirichletBC apprach, the BCs are applied on the initial guess before linearising. This could be problematic, as the intial state with BCs could cause NaNs for some nonlinear problems containing functions that blow up like logarithms.

This PR adds a kwarg to solve(F == 0, u, bcs, pre_apply_bcs=False) to delay the imposition of bcs, so that the problem is linearised around the initial guess before imposing the boundary conditions. Internally, we assemble the residual of the bcs: bc_resid = u - bc_data on the rows of the residual Cofunction, and the rows and columns of the Jacobian remain as those of the identity, to preserve symmetry. This means that the interior rows of residual need an extra term F -= action(J, bc_resid) coming from the lifted BC values on each nonlinear update, in a similar way we already do for the BC lifting in the linear case.

A cool implication of this approach for nonlinear problems where the forcing is driven by inhomogeneous boundary conditions (inflow or traction BCs) is that a linesearch method automatically enables some sort of parameter continuation.

@pbrubeck pbrubeck force-pushed the pbrubeck/feature/fenics-bcs branch from 2f9c927 to c2e26af Compare January 27, 2025 17:08
Copy link

github-actions bot commented Jan 27, 2025

TestsPassed ✅Skipped ⏭️Failed ❌
Firedrake real8080 ran7365 passed715 skipped0 failed

Copy link

github-actions bot commented Jan 27, 2025

TestsPassed ✅Skipped ⏭️Failed ❌
Firedrake complex8108 ran6558 passed1550 skipped0 failed

@pbrubeck pbrubeck force-pushed the pbrubeck/feature/fenics-bcs branch 2 times, most recently from 7acf5d9 to 03a0b3a Compare January 27, 2025 17:45
@pbrubeck pbrubeck requested a review from ksagiyam January 28, 2025 09:09
@pbrubeck pbrubeck force-pushed the pbrubeck/feature/fenics-bcs branch from 03a0b3a to ec733f2 Compare January 28, 2025 09:47
firedrake/variational_solver.py Outdated Show resolved Hide resolved
@pbrubeck pbrubeck force-pushed the pbrubeck/feature/fenics-bcs branch 4 times, most recently from 7226e77 to 72bfb6e Compare January 28, 2025 23:51
@pbrubeck pbrubeck force-pushed the pbrubeck/feature/fenics-bcs branch 3 times, most recently from 82cd4e1 to bc8d611 Compare January 29, 2025 15:39
@pbrubeck pbrubeck requested a review from ksagiyam January 29, 2025 15:45
@pbrubeck pbrubeck force-pushed the pbrubeck/feature/fenics-bcs branch from bc8d611 to 20985af Compare January 29, 2025 16:42
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.

2 participants