-
Notifications
You must be signed in to change notification settings - Fork 25
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
Custom fenics mesh #677
Custom fenics mesh #677
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## fenicsx #677 +/- ##
===========================================
+ Coverage 99.07% 99.09% +0.02%
===========================================
Files 24 24
Lines 1076 1107 +31
===========================================
+ Hits 1066 1097 +31
Misses 10 10 ☔ View full report in Codecov by Sentry. |
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.
I don't understand the need for a new class here?
The mesh
setter/getter could go in F.Mesh
The only thing that this class does is temporarily store the meshtags that are then passed to HTransportProblem
.
We could save us the trouble of maintaining/documenting another class (although small) and instead allow users to simply set the mesh
, facet_meshtags
and volume_meshtags
attributes of HTransportProblem
If users want to provide their own mesh and mesh_tags, could they not simply do the following :
import festim as F
# make a fenics mesh and meshtags
# ...
my_problem = F.HTransportProblem()
my_problem.mesh = F.Mesh(custom_mesh)
my_problem.facet_meshtags = custom_facet_meshtags
my_problem.volume_meshtags = cutsom_volume_meshtags
....
festim/mesh/mesh_custom_fenics.py
Outdated
self.surface_meshtags = surface_meshtags | ||
self.volume_meshtags = volume_meshtags |
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.
In HTransportProblem
the meshtags are facet_meshtags
and volume_meshtags
, I would keep the same naming
test/test_h_transport_problem.py
Outdated
my_mesh = F.CustomFenicsMesh( | ||
mesh=mesh_1D, | ||
surface_meshtags=my_surface_meshtags, | ||
volume_meshtags=my_volume_meshtags, | ||
) | ||
|
||
my_model = F.HydrogenTransportProblem(mesh=my_mesh) |
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.
The usage could simply be:
my_mesh = F.CustomFenicsMesh( | |
mesh=mesh_1D, | |
surface_meshtags=my_surface_meshtags, | |
volume_meshtags=my_volume_meshtags, | |
) | |
my_model = F.HydrogenTransportProblem(mesh=my_mesh) | |
my_mesh = F.Mesh(mesh_1D) | |
my_model = F.HydrogenTransportProblem(mesh=my_mesh) | |
my_model.facet_meshtags = my_surface_meshtags | |
my_model.volume_meshtags = my_volume_meshtags |
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.
We could even simplify things further by doing:
my_mesh = mesh_1D
my_model = F.HydrogenTransportProblem(mesh=my_mesh)
my_model.facet_meshtags = my_surface_meshtags
my_model.volume_meshtags = my_volume_meshtags
Then, in HTransportProblem make the setter of the mesh attribute:
def mesh(self, value):
if isinstance(value, dolfinx.mesh.Mesh):
self._mesh = F.Mesh(value)
else:
....
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.
Just a couple of final small comments and we're good to go!
Co-authored-by: Rémi Delaporte-Mathurin <[email protected]>
Is this PR linked to #647? |
Yes! |
Proposed changes
With this users will be able to give their own fenics mesh with custom mesh tags.
Types of changes
What types of changes does your code introduce to FESTIM?
Checklist
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...