Skip to content

Commit

Permalink
【PPSCI Doc No.107】update doc for ppsci.visualize.save_vtu_to_mesh (P…
Browse files Browse the repository at this point in the history
…addlePaddle#763)

* doc107

* fix
  • Loading branch information
ooooo-create authored Jan 23, 2024
1 parent 77a6f6b commit 627e4b6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ppsci/visualize/vtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,27 @@ def save_vtu_to_mesh(
data_dict (Dict[str, np.ndarray]): Data in dict.
coord_keys (Tuple[str, ...]): Tuple of coord key. such as ("x", "y").
value_keys (Tuple[str, ...]): Tuple of value key. such as ("u", "v").
Examples:
>>> import ppsci
>>> import numpy as np
>>> filename = "path/to/file.vtu"
>>> data_dict = {
... "x": np.array([[1], [2], [3],[4]]),
... "y": np.array([[2], [3], [4],[4]]),
... "z": np.array([[3], [4], [5],[4]]),
... "u": np.array([[4], [5], [6],[4]]),
... "v": np.array([[5], [6], [7],[4]]),
... }
>>> coord_keys = ("x","y","z")
>>> value_keys = ("u","v")
>>> ppsci.visualize.save_vtu_to_mesh(filename, data_dict, coord_keys, value_keys) # doctest: +SKIP
"""
npoint = len(next(iter(data_dict.values())))
coord_ndim = len(coord_keys)

# get the list variable transposed
points = np.stack((data_dict[key] for key in coord_keys)).reshape(
points = np.stack(tuple(data_dict[key] for key in coord_keys)).reshape(
coord_ndim, npoint
)
mesh = meshio.Mesh(
Expand Down

0 comments on commit 627e4b6

Please sign in to comment.