-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspace_grid.cpp
44 lines (35 loc) · 1.33 KB
/
space_grid.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
#include "space_grid.h"
vector<double> Make_1D_x_grid(size_t x_size, double distance){
/* This function build 1D grid size of "v_size"
* with boundaries [-Vmax, Vmax].
* Attention!!! Grid includes point v = 0. So v_size must be odd!
* function throws exception "invalid_argument"
*/
vector<double> result;
result.reserve(x_size);
for(size_t i = 0; i < x_size; ++i){
result.push_back( (0.5 + i) * distance / x_size );
}
return result;
}
Walls::Walls(const pair<BC_Type, BC_Type>& walls_BC_Type, const pair<double, double>& walls_temperature) : walls_BC(walls_BC_Type),
walls_T(walls_temperature){};
SpaceGrid::SpaceGrid(size_t x_size, double distance, const pair<BC_Type, BC_Type>& walls_BC_Type, const pair<double, double>& walls_temperature) :
x_grid(Make_1D_x_grid(x_size, distance)), walls( Walls(walls_BC_Type, walls_temperature) ){}
SpaceGrid::SpaceGrid() : x_grid(vector<double>({0})),
walls(Walls(make_pair(BC_Type::empty, BC_Type::empty), make_pair(0.0,0.0))) {}
size_t SpaceGrid::GetSize() const{
return x_grid.size();
}
double SpaceGrid::GetGridStep() const{
return x_grid[1] - x_grid[0];
}
vector<double> SpaceGrid::Get1DGrid() const{
return x_grid;
}
double SpaceGrid::GetDistance() const{
return *x_grid.rbegin();
}
Walls SpaceGrid::GetWalls() const{
return walls;
}