-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwsolut.cpp
32 lines (22 loc) · 832 Bytes
/
wsolut.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
#include "basic_definitions.h"
/****function to write sollution output to file****/
void Wsolut(int &imax, int &ib2, double *&x, double *&a, double **&cv, double *&p){
double rho, u, temp, c, mach;
ofstream ofile("solution.dat");
ofile.flags(ios::dec | ios::scientific);
ofile.precision(5);
if(!ofile){
cerr<<"File couldn't be opened to write the solution"<<endl;
exit(1);
}
ofile<<"x"<<"\t"<<"\t"<<"a"<<"\t"<<"\t"<<"rho"<<"\t"<<"\t"<<"u"<<"\t"<<"\t"<<"p"<<"\t"<<"\t"<<"tempr"<<"\t"<<"\t"<<"mach"<<"\t"<<"\t"<<"massflow"<<endl;
for(int j=2; j<=ib2; j++){
rho = cv[0][j]/a[j];
u = cv[1][j]/cv[0][j];
temp = p[j]/(rgas*rho);
c = sqrt(Gamma*p[j]/rho);
mach = u/c;
ofile<<x[j]<<"\t"<<a[j]<<"\t"<<rho<<"\t"<<u<<"\t"<<p[j]<<"\t"<<temp<<"\t"<<mach<<"\t"<<cv[1][j]<<endl;
}
ofile.close();
}