holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.71k stars 403 forks source link

Hybrid mesh support? #3812

Open kjnam opened 5 years ago

kjnam commented 5 years ago

Hi, I deal with hybrid meshes, which are mixture of triangular and quadrilateral cells (or simplices) for ocean-scale simulations. I would like to try pyviz tools (holoviews/geoviews/earthsim) for pre- and post-processing my data, but I think that Holoviews supports either triangle- or quad-only meshes. Is that right? If not, is there a way to manage a hybrid mesh in the pyviz ecosystem? (I guess I can split quads into triangles, but it is not an ideal solution, obviously.) By the way, thank you for your awesome work for pyviz. They look great.

philippjfr commented 5 years ago

Since HoloViews generally simply wraps external datastructures the first thing we would have to work out is what those are, so could provide a bit of background on the kinds of datastructures you use to represent hybrid meshes?

kjnam commented 5 years ago

Hi, Philipp, Thank you for the quick response first. I would say that we have our own data structure. Currently my Python data structure for the mesh is simply numpy arrays for nodes (points), cells (simplices or connectivities), and associated values, so we can convert it into something that HoloViews understands or can wraps. If you prefer a specific file format of the mesh, we use 2dm and gr3 (originated from a ELCIRC data format, I guess.) From your answer, I guess that there could be a way to wrap hybrid mesh data nicely to visualize? Sorry that I just started investigating HoloViews and GeoViews, and I might have missed basic how-to's of Holoviews. I could not find a place to ask other than GitHub.

philippjfr commented 5 years ago

I could not find a place to ask other than GitHub.

This is the right place for this discussion. I think I'm following what you're saying about the datastructure but let me just clarify what the simplex/connectivity array looks like. If you have variable length simplexes then what does the datastructure look like for a tri-cell, my basic assumption is that it is a 4 column array where the 4th column is empty (e.g. denoted by a nan). Is that correct?

kjnam commented 5 years ago

Yes, I used a 4-column array with nan for triangles for simplices.

philippjfr commented 5 years ago

Great, so the datastructure is pretty similar to what we already use to represent TriMeshes. I see no particular reason it couldn't be changed to support hybrid meshes. Since I'm not too familiar could you tell me if there is any applications that use arbitrary length meshes?

kjnam commented 5 years ago

The model that we use is SCHISM, http://ccrm.vims.edu/schismweb/, but it is a pretty common practice to use mixed elements in finite element and finite volume models, e.g. DELFT3D, UnTRIM, and SUNTANS in ocean science, to name a few. Other models like COMSOL for engineering can use various element types in one mesh.

kcpevey commented 5 years ago

I'm using the 2dm format for my triangular unstructured meshes which I feed into TriMesh. In the future, I may also need mixed element types so this is of some interest to me as well.

We've been having discussions on attempting to unify data formats for meshes. It seems ADCIRC and much of the larger community have adopted UGRID as a general standard. As far as python object storage goes, we are looking at gridded (https://github.com/NOAA-ORR-ERD/gridded) and xmsgrid (https://github.com/Aquaveo/xmsgrid) as potential options.

It might be worth some thought on the accepted data structure wrt to the community. @kjnam is yours a custom data structure, or it is common to your region of science?

kjnam commented 5 years ago

@kcpevey Mine is a custom data structure so far, but if there is a good Python implementation that meets our requirement, I will happily use those. I will look into the two repositories that you mentioned to find out if those work for me. On the side note, we are aware of UGRID, but I am not sure there is a Python implementation of UGRID.

kjnam commented 5 years ago

@kcpevey I looked through 'gridded,' and I think it could work for a data structure with I/O for the UGRID format. Thank you for pointing to the package. @philippjfr In UGRID, it uses fill values (_FillValue) with the masked array, for the unused last edge indices. See http://ugrid-conventions.github.io/ugrid-conventions/#2d-flexible-mesh-mixed-triangles-quadrilaterals-etc-topology for UGRID convention, please.

kjnam commented 4 years ago

@philippjfr I wonder if you had a chance to look at this? I took a look at the relevant parts of the codes, and it does not look simple to me to accommodate tri and quad together in the current codes...

philippjfr commented 4 years ago

Right, I'm quite sure we'd need a new representation. The main problem is still finding a good in-memory representation that does not require some complex dependency.

kjnam commented 4 years ago

Thanks for the comment. The change in the memory representation of a mesh would be a major one that would affect other parts of the codes, I am afraid. Keep me posted, please.

philippjfr commented 4 years ago

Just to be clear, we have no plans to work on this atm. I'd happy to help out if you can come up with a proposal but without that I don't foresee there being much progress being made in the near future.

kjnam commented 4 years ago

Understood. Thanks.