c++ - 流体模拟不可压缩流体

标签 c++ simulation fluid-dynamics

在流体模拟基础上paper by Stam ,流体被建模为密度网格。密度“通常取一个介于零和一之间的值”,但可以更大。边界基本上按照论文中的描述实现:

A simple way of implementing internal boundaries is to allocate a Boolean grid which indicates which cells are occupied by an object or not. Then we simply have to add some code to the set_bnd() routine to fill in values for the occupied cells from the values of their direct neighbors.

int surround = !bound[IX(i+1,j)] + !bound[IX(i-1,j)] + !bound[IX(i,j+1)] + !bound[IX(i,j-1)];
if (!surround) x[IX(i,j)] = 0;
else
    x[IX(i,j)] = ((bound[IX(i+1,j)] ? 0 : x[IX(i+1,j)]) +
                  (bound[IX(i-1,j)] ? 0 : x[IX(i-1,j)]) +
                  (bound[IX(i,j+1)] ? 0 : x[IX(i,j+1)]) +
                  (bound[IX(i,j-1)] ? 0 : x[IX(i,j-1)])) / surround;

密度法适用于空气、火或烟等可压缩流体。是否有一种方法可以更改边界例程,使密度(仅限于一种流体)限制为一个值,例如 1?这将代表一个完全充满水粒子的细胞。大于一个的密度将不得不被推到相邻的细胞中。 Stam 列出了扩展的想法,但没有包括如何:

Another extension is to use this solver as a basis to animate water flows. In this case there are two fluids with different densities: water and air. The air is usually not modeled and the solver is harder to implement for the following reason: the domain of the water fluid changes over time and has to be tracked somehow and the correct boundary conditions have to be applied at the interface. The water region can be tracked using particles which simply move through the fluid as done by Foster and Metaxas [Foster96] or can be tracked with a combination of particles and level sets [Foster01,Enright02].

最佳答案

我认为您应该说“具有自由表面的不可压缩流”。

这是一个难题,因为您必须跟踪自由表面的位置作为空间和时间的函数。

您命名的所有流体的密度都不等于 1;论文必须以某种你不清楚的方式规范化它们。

如何追踪自由表面?一个细胞可以同时有两种液体,还是全是水还是全是空气?如果是后者,则意味着您必须在表面附近有一个非常精细的网格才能解析诸如在海洋中传播的波浪之类的东西。

对于这个问题,您可以将水和空气都视为不可压缩的,即使您知道气体不是。当马赫数小于 0.1 时,空气的速度足够低,因此压缩效应很小。

关于c++ - 流体模拟不可压缩流体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34797667/

相关文章:

c++ - 在 DirectX 10 中导入 .x 模型

c++ - 从字符串流增加字数

python - 优化类模拟代码?

simulation - 模拟用 Chisel 编写的 CPU 设计

c++ - 函数的编译时检测

C++模拟按下等号(=)和问号(?)

javascript - 流体动力学模拟,有障碍物

loops - Modelica:对静态求解器进行编程,使其在仿真过程中收敛到解。差价合约示例

c++ - 剥离成员函数的正确方法