-
Notifications
You must be signed in to change notification settings - Fork 40
Boundary condition handling #1044
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
Merged
RemDelaporteMathurin
merged 7 commits into
festim-dev:fenicsx
from
jhdark:all_bcs_property
Nov 21, 2025
+82
−13
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6f18f79
all_bcs property
jhdark caac212
use all_bcs property in standard and discontinuous probem
jhdark 1612f9b
add test
jhdark 783e922
alternative approach
jhdark 6486820
pass the volume subdomain to the bc
jhdark fcb77c5
Merge branch 'fenicsx' into all_bcs_property
RemDelaporteMathurin e389dbf
rename property
jhdark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,6 +296,17 @@ def volume_meshtags(self, value): | |
| else: | ||
| raise TypeError("value must be of type dolfinx.mesh.MeshTags") | ||
|
|
||
| @property | ||
| def _unpacked_bcs(self): | ||
| """Returns all boundary conditions, including fluxes from surface reactions""" | ||
| all_boundary_conditions = [] | ||
| for bc in self.boundary_conditions: | ||
| if isinstance(bc, boundary_conditions.SurfaceReactionBC): | ||
| all_boundary_conditions.extend(bc.flux_bcs) | ||
| else: | ||
| all_boundary_conditions.append(bc) | ||
| return all_boundary_conditions | ||
|
|
||
| def initialise(self): | ||
| self.create_species_from_traps() | ||
| self.define_function_spaces(element_degree=self.settings.element_degree) | ||
|
|
@@ -641,17 +652,9 @@ def assign_functions_to_species(self): | |
| spe.test_function = sub_test_functions[idx] | ||
|
|
||
| def define_boundary_conditions(self): | ||
| # @jhdark this all_bcs could be a property | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. haha |
||
| # I just don't want to modify self.boundary_conditions | ||
| """Defines the boundary conditions of the model""" | ||
|
|
||
| # create all_bcs which includes all flux bcs from SurfaceReactionBC | ||
| all_bcs = self.boundary_conditions.copy() | ||
| for bc in self.boundary_conditions: | ||
| if isinstance(bc, boundary_conditions.SurfaceReactionBC): | ||
| all_bcs += bc.flux_bcs | ||
| all_bcs.remove(bc) | ||
|
|
||
| for bc in all_bcs: | ||
| for bc in self._unpacked_bcs: | ||
| if isinstance(bc.species, str): | ||
| # if name of species is given then replace with species object | ||
| bc.species = _species.find_species_from_name(bc.species, self.species) | ||
|
|
@@ -1322,6 +1325,13 @@ def convert_advection_term_to_fenics_objects(self): | |
| function_space=V, t=self.t | ||
| ) | ||
|
|
||
| def define_boundary_conditions(self): | ||
| for bc in self._unpacked_bcs: | ||
| if isinstance(bc, boundary_conditions.ParticleFluxBC): | ||
| bc._volume_subdomain = self.surface_to_volume[bc.subdomain] | ||
|
|
||
| super().define_boundary_conditions() | ||
|
|
||
| def create_subdomain_formulation(self, subdomain: _subdomain.VolumeSubdomain): | ||
| """ | ||
| Creates the variational formulation for each subdomain and stores it in | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reflecting on it now, the problem I have with having this as a property is that now the problem class has 2 attributes that are similar:
self.boundary_conditionsandself.all_bcs...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make
all_bcshidden instead? just_all_bcs?