ElmerCSC / elmerfem

Official git repository of Elmer FEM software
http://www.elmerfem.org
Other
1.14k stars 311 forks source link

Could not compile Elmer with VTK 9.0.3. #290

Closed kevinsmia1939 closed 2 years ago

kevinsmia1939 commented 2 years ago

Hi,

I packaging ElmerGUI as Flatpak for Linux. Flatpak is a way to package Linux software that include any dependencies the app needs. Which mean package the app once and work on all distro.

Here is what I have so far. https://github.com/kevinsmia1939/flathub/tree/fi.csc.Elmer

I want to support many feature as possible, but I have some issues.

It look like Elmer does not compile with VTK 9.0.3. The flags I use are listed below.

      - -DBUILD_SHARED_LIBS=ON
      - -DOpenGL_GL_PREFERENCE=GLVND
      - -DBUILD_TESTING:BOOL=OFF
      - -DVTK_USE_SYSTEM_ZLIB:BOOL=ON
      - -DVTK_USE_SYSTEM_EIGEN:BOOL=ON
      - -DVTK_BUILD_QT_DESIGNER_PLUGIN:BOOL=ON
      - -DVTK_GROUP_ENABLE_Qt=WANT
      - -DCMAKE_BUILD_TYPE=Release
      - -DVTK_LEGACY_REMOVE:BOOL=ON
      - -DVTK_GROUP_ENABLE_Rendering=WANT
      - -DVTK_GROUP_ENABLE_StandAlone=WANT
      - -DVTK_USE_MPI:BOOL=ON
      - -DVTK_GROUP_ENABLE_MPI=WANT
      - -DVTK_MODULE_ENABLE_VTK_CommonSystem=YES
      - -DVTK_MODULE_ENABLE_VTK_FiltersGeneral=YES
      - -DVTK_MODULE_ENABLE_VTK_FiltersGeometry=YES
      - -DVTK_MODULE_ENABLE_VTK_ImagingCore=YES
      - -DVTK_MODULE_ENABLE_VTK_ImagingHybrid=YES
      - -DVTK_MODULE_ENABLE_VTK_InteractionStyle=YES
      - -DVTK_MODULE_ENABLE_VTK_InteractionWidgets=YES
      - -DVTK_MODULE_ENABLE_VTK_IOCityGML=YES
      - -DVTK_MODULE_ENABLE_VTK_IOExodus=YES
      - -DVTK_MODULE_ENABLE_VTK_IOGeometry=YES
      - -DVTK_MODULE_ENABLE_VTK_IOImage=YES
      - -DVTK_MODULE_ENABLE_VTK_IOImport=YES
      - -DVTK_MODULE_ENABLE_VTK_IOParallel=YES
      - -DVTK_MODULE_ENABLE_VTK_IOPLY=YES
      - -DVTK_MODULE_ENABLE_VTK_IOXML=YES
      - -DVTK_MODULE_ENABLE_VTK_RenderingAnnotation=YES
      - -DVTK_MODULE_ENABLE_VTK_RenderingCore=YES
      - -DVTK_MODULE_ENABLE_VTK_RenderingLabel=YES
      - -DVTK_MODULE_ENABLE_VTK_RenderingOpenGL2=YES
      - -DVTK_MODULE_ENABLE_VTK_RenderingVolumeOpenGL2=YES
      - -DVTK_MODULE_ENABLE_VTK_jsoncpp=YES

I use latest Elmer in devel branch.

      - -DCMAKE_BUILD_TYPE:STRING=Release
      - -DWITH_ELMERGUI:BOOL=TRUE
      - -DWITH_ELMERGUILOGGER:BOOL=TRUE
      - -DWITH_CONTRIB=ON
      - -DWITH_OpenMP:BOOL=TRUE
      - -DWITH_MPI:BOOL=TRUE
      - -DWITH_Mumps:BOOL=TRUE
      - -DWITH_Hypre:BOOL=TRUE
      - -DWITH_ScatteredDataInterpolator=ON
      - -DWITH_ElmerIce:BOOL=TRUE
      - -DMumps_INCLUDE_DIR=/app/include
      - -DMumps_LIBRARIES=/app/lib
      - -DWITH_QT5=TRUE
      - -DWITH_VTK=ON

