-
Notifications
You must be signed in to change notification settings - Fork 280
Replace deprecated refine_tree_xyz across tests #1466
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
base: main
Are you sure you want to change the base?
Conversation
Replace usage of the deprecated `refine_tree_xyz` function from discretize for their latest equivalent methods of the `TreeMesh`: `refine_surface` and `refine_points`. Apply these replacements across simpeg tests.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1466 +/- ##
==========================================
+ Coverage 82.56% 82.58% +0.01%
==========================================
Files 168 168
Lines 25728 25728
==========================================
+ Hits 21243 21248 +5
+ Misses 4485 4480 -5 ☔ View full report in Codecov by Sentry. |
| self.mesh = refine_tree_xyz( | ||
| self.mesh, | ||
| topo, | ||
| method="surface", | ||
| octree_levels=nCpad, | ||
| octree_levels_padding=nCpad, | ||
| finalize=True, | ||
| ) |
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.
Ok, my bad. The issue is not with radial methods, but with surface methods. When passing octree_levels_padding, the refined meshes are different between the old code and the new code.
Minimal example:
import numpy as np
from simpeg import utils
from discretize.utils import mesh_builder_xyz, refine_tree_xyz
# First we need to define the direction of the inducing field
# As a simple case, we pick a vertical inducing field of magnitude
# 50,000nT.
# From old convention, field orientation is given as an
# azimuth from North (positive clockwise)
# and dip from the horizontal (positive downward).
h0_amplitude, h0_inclination, h0_declination = (50000.0, 90.0, 0.0)
# Create a mesh
h = [5, 5, 5]
padDist = np.ones((3, 2)) * 100
nCpad = [2, 4, 2]
# Create grid of points for topography
# Lets create a simple Gaussian topo and set the active cells
[xx, yy] = np.meshgrid(np.linspace(-200.0, 200.0, 50), np.linspace(-200.0, 200.0, 50))
b = 100
A = 50
zz = A * np.exp(-0.5 * ((xx / b) ** 2.0 + (yy / b) ** 2.0))
# We would usually load a topofile
topo = np.c_[utils.mkvc(xx), utils.mkvc(yy), utils.mkvc(zz)]
# Create and array of observation points
xr = np.linspace(-100.0, 100.0, 20)
yr = np.linspace(-100.0, 100.0, 20)
X, Y = np.meshgrid(xr, yr)
Z = A * np.exp(-0.5 * ((X / b) ** 2.0 + (Y / b) ** 2.0)) + 5
xyzLoc = np.c_[utils.mkvc(X.T), utils.mkvc(Y.T), utils.mkvc(Z.T)]
# Build mesh with deprecated functions
old_mesh = mesh_builder_xyz(
xyzLoc,
h,
padding_distance=padDist,
mesh_type="TREE",
)
old_mesh = refine_tree_xyz(
old_mesh,
topo,
method="surface",
octree_levels=nCpad,
octree_levels_padding=nCpad,
finalize=True,
)
# Build mesh with new methods
new_mesh = mesh_builder_xyz(
xyzLoc,
h,
padding_distance=padDist,
mesh_type="TREE",
)
new_mesh.refine_surface(topo, padding_cells_by_level=nCpad, finalize=True)
print(f"old_mesh.n_cells: {old_mesh.n_cells}")
print(f"new_mesh.n_cells: {new_mesh.n_cells}")old_mesh.n_cells: 39624
new_mesh.n_cells: 57516
Summary
Replace usage of the deprecated
refine_tree_xyzfunction from discretize for their latest equivalent methods of theTreeMesh:refine_surfaceandrefine_points. Apply these replacements across simpeg tests.PR Checklist
expect style.
to a Pull Request
@simpeg/simpeg-developerswhen ready for review.Reference issue
What does this implement/fix?
Part of #1467
Additional information