-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add new refine surface, bounding box, and point refine methods. #297
Conversation
Codecov Report
@@ Coverage Diff @@
## main #297 +/- ##
==========================================
+ Coverage 85.04% 85.23% +0.19%
==========================================
Files 36 36
Lines 11090 11239 +149
==========================================
+ Hits 9431 9580 +149
Misses 1659 1659
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Turns out it is about the same |
"use the `TreeMesh.refine_points` functionality. It will be removed in a " | ||
"future version of discretize.", | ||
DeprecationWarning, | ||
) |
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.
@@ -521,9 +521,9 @@ cdef class _TreeMesh: | |||
---------- |
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.
discretize/tree_mesh.py
Outdated
>>> mesh = discretize.TreeMesh([32, 32]) | ||
>>> points = np.random.rand(20, 2) * 0.25 + 3/8 | ||
|
||
Now we want to refine to the maximum level, with a no padding the in `x` |
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.
Now we want to refine to the maximum level, with a no padding the in `x` | |
Now we want to refine to the maximum level, with a no padding in the `x` |
finalize : bool, optional | ||
Whether to finalize the mesh after the call. | ||
diagonal_balance : None or bool, optional | ||
Whether to balance cells diagonally in the refinement, `None` implies using |
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.
Whether to balance cells diagonally in the refinement, `None` implies using | |
Whether to balance cells diagonally in the refinement. `None` implies using |
# padding[:, -1] = np.maximum(octree_levels - 1, 0) | ||
# padding[:, :-1] = octree_levels_padding[:, None] | ||
# padding = padding[non_zeros] | ||
# mesh.refine_bounding_box(xyz, levels, padding, finalize=finalize) |
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 here...
# padding[:, -1] = np.maximum(octree_levels - 1, 0) | ||
# padding[:, :-1] = octree_levels_padding[:, None] | ||
# padding = padding[non_zeros] | ||
# mesh.refine_surface(xyz, levels, padding, finalize=finalize, pad_down=True, pad_up=False) |
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.
Why not re-routing to the new method now? These lines don't run as is BTW
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 are here to mostly just remind ourselves of the translations between the two methods, as their calling conventions are slightly different, and the surface refine behaves slightly differently around the edges.
@jcapriot Went through it with some testing. Two sticky things for me: |
1.) In my opinion the current implementation on Maybe the |
I like the dictionary idea. I still think that working with negative indexing is cumbersome as users never care for index 0, always the max level then backward. This is just internal mechanics, we could make an effort to make it more intuitive. |
Comment on efficacy for end users: I feel like most people will want to set the finest desired level of discretization, then set the number of padding cells at level as things are more coarse. So having the level argument be int would be the easiest implementation. In addition, I think new users will naturally be inclined to set the finest discretization by having level= 1 instead of level = self.max_level. Comment on level as an array_like: If padding_cells_per_level is array_like, the function already knows what values correspond to which level even if level is int. Can someone provide a commonly encountered situation where level must be array_like in order to make the mesh they want? |
I'm pretty hard against referring to
What would make it more intuitive? I do want to force the user to be explicit about which level they want to refine to. (I've seen use cases before where users wanted to use the |
I think if a user creates a mesh and doesn't want to refine to its lowest, then they should use a bigger core cell size. But whatever, you have the final say. |
The example I recalled was they wanted to refine near the surface at the finest level, but then refine at a coarser level within a box. |
That's fine, most users won't interact at that level anyway. Tree mesh creation is tough already, we can just create simple UIs and do the translation under the hood. |
What if |
Yea that sounds good. So the |
This is intended to replace the functionality of the
refine_tree_xyz
utility, which will be marked as deprecated.The new functions have slightly more intuitive inputs (in my opinion). They use the
level
argument to explicitly refer to the octree level, andpadding_cells_by_level
to refer to the amount of padding around the object.The previous function split the padding descriptions into the
octree_levels
argument and theoctree_levels_padding
. The method of refining at specific levels is not intuitive and it was implied only by the length of the array passed tooctree_levels
, and not there values, as the name might imply.There is still missing tests, but just wanted to get these out there for feedback on the inputs and descriptions in the documentation of these functions. The newsurface
function is not necessarily any quicker than the previous, but it is more well behaved. Although it's cost rises faster with the number of triangles in the triangulation.