-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmedium.h
155 lines (106 loc) · 4.6 KB
/
medium.h
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#ifndef MEDIUM_H
#define MEDIUM_H
#include "photon.h" // Photon class is a friend of the Medium class.
#include <vector>
#include <string>
#include <iostream>
using std::cout;
using std::endl;
#include <iomanip>
#include <fstream>
#include <boost/thread/mutex.hpp>
#include <boost/shared_ptr.hpp>
// Maximum number of bins that hold absorption values.
const int MAX_BINS = 101;
// Forward declaration of PressureMap and DisplacementMap objects.
class Detector;
class Layer;
class Vector3d;
// Medium is a container object that holds one or many layer objects that the
// photon is propagated through. This allows easy simulation of heterogeneous
// media with Monte Carlo simulations.
class Medium
{
public:
friend class Photon;
// Constructor.
Medium(const double x, const double y, const double z);
~Medium();
// Common initializations for the Medium object. Called from constructors.
void initCommon(void);
// Add some portion of the photon's energy that was lost at this interaction
// point (i.e. due to absorption) to the medium's grid.
void absorbEnergy(const double z, const double energy);
// Same as above, only the argument is an array of absorbed energy values
// that is copied entirely to the Medium.
void absorbEnergy(const double *energy_array);
// Print the grid for this medium.
void printGrid(const int num_photons);
// Add a layer to the medium.
void addLayer(Layer *layer);
// Add a detector to the medium.
void addDetector(Detector *detector);
// See if photon has crossed the detector plane.
int photonHitDetectorPlane(const boost::shared_ptr<Vector3d> p0);
// Return the grid where absorption was accumulated.
double * getPlanarGrid() {return Cplanar;}
// Return the number of bins used in the grid.
int getBins() {return MAX_BINS;}
// Return the radial size of the medium (cm).
double getRadialSize() {return radial_size;}
// Return the bin size of the detector array (i.e. dr).
double getRadialBinSize() {return radial_bin_size;}
// Return the number of radial positions.
double getNumRadialPos() {return num_radial_pos;}
// Assign the array which will hold the planar absorbance values.
void setPlanarArray(double *planar);
// Returns the absorption coefficient (mu_a) for a given depth (i.e. a layer).
double getLayerAbsorptionCoeff(double depth);
// Returns the scattering coefficient (mu_s) for a given depth (i.e. a layer).
double getLayerScatterCoeff(double depth);
// Return the anisotropy ('g') value for a given depth (i.e. a layer).
double getAnisotropyFromDepth(double depth);
// Return layer from depth passed in.
Layer * getLayerFromDepth(double depth);
// Return the layer above the current layer.
Layer * getLayerAboveCurrent(Layer *currentLayer);
// Return the layer below the current layer.
Layer * getLayerBelowCurrent(double depth);
// Return the max depth of the medium.
double getDepth() {return depth;}
// Return the refractive index of the medium.
//double getRefractiveIndex(void) {return refractive_index;}
// Return the bounds of the medium.
double getXbound(void) {return x_bound;}
double getYbound(void) {return y_bound;}
double getZbound(void) {return z_bound;}
private:
// Ensure the medium is defined with specific attributes, so we make the
// default constructor private.
Medium(void);
double radial_size; // Maximum radial size.
int num_radial_pos; // Number of radial positions (i.e. NR).
double radial_bin_size; // Radial bin size of the medium (i.e dr).
// The arrays that hold the weights dropped during interaction points.
//double Cplanar[MAX_BINS]; // Planar photon concentration.
double *Cplanar;
//double Ccylinder[MAX_BINS]; // Clindrical photon concentration.
//double Cspherical[MAX_BINS]; // Spherical photon concentration.
// The total depth of the medium.
double depth;
double x_bound,
y_bound,
z_bound;
// Create a STL vector to hold the layers of the medium.
std::vector<Layer *> p_layers;
// Create a STL vector to hold the detectors in the medium.
std::vector<Detector *> p_detectors;
// Mutex to serialize access to the sensor array.
boost::mutex m_sensor_mutex;
// Mutex to serialize access to the data file that is written
// by photons.
boost::mutex m_data_file_mutex;
// The refrective index outside of the medium. We assume air.
double refractive_index;
};
#endif // MEDIUM_H