Mesh dataο
A large part of Nanomesh deals with with generating and manipulating
2D and 3D meshes. To store the data, Nanomesh uses MeshContainer
,
which is a somewhat low-level, generic container for mesh data. It can
store different types of cells and associated data. It is used
to read/write data via meshio.
To deal with mesh data more directly, use a Mesh
. Instantiating
Mesh
will create the appropriate subtype, LineMesh
,
TriangleMesh
or TetraMesh
. These contain
dedicated methods for working with a specific type of mesh and plotting them.
In addition, each can be extracted from MeshContainer
.
Classes
|
Low-level container for storing mesh data. |
|
Generic mesh class. |
|
Data class for line meshes. |
|
Data class for triangle meshes. |
|
Data class for tetrahedral meshes. |
Referenceο
- class nanomesh.MeshContainer(points: ArrayLike, cells: dict[str, ArrayLike] | list[tuple[str, ArrayLike] | CellBlock], point_data: dict[str, ArrayLike] | None = None, cell_data: dict[str, list[ArrayLike]] | None = None, field_data=None, point_sets: dict[str, ArrayLike] | None = None, cell_sets: dict[str, list[ArrayLike]] | None = None, gmsh_periodic=None, info=None)[source]ο
Bases:
Mesh
,PruneZ0Mixin
Low-level container for storing mesh data.
Can contain multiple cell types sharing a set of points. It can store different types of cells and associated data.
MeshContainer
is based onmeshio.Mesh
(https://github.com/nschloe/meshio).- Parameters
points (numpy.ndarray) β Array storing the mesh points (e.g. vertices)
cells (list) β List of cell arrays
point_data (todo) β
cell_data (todo) β
field_data (dict) β Dictionary mapping field names to cell data values.
point_sets (todo) β
cell_sets (todo) β
gmsh_periodic (todo) β
info (todo) β
Attributes:
Return cell types in order.
Mapping from fields to numbers, proxy to
MeshContainer.field_data
.Mapping from numbers to fields, proxy to
MeshContainer.field_data
.Methods:
cell_data_to_sets
(key)Convert point_data to cell_sets.
cell_sets_to_data
([data_name])copy
()from_mesh
(mesh)Convert from
nanomesh.mesh.Mesh
toMeshContainer
.from_triangle_dict
(triangle_dict)Return instance of
MeshContainer
from triangle results dict.get
([cell_type])Extract mesh with points/cells of cell_type.
get_all_cell_data
([cell_type])Get all cell data for given cell_type.
get_cell_data
(name,Β cell_type)get_cells_type
(cell_type)Try to return highest dimension type.
plot
([cell_type])Plot data.
plot_itk
([cell_type])Plot data using
itk
.plot_mpl
([cell_type])Plot data using
matplotlib
.plot_points
(**kwargs)Plot points data using :mod:`matplotlib.
plot_pyvista
([cell_type])Plot data using
pyvista
.point_data_to_sets
(key)Convert point_data to point_sets.
point_sets_to_data
([join_char])Drop third dimension (z) coordinates if present and all values are equal to 0 (within tolerance).
read
(*args,Β **kwargs)Wrapper for
meshio.read()
.set_cell_data
(cell_type,Β key,Β value)Set the cell data to the given value.
set_field_data
(cell_type,Β field_data)Update the values in
MeshContainer.field_data
.write
(filename[,Β file_format])Thin wrapper of meshio.write to avoid altering class.
- property cell_data_dictο
- property cell_sets_dictο
- property cell_typesο
Return cell types in order.
- property cells_dictο
- copy()ο
- property field_to_numberο
Mapping from fields to numbers, proxy to
MeshContainer.field_data
.
- classmethod from_mesh(mesh: Mesh)[source]ο
Convert from
nanomesh.mesh.Mesh
toMeshContainer
.- Parameters
mesh (Mesh) β Input mesh, must be a subclass of
nanomesh.mesh.Mesh
.- Return type
- classmethod from_triangle_dict(triangle_dict: dict)[source]ο
Return instance of
MeshContainer
from triangle results dict.- Parameters
triangle_dict (dict) β Triangle triangulate output dictionary.
- Returns
mesh
- Return type
- get_all_cell_data(cell_type: Optional[str] = None) dict [source]ο
Get all cell data for given cell_type.
- get_default_type() str [source]ο
Try to return highest dimension type.
Default to first type
MeshContainer.cells_dict
.- Returns
cell_type
- Return type
- property number_to_fieldο
Mapping from numbers to fields, proxy to
MeshContainer.field_data
.
- plot(cell_type: Optional[str] = None, **kwargs)[source]ο
Plot data.
- Parameters
cell_type (str, optional) β Cell type to plot.
**kwargs β These parameters are passed to plotting method.
- plot_itk(cell_type: Optional[str] = None, **kwargs)[source]ο
Plot data using
itk
.- Parameters
cell_type (str, optional) β Cell type to plot.
**kwargs β These parameters are passed to plotting method.
- plot_mpl(cell_type: Optional[str] = None, **kwargs)[source]ο
Plot data using
matplotlib
.- Parameters
cell_type (str, optional) β Cell type to plot.
**kwargs β These parameters are passed to plotting method.
- plot_points(**kwargs)[source]ο
Plot points data using :mod:`matplotlib.
- Parameters
**kwargs β These parameters are passed to the plotting method.
- plot_pyvista(cell_type: Optional[str] = None, **kwargs)[source]ο
Plot data using
pyvista
.- Parameters
cell_type (str, optional) β Cell type to plot.
**kwargs β These parameters are passed to plotting method.
- prune_z_0()ο
Drop third dimension (z) coordinates if present and all values are equal to 0 (within tolerance).
For compatibility, sometimes a column with zeroes is added, for example when exporting to gmsh2.2 format. This method drops that column.
- classmethod read(*args, **kwargs) MeshContainer [source]ο
Wrapper for
meshio.read()
.For gmsh:
remaps gmsh:physical -> physical
remaps gmsh:geometrical -> geometrical
- Parameters
*args β These parameters passed to reader
**kwargs β These parameters are passed to the reader
- Return type
- set_cell_data(cell_type: str, key: str, value: ndarray)[source]ο
Set the cell data to the given value.
Updates
MeshContainer.cell_data
.- Parameters
cell_type (str) β Cell type, must be in
MeshContainer.cell_types
key (str) β The key of the value in
MeshContainer.cell_data
value (numpy.ndarray) β Array of values to set
- set_field_data(cell_type: str, field_data: Dict[int, str])[source]ο
Update the values in
MeshContainer.field_data
.
- class nanomesh.Mesh(points: ndarray, cells: ndarray, *args, **kwargs)[source]ο
Bases:
object
Generic mesh class.
Depending on the number of dimensions of the cells, the appropriate subclass will be chosen if possible.
- Parameters
points ((m, n) numpy.ndarray[float]) β Array with points.
cells ((i, j) numpy.ndarray[int]) β Index array describing the cells of the mesh.
fields (Dict[str, int]:) β Mapping from field names to labels
region_markers (RegionMarkerList, optional) β List of region markers used for assigning labels to regions. Defaults to an empty list.
**cell_data β Additional cell data. Argument must be a 1D numpy array matching the number of cells defined by i.
Attributes:
Return centers of cells (mean of corner points).
Return number of dimensions for point data.
Shortcut for cell labels.
Mapping from numbers to fields, proxy to
{classname}.field_to_number
.Return zero labels as fallback.
Methods:
crop
([xmin,Β xmax,Β ymin,Β ymax,Β zmin,Β zmax,Β ...])Crop mesh to given region.
from_meshio
(mesh)Return
{classname}
from meshio object.get_cell_data
(key[,Β default_value])Get cell data with optional default value.
plot
(**kwargs)plot_itk
(**kwargs)Wrapper for
pyvista.plot_itk()
.plot_mpl
(**kwargs)plot_pyvista
(**kwargs)Wrapper for
pyvista.plot()
.read
(filename,Β **kwargs)Simple wrapper around
meshio.read()
.remove_cells
(*,Β label[,Β key])Remove cells with cell data matching given label.
Remove points that do not belong to any cells.
Reverse order of cells and cell data.
Return instance of
meshio.Mesh()
.Return instance of
pyvista.UnstructuredGrid
.write
(*args,Β **kwargs)Simple wrapper around
meshio.write()
.- property cell_centersο
Return centers of cells (mean of corner points).
- crop(xmin: float = -inf, xmax: float = inf, ymin: float = -inf, ymax: float = inf, zmin: float = -inf, zmax: float = inf, include_partial: bool = False)[source]ο
Crop mesh to given region.
- Parameters
xmin (float, optional) β Minimum x value.
xmax (float, optional) β Maximum x value.
ymin (float, optional) β Minimum y value.
ymax (float, optional) β Maximum y value.
zmin (float, optional) β Minimum z value (3D point data only).
zmax (float, optional) β Maximum z value (3D point data only).
include_partial (bool, optional) β If True, include cells that are partially inside the given crop region, i.e. one of its points is inside.
- Returns
cropped_mesh β Cropped mesh
- Return type
{classname}
- get_cell_data(key: str, default_value: float = 0) ndarray [source]ο
Get cell data with optional default value.
- Parameters
- Return type
- property number_to_fieldο
Mapping from numbers to fields, proxy to
{classname}.field_to_number
.
- plot_itk(**kwargs)[source]ο
Wrapper for
pyvista.plot_itk()
.- Parameters
**kwargs β These parameters are passed to
pyvista.plot_itk()
- plot_pyvista(**kwargs)[source]ο
Wrapper for
pyvista.plot()
.- Parameters
**kwargs β These parameters are passed to
pyvista.plot()
- remove_cells(*, label: int, key: Optional[str] = None)[source]ο
Remove cells with cell data matching given label.
- reverse_cell_order()[source]ο
Reverse order of cells and cell data.
Updates
{classname}.cell_data
.
- to_pyvista_unstructured_grid() pv.PolyData [source]ο
Return instance of
pyvista.UnstructuredGrid
.References
https://docs.pyvista.org/core/point-grids.html#pv-unstructured-grid-class-methods
- class nanomesh.LineMesh(points: ndarray, cells: ndarray, *args, **kwargs)[source]ο
Bases:
Mesh
Data class for line meshes.
Depending on the number of dimensions of the cells, the appropriate subclass will be chosen if possible.
- Parameters
points ((m, 2 or 3) numpy.ndarray[float]) β Array with points.
cells ((i, 2) numpy.ndarray[int]) β Index array describing the cells of the mesh.
fields (Dict[str, int]:) β Mapping from field names to labels
region_markers (RegionMarkerList, optional) β List of region markers used for assigning labels to regions. Defaults to an empty list.
**cell_data β Additional cell data. Argument must be a 1D numpy array matching the number of cells defined by i.
Attributes:
Return centers of cells (mean of corner points).
Return number of dimensions for point data.
Shortcut for cell labels.
Mapping from numbers to fields, proxy to
LineMesh.field_to_number
.Return zero labels as fallback.
Methods:
crop
([xmin,Β xmax,Β ymin,Β ymax,Β zmin,Β zmax,Β ...])Crop mesh to given region.
Return
LineMesh
from meshio object.get_cell_data
(key[,Β default_value])Get cell data with optional default value.
label_boundaries
([left,Β right,Β top,Β bottom,Β key])Labels the boundaries of the mesh with the given value.
plot
(*args,Β **kwargs)Simple line mesh plot using
matplotlib
.plot_itk
(**kwargs)Wrapper for
pyvista.plot_itk()
.plot_mpl
(*args,Β **kwargs)Simple line mesh plot using
matplotlib
.plot_pyvista
(**kwargs)Wrapper for
pyvista.plot()
.read
(filename,Β **kwargs)Simple wrapper around
meshio.read()
.remove_cells
(*,Β label[,Β key])Remove cells with cell data matching given label.
Remove points that do not belong to any cells.
Reverse order of cells and cell data.
Return instance of
meshio.Mesh()
.Return instance of
pyvista.UnstructuredGrid
.triangulate
([opts])write
(*args,Β **kwargs)Simple wrapper around
meshio.write()
.- property cell_centersο
Return centers of cells (mean of corner points).
- crop(xmin: float = -inf, xmax: float = inf, ymin: float = -inf, ymax: float = inf, zmin: float = -inf, zmax: float = inf, include_partial: bool = False)ο
Crop mesh to given region.
- Parameters
xmin (float, optional) β Minimum x value.
xmax (float, optional) β Maximum x value.
ymin (float, optional) β Minimum y value.
ymax (float, optional) β Maximum y value.
zmin (float, optional) β Minimum z value (3D point data only).
zmax (float, optional) β Maximum z value (3D point data only).
include_partial (bool, optional) β If True, include cells that are partially inside the given crop region, i.e. one of its points is inside.
- Returns
cropped_mesh β Cropped mesh
- Return type
- get_cell_data(key: str, default_value: float = 0) ndarray ο
Get cell data with optional default value.
- Parameters
- Return type
- label_boundaries(left: Optional[int | str] = None, right: Optional[int | str] = None, top: Optional[int | str] = None, bottom: Optional[int | str] = None, key: str = None)[source]ο
Labels the boundaries of the mesh with the given value.
- property number_to_fieldο
Mapping from numbers to fields, proxy to
LineMesh.field_to_number
.
- plot(*args, **kwargs)[source]ο
Simple line mesh plot using
matplotlib
.Shortcut for
plotting.linemeshplot()
.- Parameters
*args β Arguments passed to
plotting.linemeshplot()
**kwargs β Keyword arguments passed to
plotting.linemeshplot()
- Return type
plt.Axes
- plot_itk(**kwargs)ο
Wrapper for
pyvista.plot_itk()
.- Parameters
**kwargs β These parameters are passed to
pyvista.plot_itk()
- plot_mpl(*args, **kwargs) Axes [source]ο
Simple line mesh plot using
matplotlib
.Shortcut for
plotting.linemeshplot()
.- Parameters
*args β Arguments passed to
plotting.linemeshplot()
**kwargs β Keyword arguments passed to
plotting.linemeshplot()
- Return type
plt.Axes
- plot_pyvista(**kwargs)ο
Wrapper for
pyvista.plot()
.- Parameters
**kwargs β These parameters are passed to
pyvista.plot()
- classmethod read(filename, **kwargs)ο
Simple wrapper around
meshio.read()
.
- remove_cells(*, label: int, key: Optional[str] = None)ο
Remove cells with cell data matching given label.
- remove_loose_points()ο
Remove points that do not belong to any cells.
- reverse_cell_order()ο
Reverse order of cells and cell data.
Updates
LineMesh.cell_data
.
- to_meshio() meshio.Mesh ο
Return instance of
meshio.Mesh()
.
- to_pyvista_unstructured_grid() pv.PolyData ο
Return instance of
pyvista.UnstructuredGrid
.References
https://docs.pyvista.org/core/point-grids.html#pv-unstructured-grid-class-methods
- triangulate(opts: str = 'pq30Aa100', **kwargs) MeshContainer [source]ο
- write(*args, **kwargs)ο
Simple wrapper around
meshio.write()
.
- class nanomesh.TriangleMesh(points: ndarray, cells: ndarray, *args, **kwargs)[source]ο
Bases:
Mesh
,PruneZ0Mixin
Data class for triangle meshes.
Depending on the number of dimensions of the cells, the appropriate subclass will be chosen if possible.
- Parameters
points ((m, 2 or 3) numpy.ndarray[float]) β Array with points.
cells ((i, 3) numpy.ndarray[int]) β Index array describing the cells of the mesh.
fields (Dict[str, int]:) β Mapping from field names to labels
region_markers (RegionMarkerList, optional) β List of region markers used for assigning labels to regions. Defaults to an empty list.
**cell_data β Additional cell data. Argument must be a 1D numpy array matching the number of cells defined by i.
Attributes:
Return centers of cells (mean of corner points).
Return number of dimensions for point data.
Shortcut for cell labels.
Mapping from numbers to fields, proxy to
TriangleMesh.field_to_number
.Return zero labels as fallback.
Methods:
crop
([xmin,Β xmax,Β ymin,Β ymax,Β zmin,Β zmax,Β ...])Crop mesh to given region.
Return
TriangleMesh
from meshio object.from_open3d
(mesh)Return instance of
TriangleMesh
from open3d.from_scipy
(mesh)Return instance of
TriangleMesh
fromscipy.spatial.Delaunay
object.from_triangle_dict
(dct)Return instance of
TriangleMesh
from triangle results dict.from_trimesh
(mesh)Return instance of
TriangleMesh
fromtrimesh
.get_cell_data
(key[,Β default_value])Get cell data with optional default value.
optimize
(*[,Β method,Β tol,Β max_num_steps])Optimize mesh using
optimesh
.plot
(**kwargs)Shortcut for
TriangleMesh.plot_mpl()
orTriangleMesh.plot_itk()
depending on dimensions.plot_itk
(**kwargs)Wrapper for
pyvista.plot_itk()
.plot_mpl
(*args,Β **kwargs)Simple triangle mesh plot using :mod:
matplotlib
.plot_pyvista
(**kwargs)Wrapper for
pyvista.plot()
.Drop third dimension (z) coordinates if present and all values are equal to 0 (within tolerance).
read
(filename,Β **kwargs)Simple wrapper around
meshio.read()
.remove_cells
(*,Β label[,Β key])Remove cells with cell data matching given label.
Remove points that do not belong to any cells.
Reverse order of cells and cell data.
tetrahedralize
(**kwargs)Tetrahedralize mesh using
tetrahedralize()
.Return instance of
meshio.Mesh()
.Return instance of
open3d.geometry.TriangleMesh
.Return instance of
pyvista.Polydata
.Return instance of
pyvista.UnstructuredGrid
.Return instance of
trimesh.Trimesh
.write
(*args,Β **kwargs)Simple wrapper around
meshio.write()
.- property cell_centersο
Return centers of cells (mean of corner points).
- crop(xmin: float = -inf, xmax: float = inf, ymin: float = -inf, ymax: float = inf, zmin: float = -inf, zmax: float = inf, include_partial: bool = False)ο
Crop mesh to given region.
- Parameters
xmin (float, optional) β Minimum x value.
xmax (float, optional) β Maximum x value.
ymin (float, optional) β Minimum y value.
ymax (float, optional) β Maximum y value.
zmin (float, optional) β Minimum z value (3D point data only).
zmax (float, optional) β Maximum z value (3D point data only).
include_partial (bool, optional) β If True, include cells that are partially inside the given crop region, i.e. one of its points is inside.
- Returns
cropped_mesh β Cropped mesh
- Return type
- classmethod from_meshio()ο
Return
TriangleMesh
from meshio object.
- classmethod from_open3d(mesh: open3d.geometry.TriangleMesh) TriangleMesh [source]ο
Return instance of
TriangleMesh
from open3d.
- classmethod from_scipy(mesh: scipy.spatial.qhull.Delaunay) TriangleMesh [source]ο
Return instance of
TriangleMesh
fromscipy.spatial.Delaunay
object.
- classmethod from_triangle_dict(dct: dict) TriangleMesh [source]ο
Return instance of
TriangleMesh
from triangle results dict.
- classmethod from_trimesh(mesh) TriangleMesh [source]ο
Return instance of
TriangleMesh
fromtrimesh
.
- get_cell_data(key: str, default_value: float = 0) ndarray ο
Get cell data with optional default value.
- Parameters
- Return type
- property number_to_fieldο
Mapping from numbers to fields, proxy to
TriangleMesh.field_to_number
.
- optimize(*, method='CVT (block-diagonal)', tol: float = 0.001, max_num_steps: int = 10, **kwargs) TriangleMesh [source]ο
Optimize mesh using
optimesh
.- Parameters
- Return type
- plot(**kwargs)[source]ο
Shortcut for
TriangleMesh.plot_mpl()
orTriangleMesh.plot_itk()
depending on dimensions.
- plot_itk(**kwargs)ο
Wrapper for
pyvista.plot_itk()
.- Parameters
**kwargs β These parameters are passed to
pyvista.plot_itk()
- plot_mpl(*args, **kwargs) Axes [source]ο
Simple triangle mesh plot using :mod:
matplotlib
. Seeplotting.trianglemeshplot()
for details.- Parameters
*args β Arguments passed to
plotting.trianglemeshplot()
**kwargs β Keyword arguments passed to
plotting.trianglemeshplot()
- Return type
plt.Axes
- plot_pyvista(**kwargs)ο
Wrapper for
pyvista.plot()
.- Parameters
**kwargs β These parameters are passed to
pyvista.plot()
- prune_z_0()ο
Drop third dimension (z) coordinates if present and all values are equal to 0 (within tolerance).
For compatibility, sometimes a column with zeroes is added, for example when exporting to gmsh2.2 format. This method drops that column.
- classmethod read(filename, **kwargs)ο
Simple wrapper around
meshio.read()
.
- remove_cells(*, label: int, key: Optional[str] = None)ο
Remove cells with cell data matching given label.
- remove_loose_points()ο
Remove points that do not belong to any cells.
- reverse_cell_order()ο
Reverse order of cells and cell data.
Updates
TriangleMesh.cell_data
.
- tetrahedralize(**kwargs) MeshContainer [source]ο
Tetrahedralize mesh using
tetrahedralize()
.- Parameters
mesh (TriangleMesh) β Input contour mesh
opts (str, optional) β
Command-line options passed to tetgen.
More info: http://wias-berlin.de/software/tetgen/1.5/doc/manual/manual005.html
Some useful flags:
-A: Assigns attributes to tetrahedra in different regions.
-p: Tetrahedralizes a piecewise linear complex (PLC).
-q: Refines mesh (to improve mesh quality).
-a: Applies a maximum tetrahedron volume constraint.
Can be passed as a raw string, opts=β-pAq1.2β, or dict, `opts=dict(βpβ= True, βAβ= True, βqβ=1.2).
default_opts (dict, optional) β Dictionary with default options. These will be merged with opts.
- Returns
Tetrahedralized mesh.
- Return type
- to_meshio() meshio.Mesh ο
Return instance of
meshio.Mesh()
.
- to_open3d() open3d.geometry.TriangleMesh [source]ο
Return instance of
open3d.geometry.TriangleMesh
.
- to_pyvista_unstructured_grid() pv.PolyData ο
Return instance of
pyvista.UnstructuredGrid
.References
https://docs.pyvista.org/core/point-grids.html#pv-unstructured-grid-class-methods
- write(*args, **kwargs)ο
Simple wrapper around
meshio.write()
.
- class nanomesh.TetraMesh(points: ndarray, cells: ndarray, *args, **kwargs)[source]ο
Bases:
Mesh
Data class for tetrahedral meshes.
Depending on the number of dimensions of the cells, the appropriate subclass will be chosen if possible.
- Parameters
points ((m, 3) numpy.ndarray[float]) β Array with points.
cells ((i, 4) numpy.ndarray[int]) β Index array describing the cells of the mesh.
fields (Dict[str, int]:) β Mapping from field names to labels
region_markers (RegionMarkerList, optional) β List of region markers used for assigning labels to regions. Defaults to an empty list.
**cell_data β Additional cell data. Argument must be a 1D numpy array matching the number of cells defined by i.
Attributes:
Return centers of cells (mean of corner points).
Return number of dimensions for point data.
Shortcut for cell labels.
Mapping from numbers to fields, proxy to
TetraMesh.field_to_number
.Return zero labels as fallback.
Methods:
crop
([xmin,Β xmax,Β ymin,Β ymax,Β zmin,Β zmax,Β ...])Crop mesh to given region.
Return
TetraMesh
from meshio object.from_open3d
(mesh)Return instance of
TetraMesh
fromopen3d
.Return infance of
TetraMesh
frompyvista.UnstructuredGrid
.get_cell_data
(key[,Β default_value])Get cell data with optional default value.
plot
(**kwargs)Shortcut for
TetraMesh.plot_pyvista()
.plot_itk
(**kwargs)Wrapper for
pyvista.plot_itk()
.plot_mpl
(**kwargs)plot_pyvista
(**kwargs)Show grid using
pyvista
.plot_submesh
([index,Β along,Β invert,Β show,Β ...])Show submesh using
pyvista
.read
(filename,Β **kwargs)Simple wrapper around
meshio.read()
.remove_cells
(*,Β label[,Β key])Remove cells with cell data matching given label.
Remove points that do not belong to any cells.
Reverse order of cells and cell data.
Return instance of
meshio.Mesh()
.Return instance of
open3d.geometry.TetraMesh
.Return instance of
pyvista.UnstructuredGrid
.write
(*args,Β **kwargs)Simple wrapper around
meshio.write()
.- property cell_centersο
Return centers of cells (mean of corner points).
- crop(xmin: float = -inf, xmax: float = inf, ymin: float = -inf, ymax: float = inf, zmin: float = -inf, zmax: float = inf, include_partial: bool = False)ο
Crop mesh to given region.
- Parameters
xmin (float, optional) β Minimum x value.
xmax (float, optional) β Maximum x value.
ymin (float, optional) β Minimum y value.
ymax (float, optional) β Maximum y value.
zmin (float, optional) β Minimum z value (3D point data only).
zmax (float, optional) β Maximum z value (3D point data only).
include_partial (bool, optional) β If True, include cells that are partially inside the given crop region, i.e. one of its points is inside.
- Returns
cropped_mesh β Cropped mesh
- Return type
- classmethod from_pyvista_unstructured_grid(grid: pv.UnstructuredGrid)[source]ο
Return infance of
TetraMesh
frompyvista.UnstructuredGrid
.
- get_cell_data(key: str, default_value: float = 0) ndarray ο
Get cell data with optional default value.
- Parameters
- Return type
- property number_to_fieldο
Mapping from numbers to fields, proxy to
TetraMesh.field_to_number
.
- plot(**kwargs)[source]ο
Shortcut for
TetraMesh.plot_pyvista()
.
- plot_itk(**kwargs)ο
Wrapper for
pyvista.plot_itk()
.- Parameters
**kwargs β These parameters are passed to
pyvista.plot_itk()
- plot_mpl(**kwargs)ο
- plot_pyvista(**kwargs)[source]ο
Show grid using
pyvista
.- Parameters
**kwargs β These parameters are first passed to
pyvista.plot()
and then topyvista.Plotter().add_mesh()
.
- plot_submesh(index: Optional[int] = None, along: str = 'x', invert: bool = False, show: bool = True, backend: Optional[str] = None, **kwargs)[source]ο
Show submesh using
pyvista
.- Parameters
index (int, optional) β Index of where to cut the mesh. Shows all tetrahedra with cell center < index. Picks the half-way point along the axis by default.
along (str, optional) β Direction along which to cut.
invert (bool, optional) β Invert the cutting operation, and show all tetrahedra with cell center > index.
show (bool, optional) β If true, show the plot
**kwargs β Keyword arguments passed to
pyvista.Plotter.add_mesh()
.plotter (
pyvista.Plotter
) β Return plotter instance.
- classmethod read(filename, **kwargs)ο
Simple wrapper around
meshio.read()
.
- remove_cells(*, label: int, key: Optional[str] = None)ο
Remove cells with cell data matching given label.
- remove_loose_points()ο
Remove points that do not belong to any cells.
- reverse_cell_order()ο
Reverse order of cells and cell data.
Updates
TetraMesh.cell_data
.
- to_meshio() meshio.Mesh ο
Return instance of
meshio.Mesh()
.
- to_pyvista_unstructured_grid() pv.PolyData ο
Return instance of
pyvista.UnstructuredGrid
.References
https://docs.pyvista.org/core/point-grids.html#pv-unstructured-grid-class-methods
- write(*args, **kwargs)ο
Simple wrapper around
meshio.write()
.