An open source method of characteristics neutron transport code.
Track.h
Go to the documentation of this file.
1 
8 #ifndef TRACK_H_
9 #define TRACK_H_
10 
11 #ifdef __cplusplus
12 #ifdef SWIG
13 #include "Python.h"
14 #endif
15 #include "Point.h"
16 #include "Material.h"
17 #include "boundary_type.h"
18 #include <vector>
19 #include <algorithm>
20 #endif
21 
27 struct segment {
28 
30  double _length;
31 
34 
37 
40 
43 
46 
48  FP_PRECISION _starting_position[3];
49 
51  segment() {
52  _track_idx = 0;
53  _material = NULL;
54  _cmfd_surface_fwd = -1;
55  _cmfd_surface_bwd = -1;
56  _starting_position[2] = 0.;
57  }
58 };
59 
60 
67 class Track {
68 
69 protected:
70 
72  int _uid;
73 
76 
79 
81  double _phi;
82 
84  std::vector<segment> _segments;
85 
88 
93 
98 
99  /* Indices that are used to locate the track in the various track arrays */
100  int _azim_index;
101  int _xy_index;
102  int _link_index;
103 
107  long _track_next_bwd;
108  long _track_prdc_fwd;
109  long _track_prdc_bwd;
110  long _track_refl_fwd;
111  long _track_refl_bwd;
112 
117  bool _next_bwd_fwd;
118 
121  //FIXME
123 
126  int _surface_out;
127 
130  int _domain_bwd;
131 
132 public:
133  Track();
134  virtual ~Track();
135 
136  /* Setter methods */
137  virtual void setValues(const double start_x, const double start_y,
138  const double end_x, const double end_y,
139  const double phi);
140  virtual void setCoords(double x0, double y0,
141  double x1, double y1);
142  void setUid(int uid);
143  void setPhi(const double phi);
144  void setBCFwd(const boundaryType bc_fwd);
145  void setBCBwd(const boundaryType bc_bwd);
146  void setTrackNextFwd(long track_id);
147  void setTrackNextBwd(long track_id);
148  void setTrackPrdcFwd(long track_id);
149  void setTrackPrdcBwd(long track_id);
150  void setTrackReflFwd(long track_id);
151  void setTrackReflBwd(long track_id);
152  void setNextFwdFwd(bool fwd);
153  void setNextBwdFwd(bool fwd);
154  void setXYIndex(int index);
155  void setAzimIndex(int index);
156  void setSurfaceIn(int surface_in);
157  void setSurfaceOut(int surface_out);
158  void setDomainFwd(int neighbor);
159  void setDomainBwd(int neighbor);
160  void setLinkIndex(int index);
161 
162  /* Getter methods */
163  int getUid();
164  Point* getEnd();
165  Point* getStart();
166  double getPhi() const;
167  double getLength();
168  long getTrackNextFwd();
169  long getTrackNextBwd();
170  long getTrackPrdcFwd();
171  long getTrackPrdcBwd();
172  long getTrackReflFwd();
173  long getTrackReflBwd();
174  bool getNextFwdFwd();
175  bool getNextBwdFwd();
176  int getXYIndex();
177  int getAzimIndex();
178  int getLinkIndex();
179  boundaryType getBCFwd() const;
180  boundaryType getBCBwd() const;
181  segment* getSegment(int s);
182  segment* getSegments();
183  int getNumSegments();
184  int getDomainFwd();
185  int getDomainBwd();
186  int getSurfaceIn();
187  int getSurfaceOut();
188 
189  /* Worker methods */
190  void addSegment(segment* segment);
191  void removeSegment(int index);
192  void insertSegment(int index, segment* segment);
193  void clearSegments();
194  void setNumSegments(int num_segments);
195  virtual std::string toString();
196 };
197 
198 
203 inline int Track::getUid() {
204  return _uid;
205 }
206 
207 
216 
217  /* If Track doesn't contain this segment, exits program */
218  if (segment >= (int)_segments.size())
219  log_printf(ERROR, "Attempted to retrieve segment s = %d but Track only "
220  "has %d segments", segment, _segments.size());
221 
222  return &_segments[segment];
223 }
224 
225 
226 
232  return &_segments[0];
233 }
234 
235 
240 inline int Track::getNumSegments() {
241  if (_num_segments == 0)
242  return _segments.size();
243  else
244  return _num_segments;
245 }
246 
254 inline void Track::setNumSegments(int num_segments) {
255  _num_segments = num_segments;
256 }
257 
258 
263 inline Point* Track::getEnd() {
264  return &_end;
265 }
266 
267 
273  return &_start;
274 }
275 
276 
281 inline double Track::getPhi() const {
282  return _phi;
283 }
284 
285 
292  return _bc_fwd;
293 }
294 
295 
302  return _bc_bwd;
303 }
304 
305 #endif /* TRACK_H_ */
int _cmfd_surface_fwd
Definition: Track.h:42
void setSurfaceOut(int surface_out)
Set the surface at which the Track ends.
Definition: Track.cpp:130
double getLength()
Return the Track&#39;s length.
Definition: Track.cpp:157
bool _next_fwd_fwd
Definition: Track.h:116
boundaryType _bc_fwd
Definition: Track.h:92
double _length
Definition: Track.h:30
void clearSegments()
Deletes each of this Track&#39;s segments.
Definition: Track.cpp:251
void setTrackPrdcBwd(long track_id)
Set a pointer to the periodic Track in the backward direction.
Definition: Track.cpp:335
void setTrackNextFwd(long track_id)
Set a pointer to the reflective Track in the forward direction.
Definition: Track.cpp:308
void setTrackReflFwd(long track_id)
Set a pointer to the reflective Track in the forward direction.
Definition: Track.cpp:344
Point * getEnd()
Returns a pointer to the Track&#39;s end Point.
Definition: Track.h:263
int getSurfaceIn()
Get the surface from which the track originates in the domain.
Definition: Track.cpp:166
boundaryType
The types of boundary conditions supported by OpenMOC for Surfaces.
Definition: boundary_type.h:15
segment()
Definition: Track.h:51
The Point class.
void setSurfaceIn(int surface_in)
Set the surface at which the Track starts.
Definition: Track.cpp:121
Definition: log.h:88
long getTrackReflBwd()
Get a pointer to the reflective Track in the backward direction.
Definition: Track.cpp:407
virtual ~Track()
Destructor clears the Track segments container.
Definition: Track.cpp:36
int getLinkIndex()
Get a Track&#39;s link index.
Definition: Track.cpp:299
Class to represent a 2D/3D point in space.
Definition: Point.h:24
void setUid(int uid)
Initializes a Track&#39;s unique ID.
Definition: Track.cpp:78
void setNextFwdFwd(bool fwd)
Set whether the reflective track in the forward direction is pointing in forward direction.
Definition: Track.cpp:436
int getNumSegments()
Return the number of segments along this Track.
Definition: Track.h:240
void setPhi(const double phi)
Set the Track&#39;s azimuthal angle.
Definition: Track.cpp:86
int _cmfd_surface_bwd
Definition: Track.h:45
double _phi
Definition: Track.h:81
void setNumSegments(int num_segments)
Sets the number of segments in a track.
Definition: Track.h:254
int _region_id
Definition: Track.h:36
segment * getSegment(int s)
Returns a pointer to a segment with a given index.
Definition: Track.h:215
boundaryType getBCFwd() const
Returns the boundary condition for the flux along the Track&#39;s "forward" direction.
Definition: Track.h:291
virtual std::string toString()
Convert this Track&#39;s attributes to a character array.
Definition: Track.cpp:480
void setTrackPrdcFwd(long track_id)
Set a pointer to the periodic Track in the forward direction.
Definition: Track.cpp:326
void setTrackReflBwd(long track_id)
Set a pointer to the reflective Track in the backward direction.
Definition: Track.cpp:353
void setBCBwd(const boundaryType bc_bwd)
Sets the boundary condition for the incoming flux along the Track&#39;s "reverse" direction.
Definition: Track.cpp:112
A segment represents a line segment within a single flat source region along a track.
Definition: Track.h:27
int _track_idx
Definition: Track.h:39
Material * _material
Definition: Track.h:33
segment * getSegments()
Returns a vector of pointers to the Track&#39;s segments.
Definition: Track.h:231
long getTrackPrdcFwd()
Get a pointer to the periodic Track in the forward direction.
Definition: Track.cpp:380
void removeSegment(int index)
Removes a segment from this Track&#39;s list of segments.
Definition: Track.cpp:220
std::vector< segment > _segments
Definition: Track.h:84
FP_PRECISION _starting_position[3]
Definition: Track.h:48
void setAzimIndex(int index)
Set a Track&#39;s azimuthal angle index.
Definition: Track.cpp:260
int getXYIndex()
Get the xy index of this Track.
Definition: Track.cpp:425
long getTrackNextFwd()
Get a pointer to the reflective Track in the forward direction.
Definition: Track.cpp:362
int getSurfaceOut()
Get the surface at which the Track ends in the domain.
Definition: Track.cpp:175
long getTrackReflFwd()
Get a pointer to the reflective Track in the forward direction.
Definition: Track.cpp:398
int _domain_fwd
Definition: Track.h:129
void setTrackNextBwd(long track_id)
Set a pointer to the reflective Track in the backward direction.
Definition: Track.cpp:317
long getTrackPrdcBwd()
Get a pointer to the periodic Track in the backward direction.
Definition: Track.cpp:389
int _surface_in
Definition: Track.h:125
Track()
Constructor initializes an empty Track.
Definition: Track.cpp:7
int getDomainBwd()
Get the domain connected at the back end of the Track.
Definition: Track.cpp:193
void setXYIndex(int index)
Set the xy index of this Track.
Definition: Track.cpp:416
The Material class represents a unique material and its relevant nuclear data (i.e., multigroup cross-sections) for neutron transport.
Definition: Material.h:51
double getPhi() const
Return the Track&#39;s azimuthal angle (with respect to the x-axis).
Definition: Track.h:281
virtual void setValues(const double start_x, const double start_y, const double end_x, const double end_y, const double phi)
Set the values for the Track&#39;s start and end point and angle.
Definition: Track.cpp:49
void log_printf(logLevel level, const char *format,...)
Print a formatted message to the console.
Definition: log.cpp:300
void setBCFwd(const boundaryType bc_fwd)
Sets the boundary condition for the incoming flux along the Track&#39;s "forward" direction.
Definition: Track.cpp:99
boundaryType _bc_bwd
Definition: Track.h:97
void setDomainBwd(int neighbor)
Set the domain at the end of the Track in the backward direction.
Definition: Track.cpp:148
void insertSegment(int index, segment *segment)
Inserts a segment struct into this Track&#39;s list of segments.
Definition: Track.cpp:238
virtual void setCoords(double x0, double y0, double x1, double y1)
Set the values for the Track&#39;s start and end point.
Definition: Track.cpp:65
void setDomainFwd(int neighbor)
Set the domain at the end of the Track in the forward direction.
Definition: Track.cpp:139
bool _direction_in_cycle
Definition: Track.h:122
int getDomainFwd()
Get the domain connected at the front end of the Track.
Definition: Track.cpp:184
void addSegment(segment *segment)
Adds a segment to this Track&#39;s list of segments.
Definition: Track.cpp:204
long getTrackNextBwd()
Get a pointer to the reflective Track in the backward direction.
Definition: Track.cpp:371
int getAzimIndex()
Get a Track&#39;s azimuthal angle index.
Definition: Track.cpp:284
Point _start
Definition: Track.h:75
boundaryType getBCBwd() const
Returns the boundary condition for the flux along the Track&#39;s "reverse" direction.
Definition: Track.h:301
int _num_segments
Definition: Track.h:87
bool getNextFwdFwd()
Get whether the reflective track in the forward direction is pointing in forward direction.
Definition: Track.cpp:458
int getUid()
Return the Track&#39;s unique ID.
Definition: Track.h:203
void setLinkIndex(int index)
Set a Track&#39;s link index.
Definition: Track.cpp:275
int _uid
Definition: Track.h:72
A Track represents a characteristic line across the geometry.
Definition: Track.h:67
long _track_next_fwd
Definition: Track.h:106
void setNextBwdFwd(bool fwd)
Set whether the reflective track in the backward direction is pointing in forward direction...
Definition: Track.cpp:447
bool getNextBwdFwd()
Get whether the reflective track in the backward direction is pointing in forward direction...
Definition: Track.cpp:469
Point * getStart()
Returns a pointer to the Track&#39;s start Point.
Definition: Track.h:272
Point _end
Definition: Track.h:78