-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcell.cpp
More file actions
211 lines (166 loc) · 4.69 KB
/
Copy pathcell.cpp
File metadata and controls
211 lines (166 loc) · 4.69 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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#include "cell.hpp"
Cell::Cell() {};
// Pressure Get and Set
double& Cell::pressure() {
return *_pressure;
}
void Cell::set_pressure(double& value) {
*_pressure = value;
}
void Cell::set_pressure_addr(double& addr){
_pressure = &addr;
};
// Temperatur Get and Set
double& Cell::temperature() {
return *_temperatur;
}
void Cell::set_temperature(double &value) {
*_temperatur = value;
}
void Cell::set_temperature_addr(double& addr){
_temperatur = &addr;
};
// Velocity Get and Set
double& Cell::velocity(velocity_type type) {
double* vel;
switch (type) {
case velocity_type::U:
vel = _vel_u;
break;
case velocity_type::V:
vel = _vel_v;
break;
}
return *vel;
};
// Velocity Get and Set
double& Cell::velocity_u() {
return *_vel_u;
};
// Velocity Get and Set
double& Cell::velocity_v() {
return *_vel_v;
};
void Cell::set_velocity(double& value, velocity_type type) {
switch (type) {
case velocity_type::U:
*_vel_u = value;
break;
case velocity_type::V:
*_vel_v = value;
break;
}
};
void Cell::set_velocity_u(double& value) {
*_vel_u = value;
};
void Cell::set_velocity_addr_u(double& addr){
_vel_u = &addr;
};
void Cell::set_velocity_addr_v(double& addr){
_vel_v = &addr;
};
void Cell::set_velocity_v(double& value) {
*_vel_v = value;
};
// borders Get and Set
bool& Cell::border(border_position position) {
return _border[static_cast<int>(position)];
};
// Set border
void Cell::set_border(border_position position) {
_border[static_cast<int>(position)] = true;
};
Cell* Cell::neighbour(neighbour_position position) {
Cell* ret = nullptr;
switch(position) {
case neighbour_position::TOP:
ret = _top;
case neighbour_position::BOTTOM:
ret = _bottom;
case neighbour_position::LEFT:
ret = _left;
case neighbour_position::RIGHT:
ret = _right;
}
return ret;
}
Cell* Cell::neighbour_top() {
return _top;
}
Cell* Cell::neighbour_bottom() {
return _bottom;
}
Cell* Cell::neighbour_left() {
return _left;
}
Cell* Cell::neighbour_right() {
return _right;
}
void Cell::set_neighbours(Cell *top, Cell *bottom, Cell *left, Cell *right) {
_top = top;
_bottom = bottom;
_left = left;
_right = right;
if (*_type == cell_type::NOSLIP ) {
int count = 0;
if (_top != nullptr) count += _top->type() == cell_type::FLUID;
if (_bottom != nullptr) count += _bottom->type() == cell_type::FLUID;
if (_left != nullptr) count += _left->type() == cell_type::FLUID;
if (_right != nullptr) count += _right->type() == cell_type::FLUID;
if (count > 2) {
throw "Obstical cell has more than 2 fluid neighbours!";
}
if((is_fluid(top) || is_inlet(top) || is_outlet(top)) && !is_fluid(left) && !is_fluid(right) && !is_fluid(bottom)) {
_boundary = boundary_type::B_N;
}
if(!is_fluid(top) && !is_fluid(left) && is_fluid(right) && !is_fluid(bottom)) {
_boundary = boundary_type::B_E;
}
if(!is_fluid(top) && is_fluid(left) && !is_fluid(right) && !is_fluid(bottom)) {
_boundary = boundary_type::B_W;
}
if(!is_fluid(top) && !is_fluid(left) && !is_fluid(right) && (is_fluid(bottom) || is_inlet(bottom) || is_outlet(bottom))) {
_boundary = boundary_type::B_S;
}
if(is_fluid(top) && !is_fluid(left) && is_fluid(right) && !is_fluid(bottom)) {
_boundary = boundary_type::B_NE;
}
if(is_fluid(top) && is_fluid(left) && !is_fluid(right) && !is_fluid(bottom)) {
_boundary = boundary_type::B_NW;
}
if(!is_fluid(top) && !is_fluid(left) && is_fluid(right) && is_fluid(bottom)) {
_boundary = boundary_type::B_SE;
}
if(!is_fluid(top) && is_fluid(left) && !is_fluid(right) && is_fluid(bottom)) {
_boundary = boundary_type::B_SW;
}
}
}
cell_type& Cell::type() {
return *_type;
}
void Cell::set_type(cell_type type) {
*_type = type;
}
bool Cell::is_type(cell_type type) {
return *_type == type;
}
bool Cell::is_fluid() {
return *_type == cell_type::FLUID ;
}
bool Cell::is_fluid(Cell *cell) {
return cell != nullptr && cell->is_fluid();
}
bool Cell::is_inlet(Cell *cell) {
return cell != nullptr && cell->is_type(cell_type::INLET);
}
bool Cell::is_outlet(Cell *cell) {
return cell != nullptr && cell->is_type(cell_type::OUTLET);
}
boundary_type& Cell::boundary() {
return _boundary;
}
void Cell::set_type_addr(cell_type& addr){
_type = &addr;
};