Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1264 +/- ##
==========================================
+ Coverage 95.86% 96.03% +0.16%
==========================================
Files 57 57
Lines 5036 5065 +29
==========================================
+ Hits 4828 4864 +36
+ Misses 208 201 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| def integration_weight(self, mesh): | ||
| """Physical measure per unit mesh measure, assuming full angular coverage. | ||
|
|
||
| Use the integration domain's coordinates, including when it is a manifold | ||
| submesh. Cylindrical 1D quantities are per unit axial length. | ||
| """ | ||
| if self == CoordinateSystem.CARTESIAN: | ||
| return 1 | ||
| r = spatial_coordinate(mesh)[0] | ||
| if self == CoordinateSystem.CYLINDRICAL: | ||
| return 2 * math.pi * r | ||
| return 4 * math.pi * r**2 |
There was a problem hiding this comment.
Good idea to store this in the CoordinateSystem class.
| def define_meshtags(self, surface_subdomains, volume_subdomains, interfaces=None): | ||
| # check if all borders are defined | ||
| self.check_borders(volume_subdomains) | ||
| self.check_borders([v for v in volume_subdomains if v.codim(self.vdim) == 0]) |
There was a problem hiding this comment.
Good catch. Is there a test catching this bug?
There was a problem hiding this comment.
I don't believe so, I can add one
There was a problem hiding this comment.
Added a small direct unit test for this just to be safe, although several of the system tests added do fail if this bug is present
| "Lagrange", | ||
| function_space.mesh.topology.cell_name(), | ||
| 1, | ||
| 0 if function_space.mesh.topology.dim == 0 else 1, |
There was a problem hiding this comment.
- advection in 0D?
- I don't even think basix allows ("Lagrange", 0), is this tested?
There was a problem hiding this comment.
Sorry I glossed over this initially! You're right I don't think this makes sense, perhaps we can replace this with a warning/error, similar to your comment further down.
I did double-check the syntax and basix.ufl.element("Lagrange", "point", 0) does work. "point" should already be what is set from dolfinx.mesh.create_submesh.
| def spatial_coordinate(mesh): | ||
| """Coordinates on an integration mesh, including a zero-dimensional submesh. | ||
|
|
||
| FFCx 0.11 cannot compile SpatialCoordinate on a vertex cell (its coordinate | ||
| table is identically one). A P0 coefficient stores the exact coordinates at | ||
| each point, also when a point subdomain contains several disconnected points. | ||
| """ | ||
| domain = mesh if isinstance(mesh, ufl.Mesh) else mesh.ufl_domain() | ||
| # UFL exposed this as a method before the release bundled with DOLFINx 0.11. | ||
| tdim = domain.topological_dimension | ||
| if callable(tdim): | ||
| tdim = tdim() | ||
| if tdim > 0: | ||
| return ufl.SpatialCoordinate(domain) | ||
| if isinstance(mesh, ufl.Mesh): | ||
| mesh = dolfinx.mesh.Mesh(domain.ufl_cargo(), domain) | ||
| gdim = mesh.geometry.dim | ||
| V = fem.functionspace(mesh, ("P", 0, (gdim,))) | ||
| coordinate = fem.Function(V) | ||
| coordinate.interpolate(lambda x: x[:gdim]) | ||
| coordinate.x.scatter_forward() | ||
| return coordinate |
There was a problem hiding this comment.
So this is only to catch the situation where you have a vertex cell (a point mesh)?
In that case, could we not have a try/except instead?
try:
return ufl.SpatialCoordinate(domain)
except [INSERT ERROR WITH 0D MESH]:
tdim = ....
V = ....
coordinate = ...There was a problem hiding this comment.
Yes we could do something like that instead, however after a bit of testing I realize that we'd need to wrap ufl.SpatialCoordinate with dolfinx.fem.form() because it only fails at form compilation
There was a problem hiding this comment.
I left it as-is for now since trying to return ufl.SpatialCoordinate(domain) won't directly trip a try/except, but let me know if you think it would still be good to have a try/except block here
| # A radial surface is a point in a 1D mesh. Basix only supports P0 there. | ||
| if subdomain.submesh.topology.dim == 0: | ||
| element_degree = 0 |
There was a problem hiding this comment.
Do we agree that this is not necessarily related to non-cartesian manifolds but 0D manifolds in general yes?
There was a problem hiding this comment.
Yes that's my understanding as well
| if subdomain.submesh.topology.dim == 0: | ||
| # A point has no tangential direction in which a species can drift. | ||
| continue |
There was a problem hiding this comment.
Should we raise a warning or maybe even an error here?
There was a problem hiding this comment.
Yeah I agree, I think a warning might be good
|
@RemDelaporteMathurin Let me know if this looks okay now, thanks for all the feedback so far! Once it's merged it should make #1271 easier |
|
Sure! I will base my PR on this branch when I start working on #1271. @ee-nn @RemDelaporteMathurin |
Description
v2.2-rc.2released co-dimensional subdomains but only for cartesian coordinates. This adds functionality for cylindrical and cartesian coordinates.Related Issues
Fixes #1263
Type of Change
Testing
pytest)Code Quality Checklist
ruff format .)ruff check .)Documentation
Screenshots/Examples
Here is a small mwe: