-
Notifications
You must be signed in to change notification settings - Fork 2
/
heat.hpp
57 lines (47 loc) · 959 Bytes
/
heat.hpp
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
#ifndef HEAT_HPP
#define HEAT_HPP
#include <cmath>
#include <vector>
enum smode {
JSON = 0,
BINARY = 1
};
enum boundary_style {
CONSTANT = 0, // constant
PERIODIC = 1 // wraps around
};
enum initial_condition {
FLAT = 0,
GAUSSIAN = 1,
GAUSSIAN_NOISE = 2,
SPIKE = 3
};
enum disc_method {
FTCS = 0,
CRANK_NICHOLSON = 1,
JACOBI = 2,
GAUSS_SEIDEL = 3,
SOR = 4,
MULTIGRID = 5
};
enum relax_scheme {
RS_JACOBI = 0,
RS_GAUSS_SEIDEL = 1,
RS_RB_GAUSS_SEIDEL = 2
};
/// return a gaussian distribution
/* Returns an vector populated with a gaussian distribution scaled to between
* zero and one with a specified resolution.
*
* @param nx number of values in output vector
* @return filled vector of doubles
*/
std::vector<double> gaussian(size_t nx) {
std::vector<double> g(nx);
double sx = 1.0 / (nx+1);
for (size_t i = 0; i < nx; i++) {
g[i] = exp(-1*(pow((5*(double(i)/double(nx))-2.5),2)));
}
return g;
}
#endif // HEAT_HPP