FlowModelingControl / flowtorch

flowTorch - a Python library for analysis and reduced-order modeling of fluid flows
GNU General Public License v3.0
136 stars 46 forks source link

tricontourf or tricontour cannot be used in quadrilateral mesh #28

Closed jiaqiwang969 closed 2 years ago

jiaqiwang969 commented 2 years ago

Hi, sir I am trying to use this package. When quadrilateral mesh is imported, the map is not exactly right.

Thanks

AndreWeiner commented 2 years ago

Hi @jiaqiwang969, could you please provide some more context? From which format are you importing? Can you show a comparison between what you expect and how it actually looks like? Best, Andre

jiaqiwang969 commented 2 years ago

image

I am using the openfoam form, which is similar to of_cyliner_binary.

jiaqiwang969 commented 2 years ago

I have checked that Tricontour cannot deal with quadrilateral mesh but with smooth Delaunay method, which make the mistake from my case.

AndreWeiner commented 2 years ago

The dataloaders give you access to points (vertices) and field values defined in those vertices. In the case of OpenFOAM, the mesh topology is completely ignored, so it doesn't matter what type of cells the mesh is made of. What you get from loader.vertices is a tensor containing all cell centers. The easiest way to visualize a field defined in an unstructured set of points is to triangulate the points and interpolate the field values within the triangles. That's what tricontourf does (triangulation and interpolation). Edit: if you want to take a look at the vertices, use scatter instead of plot. Let's say you have a 2D mesh in the x-y-plane. Then you would do something like:

vertices = loader.vertices
plt.scatter(vertices[:, 0], vertices[:, 1], s=5)
plt.show()

Best, Andre