Categories: Fluid Flow, Simulation

Building the VM2D Source Code

One of the challenges I have run into when reading through numerical methods/simulation papers is the dearth of source code. I was therefore pleasantly surprised to find the Vortex method for 2D flow simulation program. Of course, my luck is that the comments and docs are in Russian, which I do not understand. However, availability of the source code more than makes up for that. The publication of The VM2D Open Source Code for Incompressible Flow Simulation by Using Meshless Lagrangian Vortex Methods on CPU and GPU | IEEE Conference Publication | IEEE Xplore turns out to be the documenation. To build the source code, open a developer command prompt.

git clone https://github.com/vortexmethods/VM2D
cd VM2D
cmake .

This fails with an error about MPI missing:

-- -------------------------2D CODE-------------------------
-- Checking for module 'mpi-c'
--   Can't find mpi-c.pc in any of C:/software/strawberry/c/lib/pkgconfig
use the PKG_CONFIG_PATH environment variable, or
specify extra search paths via 'search_paths'
-- Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS)
-- Checking for module 'mpi-cxx'
--   Can't find mpi-cxx.pc in any of C:/software/strawberry/c/lib/pkgconfig
use the PKG_CONFIG_PATH environment variable, or
specify extra search paths via 'search_paths'
-- Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS)
CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindMPI.cmake:1837 (find_package_handle_standard_args)
  src/VMlib/CMakeLists.txt:31 (find_package)

StackOverflow articles e.g. Installing MPI for Windows – Stack Overflow suggest installing Microsoft MPI. I Download Microsoft MPI v10.0 from Official Microsoft Download Center but why on earth does it have an IE warning when I’m already using Edge?

Microsoft MPI v10.0 Download Page

How do I know which one I want? I’ll start with the SDK MSI.

Choose the download you want
MPI SDK Setup
asdf

The publisher certificate expired in December 2021. Shouldn’t there be a warning about that? I guess the publisher is well known and not revoked? Oh well, plough ahead and install it. Reopen the developer command prompt and run cmake . again. This time, there are no errors (and I ignore all the warnings since I have things to do). A Visual Studio solution is generated. Open VM.sln in Visual Studio 2022. Building fails with these errors:

...
3>C:\repos\edu\VM2D\src\VMcuda>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\bin\nvcc.exe"  --use-local-env ... -Wno-deprecated-gpu-targets -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_53,code=sm_53 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_62,code=sm_62 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -std=c++14 ... -o VMcuda.dir\Debug\cuLib2D.obj "C:\repos\edu\VM2D\src\VMcuda\Cuda\cuLib2D.cu"
3>nvcc fatal   : Unsupported gpu architecture 'compute_35'
...
3>Done building project "VMcuda.vcxproj" -- FAILED.
...
4>LINK : fatal error LNK1104: cannot open file 'VMcuda.lib'
4>Done building project "VM2D.vcxproj" -- FAILED.

The solution is to remove the segment -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 from VM2D/CMakeLists.txt ยท vortexmethods/VM2D (github.com). Launching the application (VM2D.exe) fails with this message: The code execution cannot proceed because msmpi.dll was not found. Reinstalling the program may fix this problem.

VM2D.exe Failing to Launch

The SDK doesn’t have that DLL, so I guess that’s what the other setup executable is for.

MPI 10.0.12498 Setup
MPI Setup

I don’t see any DLLs in that installation directory. However, mpi – msmpi.dll error message in Visual Studio C++ – Stack Overflow says reinstalling MPI is the solution. Before doing so, I run the application in Visual Studio once again and this time it launches successfully. This message is displayed: queue ERROR: file problems is not found. These files are in the VM2D/run folder. Other files will not be found though if using the run folder as the current directory.

I guess I need to translate VM2D/03_starting.rst. This is the first time I have needed to translate a web page. Looks like the problems file expects to be in the tutorials directory. Copying the file in the VM2D/run folder to the VM2D/tutorials directory allows the program to find the expect files and it appears to run now. Task manager shows 100% CPU usage on my AMD Ryzen 7 5800X 8-Core Processor. The program runs for an hour and as per VM2D/05_run.rst, creates a csv file and a snapshots directory containing vtk files. To view these files, Download ParaView and install it. Launch ParaView then open the snapshots directory (it should recognize all the vtk files as a group).

Opening snapshots

Click on the Apply button on the Properties pane (see image below).

Properties of the Snapshots

Finally, click on the Play button on the toolbar to see the animation of the snapshots. The next step will be figuring out how to use the GPU to generate these snapshots in (hopefully) much less than an hour.

Snapshots in Paraview