Skip to content

Chaganti-Reddy/flux-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flux-RS: High-Performance Fluid Dynamics Solver

Flux-RS is a 2D Computational Fluid Dynamics (CFD) simulation implemented in Rust. It utilizes the Stable Fluids algorithm (Jos Stam) to solve the Navier-Stokes equations for incompressible flow in real-time.

License Language

Technical Highlights

This project was built to explore systems programming, memory safety, and numerical analysis. Key technical features include:

  • Navier-Stokes Equations: Implements solvers for Advection, Diffusion, and Pressure Projection.
  • Linear Memory Architecture: Uses a flattened 1D array to represent 2D spatial data, optimizing for CPU cache locality and reducing pointer indirection.
  • Numerical Stability: Employs a Gauss-Seidel iterative solver for the Poisson pressure equation, ensuring incompressibility and simulation stability.
  • High Performance: Designed with Rust's "Zero-Cost Abstractions," maintaining 60+ FPS on a $100 \times 100$ grid.
  • Hardware Acceleration: Uses Macroquad for efficient GPU-accelerated rendering.

Math & Physics

The simulation follows these primary steps per frame:

  1. Diffusion: Spreading density and velocity via an implicit solver.
  2. Advection: Moving the fluid along its own velocity field using semi-Lagrangian back-tracing.
  3. Projection: Calculating a pressure field to ensure the velocity field is divergence-free (mass conservation).

Installation & Usage

Ensure you have Rust installed.

  1. Clone the repository:

    git clone https://github.com/Chaganti-Reddy/flux-rs.git
    cd flux-rs
  2. Run the simulation:

    cargo run --release

Controls

  • Left Click + Drag: Inject smoke (density) and upward force into the simulation.

Future Roadmap

  • Implement Rayon for multi-threaded parallel solvers.
  • Add Heat/Thermodynamics simulation (Boussinesq approximation).
  • Support for rigid-body obstacles within the flow.

License

Distributed under the MIT License.

About

High-Performance Fluid Dynamics Solver

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages