-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
89 lines (77 loc) · 2.01 KB
/
main.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
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
#include <iostream>
#include <fstream>
#include <string>
#include <chrono>
#include <ctime>
#include "version_data.h"
#include "input_data.h"
#include "input_check.h"
#include "input_echo.h"
#include "transport_solver.h"
int main(int argc, char **argv) {
// Record program start time.
auto start = std::chrono::system_clock::now();
// Process i/o files.
std::string dot_in(argv[1]);
std::string dummy = dot_in;
std::string dot_out = dummy.erase(dummy.length() - 3).append(".out");
// Print version data of the program.
version_data(dot_out);
// Initialize variables.
int I, J, K, M;
double *dx, *dy;
double *mu, *eta, *w;
double *SigmaT, *SigmaS;
double *BC;
int *materialMatrix;
double *sourceMatrix;
double conCrit;
int maxIter;
// Read input data.
input_data(I, J, dx, dy,
K, mu, eta, w,
M, SigmaT, SigmaS, BC,
materialMatrix, sourceMatrix,
conCrit, maxIter, dot_in);
// Check input.
int check = input_check(I, J, dx, dy,
K, mu, eta, w,
M, SigmaT, SigmaS, BC,
materialMatrix, sourceMatrix);
if(check != 0) {
std::cout << "Error in input. Terminating program.\n";
return -9;
} else {
std::cout << "Input check successful. Proceeding with execution.\n";
}
// Echo input data.
input_echo(I, J, dx, dy,
K, mu, eta, w,
M, SigmaT, SigmaS, BC,
materialMatrix, sourceMatrix, dot_out);
// Solve transport equation.
transport_solver(I, J, dx, dy,
K, mu, eta, w,
M, SigmaT, SigmaS, BC,
materialMatrix, sourceMatrix,
conCrit, maxIter, dot_out);
// Free allocated space.
delete[] dx;
delete[] dy;
delete[] mu;
delete[] eta;
delete[] w;
delete[] SigmaT;
delete[] SigmaS;
delete[] BC;
delete[] materialMatrix;
delete[] sourceMatrix;
// Record program end time.
auto end = std::chrono::system_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
std::ofstream outputFile;
outputFile.open(dot_out, std::ofstream::app);
outputFile << "Execution time: " << elapsed.count() << " microseconds\n";
outputFile.close();
return 0;
}