simpeg / discretize

Discretization tools for finite volume and inverse problems.
http://discretize.simpeg.xyz/
MIT License
163 stars 33 forks source link

mesh.write_vtk and pyvista.read functions are no longer compatible #350

Open micmitch opened 4 months ago

micmitch commented 4 months ago

I recently installed a new conda environment on a bigger computer to speed up inversion results plotting.

When I tried to run my plotting script pyvista.read() is no longer able to read the .vtu file created by mesh.write_vtk()

I am not sure if this is an issue with how discretize writes the model file or how pyvista reads it. Interestingly, I can still load the .vtu into ParaView.

I tried to attach a notebook or .py file showing a simple example but that isn't allowed.... Happy to send this example some other way if that is helpful.

After creating the octree mesh and model I write the file using this command

mesh.write_vtk('rhoTrue_2BlkTest.vtu', models={"rho":rhoTrue})

Then I try to read it back in using pyvista rhoInv_vtu = pyvista.read('./rhoTrue_2BlkTest.vtu')

This results in the following Error Message: `ERROR:root:Error parsing XML in stream at line 24, column 1, byte index 1641: not well-formed (invalid token) 2024-03-13 17:15:18.859 ( 5.335s) [ 295D7740] vtkXMLParser.cxx:375 ERR| vtkXMLDataParser (0x55fcd64d6140): Error parsing XML in stream at line 24, column 1, byte index 1641: not well-formed (invalid token) ERROR:root:Error parsing input file. ReadXMLInformation aborting. 2024-03-13 17:15:18.862 ( 5.338s) [ 295D7740] vtkXMLReader.cxx:521 ERR| vtkXMLUnstructuredGridReader (0x55fcd3d09990): Error parsing input file. ReadXMLInformation aborting. ERROR:root:Algorithm vtkXMLUnstructuredGridReader (0x55fcd3d09990) returned failure for request: vtkInformation (0x55fcd59da850) 2024-03-13 17:15:18.863 ( 5.339s) [ 295D7740] vtkExecutive.cxx:740 ERR| vtkCompositeDataPipeline (0x55fcd59ca020): Algorithm vtkXMLUnstructuredGridReader (0x55fcd3d09990) returned failure for request: vtkInformation (0x55fcd59da850) Debug: Off Modified Time: 855 Reference Count: 1 Registered Events: (none) Request: REQUEST_INFORMATION ALGORITHM_AFTER_FORWARD: 1 FORWARD_DIRECTION: 0

ERROR:root:No update piece number has been set in the information for output port 0 on algorithm vtkXMLUnstructuredGridReader (0x55fcd3d09990). /gp/mamitchell/bin/miniconda3/envs/simpeg_main/lib/python3.12/site-packages/pyvista/core/utilities/fileio.py:203: UserWarning: The VTK reader vtkXMLUnstructuredGridReader in pyvista reader XMLUnstructuredGridReader('/gp/mamitchell/SimPEG_Intro/rhoTrue_2BlkTest.vtu') raised an errorwhile reading the file. "No update piece number has been set in the information for output port 0 on algorithm vtkXMLUnstructuredGridReader (0x55fcd3d09990)." warnings.warn(`