An open source method of characteristics neutron transport code.
TrackGenerator.h
Go to the documentation of this file.
1 
9 #ifndef TRACKGENERATOR_H_
10 #define TRACKGENERATOR_H_
11 
12 #ifdef __cplusplus
13 #define _USE_MATH_DEFINES
14 #ifdef SWIG
15 #include "Python.h"
16 #endif
17 #include "Track.h"
18 #include "Geometry.h"
19 #include "MOCKernel.h"
20 #include "segmentation_type.h"
21 #include <iostream>
22 #include <fstream>
23 #include <sstream>
24 #include <unistd.h>
25 #include <omp.h>
26 #endif
27 
28 
37 
38 protected:
39 
42 
44  int _num_azim;
45 
47  double _azim_spacing;
48 
51 
54  int* _num_x;
55 
58  int* _num_y;
59 
62 
65 
68 
71 
74 
76  std::string _tracks_filename;
77 
79  omp_lock_t* _FSR_locks;
80 
84 
88 
91 
93  double _z_coord;
94 
96  bool _periodic;
97 
100 
102  FP_PRECISION _max_optical_length;
103 
106 
109 
113 
115  FP_PRECISION* _FSR_volumes;
116 
119 
121  double _x_min;
122  double _y_min;
123  double _z_min;
124  double _x_max;
125  double _y_max;
126  double _z_max;
127 
129  virtual void initializeTracks();
131  virtual void segmentize();
132  virtual void setContainsSegments(bool contains_segments);
133  virtual void allocateTemporarySegments();
134  virtual void resetStatus();
135  virtual void initializeDefaultQuadrature();
136  virtual void writeExtrudedFSRInfo(FILE* out);
137  virtual void readExtrudedFSRInfo(FILE* in);
138  virtual std::string getTestFilename(std::string directory);
139 
140 public:
141 
142  TrackGenerator(Geometry* geometry, int num_azim, double azim_spacing);
143  virtual ~TrackGenerator();
144 
145  /* Get parameters */
146  int getNumAzim();
147  double getDesiredAzimSpacing();
149  virtual long getNumTracks();
150  virtual long getNumSegments();
151  long getNum2DTracks();
152  long getNum2DSegments();
153  void countSegments();
154  bool getPeriodic();
156  Track** getTracksArray();
157  Track** get2DTracks();
158  FP_PRECISION getMaxOpticalLength();
159  int getMaxNumSegments();
160  int getNumThreads();
161  int getNumX(int azim);
162  int getNumY(int azim);
163  void exportFSRVolumes(double* out_volumes, int num_fsrs);
164  void initializeVolumes();
166  FP_PRECISION* getFSRVolumesBuffer();
167  FP_PRECISION* getFSRVolumes();
168  FP_PRECISION getFSRVolume(long fsr_id);
169  double getZCoord();
171  FP_PRECISION retrieveMaxOpticalLength();
172  omp_lock_t* getFSRLocks();
174  virtual bool containsTracks();
175  virtual bool containsSegments();
176  int get2DTrackID(int a, int x);
177  long* getTracksPerAzim();
178 
179  /* Set parameters */
180  void setNumThreads(int num_threads);
181  void setNumAzim(int num_azim);
182  void setDesiredAzimSpacing(double spacing);
183  void setGeometry(Geometry* geometry);
184  void setZCoord(double z_coord);
185  void setQuadrature(Quadrature* quadrature);
186  void setMaxOpticalLength(FP_PRECISION tau);
187  void setMaxNumSegments(int max_num_segments);
188  void setDumpSegments(bool dump_segments);
189 
190  /* Worker functions */
191  virtual void retrieveTrackCoords(double* coords, long num_tracks);
192  void retrieve2DTrackCoords(double* coords, long num_tracks);
193  virtual void retrieveSegmentCoords(double* coords, long num_segments);
194  void retrieve2DSegmentCoords(double* coords, long num_segments);
195  void generateFSRCentroids(FP_PRECISION* FSR_volumes);
196  void generateTracks();
197  void splitSegments(FP_PRECISION max_optical_length);
198  double leastCommonMultiple(double a, double b);
199  void dumpSegmentsToFile();
200  bool readSegmentsFromFile();
202  void initializeTracksArray();
203  virtual void checkBoundaryConditions();
204 
205  /* Log functions */
206  void printTimerReport(bool mpi_reduce);
207  void printMemoryReport();
208 };
209 
210 
211 #endif /* TRACKGENERATOR_H_ */
virtual void resetStatus()
Resets the TrackGenerator to not contain tracks or segments.
Definition: TrackGenerator.cpp:1790
virtual void initializeDefaultQuadrature()
Allocates a new Quadrature with the default Quadrature.
Definition: TrackGenerator.cpp:879
Track ** _tracks_2D
Definition: TrackGenerator.h:64
int getNumY(int azim)
Returns the number of 2D Tracks in the y-direction for a given azimuthal angle index.
Definition: TrackGenerator.cpp:334
void countSegments()
Counts the number of segments for each Track in the Geometry.
Definition: TrackGenerator.cpp:1723
void dumpSegmentsToFile()
Writes all Track and segment data to a "*.tracks" binary file.
Definition: TrackGenerator.cpp:1349
int * _num_y
Definition: TrackGenerator.h:58
virtual long getNumTracks()
Return the total number of Tracks across the Geometry.
Definition: TrackGenerator.cpp:189
virtual void initializeTracks()
Initializes Track azimuthal angles, start and end Points.
Definition: TrackGenerator.cpp:942
void retrieve2DSegmentCoords(double *coords, long num_segments)
Fills an array with the x,y,z coordinates for each Track segment.
Definition: TrackGenerator.cpp:685
FP_PRECISION * _FSR_volumes
Definition: TrackGenerator.h:115
segmentationType _segment_formation
Definition: TrackGenerator.h:99
FP_PRECISION * getFSRVolumesBuffer()
Return the array used to store the FSR volumes.
Definition: TrackGenerator.cpp:179
int getNumThreads()
Returns the number of shared memory OpenMP threads in use.
Definition: TrackGenerator.cpp:312
virtual void retrieveSegmentCoords(double *coords, long num_segments)
Fills an array with the x,y,z coordinates for each Track segment.
Definition: TrackGenerator.cpp:664
void splitSegments(FP_PRECISION max_optical_length)
Splits Track segments into sub-segments for a user-defined maximum optical length for the problem...
Definition: TrackGenerator.cpp:1611
TrackGenerator(Geometry *geometry, int num_azim, double azim_spacing)
Constructor for the TrackGenerator assigns default values.
Definition: TrackGenerator.cpp:11
void initializeTracksArray()
Creates a Track array by increasing uid.
Definition: TrackGenerator.cpp:1742
void initializeTrackFileDirectory()
This method creates a directory to store Track files, and reads in ray tracing data for Tracks and se...
Definition: TrackGenerator.cpp:1287
bool _use_input_file
Definition: TrackGenerator.h:73
The TrackGenerator is dedicated to generating and storing Tracks which cyclically wrap across the Geo...
Definition: TrackGenerator.h:36
void setGeometry(Geometry *geometry)
Set a pointer to the Geometry to use for track generation.
Definition: TrackGenerator.cpp:528
virtual void setContainsSegments(bool contains_segments)
Updates whether the TrackGenerator contains segments.
Definition: TrackGenerator.cpp:1339
int get2DTrackID(int a, int x)
Get the id of a 2D Track based on its azimuthal angle and index in the azimuthal stack.
Definition: TrackGenerator.cpp:1812
segmentationType
The types of Track segmentation supported by OpenMOC.
Definition: segmentation_type.h:15
virtual long getNumSegments()
Return the total number of Track segments across the Geometry.
Definition: TrackGenerator.cpp:213
virtual std::string getTestFilename(std::string directory)
Returns the filename for writing tracking data.
Definition: TrackGenerator.cpp:1314
An MOCKernel object.
int getMaxNumSegments()
Returns the maximum number of segments along a single track.
Definition: TrackGenerator.cpp:303
The arbitrary quadrature parent class.
Definition: Quadrature.h:76
double getZCoord()
Returns the z-coord of the radial plane used in 2D calculations.
Definition: TrackGenerator.cpp:418
bool _segments_centered
Definition: TrackGenerator.h:112
virtual void readExtrudedFSRInfo(FILE *in)
Read information of all Extruded FSRs from a file.
Definition: TrackGenerator.cpp:1600
The master class containing references to all geometry-related objects - Surfaces, Cells, Universes and Lattices - and Materials.
Definition: Geometry.h:122
double getDesiredAzimSpacing()
Return the track azimuthal spacing (cm).
Definition: TrackGenerator.cpp:93
virtual void retrieveTrackCoords(double *coords, long num_tracks)
Fills an array with the x,y,z coordinates for each Track.
Definition: TrackGenerator.cpp:600
int _num_threads
Definition: TrackGenerator.h:41
virtual void writeExtrudedFSRInfo(FILE *out)
Write information of all Extruded FSRs to a file TODO Use implementation in 3D track generator...
Definition: TrackGenerator.cpp:1467
void setZCoord(double z_coord)
Sets the z-coord of the radial plane used in 2D calculations.
Definition: TrackGenerator.cpp:544
void generateFSRCentroids(FP_PRECISION *FSR_volumes)
Generates the numerical centroids of the FSRs.
Definition: TrackGenerator.cpp:1636
bool _dump_segments
Definition: TrackGenerator.h:108
void printTimerReport(bool mpi_reduce)
Print the track generation timer report.
Definition: TrackGenerator.cpp:1828
void generateTracks()
Generates tracks for some number of azimuthal angles and track spacing.
Definition: TrackGenerator.cpp:787
void exportFSRVolumes(double *out_volumes, int num_fsrs)
FSR volumes are copied to an array input by the user.
Definition: TrackGenerator.cpp:345
virtual void segmentize()
Generate segments for each Track across the Geometry.
Definition: TrackGenerator.cpp:1218
bool _contains_2D_segments
Definition: TrackGenerator.h:87
void retrieve2DTrackCoords(double *coords, long num_tracks)
Fills an array with the x,y,z coordinates for each Track.
Definition: TrackGenerator.cpp:621
void initializeFSRVolumesBuffer()
Initialize an array to contain the FSR volumes.
Definition: TrackGenerator.cpp:162
void setNumAzim(int num_azim)
Set the number of azimuthal angles in .
Definition: TrackGenerator.cpp:495
void setDumpSegments(bool dump_segments)
Sets a flag to record all segment information in the tracking file.
Definition: TrackGenerator.cpp:1782
virtual void checkBoundaryConditions()
Checks the boundary conditions for all 2D surfaces for inconsistent periodic boundary conditions...
Definition: TrackGenerator.cpp:745
bool _contains_2D_tracks
Definition: TrackGenerator.h:83
int _num_azim
Definition: TrackGenerator.h:44
omp_lock_t * _FSR_locks
Definition: TrackGenerator.h:79
int getNumX(int azim)
Returns the number of 2D Tracks in the x-direction for a given azimuthal angle index.
Definition: TrackGenerator.cpp:323
segmentationType getSegmentFormation()
Returns the type of ray tracing used for segment formation.
Definition: TrackGenerator.cpp:930
virtual void allocateTemporarySegments()
Allocates memory for temporary segment storage if necessary.
Definition: TrackGenerator.cpp:1802
Timer * _timer
Definition: TrackGenerator.h:118
virtual ~TrackGenerator()
Destructor frees memory for all Tracks.
Definition: TrackGenerator.cpp:38
FP_PRECISION getMaxOpticalLength()
Calculates and returns the maximum optical length for any segment in the Geometry.
Definition: TrackGenerator.cpp:290
Track ** getTracksArray()
Returns an array of the Track pointers by increasing UID.
Definition: TrackGenerator.cpp:261
void printMemoryReport()
Print the track generation memory report.
Definition: TrackGenerator.cpp:1845
bool _periodic
Definition: TrackGenerator.h:96
FP_PRECISION _max_optical_length
Definition: TrackGenerator.h:102
FP_PRECISION * getFSRVolumes()
Computes and returns an array of volumes indexed by FSR.
Definition: TrackGenerator.cpp:359
int * _num_x
Definition: TrackGenerator.h:54
long * _tracks_per_azim
Definition: TrackGenerator.h:61
Geometry * getGeometry()
Return the Geometry for this TrackGenerator if one has been set.
Definition: TrackGenerator.cpp:102
std::string _tracks_filename
Definition: TrackGenerator.h:76
int _max_num_segments
Definition: TrackGenerator.h:105
double leastCommonMultiple(double a, double b)
Calculates the least common multiple of two numbers a and b.
Definition: TrackGenerator.cpp:897
bool getPeriodic()
Returns whether periodic boundaries are present in Track generation.
Definition: TrackGenerator.cpp:1772
virtual bool containsSegments()
Returns whether or not the TrackGenerator contains segments for its current number of azimuthal angle...
Definition: TrackGenerator.cpp:579
double _x_min
Definition: TrackGenerator.h:121
Quadrature * getQuadrature()
Returns the Quadrature object.
Definition: TrackGenerator.cpp:427
double _z_coord
Definition: TrackGenerator.h:93
Quadrature * _quadrature
Definition: TrackGenerator.h:90
long getNum2DTracks()
Return the total number of 2D Tracks across the Geometry.
Definition: TrackGenerator.cpp:198
Track ** _tracks_2D_array
Definition: TrackGenerator.h:67
double _azim_spacing
Definition: TrackGenerator.h:47
void setMaxOpticalLength(FP_PRECISION tau)
Sets the max optical path length of 3D segments for use in on-the-fly computation.
Definition: TrackGenerator.cpp:1691
void initializeVolumes()
Computes the volumes/areas of each Cell and Material in the Geometry.
Definition: TrackGenerator.cpp:132
void initializeTrackReflections()
Initializes 2D Track reflections.
Definition: TrackGenerator.cpp:1078
The Timer class is for timing and profiling regions of code.
Definition: Timer.h:40
int _num_2D_tracks
Definition: TrackGenerator.h:50
bool readSegmentsFromFile()
Reads Tracks in from a "*.tracks" binary file.
Definition: TrackGenerator.cpp:1476
omp_lock_t * getFSRLocks()
Return the array of FSR locks for atomic FSR operations.
Definition: TrackGenerator.cpp:115
virtual bool containsTracks()
Returns whether or not the TrackGenerator contains Tracks for its current number of azimuthal angles...
Definition: TrackGenerator.cpp:568
void setNumThreads(int num_threads)
Sets the number of shared memory OpenMP threads to use (>0).
Definition: TrackGenerator.cpp:436
The generic Track class.
FP_PRECISION retrieveMaxOpticalLength()
Retrieves the max optical path length of 3D segments for use in on-the-fly computation.
Definition: TrackGenerator.cpp:1710
A Track represents a characteristic line across the geometry.
Definition: Track.h:67
void setMaxNumSegments(int max_num_segments)
Sets the maximum number of segments per Track.
Definition: TrackGenerator.cpp:1700
long * getTracksPerAzim()
Return the number of tracks for each azimuthal angle.
Definition: TrackGenerator.cpp:72
void setDesiredAzimSpacing(double spacing)
Set the suggested azimuthal track spacing (cm).
Definition: TrackGenerator.cpp:514
FP_PRECISION getFSRVolume(long fsr_id)
Returns the volume of an FSR.
Definition: TrackGenerator.cpp:401
The Geometry class.
Track ** get2DTracks()
Returns a 2D jagged array of the 2D Tracks.
Definition: TrackGenerator.cpp:272
void setQuadrature(Quadrature *quadrature)
Sets the Quadrature used for integrating the MOC equations.
Definition: TrackGenerator.cpp:557
int getNumAzim()
Return the number of azimuthal angles in .
Definition: TrackGenerator.cpp:81
long getNum2DSegments()
Return the total number of 2D Track segments across the Geometry.
Definition: TrackGenerator.cpp:222
Track ** get2DTracksArray()
Returns an array of the Track pointers by increasing UID.
Definition: TrackGenerator.cpp:246
Geometry * _geometry
Definition: TrackGenerator.h:70