-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgeom.cpp
More file actions
50 lines (44 loc) · 1.52 KB
/
Copy pathgeom.cpp
File metadata and controls
50 lines (44 loc) · 1.52 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
#include <iostream>
#include "input.h"
#include "geom.h"
std::vector<double> linspace(double start, double end, int num)
{
std::vector<double> result{};
double step = (end - start) / (num - 1);
for (int i = 1; i < num; i++)
result.push_back(start + i * step);
return result;
}
std::vector<double> createIntervals(const Problem& prob)
{
std::vector<double> mesh{ 0.0 };
int nPoints{ 1 };
//for (int i = 0; i < prob.dimensions.size(); i++)
//{
// // UNCOMMENT AFTER TESTING
// //if (prob.sigma[i] == 0)
// // nPoints = 2;
// //else
// // nPoints = static_cast<int>(prob.sigma[i]*prob.dimensions[i]);
// nPoints = 1;
// //assume dimensions lists width of each region
// std::vector<double> newInterval = linspace( mesh.back(), mesh.back()+prob.dimensions[i], nPoints + 1);
// mesh.insert( mesh.end(), newInterval.begin(), newInterval.end() );
//}
for (auto e : prob.dimensions)
{
nPoints = 200;
// assume dimensions lists cumulative distance
std::vector<double> newInterval = linspace(mesh.back(), e, nPoints + 1);
mesh.insert(mesh.end(), newInterval.begin(), newInterval.end());
}
std::cout << nPoints << " points per region" << '\n';
return mesh;
}
std::vector<double> findMidpoints(const std::vector<double>& mesh)
{
std::vector<double> midpoints{};
for (int i = 0; i < mesh.size() - 1; i++)
midpoints.push_back((mesh[i] + mesh[i + 1]) / 2.);
return midpoints;
}