KVSlab / VaMPy

A collection of tools for pre-processing, simulating, and post-processing vascular morphologies.
https://kvslab.github.io/VaMPy
GNU General Public License v3.0
15 stars 8 forks source link

Issues running the examples in the documentation #105

Closed stefsmeets closed 1 year ago

stefsmeets commented 1 year ago

Hi, I'm trying out vampy for the JOSS review (https://github.com/openjournals/joss-reviews/issues/5278). These are some issues I run into with the examples in the documentation. This is on Linux using Python 3.9 with the development version of vampy. I'm not sure if I did something wrong with the installation. Two error seem to be related to 'tetgen' inside of dolfin, and the other with some gzip related error.

Artery tutorial fails on tetgen part:

$ vampy-mesh -m constant -el 0.3 -i c0001/model.vtp -bl False
...
Generating volume mesh
TetGen command line options: pq1.414000q10.000000q165.000000YsT1.000000e-08zQm
Internalerror in findedge():  Unable to find an edge in subface.
2023-03-29 06:23:15.179 ( 654.314s) [        FE135740]vtkvmtkTetGenWrapper.cx:433    ERR| vtkvmtkTetGenWrapper (0x55fb77b60c10): TetGen quit with an exception.
An error occurred during tetrahedralization. Will only output surface mesh.
Writing Dolfin file.
Segmentation fault

The artery example also fails with tetgen.

$ vampy-mesh -i models/artery/artery.vtp -c 1.3
Generating volume mesh
TetGen command line options: pq1.414000q10.000000q165.000000YsT1.000000e-08zQm
Internalerror in findedge():  Unable to find an edge in subface.
2023-03-29 06:36:54.786 (  62.973s) [        F3E0B740]vtkvmtkTetGenWrapper.cx:433    ERR| vtkvmtkTetGenWrapper (0x55cadc27b6f0): TetGen quit with an exception.
An error occurred during tetrahedralization. Will only output surface mesh and boundary layer.
Assembling final mesh
2023-03-29 06:36:54.788 (  62.975s) [        F3E0B740]       vtkThreshold.cxx:84    WARN| vtkThreshold::ThresholdByUpper was deprecated for VTK 9.1 and will be removed in a future version.
Writing Dolfin file.
Segmentation fault

Finally, I get this error when running the simulation example:

$ oasis NSfracStep problem=Artery mesh_path=../../../models/artery/artery.xml.gz save_solution_after_cycle=0
Importing problem module Artery:
/home/stef/python/vampy/src/vampy/simulation/Artery.py
=== Starting simulation for case: artery ===
{...}
Traceback (most recent call last):
  File "/home/stef/miniconda3/envs/your_environment/bin/oasis", line 8, in <module>
    sys.exit(main())
  File "/home/stef/miniconda3/envs/your_environment/lib/python3.10/site-packages/oasis/run_oasis.py", line 11, in main
    from oasis import NSfracStep
  File "/home/stef/miniconda3/envs/your_environment/lib/python3.10/site-packages/oasis/NSfracStep.py", line 60, in <module>
    vars().update(post_import_problem(**vars()))
  File "/home/stef/miniconda3/envs/your_environment/lib/python3.10/site-packages/oasis/problems/__init__.py", line 212, in post_import_problem
    mesh = mesh(**NS_parameters)
  File "/home/stef/python/vampy/src/vampy/simulation/Artery.py", line 82, in mesh
    mesh = Mesh(mesh_path)
RuntimeError: gzip error: iostream error
hkjeldsberg commented 1 year ago

Dear @stefsmeets ,

Thank you for pointing out this issue. We believe the first two errors may be related to the issues we have experienced using the vmtkMeshWriter in the past due to errors in parsing in binary mode versus text mode. We tried to add a hotfix for this issue in #108, which has been merged to the master branch.

The last error experienced in Artery.py is likely caused by a defect in the volumetric mesh due to the segmentation fault above. I would recommend removing the .vtu and .xml.gz files, and see if re-meshing the geometry will help.

I hope this, and the changes made in PR #108 can help fix these issues.

Best regards, Henrik

stefsmeets commented 1 year ago

Thanks, the first 2 errors are resolved with #108

I still get the third error, but maybe this is more of an oasis issue than a vampy issue?

I tried the work-around by updating the vmtk library, but this doesn't work either. Any other ideas?

If it helps, these are the commands I'm running from a clean repository:

vampy-mesh -i models/artery/artery.vtp -c 1.3
cd src/vampy/simulation
oasis NSfracStep problem=Artery mesh_path=../../../models/artery/artery.xml.gz save_solution_after_cycle=0

This gives the RuntimeError: gzip error: iostream error error even if the vampy-mesh command does not fail.

stefsmeets commented 1 year ago

Actually, I still get the first 2 errors as well. I didn't realize the .vtu/.xml.gz files are cached. They are in the .gitignore file so I didn't realize they were not part of the repo.

hkjeldsberg commented 1 year ago

Hi @stefsmeets,

Thanks for your patience. I investigated this further and think I have found out what is causing the issues you're experiencing. Through the latest pull request (#110), I believe your two first errors should be fixed. I successfully tested this update thoroughly for both the artery.vtp model, and the c0001 model on a Linux (Ubuntu), and tested this for multiple Python versions, including 3.8, 3.9, and 3.10. Essentially the error is caused by some instability using the vtkvmtkTetGenWrapper, which I realise have been previously reported. Hopefully, with the changes in PR #110, you should now be able to mesh both models.

As for the third error, I think it is related to the first two errors. However, if the latest update does not seem to fix this issue I would try the following steps:

I hope this, and the recent changes to vampy can help fix these issues.

Best regards, Henrik

stefsmeets commented 1 year ago

Cool, everything seems to work as expected now! Thanks for the fix!