-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (32 loc) · 1.13 KB
/
Copy pathmain.cpp
File metadata and controls
38 lines (32 loc) · 1.13 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
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include "init_conds.hpp"
#include "solver.hpp"
int main(int argc, char *argv[]) {
if (argc < 6) {
printf("Usage is HeatSolver <Length> <Time> <Length Delta> <Time Delta> "
"<Print Length Delta> <Print Time Delta> <Solver>"
"<Output file>\n");
return 1;
}
double DEL_X = std::stod(argv[3]), DEL_T = std::stod(argv[4]),
T = std::stod(argv[2]), L = std::stod(argv[1]),
PDEL_X = std::stod(argv[5]), PDEL_T = std::stod(argv[6]);
char *solver = argv[7];
char *out_path = argv[8];
const int X_LEN = static_cast<unsigned>(std::ceil(L / DEL_X));
double *init = new double[X_LEN];
for (int i = 0; i <= X_LEN; i++)
init[i] = vshape(i * DEL_X, L);
if (strcmp(solver, "finite_diff") == 0)
difference_recurrence(out_path, init, L, T, DEL_X, DEL_T, PDEL_X, PDEL_T);
else if (strcmp(solver, "finite_diff_scaled") == 0)
difference_recurrence_scaled(out_path, init, L, T, DEL_X, DEL_T, PDEL_X,
PDEL_T);
else
printf("Invalid solver \"%s\"\n", solver);
delete[] init;
return 0;
}