Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_fluids.c File Reference

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_FLUIDnew_n_fluid (double density, double gravity, size_t numIters, double dt, double overRelaxation, size_t sx, size_t sy)
 !
 

Detailed Description

fluid management functions , ported from https://www.youtube.com/watch?v=iKAVRgIrUOU&t=522s

Author
Castagnier Mickael aka Gull Ra Driel
Version
1.0
Date
31/12/2022

Definition in file n_fluids.c.

Macro Definition Documentation

◆ N_FLUID_S_FIELD

#define N_FLUID_S_FIELD   2

array number for s

Definition at line 22 of file n_fluids.c.

◆ N_FLUID_U_FIELD

#define N_FLUID_U_FIELD   0

array number for u

Definition at line 18 of file n_fluids.c.

◆ N_FLUID_V_FIELD

#define N_FLUID_V_FIELD   1

array number for v

Definition at line 20 of file n_fluids.c.

Function Documentation

◆ n_fluid_advectSmoke_proc()

void * n_fluid_advectSmoke_proc ( void *  ptr)

ready to be threaded add smoke function

Parameters
ptra N_FLUID_THREAD_PARAMS ptr
Returns
NULL

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_fluid_advectVel_proc()

void * n_fluid_advectVel_proc ( void *  ptr)

ready to be threaded add velocities function

Parameters
ptra N_FLUID_THREAD_PARAMS ptr
Returns
NULL

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_fluid_integrate_proc()

void * n_fluid_integrate_proc ( void *  ptr)

ready to be threaded integration function

Parameters
ptra N_FLUID_THREAD_PARAMS ptr
Returns
NULL

Definition at line 202 of file n_fluids.c.

References _z.

Referenced by n_fluid_simulate_threaded().

+ Here is the caller graph for this function:

◆ n_fluid_setObstacleFromBitmap()

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

Parameters
fluidtargeted N_FLUID
bitmapthe bitmap source mask
xX position in fluid grid
yy position in fluid grid
vxX velocity for the point
vyY velocity for the point
rradius
Returns
TRUE or FALSE

Definition at line 784 of file n_fluids.c.

References __n_assert.

◆ n_fluid_solveIncompressibility_proc()

void * n_fluid_solveIncompressibility_proc ( void *  ptr)

ready to be threaded incompressibility solving function

Parameters
ptra N_FLUID_THREAD_PARAMS ptr
Returns
NULL

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().

+ Here is the caller graph for this function:

◆ n_memset()

void n_memset ( void *  dst,
void *  val,
size_t  size,
size_t  count 
)

memset bytes to a custom value

Parameters
dstdestination pointer
valvalue to write
sizesize of value
counthow 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: