-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
101 lines (82 loc) · 4.21 KB
/
Copy pathmain.cpp
File metadata and controls
101 lines (82 loc) · 4.21 KB
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
#include <array>
#include <iostream>
#include "SimInfo.h"
#include "ComputeDt.h"
#include "IOManager.h"
#include "Init.h"
#include "Update.h"
using namespace fv2d;
int main(int argc, char **argv)
{
// Initializing Kokkos
Kokkos::initialize(argc, argv);
{
std::cout << "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░" << std::endl;
std::cout << "░ ░░ ░░░░░░░░░ ░░░░░░░░░░░░░░░░░ ░" << std::endl;
std::cout << "▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒ ▒▒▒ ▒ ▒▒▒▒▒▒▒▒▒ ▒" << std::endl;
std::cout << "▒ ▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒▒ ▒" << std::endl;
std::cout << "▓ ▓▓▓▓▓▓ ▓▓▓ ▓▓▓▓▓▓▓▓▓ ▓▓▓▓ ▓ ▓" << std::endl;
std::cout << "▓ ▓▓▓▓▓▓▓▓▓▓▓ ▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓ ▓" << std::endl;
std::cout << "▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓ ▓▓▓ ▓" << std::endl;
std::cout << "█ █████████████ ███████ ███ █ █" << std::endl;
std::cout << "███████████████████████████████████████████████" << std::endl;
// Reading parameters from .ini file
auto params = readInifile(argv[1]);
auto device_params = params.device_params;
// Allocating main views
Array U = Kokkos::View<real_t ***>("U", device_params.Nty, device_params.Ntx, Nfields);
Array Q = Kokkos::View<real_t ***>("Q", device_params.Nty, device_params.Ntx, Nfields);
// Misc vars for iteration
real_t t = 0.0;
int ite = 0;
real_t next_save = 0.0;
// Initializing primitive variables
InitFunctor init(params);
UpdateFunctor update(params);
ComputeDtFunctor computeDt(params);
IOManager ioManager(params);
if (params.restart_file != "")
{
auto restart_info = ioManager.loadSnapshot(Q);
t = restart_info.time;
ite = restart_info.iteration;
std::cout << "Restart at iteration " << ite << " and time " << t << std::endl;
next_save = t + params.save_freq;
ite++;
}
else
init.init(Q);
primToCons(Q, U, params);
int next_log = 0;
while (t + device_params.epsilon < params.tend)
{
bool save_needed = (t + device_params.epsilon > next_save);
real_t dt = computeDt.computeDt(Q, (ite == 0 ? params.save_freq : next_save - t), t, next_log == 0);
if (next_log == 0)
next_log = params.log_frequency;
else
next_log--;
if (save_needed)
{
std::cout << " - Saving at time " << t << std::endl;
ioManager.saveSolution(Q, ite++, t);
next_save += params.save_freq;
}
update.update(Q, U, dt);
consToPrim(U, Q, params);
checkNegatives(Q, params);
t += dt;
}
std::cout << "Time at end is " << t << std::endl;
ioManager.saveSolution(Q, ite++, t);
}
Kokkos::finalize();
std::cout << std::endl << std::endl;
std::cout << " █ ▀██ ▀██ ▀██ ▄█▄ " << std::endl;
std::cout << " ███ ██ ██ ▄▄ ██ ▄▄▄ ▄▄ ▄▄▄ ▄▄▄▄ ███ " << std::endl;
std::cout << " █ ██ ██ ██ ▄▀ ▀██ ▄█ ▀█▄ ██ ██ ▄█▄▄▄██ ▀█▀ " << std::endl;
std::cout << " ▄▀▀▀▀█▄ ██ ██ █▄ ██ ██ ██ ██ ██ ██ █ " << std::endl;
std::cout << "▄█▄ ▄██▄ ▄██▄ ▄██▄ ▀█▄▄▀██▄ ▀█▄▄█▀ ▄██▄ ██▄ ▀█▄▄▄▀ ▄ " << std::endl;
std::cout << " ▀█▀ " << std::endl;
return 0;
}