Skip to content
Material Point Method in Javascript
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
ReadMe.md
algebra.js
folding.html
folding.js
index.html
mls-mpm.gif
mls-mpm.js

ReadMe.md

A Javascript version of Taichi's 88-line material point method

Roberto Toro, March 2019

This is a javascript version of the awesome implementation in 88 lines of c++ of the Moving Least Squares Material Point Method, by Yuanming Hu.

The original repository is https://github.com/yuanming-hu/taichi_mpm, and the c++ code can be directly downloaded from http://bit.ly/mls-mpm88. This link contains 2 files: taichi.h, with linear algebra and helper functions; and mls-mpm88.cpp with the actual implementation of the material point method.

In this javascript version, the linear algebra functions are in the algebra.js file, and the MPM code in the mls-mpm.js file (with the 88 removed, because now it's 148 lines... but there's much more comments, so we're still good).

A main tricky thing in the translation, which still is not completely solved, is that matrices in Taichi are coded transposed. In the translation, there's still a mix of functions that work transposed (svd, polar_decomp, mulMatVec), and those that don't. That makes some parts of the code a bit convoluted. Ideally, I'd like to move all the code to standard non-transposed matrix encoding.

Acknowledgements

  • Thanks to Yuanming Hu for making the C++ code available and for help on understanding it.
  • Thanks to Kevin Chapelier for making the javascript code x5 faster and reducing the initialisation from several seconds to barely noticeable.
You can’t perform that action at this time.