Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【PPSCI Doc No.107】update doc for ppsci.visualize.save_vtu_to_mesh #763

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
HydrogenSulfate marked this conversation as resolved.
Show resolved Hide resolved
"""
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