-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
105 lines (95 loc) · 2.1 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
//
// main.cpp
// HighResSolvers
//
// Created by ikon on 12/18/14.
// Copyright (c) 2014 ___Imaginaire___. All rights reserved.
//
#include <iostream>
#include <fstream>
#include <ctime>
#include "Matrix.h"
#include "EulerEquations.h"
// Primitive
double rho(double x){
if (x < 0.5) {
return 1;
}
else {
return 0.125;
}
}
double p(double x){
if (x < 0.5) {
return 1;
}
else {
return 0.1;
}
}
double u(double x){
return 0;
}
double rho123(double x){
return 1;
}
double p123(double x){
return 0.4;
}
double u123(double x) {
if (x < 0.5) {
return -2;
}
else {
return 2;
}
}
void WriteDensity(Profiles& u, int nCells, std::ofstream& myfile){
for (int i = 1 ; i <= nCells; i++) {
myfile << u.u1(i) << " ";
}
}
void WriteVelocity(Profiles& u, int nCells, std::ofstream& myfile){
for (int i = 1 ; i <= nCells; i++) {
myfile << u.u2(i) << " ";
}
}
void WritePressure(Profiles& u, int nCells, std::ofstream& myfile){
for (int i = 1 ; i <= nCells; i++) {
myfile << u.u3(i) << " ";
}
}
void PrintDensity(Profiles& u, int nCells){
for (int i = 1 ; i <= nCells; i++) {
std::cout<< u.u1(i) << ", ";
}
}
void PrintVelocity(Profiles& u, int nCells){
for (int i = 1 ; i <= nCells; i++) {
std::cout<< u.u2(i) << ", ";
}
}
void PrintPressure(Profiles& u, int nCells){
for (int i = 1 ; i <= nCells; i++) {
std::cout<< u.u3(i) << ", ";
}
}
int main(int argc, const char * argv[]) {
EulerSolver sol(rho, p, u);
// EulerSolver sol(rho123,p123,u123);
int nCells = 500;
sol.SetCellNumber(nCells);
sol.SetRange(0, 1);
sol.SetTime(0, 0.25);
std::clock_t start;
double duration;
start = std::clock();
Profiles res(nCells);
sol.Solve(res, &EulerSolver::FORCEFlux);
duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
std::cout<<"Duration "<< duration <<'\n';
std::ofstream density;
std::ofstream velocity;
std::ofstream pressure;
PrintDensity(res, nCells);
}