An open source method of characteristics neutron transport code.
|
The TrackGenerator is dedicated to generating and storing Tracks which cyclically wrap across the Geometry. More...
#include "src/TrackGenerator.h"
Public Member Functions | |
TrackGenerator (Geometry *geometry, int num_azim, double azim_spacing) | |
Constructor for the TrackGenerator assigns default values. More... | |
virtual | ~TrackGenerator () |
Destructor frees memory for all Tracks. | |
int | getNumAzim () |
Return the number of azimuthal angles in . More... | |
double | getDesiredAzimSpacing () |
Return the track azimuthal spacing (cm). More... | |
Geometry * | getGeometry () |
Return the Geometry for this TrackGenerator if one has been set. More... | |
virtual long | getNumTracks () |
Return the total number of Tracks across the Geometry. More... | |
virtual long | getNumSegments () |
Return the total number of Track segments across the Geometry. More... | |
long | getNum2DTracks () |
Return the total number of 2D Tracks across the Geometry. More... | |
long | getNum2DSegments () |
Return the total number of 2D Track segments across the Geometry. More... | |
void | countSegments () |
Counts the number of segments for each Track in the Geometry. More... | |
bool | getPeriodic () |
Returns whether periodic boundaries are present in Track generation. More... | |
Track ** | get2DTracksArray () |
Returns an array of the Track pointers by increasing UID. More... | |
Track ** | getTracksArray () |
Returns an array of the Track pointers by increasing UID. More... | |
Track ** | get2DTracks () |
Returns a 2D jagged array of the 2D Tracks. More... | |
FP_PRECISION | getMaxOpticalLength () |
Calculates and returns the maximum optical length for any segment in the Geometry. More... | |
int | getMaxNumSegments () |
Returns the maximum number of segments along a single track. More... | |
int | getNumThreads () |
Returns the number of shared memory OpenMP threads in use. More... | |
int | getNumX (int azim) |
Returns the number of 2D Tracks in the x-direction for a given azimuthal angle index. More... | |
int | getNumY (int azim) |
Returns the number of 2D Tracks in the y-direction for a given azimuthal angle index. More... | |
void | exportFSRVolumes (double *out_volumes, int num_fsrs) |
FSR volumes are copied to an array input by the user. More... | |
void | initializeVolumes () |
Computes the volumes/areas of each Cell and Material in the Geometry. More... | |
void | initializeFSRVolumesBuffer () |
Initialize an array to contain the FSR volumes. | |
FP_PRECISION * | getFSRVolumesBuffer () |
Return the array used to store the FSR volumes. More... | |
FP_PRECISION * | getFSRVolumes () |
Computes and returns an array of volumes indexed by FSR. More... | |
FP_PRECISION | getFSRVolume (long fsr_id) |
Returns the volume of an FSR. More... | |
double | getZCoord () |
Returns the z-coord of the radial plane used in 2D calculations. More... | |
Quadrature * | getQuadrature () |
Returns the Quadrature object. More... | |
FP_PRECISION | retrieveMaxOpticalLength () |
Retrieves the max optical path length of 3D segments for use in on-the-fly computation. More... | |
omp_lock_t * | getFSRLocks () |
Return the array of FSR locks for atomic FSR operations. More... | |
segmentationType | getSegmentFormation () |
Returns the type of ray tracing used for segment formation. More... | |
virtual bool | containsTracks () |
Returns whether or not the TrackGenerator contains Tracks for its current number of azimuthal angles, track spacing and geometry. More... | |
virtual bool | containsSegments () |
Returns whether or not the TrackGenerator contains segments for its current number of azimuthal angles, track spacing and geometry for its current segmentation type. More... | |
int | get2DTrackID (int a, int x) |
Get the id of a 2D Track based on its azimuthal angle and index in the azimuthal stack. More... | |
long * | getTracksPerAzim () |
Return the number of tracks for each azimuthal angle. More... | |
void | setNumThreads (int num_threads) |
Sets the number of shared memory OpenMP threads to use (>0). More... | |
void | setNumAzim (int num_azim) |
Set the number of azimuthal angles in . More... | |
void | setDesiredAzimSpacing (double spacing) |
Set the suggested azimuthal track spacing (cm). More... | |
void | setGeometry (Geometry *geometry) |
Set a pointer to the Geometry to use for track generation. More... | |
void | setZCoord (double z_coord) |
Sets the z-coord of the radial plane used in 2D calculations. More... | |
void | setQuadrature (Quadrature *quadrature) |
Sets the Quadrature used for integrating the MOC equations. More... | |
void | setMaxOpticalLength (FP_PRECISION tau) |
Sets the max optical path length of 3D segments for use in on-the-fly computation. More... | |
void | setMaxNumSegments (int max_num_segments) |
Sets the maximum number of segments per Track. More... | |
void | setDumpSegments (bool dump_segments) |
Sets a flag to record all segment information in the tracking file. More... | |
virtual void | retrieveTrackCoords (double *coords, long num_tracks) |
Fills an array with the x,y,z coordinates for each Track. More... | |
void | retrieve2DTrackCoords (double *coords, long num_tracks) |
Fills an array with the x,y,z coordinates for each Track. More... | |
virtual void | retrieveSegmentCoords (double *coords, long num_segments) |
Fills an array with the x,y,z coordinates for each Track segment. More... | |
void | retrieve2DSegmentCoords (double *coords, long num_segments) |
Fills an array with the x,y,z coordinates for each Track segment. More... | |
void | generateFSRCentroids (FP_PRECISION *FSR_volumes) |
Generates the numerical centroids of the FSRs. More... | |
void | generateTracks () |
Generates tracks for some number of azimuthal angles and track spacing. More... | |
void | splitSegments (FP_PRECISION max_optical_length) |
Splits Track segments into sub-segments for a user-defined maximum optical length for the problem. More... | |
double | leastCommonMultiple (double a, double b) |
Calculates the least common multiple of two numbers a and b. More... | |
void | dumpSegmentsToFile () |
Writes all Track and segment data to a "*.tracks" binary file. More... | |
bool | readSegmentsFromFile () |
Reads Tracks in from a "*.tracks" binary file. More... | |
void | initializeTrackFileDirectory () |
This method creates a directory to store Track files, and reads in ray tracing data for Tracks and segments from a Track file if one exists. More... | |
void | initializeTracksArray () |
Creates a Track array by increasing uid. More... | |
virtual void | checkBoundaryConditions () |
Checks the boundary conditions for all 2D surfaces for inconsistent periodic boundary conditions. | |
void | printTimerReport (bool mpi_reduce) |
Print the track generation timer report. More... | |
void | printMemoryReport () |
Print the track generation memory report. | |
Protected Member Functions | |
virtual void | initializeTracks () |
Initializes Track azimuthal angles, start and end Points. More... | |
void | initializeTrackReflections () |
Initializes 2D Track reflections. More... | |
virtual void | segmentize () |
Generate segments for each Track across the Geometry. | |
virtual void | setContainsSegments (bool contains_segments) |
Updates whether the TrackGenerator contains segments. More... | |
virtual void | allocateTemporarySegments () |
Allocates memory for temporary segment storage if necessary. More... | |
virtual void | resetStatus () |
Resets the TrackGenerator to not contain tracks or segments. | |
virtual void | initializeDefaultQuadrature () |
Allocates a new Quadrature with the default Quadrature. More... | |
virtual void | writeExtrudedFSRInfo (FILE *out) |
Write information of all Extruded FSRs to a file TODO Use implementation in 3D track generator. More... | |
virtual void | readExtrudedFSRInfo (FILE *in) |
Read information of all Extruded FSRs from a file. More... | |
virtual std::string | getTestFilename (std::string directory) |
Returns the filename for writing tracking data. | |
Protected Attributes | |
int | _num_threads |
int | _num_azim |
double | _azim_spacing |
int | _num_2D_tracks |
int * | _num_x |
int * | _num_y |
long * | _tracks_per_azim |
Track ** | _tracks_2D |
Track ** | _tracks_2D_array |
Geometry * | _geometry |
bool | _use_input_file |
std::string | _tracks_filename |
omp_lock_t * | _FSR_locks |
bool | _contains_2D_tracks |
bool | _contains_2D_segments |
Quadrature * | _quadrature |
double | _z_coord |
bool | _periodic |
segmentationType | _segment_formation |
FP_PRECISION | _max_optical_length |
int | _max_num_segments |
bool | _dump_segments |
bool | _segments_centered |
FP_PRECISION * | _FSR_volumes |
Timer * | _timer |
double | _x_min |
double | _y_min |
double | _z_min |
double | _x_max |
double | _y_max |
double | _z_max |
The TrackGenerator is dedicated to generating and storing Tracks which cyclically wrap across the Geometry.
The TrackGenerator creates Track and initializes boundary conditions (vacuum, reflective, or periodic) for each Track.
TrackGenerator::TrackGenerator | ( | Geometry * | geometry, |
int | num_azim, | ||
double | azim_spacing | ||
) |
Constructor for the TrackGenerator assigns default values.
geometry | a pointer to a Geometry object |
num_azim | number of azimuthal angles in |
azim_spacing | azimuthal track spacing (cm) |
|
protectedvirtual |
Allocates memory for temporary segment storage if necessary.
Temporary segments are not allocated for 2D calculations
|
virtual |
Returns whether or not the TrackGenerator contains segments for its current number of azimuthal angles, track spacing and geometry for its current segmentation type.
Reimplemented in TrackGenerator3D.
|
virtual |
Returns whether or not the TrackGenerator contains Tracks for its current number of azimuthal angles, track spacing and geometry.
Reimplemented in TrackGenerator3D.
void TrackGenerator::countSegments | ( | ) |
Counts the number of segments for each Track in the Geometry.
All segments are subject to the max optical path length to determine the number of segments for each track as well as the maximum number of segments per Track in the Geometry. For on-the-fly calculations, the temporary segment buffer is expanded to fit the calculated maximum number of segments per Track.
void TrackGenerator::dumpSegmentsToFile | ( | ) |
void TrackGenerator::exportFSRVolumes | ( | double * | out_volumes, |
int | num_fsrs | ||
) |
FSR volumes are copied to an array input by the user.
out_volumes | The array to which FSR volumes are copied |
num_fsrs | The number of FSR volumes to copy. The first num_fsrs volumes stored in the FSR volumes array are copied. |
void TrackGenerator::generateFSRCentroids | ( | FP_PRECISION * | FSR_volumes | ) |
Generates the numerical centroids of the FSRs.
This routine generates the numerical centroids of the FSRs by weighting the average x and y values of each segment in the FSR by the segment's length and azimuthal weight. The numerical centroid fomula can be found in R. Ferrer et. al. "Linear Source Approximation in CASMO 5", PHYSOR 2012.
FSR_volumes | An array of FSR volumes. |
void TrackGenerator::generateTracks | ( | ) |
Generates tracks for some number of azimuthal angles and track spacing.
Computes the effective angles and track spacing. Computes the number of Tracks for each azimuthal angle, allocates memory for all Tracks at each angle and sets each Track's starting and ending Points, azimuthal angle, and azimuthal angle quadrature weight.
int TrackGenerator::get2DTrackID | ( | int | a, |
int | x | ||
) |
Track ** TrackGenerator::get2DTracks | ( | ) |
Returns a 2D jagged array of the 2D Tracks.
The first index into the array is the azimuthal angle and the second index is the Track number.
Track ** TrackGenerator::get2DTracksArray | ( | ) |
double TrackGenerator::getDesiredAzimSpacing | ( | ) |
Return the track azimuthal spacing (cm).
This will return the user-specified track spacing and NOT the effective track spacing which is computed and used to generate cyclic tracks.
omp_lock_t * TrackGenerator::getFSRLocks | ( | ) |
Return the array of FSR locks for atomic FSR operations.
FP_PRECISION TrackGenerator::getFSRVolume | ( | long | fsr_id | ) |
Returns the volume of an FSR.
fsr_id | the ID for the FSR of interest |
FP_PRECISION * TrackGenerator::getFSRVolumes | ( | ) |
Computes and returns an array of volumes indexed by FSR.
Note: The memory is stored in the FSR volumes buffer of the TrackGenerator and is freed during deconstruction.
FP_PRECISION * TrackGenerator::getFSRVolumesBuffer | ( | ) |
Return the array used to store the FSR volumes.
Geometry * TrackGenerator::getGeometry | ( | ) |
Return the Geometry for this TrackGenerator if one has been set.
int TrackGenerator::getMaxNumSegments | ( | ) |
Returns the maximum number of segments along a single track.
The TrackGenerator::countSegments routine must be called before this function will return a correct value
FP_PRECISION TrackGenerator::getMaxOpticalLength | ( | ) |
long TrackGenerator::getNum2DSegments | ( | ) |
long TrackGenerator::getNum2DTracks | ( | ) |
Return the total number of 2D Tracks across the Geometry.
int TrackGenerator::getNumAzim | ( | ) |
Return the number of azimuthal angles in .
|
virtual |
Return the total number of Track segments across the Geometry.
Reimplemented in TrackGenerator3D.
int TrackGenerator::getNumThreads | ( | ) |
Returns the number of shared memory OpenMP threads in use.
|
virtual |
Return the total number of Tracks across the Geometry.
Reimplemented in TrackGenerator3D.
int TrackGenerator::getNumX | ( | int | azim | ) |
Returns the number of 2D Tracks in the x-direction for a given azimuthal angle index.
azim | the azimuthal angle index |
int TrackGenerator::getNumY | ( | int | azim | ) |
Returns the number of 2D Tracks in the y-direction for a given azimuthal angle index.
azim | the azimuthal angle index |
bool TrackGenerator::getPeriodic | ( | ) |
Returns whether periodic boundaries are present in Track generation.
Quadrature * TrackGenerator::getQuadrature | ( | ) |
Returns the Quadrature object.
segmentationType TrackGenerator::getSegmentFormation | ( | ) |
Returns the type of ray tracing used for segment formation.
Track ** TrackGenerator::getTracksArray | ( | ) |
Returns an array of the Track pointers by increasing UID.
Calls TrackGenerator::get2DTracksArray to return all 2D Tracks
long * TrackGenerator::getTracksPerAzim | ( | ) |
Return the number of tracks for each azimuthal angle.
double TrackGenerator::getZCoord | ( | ) |
Returns the z-coord of the radial plane used in 2D calculations.
|
protectedvirtual |
Allocates a new Quadrature with the default Quadrature.
The default quadrature for 2D calculations is the TY quadrature
void TrackGenerator::initializeTrackFileDirectory | ( | ) |
This method creates a directory to store Track files, and reads in ray tracing data for Tracks and segments from a Track file if one exists.
This method is called by the TrackGenerator::generateTracks() class method. If a Track file exists for this Geometry, number of azimuthal angles, and track spacing, then this method will import the ray tracing Track and segment data to fill the appropriate data structures.
Create directory to store Track files with pre-generated ray tracing data if the directory does not yet exist
|
protected |
Initializes 2D Track reflections.
This method computes the connecting Tracks for all 2D Tracks in the TrackGenerator analytically, handling both reflective and periodic boundaries.
|
protectedvirtual |
Initializes Track azimuthal angles, start and end Points.
Private class methods
This method computes the azimuthal angles and effective track spacing to use to guarantee cyclic Track wrapping. Based on the angles and spacing, the number of Tracks per angle and the start and end Points for each Track are computed.
void TrackGenerator::initializeTracksArray | ( | ) |
Creates a Track array by increasing uid.
An array is created which indexes Tracks by increasing uid. Parallel groups are also initialized – groups of Tracks that can be computed in parallel without the potential of overwriting angular fluxes of connecting tracks prematurely.
void TrackGenerator::initializeVolumes | ( | ) |
Computes the volumes/areas of each Cell and Material in the Geometry.
This computes the volumes/areas of each Cell and Material in the Geometry from the length of track segments crossing each Cell. This routine assigns the volume and number of instances to each Cell and Material. This is a helper routine that is called after track segmentation is complete in TrackGenerator::generateTracks().
double TrackGenerator::leastCommonMultiple | ( | double | a, |
double | b | ||
) |
Calculates the least common multiple of two numbers a and b.
a | first number |
b | second number (order does not matter) |
void TrackGenerator::printTimerReport | ( | bool | mpi_reduce | ) |
Print the track generation timer report.
mpi_reduce | whether to reduce timer across MPI processes (only once!) |
|
protectedvirtual |
Read information of all Extruded FSRs from a file.
in | file to read from |
bool TrackGenerator::readSegmentsFromFile | ( | ) |
Reads Tracks in from a "*.tracks" binary file.
Storing Tracks in a binary file saves time by eliminating ray tracing for Track segmentation in commonly simulated geometries.
void TrackGenerator::retrieve2DSegmentCoords | ( | double * | coords, |
long | num_segments | ||
) |
Fills an array with the x,y,z coordinates for each Track segment.
This class method is intended to be called by the OpenMOC Python "plotter" module as a utility to assist in plotting segments. Although this method appears to require two arguments, in reality it only requires one due to SWIG and would be called from within Python as follows:
coords | an array of coords of length 7 times the number of segments |
num_segments | the total number of Track segments |
void TrackGenerator::retrieve2DTrackCoords | ( | double * | coords, |
long | num_tracks | ||
) |
Fills an array with the x,y,z coordinates for each Track.
This class method is intended to be called by the OpenMOC Python "plotter" module as a utility to assist in plotting tracks. Although this method appears to require two arguments, in reality it only requires one due to SWIG and would be called from within Python as follows:
coords | an array of coords of length 6 times the number of Tracks |
num_tracks | the total number of Tracks |
FP_PRECISION TrackGenerator::retrieveMaxOpticalLength | ( | ) |
Retrieves the max optical path length of 3D segments for use in on-the-fly computation.
|
virtual |
Fills an array with the x,y,z coordinates for each Track segment.
This class method is intended to be called by the OpenMOC Python "plotter" module as a utility to assist in plotting segments. Although this method appears to require two arguments, in reality it only requires one due to SWIG and would be called from within Python as follows:
coords | an array of coords of length 7 times the number of segments |
num_segments | the total number of Track segments |
Reimplemented in TrackGenerator3D.
|
virtual |
Fills an array with the x,y,z coordinates for each Track.
This class method is intended to be called by the OpenMOC Python "plotter" module as a utility to assist in plotting tracks. Although this method appears to require two arguments, in reality it only requires one due to SWIG and would be called from within Python as follows:
coords | an array of coords of length 6 times the number of Tracks |
num_tracks | the total number of Tracks |
Reimplemented in TrackGenerator3D.
|
protectedvirtual |
Updates whether the TrackGenerator contains segments.
contains_segments | whether the TrackGenerator contains segments |
void TrackGenerator::setDesiredAzimSpacing | ( | double | spacing | ) |
Set the suggested azimuthal track spacing (cm).
spacing | the suggested track azimuthal spacing |
void TrackGenerator::setDumpSegments | ( | bool | dump_segments | ) |
Sets a flag to record all segment information in the tracking file.
dump_segments | whether or not to record segment information in the tracking file: true to record, false not to record |
void TrackGenerator::setGeometry | ( | Geometry * | geometry | ) |
void TrackGenerator::setMaxNumSegments | ( | int | max_num_segments | ) |
void TrackGenerator::setMaxOpticalLength | ( | FP_PRECISION | tau | ) |
Sets the max optical path length of 3D segments for use in on-the-fly computation.
tau | maximum optical path length |
void TrackGenerator::setNumAzim | ( | int | num_azim | ) |
Set the number of azimuthal angles in .
num_azim | the number of azimuthal angles in |
void TrackGenerator::setNumThreads | ( | int | num_threads | ) |
Sets the number of shared memory OpenMP threads to use (>0).
num_threads | the number of threads |
void TrackGenerator::setQuadrature | ( | Quadrature * | quadrature | ) |
Sets the Quadrature used for integrating the MOC equations.
quadrature | a pointer to the Quadrature object used in calculation |
void TrackGenerator::setZCoord | ( | double | z_coord | ) |
Sets the z-coord of the radial plane used in 2D calculations.
z_coord | the z-coord of the radial plane |
void TrackGenerator::splitSegments | ( | FP_PRECISION | max_optical_length | ) |
Splits Track segments into sub-segments for a user-defined maximum optical length for the problem.
This routine is needed so that all segment lengths fit within the exponential interpolation table used in the MOC transport sweep.
max_optical_length | the maximum optical length |
|
protectedvirtual |
Write information of all Extruded FSRs to a file TODO Use implementation in 3D track generator.
out | file to write to |
|
protected |
The requested track azimuthal spacing (cm)
|
protected |
Boolean indicating whether 2D segments have been generated (true) or not (false)
|
protected |
Boolean indicating whether the Tracks have been generated (true) or not (false)
|
protected |
Boolean to indicate whether the segments should be dumped to file
|
protected |
OpenMP mutual exclusion locks for atomic FSR operations
|
protected |
A buffer holding the computed FSR volumes
|
protected |
Maximum number of track segmenets in a single Track
|
protected |
Max optical segment length for Tracks before splitting
|
protected |
The total number of Tracks for all azimuthal angles
|
protected |
Number of azimuthal angles in
|
protected |
The number of shared memory OpenMP threads
|
protected |
An integer array of the number of Tracks starting on the x-axis for each azimuthal angle
|
protected |
An integer array of the number of Tracks starting on the y-axis for each azimuthal angle
|
protected |
Boolen to indicate whether a periodic BC exists
|
protected |
The quadrature set
|
protected |
Determines the type of track segmentation to use
|
protected |
Boolean to indicate whether the segments have been centered around their centroid or not
|
protected |
A timer to record timing data for track generation
|
protected |
A 2D ragged array of 2D tracks (azim, track index)
|
protected |
Filename for the *.tracks input / output file
|
protected |
A long integer array of the number of Tracks for each azimuthal angle
|
protected |
Boolean for whether to use Track input file (true) or not (false)
|
protected |
Geometry boundaries for this domain
|
protected |
The z-coord where the 2D Tracks should be created