usnistgov / fipy

FiPy is a Finite Volume PDE solver written in Python
http://pages.nist.gov/fipy/en/latest
Other
509 stars 149 forks source link

Vtk export is broken #312

Open guyer opened 10 years ago

guyer commented 10 years ago

As reported in http://thread.gmane.org/gmane.comp.python.fipy/2469, some 3D meshes are not exported cleanly via Vtk.

guyer commented 10 years ago

_guyer attached twin_ap_3D.msh on 03-15-2012 at 09:48_

guyer commented 10 years ago

guyer attached estat.py on 03-15-2012 at 09:47

guyer commented 10 years ago

These don't seem to be issues under FiPy's control. Although Gmsh can't read the ConvexPointSet cells that FiPy exports, Mayavi, and ParaView can. It would be good to eventually export the more specific cell types when we can, but it's not urgent.

I'm not sure what's to be done about the localization issues. FiPy doesn't actually write the file, it just supplies the data to tvtk.

Trac comment by guyer on 04-10-2012 at 15:40

guyer commented 4 years ago

There's some good information about diagnosing this with pyvista in #693 and pyvista/pyvista-support#108

amine-aboufirass commented 4 years ago

@guyer the issue from https://github.com/pyvista/pyvista-support/issues/108 is not limited to 3D meshes. Consider the following example:

from fipy import CylindricalGrid2D, Grid2D
import pyvista

mesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2)

ugrid= pyvista.UnstructuredGrid(mesh.VTKCellDataSet._vtk_obj)
plotter = pyvista.Plotter()
plotter.set_background('white')
plotter.add_mesh(ugrid, style='wireframe', color='black')
plotter.add_bounding_box(color='red')
plotter.show_grid(color="red")
plotter.view_xy()
plotter.show()

Please also take a look at the following email exchange, credit goes to @wd15 :

It's a possibility, but I suspect it would be a great deal of work. I certainly wouldn't want to tackle it. It maybe easier to just export the correct VTK ordering from FiPy as a separate function that uses the normals to reorder things correctly.

On Thu, Jan 23, 2020 at 2:44 PM A A <> wrote:

Hey Daniel,

If Im reading this correctly then it would not, in theory, break any fipy functionality should the VTK ordering be adopted?

If so, I might be tempted to look into it...

Regards,

Amine

If I'm reading this correctly then the best way forward would be to add a function which readjusts the direction of the normals, rather than than attempting to refactor in order to adopt VTK ordering. Is this correct? If so where should such a function be located?

guyer commented 4 years ago

That's not how I read that, nor is it what I'd do. The FiPy code for exporting VTK is wrong and should be fixed. What Daniel is saying is that the face normals (which FiPy already knows) can be used to figure out what order the exported vertices should be in.