Nilorea Library
C utilities for networking, threading, graphics
|
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, __componant) ( (__fluid->__componant) > (__fluid->negative_float_tolerance) && (__fluid->__componant) < (__fluid->positive_float_tolerance) ) |
test if componant is near zero, according to fluid's precision More... | |
#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 More... | |
Functions | |
int | destroy_n_fluid (N_FLUID **fluid) |
ddestroy a fluid structure More... | |
int | n_fluid_advectSmoke (N_FLUID *fluid) |
non threaded version of add smoke function More... | |
int | n_fluid_advectVel (N_FLUID *fluid) |
non threaded version of add velocities function More... | |
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 More... | |
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 More... | |
int | n_fluid_draw (N_FLUID *fluid) |
draw a N_FLUID on screen / targert bitmap More... | |
int | n_fluid_extrapolate (N_FLUID *fluid) |
non threaded extrapolation function More... | |
ALLEGRO_COLOR | n_fluid_getSciColor (N_FLUID *fluid, double val, double minVal, double maxVal) |
get fonky colors for the fluid More... | |
int | n_fluid_integrate (N_FLUID *fluid) |
non threaded version of integration function More... | |
int | n_fluid_resetObstacles (N_FLUID *fluid) |
reset the obstacles set in a N_FLUID More... | |
double | n_fluid_sampleField (N_FLUID *fluid, double x, double y, uint32_t field) |
compute a sample value at a field position More... | |
int | n_fluid_setObstacle (N_FLUID *fluid, double x, double y, double vx, double vy, double r) |
set an obstacle in the fluid grid More... | |
int | n_fluid_simulate (N_FLUID *fluid) |
non threaded version of N_FLUID global processing function More... | |
int | n_fluid_simulate_threaded (N_FLUID *fluid, THREAD_POOL *thread_pool) |
a threaded version of N_FLUID global processing function More... | |
int | n_fluid_solveIncompressibility (N_FLUID *fluid) |
non threaded version of incompressibility solving function More... | |
N_FLUID * | new_n_fluid (double density, double gravity, size_t numIters, double dt, double overRelaxation, size_t sx, size_t sy) |
! More... | |
struct N_FLUID |
structure of a fluid
Definition at line 53 of file n_fluids.h.
Data Fields | ||
---|---|---|
LIST * | advectSmoke_chunk_list |
preprocessed list of threaded procs parameters, for n_fluid_advectSmoke |
LIST * | advectVel_chunk_list | preprocessed list of threaded procs parameters, for n_fluid_advectVel |
double | cScale | scale used to deduce cellX and cellY from screen/window width and height |
double | density | density of the fluid (not working ?) |
double | dt | time between frames |
double | fluid_production_percentage | size of the produced fluid |
double | gravity | gravity on Y |
double | h | |
LIST * | integrate_chunk_list |
preprocessed list of threaded procs parameters, for n_fluid_integrate |
double * | m | holder for m arrays |
double | negative_float_tolerance | fluid double negative precision setting |
double * | newM | holder for newM arrays |
double * | newU | holder for newU arrays |
double * | newV | holder for newV arrays |
size_t | numCells | total number of cells |
size_t | numIters | number of fluid processing iterations for each frame |
size_t | numX | number of cells in X |
size_t | numY | number of cells in Y |
size_t | numZ | number of cells in Z |
double | overRelaxation | over relaxation |
double * | p | holder for p arrays |
double | positive_float_tolerance | fluid double positive precision setting |
double * | s | holder for s arrays |
bool | showPaint | activate a fonky palette, override smoke and pressure display |
bool | showPressure | display fluids pressures as color variations, can be combined with showSmoke |
bool | showSmoke | display fluid as a colored cloud instead of black and white, can be combined with showPressure |
LIST * | solveIncompressibility_chunk_list |
preprocessed list of threaded procs parameters, for n_fluid_solveIncompressibility |
double * | u | holder for u arrays |
double * | v | holder for v arrays |
struct N_FLUID_THREAD_PARAMS |
structure passed to a threaded fluid process
Definition at line 38 of file n_fluids.h.
Data Fields | ||
---|---|---|
void * | ptr | pointer to data which will be used in the proc |
size_t | x_end | x end point |
size_t | x_start | x start point |
size_t | y_end | y end point |
size_t | y_start | y start point |
#define _z | ( | __fluid, | |
__componant | |||
) | ( (__fluid->__componant) > (__fluid->negative_float_tolerance) && (__fluid->__componant) < (__fluid->positive_float_tolerance) ) |
test if componant is near zero, according to fluid's precision
Definition at line 29 of file n_fluids.h.
#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
Definition at line 34 of file n_fluids.h.
int destroy_n_fluid | ( | N_FLUID ** | fluid | ) |
ddestroy a fluid structure
fluid | pointer to the structure to destroy |
Definition at line 48 of file n_fluids.c.
References __n_assert, and FreeNoLog.
int n_fluid_advectSmoke | ( | N_FLUID * | fluid | ) |
non threaded version of add smoke function
fluid | a N_FLUID ptr |
Definition at line 582 of file n_fluids.c.
References __n_assert, _z, N_FLUID_S_FIELD, n_fluid_sampleField(), N_FLUID::newM, N_FLUID::numY, N_FLUID::u, and N_FLUID::v.
Referenced by n_fluid_simulate().
int n_fluid_advectVel | ( | N_FLUID * | fluid | ) |
non threaded version of add velocities function
fluid | a N_FLUID ptr |
Definition at line 492 of file n_fluids.c.
References __n_assert, _z, n_fluid_avgU(), n_fluid_avgV(), n_fluid_sampleField(), N_FLUID_U_FIELD, N_FLUID_V_FIELD, N_FLUID::newU, N_FLUID::newV, N_FLUID::numY, and N_FLUID::v.
Referenced by n_fluid_simulate().
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
fluid | targeted N_FLUID |
i | X position in the fluid grid |
j | Y position in the fluid grid |
Definition at line 408 of file n_fluids.c.
References __n_assert, N_FLUID::numY, and N_FLUID::u.
Referenced by n_fluid_advectVel(), and n_fluid_advectVel_proc().
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
fluid | targeted N_FLUID |
i | X position in the fluid grid |
j | Y position in the fluid grid |
Definition at line 428 of file n_fluids.c.
References __n_assert, N_FLUID::numY, and N_FLUID::v.
Referenced by n_fluid_advectVel(), and n_fluid_advectVel_proc().
int n_fluid_draw | ( | N_FLUID * | fluid | ) |
draw a N_FLUID on screen / targert bitmap
fluid | the N_FLUID to draw |
Definition at line 861 of file n_fluids.c.
References __n_assert, and n_fluid_getSciColor().
int n_fluid_extrapolate | ( | N_FLUID * | fluid | ) |
non threaded extrapolation function
fluid | a N_FLUID to extrapolate |
Definition at line 333 of file n_fluids.c.
References __n_assert, N_FLUID::numX, N_FLUID::numY, N_FLUID::u, and N_FLUID::v.
Referenced by n_fluid_simulate(), and n_fluid_simulate_threaded().
ALLEGRO_COLOR n_fluid_getSciColor | ( | N_FLUID * | fluid, |
double | val, | ||
double | minVal, | ||
double | maxVal | ||
) |
get fonky colors for the fluid
fluid | targeted N_FLUID |
val | value mixer |
minVal | minimum output value |
maxVal | maximum output value |
Definition at line 827 of file n_fluids.c.
References _zd.
Referenced by n_fluid_draw().
int n_fluid_integrate | ( | N_FLUID * | fluid | ) |
non threaded version of integration function
fluid | a N_FLUID to integrate_chunk_list |
Definition at line 225 of file n_fluids.c.
References __n_assert, and _z.
Referenced by n_fluid_simulate().
int n_fluid_resetObstacles | ( | N_FLUID * | fluid | ) |
reset the obstacles set in a N_FLUID
fluid | the targeted N_FLUID |
Definition at line 756 of file n_fluids.c.
References __n_assert.
double n_fluid_sampleField | ( | N_FLUID * | fluid, |
double | x, | ||
double | y, | ||
uint32_t | field | ||
) |
compute a sample value at a field position
fluid | target N_FLUID |
x | X position in the fluid grid |
y | Y position in the fluid grid |
field | type of field wanted, one of N_FLUID_U_FIELD, N_FLUID_V_FIELD, N_FLUID_S_FIELD |
Definition at line 359 of file n_fluids.c.
References __n_assert, N_FLUID::m, N_FLUID_S_FIELD, N_FLUID_U_FIELD, N_FLUID_V_FIELD, N_FLUID::u, and N_FLUID::v.
Referenced by n_fluid_advectSmoke(), n_fluid_advectSmoke_proc(), n_fluid_advectVel(), and n_fluid_advectVel_proc().
int n_fluid_setObstacle | ( | N_FLUID * | fluid, |
double | x, | ||
double | y, | ||
double | vx, | ||
double | vy, | ||
double | r | ||
) |
set an obstacle in the fluid grid
fluid | targeted N_FLUID |
x | X position in fluid grid |
y | y position in fluid grid |
vx | X velocity for the point |
vy | Y velocity for the point |
r | radius |
Definition at line 722 of file n_fluids.c.
References __n_assert.
int n_fluid_simulate | ( | N_FLUID * | fluid | ) |
non threaded version of N_FLUID global processing function
fluid | a N_FLUID ptr |
Definition at line 621 of file n_fluids.c.
References __n_assert, n_fluid_advectSmoke(), n_fluid_advectVel(), n_fluid_extrapolate(), n_fluid_integrate(), and n_fluid_solveIncompressibility().
int n_fluid_simulate_threaded | ( | N_FLUID * | fluid, |
THREAD_POOL * | thread_pool | ||
) |
a threaded version of N_FLUID global processing function
fluid | a N_FLUID ptr |
thread_pool | a THREAD_POOL pool to use |
Definition at line 641 of file n_fluids.c.
References __n_assert, add_threaded_process(), list_foreach, n_fluid_advectSmoke_proc(), n_fluid_advectVel_proc(), n_fluid_extrapolate(), n_fluid_integrate_proc(), n_fluid_solveIncompressibility_proc(), refresh_thread_pool(), start_threaded_pool(), SYNCED_PROC, and wait_for_synced_threaded_pool().
int n_fluid_solveIncompressibility | ( | N_FLUID * | fluid | ) |
non threaded version of incompressibility solving function
fluid | N_FLUID to solve |
Definition at line 289 of file n_fluids.c.
References __n_assert, _z, _zd, N_FLUID::p, N_FLUID::s, N_FLUID::u, and N_FLUID::v.
Referenced by n_fluid_simulate().
N_FLUID * new_n_fluid | ( | double | density, |
double | gravity, | ||
size_t | numIters, | ||
double | dt, | ||
double | overRelaxation, | ||
size_t | sx, | ||
size_t | sy | ||
) |
!
return a newly allocated fluid
density | density of the fluid |
gravity | gravity applied (Y axe) |
numIters | predefined number of iterations for each frames |
dt | preconfigured delta time |
overRelaxation | over predefined over relaxation value |
sx | number of cells on x axis |
sy | number of cells on y axis |
Definition at line 78 of file n_fluids.c.
References __n_assert, get_nb_cpu_cores(), list_push(), Malloc, n_memset(), and new_generic_list().