-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtau.cpp
More file actions
48 lines (39 loc) · 1.37 KB
/
Copy pathtau.cpp
File metadata and controls
48 lines (39 loc) · 1.37 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
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <vector>
#include "input.h"
#include "geom.h"
#include "tau.h"
double calculateOpticalDepth(const Problem& prob, int start, int end, const Geometry& geom, Eigen::VectorXd sigma_t)
{
std::vector<int> mats{ prob.cellMaterial };
double tau{ 0.0 };
if (start == end)
return tau; // No distance within the same cell
else if (start+1 == end)
return tau; // No distance between adjacent cells
else if (start < end) // going forwards
{
double sigma{ 1.0 };
for (size_t i = start+1; i < end; i++) // iterate
{
tau += sigma_t[i]*(geom.edges[i+1] - geom.edges[i]);
}
return tau;
}
else // going backwards
return -1;
}
std::vector<std::vector<double>> createOpticalDepthMatrix(const Problem& prob,
const Geometry& geom, Eigen::VectorXd sigma_t)
{
size_t n{ geom.indices.size() };
std::vector<std::vector<double>> opticalDepthMatrix{
std::vector<std::vector<double>>(n, std::vector<double>(n))};
for (size_t i = 0; i < n; i++) // iterate over indices
for (size_t j = 0; j < n; j++)
opticalDepthMatrix[i][j] = calculateOpticalDepth(prob, i, j, geom, sigma_t);
for (int i = 0; i < n; i++)
for (int j = 0; j < i; j++)
opticalDepthMatrix[i][j] = opticalDepthMatrix[j][i];
return opticalDepthMatrix;
}