-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
114 lines (86 loc) · 2.25 KB
/
main.cpp
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
#include <iostream>
#include <ctime>
#include "general/Definitions.h"
#ifdef SHOW_GUI
#include "gui/GUI.h"
#endif
#ifdef SIMPLE
#include "lbm/SimpleD2Q9.h"
#endif
#ifdef SWAP
#include "lbm/SwapD2Q9.h"
#endif
#ifdef BLOCK
#include "lbm/BlockD2Q9.h"
#endif
int main(int argc, char** args)
{
//Get number of iterations from command line
if(argc < 2) {
std::cout << "Please specify the number of iterations." << std::endl;
return -1;
}
int numIterations = atoi(args[1]);
#ifdef SIMPLE
SimpleD2Q9 sim(GRID_SIZE, GRID_SIZE);
std::string title = "Simple LBM ( 2 Arrays )";
#endif
#ifdef SWAP
SwapD2Q9 sim(GRID_SIZE, GRID_SIZE);
std::string title = "Swap LBM ( 1 Array )";
#endif
#ifdef BLOCK
BlockD2Q9 sim(GRID_SIZE, GRID_SIZE);
std::string title = "Block LBM ( 2 Arrays )";
#endif
#ifdef BUNDLE
title.append(" - Data layout: Bundle");
#endif
#ifdef COLLOPT
title.append(" - Data layout: CollOpt");
#endif
#ifdef PROPOPT
title.append(" - Data layout: PropOpt");
#endif
std::cout << "Running " << title << std::endl;
std::cout << numIterations << " Iterations on a " << GRID_SIZE << "x" << GRID_SIZE << " grid." << std::endl;
#ifdef SHOW_GUI
GUI gui(title);
VectorGrid vel(GRID_SIZE, GRID_SIZE);
#endif
sim.init(); //do not measure the initialisation step
int i = 0;
#ifndef SHOW_GUI
std::clock_t start;
start = std::clock();
#endif
for(i = 0; i < numIterations; ++i) {
#ifdef SHOW_GUI
if(gui.shouldClose()) {
break;
}
sim.getVel(vel);
gui.display(vel);
#endif
sim.collide();
sim.stream();
}
#ifdef OUTPUT_TO_LOGFILE
if( freopen("log", "a", stdout) == nullptr) {
return 0;
};
#endif
#ifndef SHOW_GUI
double elapsedTime = (std::clock() - start) / (double) CLOCKS_PER_SEC;
std::cout << "Finished " << title << std::endl;
std::cout << numIterations << " Iterations on a " << GRID_SIZE << "x" << GRID_SIZE << " grid." << std::endl;
std::cout << "Elapsed time: " << elapsedTime << std::endl;
double mlups = numIterations;
mlups /= elapsedTime;
mlups *= N;
mlups /= 1.e6;
std::cout << "MLUPS: " << mlups << std::endl;
std::cout << std::endl;
#endif
return 0;
}