- TreeMesh.refine_points(points, level=-1, padding_cells_by_level=None, finalize=True, diagonal_balance=None)#
Refine the mesh at given points to the prescribed level.
This function refines the tree mesh around the points. It will refine the tree mesh for each level given. It also optionally radially pads around each point at each level with the number of padding cells given.
The points to be refined around.
The level of the tree mesh to refine to. Negative values index tree levels backwards, (e.g. -1 is max_level).
The number of cells to pad the bounding box at each level of refinement. If a single number, each level below
levelwill be padded with those number of cells. If array_like, n_level`s below ``level` will be padded. None implies no padding.
Whether to finalize the mesh after the call.
Whether to balance cells diagonally in the refinement, None implies using the same setting used to instantiate the TreeMesh`.
Given a set of points, we want to refine the tree mesh around these points to a prescribed level with a certain amount of padding.
>>> import discretize >>> import matplotlib.pyplot as plt >>> import matplotlib.patches as patches >>> mesh = discretize.TreeMesh([32, 32])
Now we want to refine to the maximum level with 1 cell padding around the point, and then refine at the second highest level with at least 3 cells beyond that.
>>> points = np.array([[0.1, 0.3], [0.6, 0.8]]) >>> padding = [1, 3] >>> mesh.refine_points(points, -1, padding)
>>> ax = mesh.plot_grid() >>> ax.scatter(*points.T, color='C1') >>> plt.show()