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

发布于 2024-10-15 19:53:35 字数 451 浏览 2 评论 0原文

我正在尝试在 HTML5 画布上编写流体动态模拟器。我在互联网上发现了一些非常酷的东西 /a> 看起来总是一个有希望的起点,但它们都是基于细胞的,并且使用了一些疯狂的数学。

我希望能够添加任意障碍(任何方向的线、圆圈等)以使事情变得更有趣,但我不知道从哪里开始。

有谁知道一些相当简单的流体模拟方程,其中包括任何方向的障碍物?或者,有人可以向我指出采用上述示例之一并添加障碍所需的数学知识吗?

我知道这个问题与我应该问 mathoverflow 的问题接壤,但他们似乎更关注理论问题。如果我在错误的区域,请道歉。我真的不知道从哪里开始 - 如果有人以前从事过具有任意障碍物的流体模拟,我可以使用一些指针。

在这里,准确性让位于简单性。

谢谢!

I'm trying to write a fluid dynamic simulator on the HTML5 canvas. I've found some real damn cool stuff on the internets that always look like a promising starting point, but they are all cell-based and use some crazy math.

I'd like to be able to add arbitrary obstacles (lines of any orientation, circles, etc) to make things more interesting, but I've no idea where do begin.

Does anyone know of some fairly simple equations for fluid simulation that include obstacles of any orientation? Alternatively, could anybody point me towards the math required to take one of the above examples and add obstacles?

I know that this question borders on something I should ask mathoverflow, but they seem more into the theory stuff. Apologies if I'm in the wrong area. I don't really know where to begin - if anyone's worked on fluid simulation with arbitrary obstacles before, I could use some pointers.

Accuracy takes a back seat to simplicity here.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

無心 2024-10-22 19:53:35

流体动力学不是一个简单的话题。他们在其他网站上喜欢的所有“理论”正是这个领域的运作方式。

流体流动最简单的例子是二维不可压缩无旋层流。我首先要调查这一点。

但这不是一个容易的领域。市面上没有“十天自学计算流体动力学”的书。

Fluid dynamics isn't a simple topic. All that "theory" they like over at the other site is just the way this field works.

The simplest example of fluid flow is 2D, incompressible, irrotational, laminar flow. I'd start by looking into that.

But it's not an easy field. There's no "Teach Yourself Computational Fluid Dynamics In Ten Days" books out there.

ゃ懵逼小萝莉 2024-10-22 19:53:35

介绍面向图形的流体模拟的最佳书籍是 Robert Bridson 所著的《计算机图形学流体模拟》(免责声明:他是我的博士生导师)。
http://www.cs.ubc.ca/~rbridson/fluidbook/

最终,涉及大量数学知识,但也有大量代码示例可以为不太喜欢数学的人澄清问题。

它主要涵盖您提到的基于细胞的方法。另一个主要替代方案是“平滑粒子流体动力学”或 SPH。如果您想开始的话,Matthias Muller 有一些关于这方面的论文。

The best book to read for introduction to graphics-oriented fluid simulation is "Fluid Simulation for Computer Graphics" by Robert Bridson (disclaimer: he was my PhD advisor).
http://www.cs.ubc.ca/~rbridson/fluidbook/

Ultimately, there is plenty of math involved, but there's also plenty of code examples to clarify things for the less math-inclined.

It covers mainly the cell-based approach you mentioned. The other main alternative is "Smoothed Particle Hydrodynamics" or SPH. Matthias Muller has some papers about this if you're looking to get started.

七色彩虹 2024-10-22 19:53:35

如果您不关心真正的准确性,而只是想要一些炫酷的东西,我开发了一个非常简单的基于压力的模拟,它在 Javascript 中提供了一个非常快速的交互界面。您可以在此处查看它。

If you don't care about real accuracy but just want something swooshy and cool, I developed a very simple pressure-based simulation that delivers a very fast interactive interface in Javascript. You can see it here.

丶情人眼里出诗心の 2024-10-22 19:53:35

以下是您需要了解的有关流体动力学和模拟的所有内容的相当不错的列表:
http://www.dgp.toronto.edu/~stam/reality /Research/pub.html

此外,您还应该检查网站,您可以在其中找到用 Java 编写并传输到 Actionscript3 的具体源代码。它有很好的文档记录,因此传输到 Javascript 应该不成问题。

Here is a pretty decent list of everything You need to know about fluid dynamics and simulation:
http://www.dgp.toronto.edu/~stam/reality/Research/pub.html

Also you should check this site, where you can find the concrete source code written in Java and transported to Actionscript3. It's pretty documented, so shouldn't be a problem to transport to Javascript.

一身仙ぐ女味 2024-10-22 19:53:35

