# discretize.TreeMesh.refine_ball#

TreeMesh.refine_ball(self, points, radii, levels, finalize=True, diagonal_balance=None)#

Refine `TreeMesh` using radial distance (ball) and refinement level for a cluster of points.

For each point in the array points, this method refines the tree mesh based on the radial distance (ball) and refinement level supplied. The method accomplishes this by determining which cells intersect ball(s) and refining them to the prescribed level(s) of refinement.

Parameters:
points(`N`, `dim`) array_like

The centers of the refinement balls

radii`float` `or` (`N`) array_like `of` `float`

A 1D array defining the radius for each ball

levels`int` `or` (`N`) array_like `of` `int`

A 1D array defining the maximum refinement level for each ball

finalizebool, `optional`

Whether to finalize after refining

diagonal_balancebool or `None`, `optional`

Whether to balance cells diagonally in the refinement, None implies using the same setting used to instantiate the TreeMesh`.

Examples

We create a simple mesh and refine the tree mesh such that all cells that intersect the spherical balls are at the given levels.

```>>> import discretize
>>> import matplotlib.pyplot as plt
>>> import matplotlib.patches as patches
>>> tree_mesh = discretize.TreeMesh([32, 32])
>>> tree_mesh.max_level
5
```

Next we define the center and radius of the two spheres, as well as the level we want to refine them to, and refine the mesh.

```>>> centers = [[0.1, 0.3], [0.6, 0.8]]
```>>> ax = tree_mesh.plot_grid()