Table of Contents
- FLUIDS: fluid simulation example
- Structures
- Functions
- Defines
- Functions Documentation
- function new_n_fluid
- function n_fluid_solveIncompressibility
- function n_fluid_simulate_threaded
- function n_fluid_simulate
- function n_fluid_setObstacle
- function n_fluid_sampleField
- function n_fluid_resetObstacles
- function n_fluid_integrate
- function n_fluid_getSciColor
- function n_fluid_extrapolate
- function n_fluid_draw
- function n_fluid_avgV
- function n_fluid_avgU
- function n_fluid_advectVel
- function n_fluid_advectSmoke
- function destroy_n_fluid
- Macros Documentation
FLUIDS: fluid simulation example
Structures
| Name | |
|---|---|
| struct | N_FLUID_THREAD_PARAMS structure passed to a threaded fluid process |
| struct | N_FLUID structure of a fluid |
Functions
| Name | |
|---|---|
| N_FLUID * | new_n_fluid(double density, double gravity, size_t numIters, double dt, double overRelaxation, size_t sx, size_t sy) create a new fluid simulation |
| int | n_fluid_solveIncompressibility(N_FLUID * fluid) solve incompressibility constraint |
| int | n_fluid_simulate_threaded(N_FLUID * fluid, THREAD_POOL * thread_pool) run one simulation step using thread pool |
| int | n_fluid_simulate(N_FLUID * fluid) run one simulation step |
| int | n_fluid_setObstacle(N_FLUID * fluid, double x, double y, double vx, double vy, double r) set an obstacle in the fluid |
| double | n_fluid_sampleField(N_FLUID * fluid, double x, double y, uint32_t field) sample a field value at given coordinates |
| int | n_fluid_resetObstacles(N_FLUID * fluid) reset all obstacles |
| int | n_fluid_integrate(N_FLUID * fluid) integrate fluid velocities |
| 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_extrapolate(N_FLUID * fluid) extrapolate fluid boundaries |
| int | n_fluid_draw(N_FLUID * fluid) draw the fluid simulation |
| double | n_fluid_avgV(const N_FLUID * fluid, size_t i, size_t j) compute average V velocity at cell |
| double | n_fluid_avgU(const N_FLUID * fluid, size_t i, size_t j) compute average U velocity at cell |
| int | n_fluid_advectVel(N_FLUID * fluid) advect velocity field |
| int | n_fluid_advectSmoke(N_FLUID * fluid) advect smoke density field |
| int | destroy_n_fluid(N_FLUID ** fluid) destroy a fluid simulation |
Defines
| Name | |
|---|---|
| _zd(__fluid, __value) test if value is near zero, according to fluid's precision |
|
| _z(__fluid, __component) test if component is near zero, according to fluid's precision |
Functions Documentation
function new_n_fluid
N_FLUID * new_n_fluid(
double density,
double gravity,
size_t numIters,
double dt,
double overRelaxation,
size_t sx,
size_t sy
)
create a new fluid simulation
Parameters:
- 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
Return: a newly allocated N_FLUID structure
return a newly allocated fluid
create a new fluid simulation
function n_fluid_solveIncompressibility
int n_fluid_solveIncompressibility(
N_FLUID * fluid
)
solve incompressibility constraint
Parameters:
- fluid N_FLUID to solve
Return: TRUE or FALSE
non threaded version of incompressibility solving function
solve incompressibility constraint
function n_fluid_simulate_threaded
int n_fluid_simulate_threaded(
N_FLUID * fluid,
THREAD_POOL * thread_pool
)
run one simulation step using thread pool
Parameters:
- fluid a N_FLUID ptr
- thread_pool a THREAD_POOL pool to use
Return: TRUE or FALSE
a threaded version of N_FLUID global processing function
run one simulation step using thread pool
function n_fluid_simulate
int n_fluid_simulate(
N_FLUID * fluid
)
run one simulation step
Parameters:
- fluid a N_FLUID ptr
Return: TRUE or FALSE
non threaded version of N_FLUID global processing function
run one simulation step
function n_fluid_setObstacle
int n_fluid_setObstacle(
N_FLUID * fluid,
double x,
double y,
double vx,
double vy,
double r
)
set an obstacle in the fluid
Parameters:
- 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
Return: TRUE or FALSE
set an obstacle in the fluid grid
set an obstacle in the fluid
function n_fluid_sampleField
double n_fluid_sampleField(
N_FLUID * fluid,
double x,
double y,
uint32_t field
)
sample a field value at given coordinates
Parameters:
- 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
Return: the computed value
compute a sample value at a field position
sample a field value at given coordinates
function n_fluid_resetObstacles
int n_fluid_resetObstacles(
N_FLUID * fluid
)
reset all obstacles
Parameters:
- fluid the targeted N_FLUID
Return: TRUE or FALSE
reset the obstacles set in a N_FLUID
reset all obstacles
function n_fluid_integrate
int n_fluid_integrate(
N_FLUID * fluid
)
integrate fluid velocities
Parameters:
- fluid a N_FLUID to integrate_chunk_list
Return: TRUE or FALSE
non threaded version of integration function
integrate fluid velocities
function n_fluid_getSciColor
ALLEGRO_COLOR n_fluid_getSciColor(
const N_FLUID * fluid,
double val,
double minVal,
double maxVal
)
get a scientific color for a value
Parameters:
- fluid targeted N_FLUID
- val value mixer
- minVal minimum output value
- maxVal maximum output value
Return: the generated ALLEGRO_COLOR
get funky colors for the fluid
get a scientific color for a value
function n_fluid_extrapolate
int n_fluid_extrapolate(
N_FLUID * fluid
)
extrapolate fluid boundaries
Parameters:
- fluid a N_FLUID to extrapolate
Return: TRUE or FALSE
non threaded extrapolation function
extrapolate fluid boundaries
function n_fluid_draw
int n_fluid_draw(
N_FLUID * fluid
)
draw the fluid simulation
Parameters:
- fluid the N_FLUID to draw
Return: TRUE or FALSE
draw a N_FLUID on screen / targert bitmap
draw the fluid simulation
function n_fluid_avgV
double n_fluid_avgV(
const N_FLUID * fluid,
size_t i,
size_t j
)
compute average V velocity at cell
Parameters:
- fluid targeted N_FLUID
- i X position in the fluid grid
- j Y position in the fluid grid
Return: the average computed value
compute the average V value at a fluid position using it's surrounding
compute average V velocity at cell
function n_fluid_avgU
double n_fluid_avgU(
const N_FLUID * fluid,
size_t i,
size_t j
)
compute average U velocity at cell
Parameters:
- fluid targeted N_FLUID
- i X position in the fluid grid
- j Y position in the fluid grid
Return: the average computed value
compute the average U value at a fluid position using it's surrounding
compute average U velocity at cell
function n_fluid_advectVel
int n_fluid_advectVel(
N_FLUID * fluid
)
advect velocity field
Parameters:
- fluid a N_FLUID ptr
Return: TRUE or FALSE
non threaded version of add velocities function
advect velocity field
function n_fluid_advectSmoke
int n_fluid_advectSmoke(
N_FLUID * fluid
)
advect smoke density field
Parameters:
- fluid a N_FLUID ptr
Return: TRUE or FALSE
non threaded version of add smoke function
advect smoke density field
function destroy_n_fluid
int destroy_n_fluid(
N_FLUID ** fluid
)
destroy a fluid simulation
Parameters:
- fluid pointer to the structure to destroy
Return: TRUE or FALSE
destroy a fluid structure
destroy a fluid simulation
Macros Documentation
define _zd
#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
define _z
#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
Modules
- AABB3D
- ACCEPT_POOL
- ALLEGRO4
- ALLEGRO5
- ANIM_LIB
- ASTAR
- ATLAS_LIB
- AVRO
- CLOCK_SYNC
- COMMONS
- CONFIGFILE
- CYPHER_BASE64
- CYPHER_VIGENERE
- DEAD_RECKONING
- ENUMS
- EXCEPTIONS
- GAME_ENV
- GIT
- GUI
- HASH_TABLE
- ISOMETRIC_ENGINE
- LIST
- LOG
- LOGNODUP
- LZ4
- NETWORKING
- NETWORK_MSG
- N_COOKIES
- N_DIFF
- N_DIGEST
- N_DISK_CACHE
- N_DNS
- N_ECC
- N_ENTROPY
- N_FILES
- N_FLUIDS
- N_GUI_COLOR
- N_GUI_COLORWHEEL
- N_GUI_CURVE
- N_GUI_GRID
- N_GUI_POPUP
- N_HEX
- N_HTTP3
- N_HTTP_COOKIE
- N_HTTP_FORM
- N_HTTP_MIME
- N_HTTP_REQ
- N_HTTP_RESP
- N_HTTP_ROUTER
- N_HTTP_SERVER
- N_ICC
- N_JSON
- N_KAFKA
- N_LINALG
- N_MODULE
- N_OPENSSL_COMPAT
- N_PRETTY
- N_PTH
- N_QUERY
- N_RANDOM
- N_SHA256
- N_STR
- N_TIFF
- N_TIME
- N_USER
- N_X509
- N_ZIP
- PARTICLES
- PCRE
- PHYSICS
- SIGNALS
- STACK
- THREADS
- TRAJECTORY
- TREE
- ZLIB