Modernized Moving Particle Semi-implicit/Simulation method code written in C++.
- Git
- cmake (newer than 3.9)
- C++ 17 compiler
- OpenMP 5.0 and above (optional)
- Doxygen and Graphviz (optional, for building documents)
- Install dependencies as follows before the first build.
git submodule update --init eigen
- It's easier to do it in Visual Studio Code as shown later, but it's better to do it in command line for your understanding.
cmake -S . -B build # Generate build system
# -S: Source tree. The location of CMakeLists.txt
# -B: Build tree. Directory for storing products for builds
cmake --build build # Execute build- You don't have to make
builddirectory (mkdir build) and move to the directory (cd build), thanks to the-B buildoption. Thebuilddirectory will be automatically generated if you don't have one.
Get-ChildItem result/dambreak -Include *.* -Recurse | del # remove all folders/files in result/dambreak
./build/mps.exe input/dambreak/settings.yml 2> result/dambreak/error.log | Tee-Object -FilePath "result/dambreak/console.log" # run simulationThe execution command consists of three parts.
- Pass the location of the input file and execute.
./build/mps.exe input/dambreak/settings.yml
- Change standard error output to the specified file.
2> result/dambreak/error.log - Save the console output to the specified file.
Tee-Object -Filepath "result/dambreak/console.log"
mkdir -p result/dambreak/ # remove all folders/files in result/dambreak
./build/mps input/dambreak/settings.yml 2> result/dambreak/error.log | tee result/dambreak/console.log # run simulation(1). Standard (Error) Output
The output of a c++ program includes standard output and standard error output.
The standard output comes from std::cout or printf(),
while the standard error output comes from std::cerr or fprintf(stderr, ).
By default, both the standard output and the standard error output will be shown in the console.
Changing the output destination is called "redirect", and can be accomplished with the > command.
For example, the standard output of the command below
will be written to result.log.
The standard error output will be shown in the console as usual.
./test.exe > resut.logIn the next example, the standard output will be written to result.log,
and the standard error output will be written to error.log.
./test.exe 1> result.log 2> error.log
# "1" can be omitted like below.
# ./test.exe > result.log 2> error.log(2). tee command
tee command allows us to show the standard output in the console
and save them into a file at the same time.
it sends the output of a command in two directions (like the letter T)
Foe example, the standard output of the command below will be shown in the console
and will be written to result.log at the same time.
./test.exe | tee result.log- Execute in the same way as the command line.
- Script files are prepared in the
scriptsfolder. You can just call it. - Don't use the
Launchbutton on the CMake tab. It will launch the program in a wrong directory, and it won't delete existing files.
./scripts/windows.ps1./scripts/linux.sh- You can configure
tasksto do it easily.
-
Create
.vscode/tasks.jsonfile. -
An example for Windows:
{ "tasks": [ { "label": "Execute", "type": "shell", "command": "./scripts/windows.ps1", "options": { "cwd": "${workspaceFolder}" }, "group": { "kind": "test", "isDefault": true } }, ], "version": "2.0.0" } -
Open Command Palette (
Ctrl + Shift + PorF1). Search and executeTasks: Run Test Task. It does the same thing as calling the script in the terminal.
-
You can set a keyboard shortcut to run test task. To do so, open Command Palette and move on to
Preferences: Keyboard Shortcuts. SearchTasks: Run Test Taskand set any keybinding you want.Ctrl + Shift + Tis a suggestion of the writer.
- Unlike the
launchbutton in the previous section, thedebugbutton will execute the code in the correct directory. Also, there is no need to delete existing files when debugging. So you can just press it this time.
To be written.
- The results are written in the following formats:
result/prof: Profile dataresult/vtu: VTK data
- The profile data is in the following format:
0 // time
627 // number of particles
3 -0.1 -0.1 0 0 0 0 // type x y z u v w
3 -0.1 -0.075 0 0 0 0
3 -0.1 -0.05 0 0 0 0
...
doxygen Doxyfile- You can see the documents in
doxygen/html/index.html. - If you want PDF files, you can use
makecommand in thedoxygen/latexdirectory (LaTeX is required).
Please ask the authors if you have any questions.
Read CONTRIBUTING.md for details.
MIT License
This project is under development.





