-
Notifications
You must be signed in to change notification settings - Fork 161
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
Merged
Merged
FEniCS-style bcs #3995
Conversation
This file contains 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
2f9c927
to
c2e26af
Compare
|
|
7acf5d9
to
03a0b3a
Compare
03a0b3a
to
ec733f2
Compare
ksagiyam
requested changes
Jan 28, 2025
7226e77
to
72bfb6e
Compare
82cd4e1
to
bc8d611
Compare
1dadd06
to
c86e896
Compare
c86e896
to
89fdfef
Compare
ksagiyam
requested changes
Feb 5, 2025
Co-authored-by: ksagiyam <[email protected]>
…ject/firedrake into pbrubeck/feature/fenics-bcs
ksagiyam
previously requested changes
Feb 5, 2025
JHopeCollins
reviewed
Feb 5, 2025
JHopeCollins
reviewed
Feb 5, 2025
dham
reviewed
Feb 5, 2025
c27f393
to
f4514a3
Compare
Please don't resolve comments with reviewer questions. The reviewer might still have questions/comments on that topic, and should be the one to decide if it is resolved or not. |
pbrubeck
commented
Feb 6, 2025
Gusto and asQ tests all pass with this branch. |
dham
approved these changes
Feb 12, 2025
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.
Description
With the default DirichletBC approach, 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 residualCofunction
, 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 termF -= 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.
We also restore the old behaviour of
zero_bc_nodes=False
, so it no longer errors when we write primal data on a dualCofunction
boundary nodes, butzero_bc_nodes=True
will remain as the default.