forked from debanshusingh/CIS563-FluidSolver
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
81 lines (66 loc) · 2.82 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
#include <core/display/Window.h>
#include <core/fileIO/SceneLoader.h>
#include <core/fileIO/ParticlesWriter.h>
#include <core/display/painters/ParticlesPainter.h>
#include <core/display/painters/GridVectorAttributePainter.h>
#include <core/display/painters/GridScalarAttributePainter.h>
#include <core/display/painters/BoxPainter.h>
#include <ctime>
int main(int argc, char* argv[]) {
Window* window = new Window("Fluid Solver");
FluidSolver* solver = SceneLoader::LoadScene(argv[1]);
// ParticlesWriter particlesWriter;
solver->init();
// particlesWriter.writeData(solver, "particles_0.vdb");
ParticlesPainter particlesPainter(solver, 2);
BoxPainter boxPainter((Box *) solver->_container);
GridVectorAttributePainter uPainter (&solver->_MAC->_gU, 1.f, glm::vec3(1,0,0), glm::vec3(0.2,0,0));
GridVectorAttributePainter vPainter (&solver->_MAC->_gV, 1.f, glm::vec3(0,1,0), glm::vec3(0,0.2,0));
GridVectorAttributePainter wPainter (&solver->_MAC->_gW, 1.f, glm::vec3(0,0,1), glm::vec3(0,0,0.2));
GridScalarAttributePainter tPainter (
&solver->_MAC->_gType, 0.f, 2.f, 2.f, 8.f, glm::vec3(0,1,1), glm::vec3(0,0,0));
GridScalarAttributePainter posPressurePainter (
&solver->_MAC->_gP, 0.f, 50.f, 0.f, 5.f, glm::vec3(1,1,0), glm::vec3(1,0,0));
GridScalarAttributePainter negPressurePainter (
&solver->_MAC->_gP, 0.f, -2.f, 0.f, 5.f, glm::vec3(0,1,1), glm::vec3(0,0,1));
window->addPainter(&particlesPainter);
window->addPainter(&boxPainter);
// window->addPainter(&uPainter);
// window->addPainter(&vPainter);
// window->addPainter(&wPainter);
// window->addPainter(&tPainter);
// window->addPainter(&posPressurePainter);
// window->addPainter(&negPressurePainter);
window->loadSceneCB = [](void*) {
std::cout << "what" << std::endl;
};
// window->initializeTweakBar();
int framerate = 24;
double start = glfwGetTime();
int frame = 0;
float totalComputeTime = 0;
window->initloop([&]() {
double now = glfwGetTime();
float duration = (float) (now - start);
// limit solver update to 24fps
if (duration >= 1.f / framerate) {
start = now;
//solver->update(duration);
solver->update(1.f / framerate);
totalComputeTime += glfwGetTime() - start;
std::string filename = "particles_";
filename.append(std::to_string(++frame));
filename.append(".tga");
// window->saveImage(filename);
// particlesWriter.writeData(solver, filename);
if (frame >= 960) {
exit(0);
}
}
});
// solver->update(0.1f);
std::cout << "Average compute time: " << totalComputeTime / frame << " seconds" << std::endl;
delete window;
delete solver;
return 0;
}