-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.cu
66 lines (54 loc) · 1.5 KB
/
main.cu
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
#include <stdio.h>
#include "Lattice.h"
#include "lb.h"
#include "SwimmerArray.h"
int main(int argc, char* argv[]) {
int size = 16;
double tau = 0.25;
Lattice* lat = LatticeNew(size,size,size, tau,tau);
LatticeAddressing* addr = lat->h->addr;
/* Set the initial conditions:
* u = 0
* rho = 1 except a peak in the box centre
*/
for (int i=0; i<size; i++) {
for (int j=0; j<size; j++) {
for (int k=0; k<size; k++) {
int ijk = addr->strides[DQ_X]*i +
addr->strides[DQ_Y]*j +
addr->strides[DQ_Z]*k;
double d = (i==8 && j==8 && k == 8) ? 1.1 : 1.0;
lat->h->data->rho_ptr[ijk] = d;
for (int a=0; a<DQ_d; a++) {
lat->h->data->u_ptr[a*addr->n + ijk] = 0.0;
lat->h->data->force_ptr[a*addr->n + ijk] = 0.0;
}
}
}
}
/* Copy to device */
LatticeRhoH2D(lat);
LatticeUH2D(lat);
LatticeForceH2D(lat);
/* Set the dists */
LatticeInitFromHydro(lat);
SwimmerArray* swimmers = SwimmerArrayNew(2, 1.5);
swimmers->h->r[0] = 1.0; swimmers->h->r[1] = 4.0;
swimmers->h->r[2] = 1.0; swimmers->h->r[1] = 4.0;
swimmers->h->r[4] = 1.0; swimmers->h->r[1] = 4.0;
while (lat->time_step < 100) {
LatticeStep(lat);
if (lat->time_step % 10 == 0) {
LatticeCalcHydro(lat);
LatticeRhoD2H(lat);
int i = 8, j = 8;
for (int k=0; k<size; k++) {
int ijk = addr->strides[DQ_X]*i +
addr->strides[DQ_Y]*j +
addr->strides[DQ_Z]*k;
printf(" %f", lat->h->data->rho_ptr[ijk]);
}
printf("\n");
}
}
}