File: read_parallel.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 (51 lines) | stat: -rw-r--r-- 1,267 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
.. _read_parallel_example:

Parallel Files
~~~~~~~~~~~~~~

The VTK library supports parallel file formats. Reading meshes broken up into
several files is natively supported by VTK and PyVista.
"""

from __future__ import annotations

from pathlib import Path

# sphinx_gallery_thumbnail_number = 1
import pyvista as pv
from pyvista import examples

# %%
# Let's go ahead and download the sample dataset containing an
# :class:`pyvista.UnstructuredGrid` broken up into several files.
#
# Let's inspect where this downloaded our dataset by setting ``load=False`` and
# looking at the directory containing the file we downloaded.
filename = examples.download_blood_vessels(load=False)
path = Path(filename).parent
list(path.iterdir())


# %%
list((path / 'T0000000500').iterdir())


# %%
# Note that a ``.pvtu`` file is available alongside a directory. This
# directory contains all the parallel files or pieces that make the whole mesh.
# We can simply read the ``.pvtu`` file and VTK will handle putting the mesh
# together. In PyVista, this is accomplished through :func:`pyvista.read`.
mesh = pv.read(filename)
mesh


# %%
# Plot the pieced together mesh
mesh.plot(scalars='node_value', categories=True)


# %%
mesh.plot(scalars='density')
# %%
# .. tags:: load