GithubHelp home page GithubHelp logo

weigert / tinyfluid Goto Github PK

View Code? Open in Web Editor NEW
22.0 1.0 2.0 35.57 MB

FV based Navier-Stokes / Transport Equation / Conservation Law Solver for Procedural World Simulation. Designed for CFD learning purposes.

C++ 100.00%
navier-stokes navier-stokes-equations pde pde-solver conservation-laws climate-model procedural-generation simulation fluid-dynamics fluid-simulation

tinyfluid's Introduction

TinyFluid

Finite-Volume based Navier-Stokes and general Transport-Equation / Conservation-Law solver

Originally written to solve fluid-dynamics problems to model physical-phenomena for procedural world generation.

Written also to be an understandable implementation of the SIMPLE / SIMPLEC algorithm in C++, based on the book "Computational Methods for Fluid Dynamics" by Ferziger and Peric. Also implements the solution of the general transport equations (differential conservation laws / PDEs) for arbitrary sources and sinks, using numerical methods, in a legible manner.

If you have questions or find something unclear, feel free to open an issue.

Pressure

Time-evolution of two gaussian pressure spikes on the central x-axis dissipating and then colliding, forming vortices. Lines indicate direction, color indicates velocity magnitude.

Features

  • Explicit and implicit time-discretization schemes of higher orders, and corresponding support for point-implicit solutions
  • Arbitrary order space-discretization operators using finite differences
  • Arbitrary order space-interpolation operators using lagrange polynomials
  • Support for 1D, 2D and 3D regular orthogonal grids (solution generated using flattened arrays though)
  • Support for arbitrary source terms for coupling transport equations

Usage

To include the numerical solver in your own program, copy the folder TinyFluid to your program and include the main file TinyFluid.h. Then you have access to the methods.

See the individual examples (e.g. the base example) for information on how to use the renderer, as well as how to construct and then solve a fluid-mechanics problem.

Compilation

Compiled using gcc C++14 on Ubuntu 18 LTS

Use the make file included to compile the examples:

sudo make all

Make sure to properly link the dependencies listed below to compile your own program. See makefile for examples.

Note: Make sure to compile with the -O3 flag so that Eigen is optimized. This will make it run orders of magnitude faster.

Dependencies

TinyFluid Core:

- Eigen C++ (Linear Algebra)
- GLM (Useful small-vector math)

Renderer (Optional):

- SDL2

Other (Optional)

- Timer Helper: pthread

To-Do

There are still some issues with the pressure correction laplace equation concerning spurious modes appearing and causing checkerboard patterns. I need to read up again on why exactly there are problems with choosing an FFD + BFD scheme. It's hard to wrap my head around.

- Write a Wiki that contains the necessary information on how this works
- Make the solver capable of handling variable cell volumes and contact areas
- Make the solver *theoretically* capable of handling 3D systems of cells

Future Desirable Applications

  1. Ocean Currents
  2. Ground Water Flow

Sources

This project was based on information from the book "Computational Methods for Fluid Dynamics" by Ferziger and Peric. Particularly chapter 7 of the latest edition (at the time of writing - January 2020) helped me in implementing the solution of the pressure coupled Navier-Stokes equation.

The code is still written 100% from scratch, as I found the Fortran77 implementation referenced in the book absolutely unintelligible.

A big thank you to Dr. Daniel Meyer-Massetti for his excellent course "Numerical Methods for Transport Phenomena" at ETH Zurich that first introduced me to numerical methods for solving PDEs. The content of that course was the strong foundation that even let me know how to begin to create this repository.

License

All source code is licensed under the MIT License.

tinyfluid's People

Contributors

weigert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tinyfluid's Issues

License?

This project looks very cool. What is the license for using the code?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.