![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Fluid management functions , ported from https://www.youtube.com/watch?v=iKAVRgIrUOU&t=522s. More...
#include <math.h>#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <stdbool.h>#include <strings.h>#include "nilorea/n_fluids.h"#include "nilorea/n_common.h"#include "nilorea/n_thread_pool.h"
Include dependency graph for n_fluids.c:Go to the source code of this file.
Macros | |
| #define | N_FLUID_S_FIELD 2 |
| array number for s | |
| #define | N_FLUID_U_FIELD 0 |
| array number for u | |
| #define | N_FLUID_V_FIELD 1 |
| array number for v | |
Functions | |
| int | destroy_n_fluid (N_FLUID **fluid) |
| ddestroy a fluid structure | |
| int | n_fluid_advectSmoke (N_FLUID *fluid) |
| non threaded version of add smoke function | |
| void * | n_fluid_advectSmoke_proc (void *ptr) |
| ready to be threaded add smoke function | |
| int | n_fluid_advectVel (N_FLUID *fluid) |
| non threaded version of add velocities function | |
| void * | n_fluid_advectVel_proc (void *ptr) |
| ready to be threaded add velocities function | |
| 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 | |
| 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 | |
| int | n_fluid_draw (N_FLUID *fluid) |
| draw a N_FLUID on screen / targert bitmap | |
| int | n_fluid_extrapolate (N_FLUID *fluid) |
| non threaded extrapolation function | |
| ALLEGRO_COLOR | n_fluid_getSciColor (N_FLUID *fluid, double val, double minVal, double maxVal) |
| get fonky colors for the fluid | |
| int | n_fluid_integrate (N_FLUID *fluid) |
| non threaded version of integration function | |
| void * | n_fluid_integrate_proc (void *ptr) |
| ready to be threaded integration function | |
| int | n_fluid_resetObstacles (N_FLUID *fluid) |
| reset the obstacles set in a N_FLUID | |
| double | n_fluid_sampleField (N_FLUID *fluid, double x, double y, uint32_t field) |
| compute a sample value at a field position | |
| int | n_fluid_setObstacle (N_FLUID *fluid, double x, double y, double vx, double vy, double r) |
| set an obstacle in the fluid grid | |
| int | n_fluid_setObstacleFromBitmap (N_FLUID *fluid, ALLEGRO_BITMAP *bitmap, double x, double y, double vx, double vy, double r) |
| set an obstacle in the fluid grid from a bitmap mask | |
| int | n_fluid_simulate (N_FLUID *fluid) |
| non threaded version of N_FLUID global processing function | |
| int | n_fluid_simulate_threaded (N_FLUID *fluid, THREAD_POOL *thread_pool) |
| a threaded version of N_FLUID global processing function | |
| int | n_fluid_solveIncompressibility (N_FLUID *fluid) |
| non threaded version of incompressibility solving function | |
| void * | n_fluid_solveIncompressibility_proc (void *ptr) |
| ready to be threaded incompressibility solving function | |
| void | n_memset (void *dst, void *val, size_t size, size_t count) |
| memset bytes to a custom value | |
| 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 | |
Fluid management functions , ported from https://www.youtube.com/watch?v=iKAVRgIrUOU&t=522s.
Definition in file n_fluids.c.
| #define N_FLUID_S_FIELD 2 |
array number for s
Definition at line 23 of file n_fluids.c.
| #define N_FLUID_U_FIELD 0 |
array number for u
Definition at line 19 of file n_fluids.c.
| #define N_FLUID_V_FIELD 1 |
array number for v
Definition at line 21 of file n_fluids.c.
| void * n_fluid_advectSmoke_proc | ( | void * | ptr | ) |
ready to be threaded add smoke function
| ptr | a N_FLUID_THREAD_PARAMS ptr |
Definition at line 503 of file n_fluids.c.
References _z, N_FLUID::dt, N_FLUID::h, N_FLUID_S_FIELD, n_fluid_sampleField(), N_FLUID::newM, N_FLUID::numY, N_FLUID_THREAD_PARAMS::ptr, N_FLUID::u, N_FLUID::v, N_FLUID_THREAD_PARAMS::x_end, N_FLUID_THREAD_PARAMS::x_start, N_FLUID_THREAD_PARAMS::y_end, and N_FLUID_THREAD_PARAMS::y_start.
Referenced by n_fluid_simulate_threaded().
Here is the call graph for this function:
Here is the caller graph for this function:| void * n_fluid_advectVel_proc | ( | void * | ptr | ) |
ready to be threaded add velocities function
| ptr | a N_FLUID_THREAD_PARAMS ptr |
Definition at line 407 of file n_fluids.c.
References _z, N_FLUID::dt, N_FLUID::h, 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, N_FLUID_THREAD_PARAMS::ptr, N_FLUID::u, N_FLUID::v, N_FLUID_THREAD_PARAMS::x_end, N_FLUID_THREAD_PARAMS::x_start, N_FLUID_THREAD_PARAMS::y_end, and N_FLUID_THREAD_PARAMS::y_start.
Referenced by n_fluid_simulate_threaded().
Here is the call graph for this function:
Here is the caller graph for this function:| void * n_fluid_integrate_proc | ( | void * | ptr | ) |
ready to be threaded integration function
| ptr | a N_FLUID_THREAD_PARAMS ptr |
Definition at line 187 of file n_fluids.c.
References _z, N_FLUID::dt, N_FLUID::gravity, N_FLUID::numY, N_FLUID_THREAD_PARAMS::ptr, N_FLUID::v, N_FLUID_THREAD_PARAMS::x_end, N_FLUID_THREAD_PARAMS::x_start, N_FLUID_THREAD_PARAMS::y_end, and N_FLUID_THREAD_PARAMS::y_start.
Referenced by n_fluid_simulate_threaded().
Here is the caller graph for this function:| int n_fluid_setObstacleFromBitmap | ( | N_FLUID * | fluid, |
| ALLEGRO_BITMAP * | bitmap, | ||
| double | x, | ||
| double | y, | ||
| double | vx, | ||
| double | vy, | ||
| double | r | ||
| ) |
set an obstacle in the fluid grid from a bitmap mask
| fluid | targeted N_FLUID |
| bitmap | the bitmap source mask |
| 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 703 of file n_fluids.c.
References __n_assert, N_FLUID::m, N_FLUID::numX, N_FLUID::numY, N_FLUID::s, N_FLUID::u, and N_FLUID::v.
| void * n_fluid_solveIncompressibility_proc | ( | void * | ptr | ) |
ready to be threaded incompressibility solving function
| ptr | a N_FLUID_THREAD_PARAMS ptr |
Definition at line 224 of file n_fluids.c.
References _z, _zd, N_FLUID::density, N_FLUID::dt, N_FLUID::h, N_FLUID::numY, N_FLUID::overRelaxation, N_FLUID::p, N_FLUID_THREAD_PARAMS::ptr, N_FLUID::s, N_FLUID::u, N_FLUID::v, N_FLUID_THREAD_PARAMS::x_end, N_FLUID_THREAD_PARAMS::x_start, N_FLUID_THREAD_PARAMS::y_end, and N_FLUID_THREAD_PARAMS::y_start.
Referenced by n_fluid_simulate_threaded().
Here is the caller graph for this function:| void n_memset | ( | void * | dst, |
| void * | val, | ||
| size_t | size, | ||
| size_t | count | ||
| ) |
memset bytes to a custom value
| dst | destination pointer |
| val | value to write |
| size | size of value |
| count | how many val are we writting |
Definition at line 32 of file n_fluids.c.
Referenced by new_n_fluid().
Here is the caller graph for this function: