Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_fluids.h File Reference

Fluid management port from "How to write an Eulerian fluid simulator with 200 lines of code", by Ten Minute Physics ( https://www.youtube.com/watch?v=iKAVRgIrUOU ) More...

#include "allegro5/allegro.h"
#include <allegro5/allegro_primitives.h>
#include "nilorea/n_list.h"
#include "nilorea/n_thread_pool.h"
+ Include dependency graph for n_fluids.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  N_FLUID
 structure of a fluid More...
 
struct  N_FLUID_THREAD_PARAMS
 structure passed to a threaded fluid process More...
 

Macros

#define _z(__fluid, __component)   ((__fluid->__component) > (__fluid->negative_float_tolerance) && (__fluid->__component) < (__fluid->positive_float_tolerance))
 test if component is near zero, according to fluid's precision
 
#define _zd(__fluid, __value)   ((__value) > (__fluid->negative_float_tolerance) && (__value) < (__fluid->positive_float_tolerance))
 test if value is near zero, according to fluid's precision
 

Functions

int destroy_n_fluid (N_FLUID **fluid)
 destroy a fluid simulation
 
int n_fluid_advectSmoke (N_FLUID *fluid)
 advect smoke density field
 
int n_fluid_advectVel (N_FLUID *fluid)
 advect velocity field
 
double n_fluid_avgU (N_FLUID *fluid, size_t i, size_t j)
 compute average U velocity at cell
 
double n_fluid_avgV (N_FLUID *fluid, size_t i, size_t j)
 compute average V velocity at cell
 
int n_fluid_draw (N_FLUID *fluid)
 draw the fluid simulation
 
int n_fluid_extrapolate (N_FLUID *fluid)
 extrapolate fluid boundaries
 
ALLEGRO_COLOR n_fluid_getSciColor (const N_FLUID *fluid, double val, double minVal, double maxVal)
 get a scientific color for a value
 
int n_fluid_integrate (N_FLUID *fluid)
 integrate fluid velocities
 
int n_fluid_resetObstacles (N_FLUID *fluid)
 reset all obstacles
 
double n_fluid_sampleField (N_FLUID *fluid, double x, double y, uint32_t field)
 sample a field value at given coordinates
 
int n_fluid_setObstacle (N_FLUID *fluid, double x, double y, double vx, double vy, double r)
 set an obstacle in the fluid
 
int n_fluid_simulate (N_FLUID *fluid)
 run one simulation step
 
int n_fluid_simulate_threaded (N_FLUID *fluid, THREAD_POOL *thread_pool)
 run one simulation step using thread pool
 
int n_fluid_solveIncompressibility (N_FLUID *fluid)
 solve incompressibility constraint
 
N_FLUIDnew_n_fluid (double density, double gravity, size_t numIters, double dt, double overRelaxation, size_t sx, size_t sy)
 create a new fluid simulation
 

Detailed Description

Fluid management port from "How to write an Eulerian fluid simulator with 200 lines of code", by Ten Minute Physics ( https://www.youtube.com/watch?v=iKAVRgIrUOU )

Author
Castagnier Mickael aka Gull Ra Driel
Version
1.0
Date
31/12/2022

Definition in file n_fluids.h.