-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathn_fluids.h
121 lines (94 loc) · 3.29 KB
/
n_fluids.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "allegro5/allegro.h"
#include <allegro5/allegro_primitives.h>
/**\file n_fluids.h
*
* fluid management
*
*\author Castagnier Mickaël aka Gull Ra Driel
*
*\version 1.0
*
*\date 31/12/2022
*
*/
#ifndef __N_FLUID_HEADER
#define __N_FLUID_HEADER
#ifdef __cplusplus
extern "C" {
#endif
#include "nilorea/n_list.h"
#include "nilorea/n_thread_pool.h"
#ifndef _z
#define _z( __fluid , __componant ) ( (__fluid->__componant) > (__fluid->negative_float_tolerance) && (__fluid->__componant) < (__fluid->positive_float_tolerance) )
#endif
#ifndef _zd
#define _zd( __fluid , __value ) ( (__value) > (__fluid->negative_float_tolerance) && (__value) < (__fluid->positive_float_tolerance) )
#endif
typedef struct N_FLUID_THREAD_PARAMS
{
/*! pointer to data which will be used in the proc */
void *ptr ;
/*! x start point */
size_t x_start ;
/*! x end point */
size_t x_end ;
/*! y start point */
size_t y_start ;
/*! y end point */
size_t y_end ;
} N_FLUID_THREAD_PARAMS ;
typedef struct N_FLUID
{
size_t numX ;
size_t numY ;
size_t numZ ;
size_t numCells ;
size_t numIters ;
double density ;
double dt ;
double h ;
double gravity ;
double overRelaxation ;
bool showSmoke ;
bool showPaint ;
bool showPressure ;
double negative_float_tolerance ;
double positive_float_tolerance ;
double fluid_production_percentage ;
double cScale ;
double *u ;
double *newU ;
double *v ;
double *newV ;
double *p ;
double *s ;
double *m ;
double *newM ;
/*! preprocessed list of threaded procs parameters, for n_fluid_integrate */
LIST *integrate_chunk_list ;
/*! preprocessed list of threaded procs parameters, for n_fluid_solveIncompressibility */
LIST *solveIncompressibility_chunk_list ;
/*! preprocessed list of threaded procs parameters, for n_fluid_advectVel */
LIST *advectVel_chunk_list ;
/*! preprocessed list of threaded procs parameters, for n_fluid_advectSmoke */
LIST *advectSmoke_chunk_list ;
} N_FLUID ;
int destroy_n_fluid( N_FLUID **fluid );
N_FLUID *new_n_fluid( double density , double gravity , size_t numIters , double dt , double overRelaxation , size_t sx , size_t sy );
int n_fluid_integrate( N_FLUID *fluid );
int n_fluid_solveIncompressibility( N_FLUID *fluid );
int n_fluid_extrapolate( N_FLUID *fluid );
double n_fluid_sampleField( N_FLUID *fluid , double x , double y , uint32_t field );
double n_fluid_avgU( N_FLUID *fluid , size_t i , size_t j );
double n_fluid_avgV( N_FLUID *fluid , size_t i , size_t j );
int n_fluid_advectVel( N_FLUID *fluid );
int n_fluid_advectSmoke( N_FLUID *fluid );
int n_fluid_simulate( N_FLUID *fluid );
int n_fluid_simulate_threaded( N_FLUID *fluid , THREAD_POOL *thread_pool );
int n_fluid_setObstacle( N_FLUID *fluid , double x , double y , double vx , double vy , double r , bool reset );
ALLEGRO_COLOR n_fluid_getSciColor( N_FLUID *fluid , double val , double minVal , double maxVal );
int n_fluid_draw( N_FLUID *fluid );
#ifdef __cplusplus
}
#endif
#endif