SPlisH SPlasH

Back to Index

You still there? Ok, time to use CMake.

Now, we will compile SPlisH SPlasH via GIT. To keep things organized, I created a directory in miniconda/envs/DeepFluid/GIT. Then, I cloned the repository by:

  • git clone https://github.com/InteractiveComputerGraphics/SPlisHSPlasH.git

The Deep Fluid readme needs SPlisH SPlasH 2.4, because this version compiles the two binaries for building the dataset. You can find the released versions here, and the needed version here [1]. One of these binaries have a Graphical User Interface. When the program is compiled within WSL, the GUI won't show. But a version compiled under Windows, with "exe" extension, will show it, and the WSL terminal can call it with GUI.[2]

So, change to the correct release:

  • cd SPlisHSPlasH
  • git checkout 2.4.0
  • sudo apt-get install freeglut3-dev
    • Do a sudo install, so CMake will find it. FreeGlut is another lib that other programs may need. Leave it visible to everyone.

There is a problem to compile the Volume Sampling and the Dynamic and Static Boundary Simulator. So, just put the following lines in the CMakeLists of both, just below the endif() of if(WIN32), right in the begining of the file of the two simulators, and in the beginning of the file for the volume sampling.

option (USE_OpenMP "Use OpenMP" ON)
if(USE_OpenMP)
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
endif()

In the main CMakeLists, you may write this anywhere, to avoid a warning of conflicting OpenGL versions between legacy and vendor:
  • set(OpenGL_GL_PREFERENCE GLVND)

Optional but recomendedActivate the neighborhood search with Cuda to speed up greatly the simulations. To do so, add the following lines right before "enable_language(CUDA)" in "SPlisHSPlasH/CMake/NeighborhoodSearch.cmake" (or in the main CMakeLists, anywhere on the top of the file):
  • set(CUDA_PATH "/usr/local/cuda")
  • set(CUDAToolkit_ROOT "/usr/local/cuda")
  • set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin/nvcc")

In the same "NeighborhoodSearch.cmake" file, inside "ExternalProject_Add ( Ext_NeighborhoodSearch ... )", add the following options to ensure that the correct path for the Nvidia compiler is passed:
  • -DCUDA_PATH=${CUDA_PATH}
  • -DCUDAToolkit_ROOT=${CUDAToolkit_ROOT}
  • -DCMAKE_CUDA_COMPILER=${CMAKE_CUDA_COMPILER}

If the error " CUB/Thrust requires C++14." appears, change the C++ setting inside the CMakeLists of the extern/cuNSearch/src/Ext_NeighborhoodSearch (in line 21, maybe)
  • set(CMAKE_CXX_STANDARD 14) 
 
This way, CMake will correctly find the Cuda compiler within WSL, not the one in Windows. The file that does this search is in "/usr/local/share/cmake-3.20/Modules/CMakeDetermineCUDACompiler.cmake".


Optional: The fluid simulation can be slow even with Cuda. So, if you want to see if the simulation is updating or if somehow it is trapped in an infinite loop, go to "main.cpp" in DynamicBoundarySimulator directory, and write this:
  • std::cout<<"Time: "<<TimeManager::getCurrent()->getTime()<<" to "<<stopAt<<std::endl;
at the end of the funcion "timeStepNoGUI()".


Finally, we compile:
  • mkdir build && cd build 
  • cmake ..
  • make
The binaries will be at SPlisHSPlasH/bin. There is no make install here.




[1] NoteI found the pre-compiled binaries for Windows here, for version 2.3.0, so you can execute it on Windows without compiling it from the source, if you need. But 2.3.0 version does not write some files that the Deep Lagrangian Fluid net needs.

[2] Note: If you want to visualize the simulation with SPlisH SPlasH, compile it on Windows and be sure to checkout to the latest release version. The latest version in the main branch, may not include all the features with all the options available. Like, the Foam Generator does not work with Cuda yet, and it is not available for the 2.10.0 (current version as I'm writing this).


<- Back

Next ->

No comments:

Post a Comment

Global Game Jam 2024

Wow, what a weekend. The Global Game Jam is intense. But I and 3 other members manage to build a game for the theme "Make me laugh&quo...