gcc 10.2.0 cmake 3.20.2

I use openSUSE Tumbleweed.

Operating System: openSUSE Tumbleweed 20210929
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2
Kernel Version: 5.14.6-1-default (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 4600H with Radeon Graphics
Memory: 7.1 GiB of RAM
Graphics Processor: AMD RENOIR
[ 65%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/IterativeMethods.F90.o
/run/build/Elmer/ElmerGUI/Application/vtkpost/vtkpost.cpp:84:10: fatal error: QVTKWidget.h: No such file or directory
   84 | #include <QVTKWidget.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [ElmerGUI/Application/CMakeFiles/ElmerGUI.dir/build.make:847: ElmerGUI/Application/CMakeFiles/ElmerGUI.dir/vtkpost/vtkpost.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 65%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/ListMatrix.F90.o
In file included from /run/build/Elmer/ElmerGUI/Application/src/mainwindow.h:63,
                 from /run/build/Elmer/ElmerGUI/Application/src/convergenceview.cpp:44:
/run/build/Elmer/ElmerGUI/Application/src/objectbrowser.h:52:60: warning: ‘constexpr QFlags<T>::QFlags(QFlags<T>::Zero) [with Enum = Qt::WindowType; QFlags<T>::Zero = int QFlags<Qt::WindowType>::Private::*]’ is deprecated: Use default constructor instead [-Wdeprecated-declarations]
   52 |   ObjectBrowser(QMainWindow *parent, Qt::WindowFlags flags=0);
      |                                                            ^
In file included from /usr/include/QtCore/qglobal.h:1299,
                 from /usr/include/QtCore/QtCore:4,
                 from /usr/include/QtGui/QtGuiDepends:3,
                 from /usr/include/QtGui/QtGui:3,
                 from /run/build/Elmer/ElmerGUI/Application/src/convergenceview.cpp:41:
/usr/include/QtCore/qflags.h:123:80: note: declared here
  123 |     QT_DEPRECATED_X("Use default constructor instead") Q_DECL_CONSTEXPR inline QFlags(Zero) noexcept : i(0) {}
      |                                                                                ^~~~~~
/run/build/Elmer/ElmerGUI/Application/src/convergenceview.cpp: In member function ‘void ConvergenceView::savePictureSlot()’:
/run/build/Elmer/ElmerGUI/Application/src/convergenceview.cpp:329:44: warning: ‘static QPixmap QPixmap::grabWidget(QObject*, int, int, int, int)’ is deprecated: Use QWidget::grab() instead [-Wdeprecated-declarations]
  329 |   QPixmap pixmap = QPixmap::grabWidget(plot);
      |                                            ^
In file included from /usr/include/QtGui/qbrush.h:52,
                 from /usr/include/QtGui/qpen.h:45,
                 from /usr/include/QtGui/qtextformat.h:49,
                 from /usr/include/QtGui/qtextlayout.h:50,
                 from /usr/include/QtGui/qabstracttextdocumentlayout.h:45,
                 from /usr/include/QtGui/QtGui:5,
                 from /run/build/Elmer/ElmerGUI/Application/src/convergenceview.cpp:41:
/usr/include/QtGui/qpixmap.h:122:20: note: declared here
  122 |     static QPixmap grabWidget(QObject *widget, int x = 0, int y = 0, int w = -1, int h = -1);
      |                    ^~~~~~~~~~
/run/build/Elmer/ElmerGUI/Application/src/convergenceview.cpp:339:18: warning: ignoring return value of ‘QString QString::toUpper() const &’, declared with attribute ‘nodiscard’ [-Wunused-result]
  339 |   suffix.toUpper();
      |                  ^
In file included from /usr/include/QtCore/qobject.h:47,
                 from /usr/include/QtCore/qabstractanimation.h:43,
                 from /usr/include/QtCore/QtCore:6,
                 from /usr/include/QtGui/QtGuiDepends:3,
                 from /usr/include/QtGui/QtGui:3,
                 from /run/build/Elmer/ElmerGUI/Application/src/convergenceview.cpp:41:
/usr/include/QtCore/qstring.h:512:31: note: declared here
  512 |     Q_REQUIRED_RESULT QString toUpper() const &
      |                               ^~~~~~~
/run/build/Elmer/ElmerGUI/Application/vtkpost/featureedge.cpp: In member function ‘void FeatureEdge::draw(VtkPost*, Preferences*)’:
/run/build/Elmer/ElmerGUI/Application/vtkpost/featureedge.cpp:99:11: error: ‘class vtkGeometryFilter’ has no member named ‘SetInput’; did you mean ‘GetInput’?
   99 |   filter->SetInput(grid);
      |           ^~~~~~~~
      |           GetInput
[ 65%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/IterSolve.F90.o
/run/build/Elmer/ElmerGUI/Application/vtkpost/isosurface.cpp: In member function ‘void IsoSurface::draw(VtkPost*, TimeStep*)’:
/run/build/Elmer/ElmerGUI/Application/vtkpost/isosurface.cpp:181:21: warning: ‘void qSort(Container&) [with Container = QVector<double>]’ is deprecated: Use std::sort [-Wdeprecated-declarations]
  181 |   qSort(contourValue);
      |                     ^
In file included from /usr/include/QtCore/qlist.h:43,
                 from /usr/include/QtCore/qobject.h:49,
                 from /usr/include/QtCore/qabstractanimation.h:43,
                 from /usr/include/QtCore/QtCore:6,
                 from /usr/include/QtGui/QtGuiDepends:3,
                 from /usr/include/QtGui/QtGui:3,
                 from /run/build/Elmer/ElmerGUI/Application/vtkpost/isosurface.cpp:41:
/usr/include/QtCore/qalgorithms.h:188:46: note: declared here
  188 | QT_DEPRECATED_X("Use std::sort") inline void qSort(Container &c)
      |                                              ^~~~~
/run/build/Elmer/ElmerGUI/Application/vtkpost/isosurface.cpp:230:8: error: ‘class vtkContourFilter’ has no member named ‘SetInput’; did you mean ‘GetInput’?
  230 |   iso->SetInput(vtkPost->GetVolumeGrid());
      |        ^~~~~~~~
      |        GetInput

Thanks.

raback commented 2 years ago

Hi,

If you study the code for ElmerGUI you find lines like this:

if VTK_MAJOR_VERSION >= 8

include

include

else

include

endif

It seems that the QVTKWidget was renamed and has been depricated. I wonder why this VTK_MAJOR_VERSION is not defined for you. Personally I'm almost useless on build issues but maybe this gets you forward. I appreciate the effort!

raback commented 2 years ago

On further reading there seems to be a new renaming for VTK9: QVTKOpenGLNativeWidget -> QVTKOpenGLWidget https://discourse.vtk.org/t/yet-another-qvtkopenglwidget-renaming/2602 So maybe the #if #else statements should be further enhanced to deal with VTK9. You may well be the 1st one to face this issue.

kevinsmia1939 commented 2 years ago

@raback Thanks, I think the renaming in VTK 9 cause the issue. I'm surprise no one report on this issue yet.

raback commented 2 years ago

Can you maybe try out this and make a PR if succesful? I'm still working with an older VTK and basically would not like to add untested code even though this should be pretty straight-forward.

kevinsmia1939 commented 2 years ago

Can you maybe try out this and make a PR if succesful? I'm still working with an older VTK and basically would not like to add untested code even though this should be pretty straight-forward.

I don't really know how to code... But I can test if anyone make pr for it.

kevinsmia1939 commented 2 years ago

@raback Hi, I did this in ElmerGUI/Application/vtkpost/vtkpost.cpp, but still same error.

#if VTK_MAJOR_VERSION == 8
#include <QVTKOpenGLNativeWidget.h>
#elif VTK_VERSION >= 9
#include <QVTKOpenGLWidget.h>
#else
#include <QVTKWidget.h>
#endif
t7saeki commented 2 years ago

Hi,

QVTKOpenGLNativeWidget is still available in VTK9. I guess this problem was caused because vtkVersionMacros.h was not automatically included due to "-DVTK_LEGACY_REMOVE:BOOL=ON" option from vtkConfigure.h. So, you don't need to modify vtkpost.cpp. Instead, I recommend to try modifying vtkpost.h line 60 to 64

from

#if 1 
#include "vtkConfigure.h"
#else
#include "vtkVersionMacros.h"
#endif

to simply

#include "vtkConfigure.h" 
#include "vtkVersionMacros.h"