2D mls-mpm fluid learning&implementation (math)

code

Quadratic B-spline weight

used to scatter particle to grid or back from grid.

in actual code(discretely & calculated without judging input range). for each cell in 9 surrounding cells is in . so there has to be 6 value for and . According to paper, takes as input( Below Eq.1 ). And the cell center is defined as the center of the square, so the input will be .

(!notice: is vector, and is vector operation.)

refer to and (can be reversed). and both are shifted to and are symmetrical about .

(对于一个粒子来说其只能落在一个网格中,现在需要其距离其所属的网格的中心的距离(x,y 2个方向分开)计算差值的系数,该距离的范围是。在实现中,上述的方法可以的到与该距离有关的3个差值系数,分布如下) quadratic b spline

gradient of weight

(!notice:mls-mpm use to calculate . Traditional mpm : .)

is the derivative of .

particle to grid (first phase)

scatter particle mass to grid

for each particle, just loop through 9 surrounding cells and calculate each cell’s weight and sum together.(Eq.172)

momentum (1)

(Eq.173). !notice: 1. is a matrix quantity stored at each particle(like mass, velocity). 2. , which is matrix derived by preserving affine motion during the transfer(通过传输过程中保持仿射运动来得到). 3. In implementation, can be stored together as the affine momentum matrix at each particle. 4. Conveniently, is for quadratic and for cubic , which remain const. 5. (affine momentum matrix) defined in APIC paper, is the velocity derivatives. can be seen as

particle to grid(second phase)

estimate particle volume

summing up neighborhood's weighted mass contribution. (Eq.150-152) for each particle, volume is mass / density.

constitutive equation for isotropic fluid

stress

- pressure part

  • viscosity part velocity gradient (Eq.17) the velocity derivatives(linear) is . So the gradient should be so the viscosity part of stress is

Fused force/momentum(2) on grid node

(Eq.16) for quadratic (const ).

In implementation, for each grid node surrounding current particle !notice: as part of the process of fusing the momentum and force update for mls-mpm, we multiply it by .

Update grid

current we have calculate the mass and momentum of each grid node. we need to convert momentum to velocity and apply gravity. Boundary conditions current: simply let x/y component of velocity be 0.

Grid To Particles

Use APIC or PolyPIC to transfer velocities and affine/polynomial coefficients from the grid to the particles. (Eq.175,176) and Particle advection:

Deformation Update(Plasticity only)

No need for fluid simulation as we never use it in constitutive equation.

(Eq.181 & E1)