-
Notifications
You must be signed in to change notification settings - Fork 0
/
Solution.cpp
135 lines (111 loc) · 2.46 KB
/
Solution.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#ifndef _SOLUTION_CPP
#include "Solution.h"
Solution::Solution(DataFile* data_file):
_df(data_file)
{
T.resize(_df->Get_Nx() * _df->Get_Ny());
rho.resize(_df->Get_Nx() * _df->Get_Ny());
if (abs(_df->Get_Aref())>1e-16)
rhostar.resize(_df->Get_Nx() * _df->Get_Ny());
}
double Solution::T_cell(int i, int j) //i la ligne et j la colonne
{
double Nx=_df->Get_Nx();
return T[i*Nx+j];
}
double Solution::T_coord(double x, double y)
{
double dx=_df->Get_dx();
double dy=_df->Get_dy();
int i=int(x/dx)+1;
int j=int(y/dy)+1;
return T_cell(i,j);
}
double Solution::rho_cell(int i, int j) //i la ligne et j la colonne
{
double Nx=_df->Get_Nx();
return rho[i*Nx+j];
}
double Solution::rho_coord(double x, double y)
{
double dx=_df->Get_dx();
double dy=_df->Get_dy();
int i=int(x/dx)+1;
int j=int(y/dy)+1;
return rho_cell(i,j);
}
double Solution::rhostar_cell(int i, int j) //i la ligne et j la colonne
{
double Nx=_df->Get_Nx();
return rhostar[i*Nx+j];
}
double Solution::rhostar_coord(double x, double y)
{
double dx=_df->Get_dx();
double dy=_df->Get_dy();
int i=int(x/dx)+1;
int j=int(y/dy)+1;
return rhostar_cell(i,j);
}
Eigen::VectorXd Solution::Get_Ty(int j)//Le vecteur de la colonne j
{
Eigen::VectorXd V;
V.resize(_df->Get_Ny());
for (int i=0; i<V.size(); i++)
V(i)=T_cell(i,j);
return V;
}
Eigen::VectorXd Solution::Get_Tx(int i)// Le vecteur de la ligne i
{
Eigen::VectorXd V;
V.resize(_df->Get_Nx());
for (int j=0; j<V.size(); j++)
V(j)=T_cell(i,j);
return V;
}
Eigen::VectorXd Solution::Get_rhoy(int j)//Le vecteur de la colonne j
{
Eigen::VectorXd V;
V.resize(_df->Get_Ny());
for (int i=0; i<V.size(); i++)
V(i)=rho_cell(i,j);
return V;
}
Eigen::VectorXd Solution::Get_rhox(int i)// Le vecteur de la ligne i
{
Eigen::VectorXd V;
V.resize(_df->Get_Nx());
for (int j=0; j<V.size(); j++)
V(j)=rho_cell(i,j);
return V;
}
Eigen::VectorXd Solution::Get_rhostary(int j)//Le vecteur de la colonne j
{
Eigen::VectorXd V;
V.resize(_df->Get_Ny());
for (int i=0; i<V.size(); i++)
V(i)=rhostar_cell(i,j);
return V;
}
Eigen::VectorXd Solution::Get_rhostarx(int i)// Le vecteur de la ligne i
{
Eigen::VectorXd V;
V.resize(_df->Get_Nx());
for (int j=0; j<V.size(); j++)
V(j)=rhostar_cell(i,j);
return V;
}
bool Solution::Is_Positive()
{
bool p = true;
for (int i=0; i< T.size(); i++)
{
if (T(i)<=0 || rho(i)<=0)
{
p = false;
}
}
return p;
}
#define _SOLUTION_CPP
#endif