forked from michal1000w/GPUSmoke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFluid_State.cuh
95 lines (77 loc) · 2.68 KB
/
Fluid_State.cuh
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
#include "Object.h"
// Container for simulation state
struct fluid_state {
float3 impulseLoc;
float impulseTemp;
float impulseDensity;
float impulseRadius;
float f_weight;
float cell_size;
float time_step;
int3 dim;
int64_t nelems;
int step;
DoubleBuffer<float3>* velocity;
DoubleBuffer<float>* density;
DoubleBuffer<float>* temperature;
DoubleBuffer<float>* flame;
DoubleBuffer<float>* pressure;
DoubleBuffer<float>* noise;
//std::vector<float*> diverge;
DoubleBuffer<float>* diverge;
DoubleBuffer<float>* collision;
int devicesCount = 1;
fluid_state(int3 dims, int devicesCount, int deviceIndex) {
this->devicesCount = devicesCount;
step = 0;
dim = dims;
nelems = dims.x * dims.y * dims.z;
velocity = new DoubleBuffer<float3>((int)nelems, devicesCount, deviceIndex);
velocity->setDim(dims);
density = new DoubleBuffer<float>((int)nelems, devicesCount, deviceIndex);
density->setDim(dims);
temperature = new DoubleBuffer<float>((int)nelems, devicesCount, deviceIndex);
temperature->setDim(dims);
pressure = new DoubleBuffer<float>((int)nelems, devicesCount, deviceIndex);
pressure->setDim(dims);
flame = new DoubleBuffer<float>((int)nelems, devicesCount, deviceIndex);
flame->setDim(dims);
collision = new DoubleBuffer<float>((int)nelems, devicesCount, deviceIndex);
collision->setDim(dims);
//diverge = multiGPU_malloc<float>(devicesCount,deviceIndex, nelems);
diverge = new DoubleBuffer<float>((int)nelems, devicesCount, deviceIndex);
diverge->setDim(dims);
int noiseDim = 64;
int3 noiseDims = make_int3(noiseDim, noiseDim, noiseDim);
int nnelems = noiseDim * noiseDim * noiseDim;
noise = new DoubleBuffer<float>((int)nnelems, devicesCount, deviceIndex);
noise->setDim(noiseDims);
}
void zeros(int devicesCount, int deviceIndex) {
density->zeros(deviceIndex);
temperature->zeros(deviceIndex);
pressure->zeros(deviceIndex);
flame->zeros(deviceIndex);
diverge->zeros(deviceIndex);
noise->zeros(deviceIndex);
velocity->zeros(deviceIndex);
collision->zeros(deviceIndex);
}
fluid_state() {
}
~fluid_state() {
delete velocity;
delete density;
delete temperature;
delete pressure;
delete flame;
delete noise;
delete collision;
//cudaFree(diverge);
//multiGPU_free(devicesCount, diverge);
delete diverge;
}
void sync_devices(int devicesCount = 1) {
//todo
}
};