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

Check if unstructured mesh has only triangular faces #127

Merged
merged 2 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog for pymt
1.2.2 (unreleased)
------------------

- Nothing changed yet.
- Fixed an issue in quick_plot when trying to plot unstructured meshes (#127)


1.2.1 (2020-09-22)
Expand Down
17 changes: 11 additions & 6 deletions pymt/framework/bmi_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@ def quick_plot(bmi, name, **kwds):
gtype = bmi.grid_type(gid)
grid = bmi.grid[gid]

x, y = grid.node_x.values, grid.node_y.values
z = bmi.get_value(name)

x_label = "{name} ({units})".format(
name=grid.node_x.standard_name, units=grid.node_x.units
)
y_label = "{name} ({units})".format(
name=grid.node_y.standard_name, units=grid.node_y.units
)

if gtype in ("unstructured_triangular",):
tris = bmi.grid_face_node_connectivity(gid).reshape((-1, 3))
plt.tripcolor(x, y, tris, z, **kwds)
z = bmi.get_value(name)

if gtype.startswith("unstructured"):
x, y = grid.node_x.values, grid.node_y.values
nodes_per_face = bmi.grid_nodes_per_face(gid)
if np.all(nodes_per_face == 3):
tris = bmi.grid_face_nodes(gid).reshape((-1, 3))
# tris = bmi.grid_face_node_connectivity(gid).reshape((-1, 3))
plt.tripcolor(x, y, tris, z, **kwds)
else:
raise ValueError("quickplot is only able to plot unstructured meshes of triangles")
elif gtype in ("uniform_rectilinear", "structured_quad"):
shape = bmi.grid_shape(gid)
spacing = bmi.grid_spacing(gid)
Expand Down