-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_data.cpp
76 lines (65 loc) · 1.59 KB
/
input_data.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
#include <iostream>
#include <fstream>
#include <string>
void input_data(int &I, int &J, double *&dx, double *&dy,
int &K, double *&mu, double *&eta, double *&w,
int &M, double *&SigmaT, double *&SigmaS, double *&BC,
int *&materialMatrix, double *&sourceMatrix,
double &conCrit, int &maxIter, std::string dot_in) {
// Read from file.
std::ifstream inputFile(dot_in);
// Input I, J.
inputFile >> I >> J;
// Allocate cell sizes.
dx = new double [I];
dy = new double [J];
// Input dx, dy.
for(int i = 0; i < I; i++) {
inputFile >> dx[i];
}
for(int i = 0; i < J; i++) {
inputFile >> dy[i];
}
// Input K;
inputFile >> K;
// Allocate mu, eta, w.
mu = new double[K];
eta = new double[K];
w = new double[K];
//Input mu, eta, w.
for(int i = 0; i < K; i++) {
inputFile >> mu[i] >> eta[i] >> w[i];
}
// Input M;
inputFile >> M;
//Allocate cross sections.
SigmaT = new double[M];
SigmaS = new double[M];
//Input SigmaT, SigmaS.
for(int i = 0; i < M; i++) {
inputFile >> SigmaT[i] >> SigmaS[i];
}
// Input boundary conditions.
BC = new double[4];
for(int i = 0; i < 4; i++) {
inputFile >> BC[i];
}
// Initialize material and source matrices.
materialMatrix = new int[I*J];
sourceMatrix = new double[I*J];
// Input material matrix.
for(int j = 0; j < J; j++) {
for(int i = 0; i < I; i++) {
inputFile >> materialMatrix[j*I + i];
}
}
// Input source matrix.
for(int j = 0; j < J; j++) {
for(int i = 0; i < I; i++) {
inputFile >> sourceMatrix[j*I + i];
}
}
// Convergence criterion & max inner iterations.
inputFile >> conCrit >> maxIter;
inputFile.close();
}