Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_fluids.h
Go to the documentation of this file.
1
10#ifndef __N_FLUID_HEADER
11#define __N_FLUID_HEADER
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
22#include "allegro5/allegro.h"
23#include <allegro5/allegro_primitives.h>
24#include "nilorea/n_list.h"
26
27#ifndef _z
29#define _z(__fluid, __component) ((__fluid->__component) > (__fluid->negative_float_tolerance) && (__fluid->__component) < (__fluid->positive_float_tolerance))
30#endif
31
32#ifndef _zd
34#define _zd(__fluid, __value) ((__value) > (__fluid->negative_float_tolerance) && (__value) < (__fluid->positive_float_tolerance))
35#endif
36
38typedef struct N_FLUID_THREAD_PARAMS {
40 void* ptr;
42 size_t x_start;
44 size_t x_end;
46 size_t y_start;
48 size_t y_end;
50
52typedef struct N_FLUID {
54 size_t numX;
56 size_t numY;
58 size_t numZ;
60 size_t numCells;
62 size_t numIters;
64 double density;
66 double dt;
68 double h;
70 double gravity;
79
84
88 double cScale;
89
91 double* u;
93 double* newU;
94
96 double* v;
98 double* newV;
99
101 double* p;
103 double* s;
104
106 double* m;
108 double* newM;
109
118
119} N_FLUID;
120
121int destroy_n_fluid(N_FLUID** fluid);
122N_FLUID* new_n_fluid(double density, double gravity, size_t numIters, double dt, double overRelaxation, size_t sx, size_t sy);
123
124int n_fluid_integrate(N_FLUID* fluid);
126int n_fluid_extrapolate(N_FLUID* fluid);
127
128double n_fluid_sampleField(N_FLUID* fluid, double x, double y, uint32_t field);
129double n_fluid_avgU(N_FLUID* fluid, size_t i, size_t j);
130double n_fluid_avgV(N_FLUID* fluid, size_t i, size_t j);
131
132int n_fluid_advectVel(N_FLUID* fluid);
133int n_fluid_advectSmoke(N_FLUID* fluid);
134
135int n_fluid_simulate(N_FLUID* fluid);
136int n_fluid_simulate_threaded(N_FLUID* fluid, THREAD_POOL* thread_pool);
137
138int n_fluid_setObstacle(N_FLUID* fluid, double x, double y, double vx, double vy, double r);
140
141ALLEGRO_COLOR n_fluid_getSciColor(N_FLUID* fluid, double val, double minVal, double maxVal);
142int n_fluid_draw(N_FLUID* fluid);
143
148#ifdef __cplusplus
149}
150#endif
151
152#endif
Structure of a generic LIST container.
Definition n_list.h:39
double * newU
holder for newU arrays
Definition n_fluids.h:93
size_t numY
number of cells in Y
Definition n_fluids.h:56
size_t y_start
y start point
Definition n_fluids.h:46
double fluid_production_percentage
size of the produced fluid
Definition n_fluids.h:86
bool showSmoke
display fluid as a colored cloud instead of black and white, can be combined with showPressure
Definition n_fluids.h:74
size_t numX
number of cells in X
Definition n_fluids.h:54
LIST * advectSmoke_chunk_list
preprocessed list of threaded procs parameters, for n_fluid_advectSmoke
Definition n_fluids.h:117
double overRelaxation
over relaxation
Definition n_fluids.h:72
bool showPressure
display fluids pressures as color variations, can be combined with showSmoke
Definition n_fluids.h:78
void * ptr
pointer to data which will be used in the proc
Definition n_fluids.h:40
double positive_float_tolerance
fluid double positive precision setting
Definition n_fluids.h:83
LIST * solveIncompressibility_chunk_list
preprocessed list of threaded procs parameters, for n_fluid_solveIncompressibility
Definition n_fluids.h:113
size_t x_end
x end point
Definition n_fluids.h:44
bool showPaint
activate a fonky palette, override smoke and pressure display
Definition n_fluids.h:76
double * u
holder for u arrays
Definition n_fluids.h:91
LIST * integrate_chunk_list
preprocessed list of threaded procs parameters, for n_fluid_integrate
Definition n_fluids.h:111
double * newV
holder for newV arrays
Definition n_fluids.h:98
double dt
time between frames
Definition n_fluids.h:66
double * s
holder for s arrays
Definition n_fluids.h:103
double * v
holder for v arrays
Definition n_fluids.h:96
size_t numCells
total number of cells
Definition n_fluids.h:60
size_t numIters
number of fluid processing iterations for each frame
Definition n_fluids.h:62
double density
density of the fluid (not working ?)
Definition n_fluids.h:64
LIST * advectVel_chunk_list
preprocessed list of threaded procs parameters, for n_fluid_advectVel
Definition n_fluids.h:115
double * m
holder for m arrays
Definition n_fluids.h:106
double cScale
scale used to deduce cellX and cellY from screen/window width and height
Definition n_fluids.h:88
double * newM
holder for newM arrays
Definition n_fluids.h:108
size_t numZ
number of cells in Z
Definition n_fluids.h:58
double * p
holder for p arrays
Definition n_fluids.h:101
size_t x_start
x start point
Definition n_fluids.h:42
double gravity
gravity on Y
Definition n_fluids.h:70
size_t y_end
y end point
Definition n_fluids.h:48
double negative_float_tolerance
fluid double negative precision setting
Definition n_fluids.h:81
double n_fluid_avgV(N_FLUID *fluid, size_t i, size_t j)
compute the average V value at a fluid position using it's surrounding
Definition n_fluids.c:392
int n_fluid_draw(N_FLUID *fluid)
draw a N_FLUID on screen / targert bitmap
Definition n_fluids.c:781
int n_fluid_simulate_threaded(N_FLUID *fluid, THREAD_POOL *thread_pool)
a threaded version of N_FLUID global processing function
Definition n_fluids.c:579
int n_fluid_simulate(N_FLUID *fluid)
non threaded version of N_FLUID global processing function
Definition n_fluids.c:562
double n_fluid_avgU(N_FLUID *fluid, size_t i, size_t j)
compute the average U value at a fluid position using it's surrounding
Definition n_fluids.c:375
double n_fluid_sampleField(N_FLUID *fluid, double x, double y, uint32_t field)
compute a sample value at a field position
Definition n_fluids.c:320
ALLEGRO_COLOR n_fluid_getSciColor(N_FLUID *fluid, double val, double minVal, double maxVal)
get fonky colors for the fluid
Definition n_fluids.c:738
int n_fluid_extrapolate(N_FLUID *fluid)
non threaded extrapolation function
Definition n_fluids.c:298
int n_fluid_advectSmoke(N_FLUID *fluid)
non threaded version of add smoke function
Definition n_fluids.c:529
int n_fluid_solveIncompressibility(N_FLUID *fluid)
non threaded version of incompressibility solving function
Definition n_fluids.c:260
int n_fluid_resetObstacles(N_FLUID *fluid)
reset the obstacles set in a N_FLUID
Definition n_fluids.c:678
int n_fluid_integrate(N_FLUID *fluid)
non threaded version of integration function
Definition n_fluids.c:205
int n_fluid_setObstacle(N_FLUID *fluid, double x, double y, double vx, double vy, double r)
set an obstacle in the fluid grid
Definition n_fluids.c:651
int destroy_n_fluid(N_FLUID **fluid)
ddestroy a fluid structure
Definition n_fluids.c:44
int n_fluid_advectVel(N_FLUID *fluid)
non threaded version of add velocities function
Definition n_fluids.c:449
N_FLUID * new_n_fluid(double density, double gravity, size_t numIters, double dt, double overRelaxation, size_t sx, size_t sy)
!
Definition n_fluids.c:71
structure of a fluid
Definition n_fluids.h:52
structure passed to a threaded fluid process
Definition n_fluids.h:38
Structure of a trhead pool.
List structures and definitions.
Thread pool declaration.