【Heskey带你玩模拟】流体基础
作者:互联网
首先,老规矩:
未经允许禁止转载(防止某些人乱转,转着转着就到蛮牛之类的地方去了)
B站:Heskey0
Eulerian-View
N-S:
\[\rho\frac{Dv}{Dt}=\rho g-\nabla p+\mu\nabla^2v \]\[\nabla\cdot v=0 \]operator splitting之后,分为
-
advection
\[\rho\frac{Dv}{Dt}=\rho g+\mu\nabla^2v \] -
projection : 把velocity散度投影为0
\[\rho\frac{Dv}{Dt}=-\nabla p \]\[\nabla\cdot v=0 \]
Finite difference
-
Forward difference
\[\frac{\part q}{\part x}\approx\frac{q_{i+1}-q_i}{\Delta x} \] -
backward difference
-
central difference(unbiased, 精度高)
\[\frac{\part q}{\part x}\approx\frac{q_{i+1}-q_{i-1}}{2\Delta x} \]改进:(staggered grid)
\[\frac{\part q}{\part x}\approx\frac{q_{i+1/2}-q_{i-1/2}}{\Delta x} \]
1. Advection
物理量的material derivative为0
\[\frac{Dq}{Dt}=\frac{\part q}{\part t}+v\cdot\nabla q=0 \]在Lagrangian view下,粒子上的表现为:
\[q^{n+1}=q^n \]在Eulerian View下
semi-Lagrangian :
- 假设粒子 \(q^{n+1}\) 正好运动到了grid marker(grid的中心点)
- 上一帧 \(q^n\) 的位置反算出来,然后可以通过双线性插值算出quantity
2. Projection
上下左右分别做 Finite Difference
\[\rho\frac{Dv}{Dt}=-\nabla p \]最终得到 :
\[-\frac{\Delta t}{\rho}\nabla\cdot\nabla p=-\nabla\cdot v^n \]问题转化为:Poisson problem
Boundary conditions :
-
狄利克雷boundary condition (流体顶部与空气接触的地方) (知道边界外的压力为0)
- \(p=0\) for void grids
-
诺依曼boundary condition (流体与容器接触的地方) (不知道墙的压力是多少)
- 知道压强的梯度,反推墙的压强
线性系统的解
- Direct solvers (e.g. PARDISO)
- Iterative solvers:
- Gauss-Seidel
- (Damped) Jacobi
- (Preconditioned) Krylov-subspace solvers (e.g. conjugate gradients)
Krylov-subspace solvers
很有效的linear system solvers,有很多变形,最常用的一种是conjugate gradients
Poisson equation的解
-
一般会用conjugate gradients,其中multi-grid做precondition
-
multi-grid的每一层用damped Jacobi做smoothing
-
multi-grid的最下面一层用PARDISO这个Direct solver
Hybrid Eulerian-Lagrangian Schemes (Lagrangian View + Eulerian View) :
fluid solver has two components(对于incompressible fluid solver来说):
- Advection (移动流场)
- Material derivative
- Quantity advection
- Projection (enforcing incompressibility 把速度的散度分量投影掉)
- Poisson's equation
- Boundary conditions
1. Eulerian View :
- 方便discretize,容易查找邻居,所以擅长于Projection
- Advection过程中存在数值耗散.
2. Lagrangian View :
- 擅长advection
- 难以projection,例如SPH中找邻居很复杂.
Hybrid Eulerian-Lagrangian
粒子作为一轮共鸣,网格作为二轮共鸣
- Particle to Grid
- Grid操作(projection)
- Grid to Particle
- Particle操作(Advection)
具体方法 :
PIC (Particle in cell)
- P2G, scatter velocity from particles to grid,传递时,使用kernel(靠近的点权重大)(常用Quadratic的B样条曲线)
- Grid normalization,归一化(除以权重的和,保证物理量守恒)
- pressure projection
- G2P gather velocity(自由度损耗,丢失信息)
- 数值耗散大
APIC (Affine Particle in cell) : 推导及其复杂,实现非常简单
-
P2G, 除了velocity还会转移局部的affine速度场
grid_v = weight*(v + affine)
-
更新affine
- 在Particle上记录更多信息,Particle上记录了6个自由度(除了x,y方向速度之外,增加了4个,拉伸,剪切等)
PolyPIC(poly particle in cell)
- APIC的升级版,在Particle上记录更多自由度
MPM(Material Point Method)
MLS-MPM(Moving Least Squares MPM)
- 基于APIC
标签:frac,Particle,nabla,Heskey,流体,part,grid,rho,模拟 来源: https://www.cnblogs.com/Heskey0/p/16182848.html