-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
106 lines (98 loc) · 2.77 KB
/
main.cpp
File metadata and controls
106 lines (98 loc) · 2.77 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
102
103
104
105
106
#include "./src/FVM.h"
#include <fstream>
#include <iostream>
#include <chrono>
vector<vector<quadriFP64>> initializeU_4shocks(int N)
{
quadriFP64 U1 = {1.5, 1.5, 0.0, 0.0};
quadriFP64 U2 = {0.5323, 0.3, 1.206, 0.0};
quadriFP64 U3 = {0.138, 0.029, 1.206, 1.206};
quadriFP64 U4 = {0.5323, 0.3, 0.0, 1.206};
vector<vector<quadriFP64>> ret;
for (auto i = 0; i < N / 5; i++)
{
vector<quadriFP64> x_oriented_i(N);
for (auto j = 0; j < 4 * N / 5; j++)
{
x_oriented_i[j] = U2;
}
for (auto j = 4 * N / 5; j < N; j++)
{
x_oriented_i[j] = U1;
}
ret.push_back(x_oriented_i);
}
for (auto i = N / 5; i < N; i++)
{
vector<quadriFP64> x_oriented_i(N);
for (auto j = 0; j < 4 * N / 5; j++)
{
x_oriented_i[j] = U3;
}
for (auto j = 4 * N / 5; j < N; j++)
{
x_oriented_i[j] = U4;
}
ret.push_back(x_oriented_i);
}
return ret;
}
std::vector<std::vector<quadriFP64>> initialize_2Mach(int N)
{
std::vector<std::vector<quadriFP64>> U(N, std::vector<quadriFP64>(4 * N, {1.4, 1.0, 0.0, 0.0}));
for (auto i = N - 1; i >= 0; i--)
{
double temp = double(N - i + 3) / sqrt(3);
int l = N / 6 + int(temp);
for (auto j = 0; j < l; j++)
{
U[i][j] = {8, 116.5, 4.125 * sqrt(3), -4.125};
}
}
return U;
}
std::vector<std::vector<quadriFP64>> initialize_jet800(int N)
{
std::vector<std::vector<quadriFP64>> U(N, std::vector<quadriFP64>(3 * N, {0.14, 1.0, 0.0, 0.0}));
for (auto i = 0; i < N; ++i)
{
if (i > 9 * N / 10)
{
U[i][0] = {1.4, 1.0, 800.0, 0.0};
}
}
return U;
}
int main()
{
quadriFP64 U1 = {1.0, 1.0, 0.75, -0.5};
quadriFP64 U2 = {2.0, 1.0, 0.75, 0.5};
quadriFP64 U3 = {1.0, 1.0, -0.75, 0.5};
quadriFP64 U4 = {3.0, 1.0, -0.75, -0.5};
int N = 1000;
// FVM solver(U1, U2, U3, U4, 1.0, 1.0, N, N);
FVM solver(initialize_jet800(1200), 1.5, 0.5);
solver.setGhostCellType(ghostCellType::jet800);
solver.setAlpha(1.8);
solver.setEndingTime(0.002);
auto start = std::chrono::high_resolution_clock::now();
auto r = solver.solve();
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
std::cout << duration.count() / 1000.0 << "ms";
std::ofstream file_rho("rho.txt");
if (file_rho.is_open())
{
for (const auto &row : r)
{
for (const auto &elem : row)
{
file_rho << elem[0] << " ";
}
file_rho << "\n";
}
}
file_rho.close();
system("pause");
return 0;
}