Categories: Visualization

Building ParaView

The Elmer Parallel Demo used ParaView to visualize the results of the simulation. It looks like such a useful tool so I decided to get the source code and build it to learn a little bit about it.

Building on Windows

The building documentation looks thorough. I used a similar directory structure and didn’t need the Git Bash window since I ran all the commands in the VS2019 x64 Native Tools Command Prompt.

cd \dev\repos
mkdir pv
cd pv
git clone --recursive https://gitlab.kitware.com/paraview/paraview.git

This is one of the more interesting clones I have done – a lot going on with these submodules.

Cloning into 'paraview'...
remote: Enumerating objects: 469980, done.
remote: Counting objects: 100% (4454/4454), done.
remote: Compressing objects: 100% (1787/1787), done.
remote: Total 469980 (delta 2771), reused 4233 (delta 2592), pack-reused 465526Receiving objects: 100% (469980/469980), 197.93 MiB | 2.63 MiB/s
Receiving objects: 100% (469980/469980), 198.52 MiB | 2.40 MiB/s, done.
Resolving deltas: 100% (349710/349710), done.
Updating files: 100% (9092/9092), done.
Submodule 'ThirdParty/IceT/vtkicet' (https://gitlab.kitware.com/paraview/icet.git) registered for path 'ThirdParty/IceT/vtkicet'
Submodule 'ThirdParty/QtTesting/vtkqttesting' (https://gitlab.kitware.com/paraview/qttesting.git) registered for path 'ThirdParty/QtTesting/vtkqttesting'
Submodule 'Utilities/VisItBridge' (https://gitlab.kitware.com/paraview/visitbridge.git) registered for path 'Utilities/VisItBridge'
Submodule 'VTK' (https://gitlab.kitware.com/vtk/vtk.git) registered for path 'VTK'
Cloning into 'C:/dev/repos/paraview/ThirdParty/IceT/vtkicet'...
remote: Enumerating objects: 4587, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 4587 (delta 1), reused 1 (delta 0), pack-reused 4582
Receiving objects: 100% (4587/4587), 1.15 MiB | 1.94 MiB/s, done.
Resolving deltas: 100% (3447/3447), done.
Cloning into 'C:/dev/repos/paraview/ThirdParty/QtTesting/vtkqttesting'...
remote: Enumerating objects: 2358, done.
remote: Counting objects: 100% (239/239), done.
remote: Compressing objects: 100% (103/103), done.
remote: Total 2358 (delta 136), reused 239 (delta 136), pack-reused 2119
Receiving objects: 100% (2358/2358), 670.37 KiB | 1.55 MiB/s, done.
Resolving deltas: 100% (1777/1777), done.
Cloning into 'C:/dev/repos/paraview/Utilities/VisItBridge'...
remote: Enumerating objects: 14424, done.
remote: Counting objects: 100% (235/235), done.
remote: Compressing objects: 100% (113/113), done.
remote: Total 14424 (delta 127), reused 186 (delta 122), pack-reused 14189
Receiving objects: 100% (14424/14424), 11.66 MiB | 1.99 MiB/s, done.
Resolving deltas: 100% (11036/11036), done.
Cloning into 'C:/dev/repos/paraview/VTK'...
remote: Enumerating objects: 647510, done.
remote: Counting objects: 100% (787/787), done.
remote: Compressing objects: 100% (418/418), done.
remote: Total 647510 (delta 450), reused 652 (delta 367), pack-reused 646723
Receiving objects: 100% (647510/647510), 231.49 MiB | 2.44 MiB/s, done.
Resolving deltas: 100% (497923/497923), done.
Submodule path 'ThirdParty/IceT/vtkicet': checked out '32816fe5592de3be664da6f8466a546f221d8532'
Submodule path 'ThirdParty/QtTesting/vtkqttesting': checked out '08d96e9277bc4c26804fd77ce1b4fa5c791605ae'
Submodule path 'Utilities/VisItBridge': checked out 'df098f4148a96d62c388861c1d476039e02224ae'
Submodule path 'VTK': checked out 'e38d93f8b9d7a9475593e502adefa9e02d5c60fe'
Submodule 'VTK-m' (https://gitlab.kitware.com/vtk/vtk-m.git) registered for path 'VTK/ThirdParty/vtkm/vtkvtkm/vtk-m'
Cloning into 'C:/dev/repos/paraview/VTK/ThirdParty/vtkm/vtkvtkm/vtk-m'...
remote: Enumerating objects: 86181, done.
remote: Counting objects: 100% (6317/6317), done.
remote: Compressing objects: 100% (1922/1922), done.
remote: Total 86181 (delta 4616), reused 5994 (delta 4377), pack-reused 79864
Receiving objects: 100% (86181/86181), 23.04 MiB | 2.56 MiB/s, done.
Resolving deltas: 100% (70045/70045), done.
Filtering content: 100% (102/102), 30.28 MiB | 3.84 MiB/s, done.
Submodule path 'VTK/ThirdParty/vtkm/vtkvtkm/vtk-m': checked out '982e965536b41b334bd2bbb765373e6503c823ec'

Setting up the build is simple too.

mkdir build
cd build

cmake -GNinja -DPARAVIEW_USE_PYTHON=ON -DPARAVIEW_USE_MPI=ON -DVTK_SMP_IMPLEMENTATION_TYPE=STDThread -DCMAKE_BUILD_TYPE=Release ..\paraview

Unfortunately, cmake fails on the first try because it cannot find MPI.

-- Check size of uintptr_t
-- Check size of uintptr_t - done
-- Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS)
-- Could NOT find MPI (missing: MPI_C_FOUND C)
CMake Error at VTK/CMake/vtkModule.cmake:4578 (message):
  Could not find the MPI external dependency.
Call Stack (most recent call first):
  VTK/CMake/vtkModule.cmake:5172 (vtk_module_find_package)
  VTK/Utilities/MPI/CMakeLists.txt:1 (vtk_module_third_party_external)

The error log contains a more specific error message:

C:\PROGRA~2\MIB055~1\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe  /nologo   /DWIN32 /D_WINDOWS /bigobj   /Zi /Ob0 /Od /RTC1 -MDd /showIncludes /FoCMakeFiles\cmTC_77827.dir\test_mpi.c.obj /FdCMakeFiles\cmTC_77827.dir\ /FS -c C:\dev\repos\pv\paraview\VTK\CMake\patches\3.22\FindMPI\test_mpi.c

C:\dev\repos\pv\paraview\VTK\CMake\patches\3.22\FindMPI\test_mpi.c(1): fatal error C1083: Cannot open include file: 'mpi.h': No such file or directory
ninja: build stopped: subcommand failed.

Some folks have already run into this before, e.g.

The problem is that I already had Microsoft MPI installed (by Elmer) but I didn’t have the SDK. Gotta take those prerequisites seriously… However, it’s good to know that the Microsoft MPI source code is on GitHub! Weird that I can’t download the MPI SDK by itself. The SDK’s default install path is “C:\Program Files (x86)\Microsoft SDKs\MPI\

Microsoft MPI SDK Setup Wizard

This addresses that cmake failure but also points out my other dereliction of prerequisite installation…

...
-- Found MPI_C: C:/Program Files (x86)/Microsoft SDKs/MPI/Lib/x64/msmpi.lib (found version "2.0")
-- Found MPI: TRUE (found version "2.0") found components: C
...
CMake Warning at VTK/CMake/vtkModule.cmake:4572 (find_package):
  By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5" (requested
  version 5.9) with any of the following names:

    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.  If "Qt5" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  VTK/GUISupport/Qt/CMakeLists.txt:43 (vtk_module_find_package)


CMake Error at VTK/CMake/vtkModule.cmake:4578 (message):
  Could not find the Qt5 external dependency.
Call Stack (most recent call first):
  VTK/GUISupport/Qt/CMakeLists.txt:43 (vtk_module_find_package)

Interestingly, there are only .zip files in the linked to 5.15.3 archive. The installer I need Download Offline Installers | Source Package Offline Installer | Qt. This thing needs an account??? I create a personal account and try to install it to C:\Qt\Qt5.12.12.

Qt 5.12.12 Setup Dialog – Account Required

Unfortunately, I don’t see an MSVC 2019 component! Could this be why they require 5.15.3?

Qt 5.12.12 Setup Dialog – Component Selection

Even more unfortunate is the discovery that the reason I can’t find 5.15 installers is because they need a commercial license. Here’s the linked to blog post: Qt offering changes 2020. Interestingly, there was pushback against the account requirement a while back too – Changing Qt Account to be Optional in the Online Installer. I had been considering learning more about Qt and perhaps porting some code to Qt but this level of friction has me reconsidering doing anything with Qt. For now, I’m setting aside the Windows platform to see what the situation is on Linux.

Building on Linux

Building on Linux is straightforward on my Ubuntu 20.04 VM.

cd ~/repos/sci
mkdir pv
cd pv
git clone --recursive https://gitlab.kitware.com/paraview/paraview.git

sudo apt-get install git cmake build-essential libgl1-mesa-dev libxt-dev qt5-default libqt5x11extras5-dev libqt5help5 qttools5-dev qtxmlpatterns5-dev-tools libqt5svg5-dev python3-dev python3-numpy libopenmpi-dev libtbb-dev ninja-build

mkdir build
cd build
cmake -GNinja -DPARAVIEW_USE_PYTHON=ON -DPARAVIEW_USE_MPI=ON -DVTK_SMP_IMPLEMENTATION_TYPE=TBB -DCMAKE_BUILD_TYPE=Release ../paraview

time ninja

ninja takes about 3h 45min on my machine but it completes successfully. Launch ParaView by running:

bin/paraview
ParaView Built on Ubuntu

Building on macOS

The approach I took was to start building using the same cmake configuration as I did on my Ubuntu VM.

brew install ninja

cmake -GNinja -DPARAVIEW_USE_PYTHON=ON -DPARAVIEW_USE_MPI=ON -DVTK_SMP_IMPLEMENTATION_TYPE=TBB -DCMAKE_BUILD_TYPE=Release ../paraview

I hadn’t really thought much about what TBB is until cmake failed with this error:

-- Could NOT find TBB (missing: TBB_DIR)
CMake Error at VTK/CMake/vtkModule.cmake:4578 (message):
  Could not find the TBB external dependency.
Call Stack (most recent call first):
  VTK/Common/Core/vtkSMPSelection.cmake:42 (vtk_module_find_package)
  VTK/Common/Core/CMakeLists.txt:51 (include)

Searching through the source code for VTK_SMP_IMPLEMENTATION_TYPE leads me to the VTK build instructions, which list all the possible values. For now, I’ll just remove this define from the cmake command line.

cmake -GNinja -DPARAVIEW_USE_PYTHON=ON -DPARAVIEW_USE_MPI=ON -DCMAKE_BUILD_TYPE=Release ../paraview

This fails because MPI cannot be found (just like on Windows).

CMake Error at VTK/CMake/vtkModule.cmake:4578 (message):
  Could not find the MPI external dependency.
Call Stack (most recent call first):
  VTK/CMake/vtkModule.cmake:5172 (vtk_module_find_package)
  VTK/Utilities/MPI/CMakeLists.txt:1 (vtk_module_third_party_external)

Installing Open MPI using brew addresses this.

brew install openmpi

The next error is about Qt5 missing:

CMake Warning at VTK/CMake/vtkModule.cmake:4572 (find_package):
  By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5" (requested
  version 5.9) with any of the following names:

    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.  If "Qt5" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  VTK/GUISupport/Qt/CMakeLists.txt:43 (vtk_module_find_package)


CMake Error at VTK/CMake/vtkModule.cmake:4578 (message):
  Could not find the Qt5 external dependency.
Call Stack (most recent call first):
  VTK/GUISupport/Qt/CMakeLists.txt:43 (vtk_module_find_package)

Install it using the command from https://formulae.brew.sh/formula/qt@5

brew install qt@5

The summary contains more information than the ninja or Open MPI installations did.

==> Summary
🍺  /opt/homebrew/Cellar/qt@5/5.15.5_1: 10,846 files, 344.2MB
==> Running `brew cleanup qt@5`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> qt@5
We agreed to the Qt open source license for you.
If this is unacceptable you should uninstall.

qt@5 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have qt@5 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/qt@5/bin:$PATH"' >> ~/.zshrc

For compilers to find qt@5 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/qt@5/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/qt@5/include"

The same Qt error is displayed though. I use the approach from https://github.com/Cockatrice/Cockatrice/issues/205#issuecomment-48705334

cmake -GNinja -DPARAVIEW_USE_PYTHON=ON -DPARAVIEW_USE_MPI=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/qt@5/ ../paraview

We finally have a successful cmake run. Now we time the ninja build. It takes only 39 minutes on my MacBook M1.

date; time ninja; date
ParaView Built on macOS

Article info




Leave a Reply

Your email address will not be published. Required fields are marked *