AndreWeiner / ml-cfd-lecture

Lecture material for machine learning applied to computational fluid mechanics
GNU General Public License v3.0
330 stars 116 forks source link

Current ParaView version not compatible with FOAMDataloader #20

Closed JanisGeise closed 2 years ago

JanisGeise commented 2 years ago

Hi @AndreWeiner,

just a heads up for the upcoming exercises:

The version of ParaView (v5.7) installed in exercise 1 uses python 3.7, but the virtual environment is for python3.8. When importing the flowtorch FOAMDataloader, this will give the following error:

Traceback (most recent call last): File "/home/.../dataloader.py", line 7, in <module> from flowtorch.data import FOAMDataloader File "/home/janis/.local/lib/python3.8/site-packages/flowtorch/data/__init__.py" from .tecplot_dataloader import TecplotDataloader File "/home/janis/.local/lib/python3.8/site-packages/flowtorch/data/tecplot_dataloader.py", line 10, in <module> from paraview import servermanager as sm ModuleNotFoundError: No module named 'paraview'

The issue can be resolved by installing ParaView version v.5.11 as described in the flowtorch repo. When executing python scripts inside an IDE, the paths added to the ~\.bashrc need to be set in the script before importing flowtorch, e.g. as:

import sys sys.path.insert(0, "/opt/ParaView-5.9.1-MPI-Linux-Python3.8-64bit/bin") sys.path.insert(0, "/opt/ParaView-5.9.1-MPI-Linux-Python3.8-64bit/lib/python3.8/site-packages") from flowtorch.data import FOAMDataloader

Regards, Janis

AndreWeiner commented 2 years ago

Hi Janis, thanks for the heads-up. I already fixed this issue on the flowTorch side by making the import conditional (commit). However, in the requirements.txt, the last flowTorch version from the main branch is installed, where the fix is not yet included. My preferred solution would be to re-install flowTorch in the virtual environment rather than updating ParaView. I'll add a note to both the next exercise and lecture notebooks. Thanks again! Andre