-
Notifications
You must be signed in to change notification settings - Fork 0
/
input_check.cpp
70 lines (61 loc) · 1.53 KB
/
input_check.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
#include <iostream>
int input_check(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) {
if(!(I > 0) || !(J > 0) || !(K > 0) || !(M > 0)) {
std::cout << "Error in I, J, K or M.\n";
return -1;
}
// cell size > 0
for(int i = 0; i < I; i++) {
if(dx[i] <= 0) {
std::cout << "Error in x-dimension cell size.\n";
return -2;
}
}
for(int j = 0; j < J; j++) {
if(dy[j] <= 0) {
std::cout << "Error in y-dimension cell size.\n";
return -2;
}
}
for(int k = 0; k < K; k++) {
if((mu[k] < -1) || (eta[k] < -1) || (mu[k] > 1) || (eta[k] > 1) || (w[k] < 0)) {
std::cout << "Error in angular quadrature.\n";
return -3;
}
}
// SigmaT >= SigmaS
for(int i = 0; i < M; i++) {
if((SigmaT[i] < 0) || (SigmaS[i] < 0) || (SigmaT[i] < SigmaS[i])) {
std::cout << "Error in cross section.\n";
return -4;
}
}
// BCs = 0 or 1
for(int i = 0; i < 4; i++) {
if(!(BC[i] == 0 || BC[i] == 1)) {
std::cout << "Error in boundary condition.\n";
return -5;
}
}
// material indices between 1 & the number of materials
for(int j = 0; j < J; j++) {
for(int i = 0; i < I; i++) {
if(materialMatrix[j*I + i] < 1 || materialMatrix[j*I + i] > M) {
std::cout << "Error in material matrix.\n";
return -6;
}
}
}
for(int j = 0; j < J; j++) {
for(int i = 0; i < I; i++) {
if(sourceMatrix[j*I + i] < 0) {
std::cout << "Error in source matrix.\n";
return -7;
}
}
}
return 0;
}