-
Notifications
You must be signed in to change notification settings - Fork 24
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
Average surface and volume derived quantities in Cylindrical and Spherical #820
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #820 +/- ##
=======================================
Coverage 99.56% 99.57%
=======================================
Files 61 61
Lines 2747 2796 +49
=======================================
+ Hits 2735 2784 +49
Misses 12 12 ☔ 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.
@@ -47,3 +48,101 @@ def compute(self): | |||
return f.assemble(self.function * self.ds(self.surface)) / f.assemble( | |||
1 * self.ds(self.surface) | |||
) | |||
|
|||
|
|||
class AverageSurfaceCylindrical(AverageSurface): |
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.
Since #832 you need to override the allowed_meshes
property for these quantities.
Is this where we could make use of things like abstract methods and stuff?
# dV_z = r dr dtheta , assuming axisymmetry dV_z = theta r dr | ||
# dV_r = r dz dtheta , assuming axisymmetry dV_r = theta r dz | ||
# in both cases the expression with self.dx is the same |
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.
Not true for spherical, please adapt
return avg_surf | ||
|
||
|
||
class AverageSurfaceSpherical(AverageSurface): |
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.
Since spherical coordinates can only be used in 1D, then the surface is always 0D.
Do we need this class at all? Since for 0D surfaces
Then we have AverageSurfaceSpherical = AverageSurface
.
Does that make sense?
top_id = 2 | ||
top_surface.mark(surface_markers, top_id) | ||
|
||
my_export = AverageSurfaceCylindrical("solute", top_id) |
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.
These tests pass if you replace the class on this line with AverageSurface
(cartesian).
Maybe the test case isn't chosen correctly chosen
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.
That's because the concentration field is constant on the top surface...
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.
Try with
c_fun = lambda r: 2 * r
right_surface.mark(surface_markers, right_id) | ||
ds = f.Measure("ds", domain=mesh_fenics, subdomain_data=surface_markers) | ||
|
||
my_export = AverageSurfaceSpherical("solute", right_id) |
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.
Follwing my comment above (AverageSurfaceSpherical = AverageSurface) if you replace this by AverageSurface the tests pass
volume_markers.set_all(1) | ||
dx = f.Measure("dx", domain=mesh_fenics, subdomain_data=volume_markers) | ||
|
||
my_export = AverageVolumeCylindrical("solute", 1) |
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.
Same comment as above. If you change this to simply AverageVolume
then the tests pass. The c_fun function doesn't vary in
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.
Try with
|
||
my_export = AverageVolumeSpherical("solute", 1) | ||
V = f.FunctionSpace(mesh_fenics, "P", 1) | ||
c_fun = lambda r: c_left + (c_right - c_left) / (r1 - r0) * r |
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 noting that
Proposed changes
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
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...