-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FluidSimulation2D example #71
Conversation
Here is the video for this example: https://vimeo.com/372790124 |
ddf3b42
to
92f5f09
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my. This ... this is art. And also a ton of work. Thank you. 😍
I'll try to convert this one to a web version first as it's single-threaded compared to the 3D version and thus should be simpler :)
const auto tx = T(1) - std::abs(d.x() * hInv); | ||
const auto ty = T(1) - std::abs(d.y() * hInv); | ||
return Math::max(tx * ty, T(0)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look like they could be great additions to the core math lib itself -- I'll see where these could fit.
|
||
namespace Magnum { namespace Examples { | ||
template<class T> | ||
class Array2X { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really want to make Array1X/2X/3X be part of magnum. Currently, Array1D/2D/3D in mangum only have fixed size (1-2-3 elements). Dynamic size arrays are more useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I finally got around to merge this, hopefully finishing later today -- sorry for the long and demotivating delay.)
Re Array -- I'd say there's two different use cases and I don't think combining those two (like Eigen does) makes sense. The matrices and vectors in Math
have compile-time size (2, 4, 17, ... elements) and are suited for basic geometry work where you don't want any allocations or uncontrolled memory access patterns, but definitely not for anything huge -- you don't want to use algorithms that perform well on a 4x4 matrix on a 100-element matrix, and vice versa.
For dynamic multidimensional arrays there's StridedArrayView and the way forward I see is providing a set of algorithms operating on it. Very few things are already in Math/FunctionsBatch.h, and the MeshTools provides an increasing set of mesh-oriented algos operating on top of this data structure. And with mosra/magnum#306 I'm aiming to have all those SIMD-accelerated.
The most time-consuming about all this is not the code itself, but ensuring it's all well-documented, thoroughly tested and with a consistent interface that isn't annoying to use :)
Merged as f7c060f, thanks a billion and sorry again for the extreme demotivating delay from my side. Docs online at https://doc.magnum.graphics/magnum/examples-fluidsimulation2d.html, I also managed to do an initial port to Emscripten, but need to tune the perf a bit until I can publish :) |
Hi there!
Another magnum example: FluidSimulation2D. This example has a different simulation model (APIC) than the previous FluidSimulation3D example (SPH), and run with just a single thread.
Again, you're free to modify it as you want. I have tried to tightly follow magnum coding convention.
You can write a short description for this example as "A 2D fluid simulation using Affine Particle-in-Cell (APIC) method".