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"
Go to the source code of this file.
Macros | |
#define | N_FLUID_S_FIELD 2 |
array number for s More... | |
#define | N_FLUID_U_FIELD 0 |
array number for u More... | |
#define | N_FLUID_V_FIELD 1 |
array number for v 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... | |
void * | n_fluid_advectSmoke_proc (void *ptr) |
ready to be threaded add smoke function More... | |
int | n_fluid_advectVel (N_FLUID *fluid) |
non threaded version of add velocities function More... | |
void * | n_fluid_advectVel_proc (void *ptr) |
ready to be threaded 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... | |
void * | n_fluid_integrate_proc (void *ptr) |
ready to be threaded 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_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 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... | |
void * | n_fluid_solveIncompressibility_proc (void *ptr) |
ready to be threaded incompressibility solving function More... | |
void | n_memset (void *dst, void *val, size_t size, size_t count) |
memset bytes to a custom value More... | |
N_FLUID * | new_n_fluid (double density, double gravity, size_t numIters, double dt, double overRelaxation, size_t sx, size_t sy) |
! More... | |
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 22 of file n_fluids.c.
#define N_FLUID_U_FIELD 0 |
array number for u
Definition at line 18 of file n_fluids.c.
#define N_FLUID_V_FIELD 1 |
array number for v
Definition at line 20 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 550 of file n_fluids.c.
References _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_threaded().
void * n_fluid_advectVel_proc | ( | void * | ptr | ) |
ready to be threaded add velocities function
ptr | a N_FLUID_THREAD_PARAMS ptr |
Definition at line 444 of file n_fluids.c.
References _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_threaded().
void * n_fluid_integrate_proc | ( | void * | ptr | ) |
ready to be threaded integration function
ptr | a N_FLUID_THREAD_PARAMS ptr |
Definition at line 202 of file n_fluids.c.
References _z.
Referenced by n_fluid_simulate_threaded().
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 784 of file n_fluids.c.
References __n_assert.
void * n_fluid_solveIncompressibility_proc | ( | void * | ptr | ) |
ready to be threaded incompressibility solving function
ptr | a N_FLUID_THREAD_PARAMS ptr |
Definition at line 248 of file n_fluids.c.
References _z, _zd, N_FLUID::p, N_FLUID::s, N_FLUID::u, and N_FLUID::v.
Referenced by n_fluid_simulate_threaded().
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().