discretize.utils.mesh_builder_xyz

discretize.utils.mesh_builder_xyz(xyz, h, padding_distance=[[0, 0], [0, 0], [0, 0]], base_mesh=None, depth_core=None, expansion_factor=1.3, mesh_type='tensor')[source]

Function to quickly generate a Tensor or Tree mesh given a cloud of xyz points, finest core cell size and padding distance. If a base_mesh is provided, the core cells will be centered on the underlaying mesh to reduce interpolation errors. The core extent is set by the bounding box of the xyz location.

Parameters:
  • xyz (numpy.ndarray) – Location points [n x dim]
  • h (list) – Cell size for the core mesh [1 x ndim]
  • padding_distance (list) – Padding distances [[W,E], [N,S], [Down,Up]]
  • base_mesh (discretize.BaseMesh) – discretize mesh used to center the core mesh
  • depth_core (float) – Depth of core mesh below xyz
  • expansion_factor (float) – Expension factor for padding cells [1.3]
  • mesh_type (str) – Specify output mesh type: [“TENSOR”] or “TREE”
Returns:

Mesh of “mesh_type”

Return type:

discretize.BaseMesh

Example

import discretize
import matplotlib.pyplot as plt
import numpy as np

xyLoc = np.random.randn(8,2)

mesh = discretize.utils.meshutils.mesh_builder_xyz(
    xyLoc, [0.1, 0.1], depth_core=0.5,
    padding_distance=[[1,2], [1,0]],
    mesh_type='tensor',
)

axs = plt.subplot()
mesh.plotImage(mesh.vol, grid=True, ax=axs)
axs.scatter(xyLoc[:,0], xyLoc[:,1], 15, c='w', zorder=3)
axs.set_aspect('equal')
plt.show()

(Source code, png, hires.png, pdf)

../../_images/discretize-utils-mesh_builder_xyz-1.png