-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample9_1.cpp
65 lines (59 loc) · 1.32 KB
/
Example9_1.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
#include <iostream>
#include <fstream>
#include "wrappers.h"
int main(int, char**)
{
// analytic solution
vec3d Ul(1.0, 1.0, 0.0);
vec3d Ur(0.125, 0.100, 0.0);
auto solver = RPSolver(Ul, Ur);
solver.solve();
int n = 100;
auto U0 = vector<vec3d>(n);
for (auto i = 0; i < n; i++)
{
if (i < n / 2)
{
U0[i] << 1.0, 1.0, 0.0;
}
else
{
U0[i] << 0.125, 0.100, 0.0;
}
}
FVM_1D numericSolver(U0, 0.0, 1.0);
numericSolver.setEndingTime(0.15);
auto r = numericSolver.solve();
// write the numeric result to the files
ofstream oFileRho("./test_rho.txt");
ofstream oFileP("./test_p.txt");
ofstream oFileU("./test_u.txt");
if (oFileRho && oFileP && oFileU)
{
for (auto i = 0; i < r.size(); i++)
{
oFileRho << r[i](0) << ' ';
oFileP << r[i](1) << ' ';
oFileU << r[i](2) << ' ';
}
oFileRho.close();
oFileP.close();
oFileU.close();
}
ofstream oFileRho_("./test_rho_exa.txt");
ofstream oFileP_("./test_p_exa.txt");
ofstream oFileU_("./test_u_exa.txt");
if (oFileRho_ && oFileP_ && oFileU_)
{
for (auto i = 0; i < 1000; i++)
{
oFileRho_ << solver(0.001 * double(i - 500), 0.15)(0) << ' ';
oFileP_ << solver(0.001 * double(i - 500), 0.15)(1) << ' ';
oFileU_ << solver(0.001 * double(i - 500), 0.15)(2) << ' ';
}
oFileRho_.close();
oFileP_.close();
oFileU_.close();
}
return 0;
}