File: ghost_cells.py

package info (click to toggle)
python-pyvista 0.46.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 176,968 kB
  • sloc: python: 94,346; sh: 216; makefile: 70
file content (37 lines) | stat: -rw-r--r-- 946 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
.. _ghost_cells_example:

Hide Cells with Ghosting
~~~~~~~~~~~~~~~~~~~~~~~~

Specify specific cells to hide when plotting.

This is a lightweight alternative to thresholding to quickly hide cells in a
mesh without creating a new mesh.

Notably, the mesh must be cast to an :class:`pyvista.UnstructuredGrid` type
for this to work (use the ``cast_to_unstructured_grid`` filter).
"""

from __future__ import annotations

import numpy as np

from pyvista import examples

vol = examples.load_channels()
mesh = vol.cast_to_unstructured_grid()

# %%
# Decide which cells are ghosted with a criteria (feel free to adjust this
# or manually create this array to hide specific cells).
ghosts = np.argwhere(mesh['facies'] < 1.0)

# This will act on the mesh inplace to mark those cell indices as ghosts
mesh.remove_cells(ghosts, inplace=True)

# %%
# Now we can plot the mesh and those cells will be hidden
mesh.plot(clim=[0, 4])
# %%
# .. tags:: plot