Git Product home page Git Product logo

mpm's Introduction

This repository contains code for a simple CUDA accelerated material point method simulation.

Here is a demo of the simulation which was rendered offline using Blender. (Click to view)

Watch the video

Running using Docker

The easiest way to run the code is using the provided Docker configuration. Build the image by running docker build -t mpm . from the project directory. Once built, the image can be run with ./docker_run.sh. Any arguments passed in, will be passed on to the simulation program. Check include/options.h for a full list of arguments.

Here are some example simulations to try:

./docker_run.sh --scene scenes/rubber_duck.toml -N 16 --particle-count 10000
./docker_run.sh --scene scenes/liquid_bunny.toml -N 32 --particle-count 1000000
./docker_run.sh --scene scenes/snowman.toml -N 64 --particle-count 500000

You should see the real-time debug view pop up. It looks 2D, but the simulation is actually run in 3D. Debug view

To export meshes add the --save-dir out/ as an option.

./docker_run.sh --save-dir out/

Reconstructed meshes will be written to the directory out/meshes.

Installing natively

Our code was developed on Linux (Ubuntu, specifically). It should work anywhere, of course, but has never been tested on Windows or Mac. The below instructions will therefore be specific to Ubuntu. Please feel free to apply them to the system of your choice analogously.

We use cmake to build stuff.

Dependencies

The following dependencies are required:

  • OpenGL
  • GLFW 3
  • OpenMP (Kind-of required. If not available, set the cmake option USE_OPENMP to OFF)
  • Boost
  • Eigen3

And these are optional:

  • Partio (just for exporting particles)
  • GTest (but of course there are no bugs, so...)

Installing dependencies:

On Ubuntu, the following should do:

sudo apt install libeigen3-dev libgtest-dev libboost1.65-dev libglfw3-dev libomp-dev cmake

Building

Default

The usual cmake procedure

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j

Using Partio (optional)

We make use of the Partio for saving particles to a file. To install the library, I would recommend creating a local install folder and installing it there. Roughly, the installation goes like this:

mkdir ~/local_build # Or anywhere else you would like to install the library.
export LOCAL_BUILD=~/local_build
git clone https://github.com/wdas/partio.git
cd partio
make -j prefix=$LOCAL_BUILD install

Create a build directory, run cmake to generate the makefile, run make, then run the binary.

mkdir build && cd build
cmake -DLOCAL_INCLUDE_DIR=$LOCAL_BUILD/include -DLOCAL_LIB_DIR=$LOCAL_BUILD/lib -DCMAKE_BUILD_TYPE=Release ..
make -j

Running

From the build directory, type

./bin/mpm --scene ../scenes/snowman.toml

This should open a small 2D visualization of the simulation with a yellow snowman and start simulating.

Some command line options are available; these are the most important ones:

dt timestep (default 1e-4)

N number of MPM-grid cells per dimension (default 60)

particle-count number of particles per unit cube. Note: the simulation domain is a unit cube. (default 500000)

save-dir where to save the output (mesh or particles) (default is empty, so no output is generated)

laplacian smooth whether to apply laplacian smoothing to the output mesh (0 or 1, default is 0).

For further options, please refer directly to the file options.h.

Example usage:

./bin/mpm -N 80 --dt 1e-4 --save-dir ./output/ --laplacian_smooth 0

Credits

This project was created in collaboration Simon Duenser. The simulation implements the method as detailed in the paper

Hu, Yuanming, et al. "A moving least squares material point method with displacement discontinuity and two-way rigid body coupling." ACM Transactions on Graphics (TOG) 37.4 (2018): 1-14.

Their simplified implementation helped us get started.

The license is GPLv3 due to the marching cubes library used from libigl.

mpm's People

Contributors

kekeblom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

liudeke syguan96

mpm's Issues

Cannot run the program

I built the program as given in the README and I keep getting the error:


./bin/mpm --scene ../scenes/snowman.toml
Loading scene file: ../scenes/snowman.toml
Warning: readOBJ() ignored non-comment line 1:
  version https://git-lfs.github.com/spec/v1
Warning: readOBJ() ignored non-comment line 2:
  oid sha256:24a15dfec58c5e82d2a33648a54860fc788730ef7fac8b0ed14262a5e7113ae0
Segmentation fault (core dumped)

Any help you can provide?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.