我已经尝试过,只是为了让您知道任何类型的流体模拟都有一个重要部分,称为投影,它的计算量很大,即使在 CPU 上也需要很多时间,而且您可能很清楚,由于多种原因,Javascript 相当慢。

I have tried that and just to let you know there is an important part of Fluid simulation of any kind called Projection which is computationally extensive even on CPU it takes much and you might well know that Javascript is quite slow for many reasons.

猫九 2024-10-22 19:53:35

我在这里找到了非常简单的 Fluid js 代码:

https://codepen.io/aecend/pen/WbONyK< /a>

没有“疯狂的数学”:

function update_Pressure(cell_data) {

//This calculates the collective pressure on the X axis by summing the surrounding velocities
var pressure_x = (
    cell_data.up_left.xv * 0.5 //Divided in half because it's diagonal
    + cell_data.left.xv
    + cell_data.down_left.xv * 0.5 //Same
    - cell_data.up_right.xv * 0.5 //Same
    - cell_data.right.xv
    - cell_data.down_right.xv * 0.5 //Same
);

//This does the same for the Y axis.
var pressure_y = (
    cell_data.up_left.yv * 0.5
    + cell_data.up.yv
    + cell_data.up_right.yv * 0.5
    - cell_data.down_left.yv * 0.5
    - cell_data.down.yv
    - cell_data.down_right.yv * 0.5
);

//This sets the cell pressure to one-fourth the sum of both axis pressure.
cell_data.pressure = (pressure_x + pressure_y) * 0.25;

}

/*
该函数使用以下函数更新单个单元的速度值
相邻细胞的速度。
*/
函数 update_velocity(cell_data) {

/*
This adds one-fourth of the collective pressure from surrounding cells to the 
cell's X axis velocity.
*/
cell_data.xv += (
    cell_data.up_left.pressure * 0.5
    + cell_data.left.pressure
    + cell_data.down_left.pressure * 0.5
    - cell_data.up_right.pressure * 0.5
    - cell_data.right.pressure
    - cell_data.down_right.pressure * 0.5
) * 0.25;

//This does the same for the Y axis.
cell_data.yv += (
    cell_data.up_left.pressure * 0.5
    + cell_data.up.pressure
    + cell_data.up_right.pressure * 0.5
    - cell_data.down_left.pressure * 0.5
    - cell_data.down.pressure
    - cell_data.down_right.pressure * 0.5
) * 0.25;

/*
This slowly decreases the cell's velocity over time so that the fluid stops
if it's left alone.
*/
cell_data.xv *= 0.99;
cell_data.yv *= 0.99;

}

I found pretty simple js code of fluid here:

https://codepen.io/aecend/pen/WbONyK

There no "crazy math":

function update_pressure(cell_data) {

//This calculates the collective pressure on the X axis by summing the surrounding velocities
var pressure_x = (
    cell_data.up_left.xv * 0.5 //Divided in half because it's diagonal
    + cell_data.left.xv
    + cell_data.down_left.xv * 0.5 //Same
    - cell_data.up_right.xv * 0.5 //Same
    - cell_data.right.xv
    - cell_data.down_right.xv * 0.5 //Same
);

//This does the same for the Y axis.
var pressure_y = (
    cell_data.up_left.yv * 0.5
    + cell_data.up.yv
    + cell_data.up_right.yv * 0.5
    - cell_data.down_left.yv * 0.5
    - cell_data.down.yv
    - cell_data.down_right.yv * 0.5
);

//This sets the cell pressure to one-fourth the sum of both axis pressure.
cell_data.pressure = (pressure_x + pressure_y) * 0.25;

}

/*
This function updates the velocity value for an individual cell using the
velocities of neighboring cells.
*/
function update_velocity(cell_data) {

/*
This adds one-fourth of the collective pressure from surrounding cells to the 
cell's X axis velocity.
*/
cell_data.xv += (
    cell_data.up_left.pressure * 0.5
    + cell_data.left.pressure
    + cell_data.down_left.pressure * 0.5
    - cell_data.up_right.pressure * 0.5
    - cell_data.right.pressure
    - cell_data.down_right.pressure * 0.5
) * 0.25;

//This does the same for the Y axis.
cell_data.yv += (
    cell_data.up_left.pressure * 0.5
    + cell_data.up.pressure
    + cell_data.up_right.pressure * 0.5
    - cell_data.down_left.pressure * 0.5
    - cell_data.down.pressure
    - cell_data.down_right.pressure * 0.5
) * 0.25;

/*
This slowly decreases the cell's velocity over time so that the fluid stops
if it's left alone.
*/
cell_data.xv *= 0.99;
cell_data.yv *= 0.99;

}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文