This is the final project for the course, General-Purpose GPU Programming @ NTU CSIE.
We model and simulate fluid-like materials, such as snow and sand, using material point method. MPM is implemented in C++ & CUDA. And OpenGL is used for real-time result viewing. Besides, for high quality rendering, we use NVIDIA GVDB + OptiX Ray Tracing Engine.
The material point method (MPM) is a numerical technique used to simulate the behavior of solids, liquids, gases, and any other continuum material. In the MPM, a continuum body is described by a number of small Lagrangian elements referred to as 'material points'. These material points are surrounded by a background mesh/grid that is used only to calculate gradient terms such as the deformation gradient. For more information, please go to Material point method - Wikipedia
For more details about implementation, please go to our Project Page
The following libraries has been put into this repository,
For high quality rendering as screenshots,
To generate videos from saved rendered frames,
Source code are put in inc/
and src/
. To compile the simulation program, simply type make
. Compiled objects would appear in obj/
, and there would be the executable file in root directory of the repository.
To compile the rendering program, GVDB-Voxels library and Nvidia OptiX ray tracing engine are needed. So please build gvdb-library at first. Then build the code in directory, gPointCloud/
, which is modified from the sample code. For more information, please go to NVIDIA/gvdb-voxels.
First of all, run make
to generate the executable. Then prepare your own configuration file with format as follows:
model=MODEL
where MODEL
is a JSON file formatted as:
{
"model1": {
"path": "PATH",
"translate": [50.0, 0.0, 50.0],
"scale": 0.5,
"mass": 0.000026,
"velocity": [0.0, -10.0, 0.0],
"hardening": 15.0,
"young": 1.4e5,
"poisson": 0.2,
"compression": 5.0e-2,
"stretch": 5.0e-2
}
}
The PATH
is the ascii point cloud file where each line contains three values x y z
seperated by a single space, and other parameters depend on your model setting. Finally, run
./test --config CONFIG_FILE
to simulate using MPM and render with OpenGL!
- Multi-species simulation of porous sand and water mixtures
- A material point method for snow simulation
Issues and pull requests are welcomed, so are stars! ^_^ Feel free to contact project owner Sung Tzu-Wei, or contributors Yist Lin and Chen Li-Yu.