-
-
Notifications
You must be signed in to change notification settings - Fork 119
Postprocess and visualize CHT flow over plate results #199
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
Conversation
@oguzziya knows a different approach to this problem. Maybe worth switching to it? |
If the script is that long, it might not worth the hassle. However, if we gonna have different kinds of VTK files, such as unstructured, structured, etc. It might be a good approach. PyVista is pretty handy to manipulate the data. For example, the following snippet is a code that I use in general to obtain a contour plot. The good thing is, you can obtain pretty flexible plots combining with matplotlib, especially good for papers (LaTeX, pdf output, etc.) I have also scripts to plot data along an axis and comparing it with an experimental data but the approach is basically the same. def contour_plot(self, file_path, field_name, save_name=None, cmap="bone"):
mesh = pv.read(file_path)
midplane = mesh.ctp().slice(normal=self.axis[self.directions["tangential"]], generate_triangles=True)
midplane.active_scalars_name = field_name
x = midplane.points
tri = midplane.faces.reshape((-1,4))[:, 1:]
data = midplane.active_scalars
data_max = round(float(np.max(data)) / 10) * 10
data_min = int(float(np.min(data)) / 10) * 10
# Rest is matplotlib
fig = plt.figure(figsize=(20, 5))
ax = fig.add_subplot(1,1,1)
cont = ax.tricontourf(x[:, self.directions["axial"]], x[:, self.directions["radial"]], tri, data, levels=np.linspace(data_min, data_max, 39), cmap=cmap)
cbar = fig.colorbar(cont, ax=ax)
cbar.set_ticks(np.linspace(data_min, data_max, 5, endpoint=True))
ax.set_yticklabels([])
ax.set_yticks([])
ax.set_label(field_name)
cbar.set_label(field_name, fontsize=20)
if save_name is not None:
fig.savefig(save_name + ".png", dpi=300) |
@oguzziya Never heard about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it 👌 Works like a charm.
Small comments:
- Please add the dependency
vtk
in the README (and how to get it normally from PyPI). matplotlib as well? example.vtk
can be deleted, right?
and see below.
Please merge after fixing these.
Co-authored-by: Benjamin Uekermann <benjamin.uekermann@gmail.com>
Similar to #196, just for a different case. In the end we want to plot the temperature across the coupling interface.
What kind of plot?
In the end we want a plot similar to the one above taken from Fig3c from this paper, but automatically generated from the preCICE output data. Note that this will restrict us to the coupling interface, i.e. the interval x = [0,1] and not the whole bottom of the channel x = [-0.5,3].
What we get with this PR: