-
Notifications
You must be signed in to change notification settings - Fork 0
/
Simulation.h
62 lines (48 loc) · 1.18 KB
/
Simulation.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
//
// Created by Jack Coughlin on 2/7/18.
//
#ifndef FLUIDS_SIMULATION_H
#define FLUIDS_SIMULATION_H
class Simulation {
int nx;
int ny;
float dx;
float dy;
float dt;
float rdx;
float **p;
float **u_x;
float **u_y;
/* An array of shape (nm, 2) containing xy coordinates
* of the particles we are tracking
*/
float **particles;
/* Arrays of 0/1 to track where water, solid, and air are. */
short **water_mask;
short **air_mask;
short **solid_mask;
/* Array containing the divergence of each fluid cell. */
float **divergence;
short **Adiag;
short **Aplusi;
short **Aplusj;
double **precon;
public:
Simulation(int nx, int ny, float dx, float dy, float dt);
void step();
void cleanup();
void show();
private:
void allocateArrays();
void applyBodyForces();
void computeDivergence();
void correctPressure();
void advectU_x();
void advectU_y();
void advectParticles();
void updateLaplacian();
void calculatePreconditioner();
void applyPreconditioner(float **r, float **z);
void applyLaplacian(float **s, float **dest);
};
#endif //FLUIDS_SIMULATION_H