An open source method of characteristics neutron transport code.
Vector Class Reference

Public Member Functions

 Vector (omp_lock_t *cell_locks, int num_x=1, int num_y=1, int num_z=1, int num_groups=1)
 Constructor initializes Vector object as a floating point array and sets the vector dimensions. More...
 
virtual ~Vector ()
 Destructor deletes the arrays used to represent the vector.
 
void incrementValue (int cell, int group, CMFD_PRECISION val)
 Increment a value in the vector. More...
 
void incrementValues (int cell, int group_start, int group_end, CMFD_PRECISION *vals)
 Increment values in the vector. More...
 
void clear ()
 Clear all values in the vector.
 
void scaleByValue (CMFD_PRECISION val)
 Scales the vector by a given value. More...
 
void printString ()
 Print the vector object to the log file.
 
void copyTo (Vector *vector)
 Copy the values from the current vector to an input vector. More...
 
CMFD_PRECISION getValue (int cell, int group)
 Get a value at location described by a given cell and group index. More...
 
CMFD_PRECISION * getArray ()
 Get the array describing the vector. More...
 
int getNumX ()
 Get the number of cells in the x dimension. More...
 
int getNumY ()
 Get the number of cells in the y dimension. More...
 
int getNumZ ()
 Get the number of cells in the z dimension. More...
 
int getNumGroups ()
 Get the number of groups in each cell. More...
 
int getNumRows ()
 Get the number of rows in the vector. More...
 
double getSum ()
 Get the sum of all the values in the vector. More...
 
omp_lock_t * getCellLocks ()
 Return the array of cell locks for atomic cell operations. More...
 
void setValue (int cell, int group, CMFD_PRECISION val)
 Set a value in the vector. More...
 
void setValues (int cell, int group_start, int group_end, CMFD_PRECISION *vals)
 Set values in the vector. More...
 
void setAll (CMFD_PRECISION val)
 Fill vector with a value. More...
 

Constructor & Destructor Documentation

◆ Vector()

Vector::Vector ( omp_lock_t *  cell_locks,
int  num_x = 1,
int  num_y = 1,
int  num_z = 1,
int  num_groups = 1 
)

Constructor initializes Vector object as a floating point array and sets the vector dimensions.

The vector is ordered by cell (as opposed to by group) on the outside to be consistent with the Matrix object. Locks are used to make the vector object thread-safe against concurrent writes the same value. One lock locks out multiple rows of the vector at a time representing multiple groups in the same cell.

Parameters
cell_locksOpenMP locks for atomic cell operations.
num_xThe number of cells in the x direction.
num_yThe number of cells in the y direction.
num_zThe number of cells in the z direction.
num_groupsThe number of energy groups in each cell.

Member Function Documentation

◆ copyTo()

void Vector::copyTo ( Vector vector)

Copy the values from the current vector to an input vector.

Parameters
vectorThe vector to copy values to.

◆ getArray()

CMFD_PRECISION * Vector::getArray ( )

Get the array describing the vector.

Returns
The array describing the vector.

◆ getCellLocks()

omp_lock_t * Vector::getCellLocks ( )

Return the array of cell locks for atomic cell operations.

Returns
an array of cell locks

◆ getNumGroups()

int Vector::getNumGroups ( )

Get the number of groups in each cell.

Returns
The number of groups in each cell.

◆ getNumRows()

int Vector::getNumRows ( )

Get the number of rows in the vector.

Returns
The number of rows in the vector.

◆ getNumX()

int Vector::getNumX ( )

Get the number of cells in the x dimension.

Returns
The number of cells in the x dimension.

◆ getNumY()

int Vector::getNumY ( )

Get the number of cells in the y dimension.

Returns
The number of cells in the y dimension.

◆ getNumZ()

int Vector::getNumZ ( )

Get the number of cells in the z dimension.

Returns
The number of cells in the z dimension.

◆ getSum()

double Vector::getSum ( )

Get the sum of all the values in the vector.

Returns
The sum of all the values in the vector.

◆ getValue()

CMFD_PRECISION Vector::getValue ( int  cell,
int  group 
)

Get a value at location described by a given cell and group index.

Parameters
cellThe cell location index.
groupThe group location index.

◆ incrementValue()

void Vector::incrementValue ( int  cell,
int  group,
CMFD_PRECISION  val 
)

Increment a value in the vector.

This method takes a cell and group and floating point value. The cell and group are used to compute the row in the vector. If a value exists for the row, the value is incremented by val; otherwise, it is set to val.

Parameters
cellThe cell location.
groupThe group location.
valThe value used to increment the row location.

◆ incrementValues()

void Vector::incrementValues ( int  cell,
int  group_first,
int  group_last,
CMFD_PRECISION *  vals 
)

Increment values in the vector.

This method takes a cell, first group, last group, and floating point value. The cell and groups are used to compute the rows in the vector. If values exist for the rows, the values are incremented by vals; otherwise, they are set.

Parameters
cellThe cell location.
group_firstThe first group location to increment.
group_lastThe last group location to increment.
valsThe values used to increment the row locations. NOTE: vals at group_first must be aligned with cache boundaries.

◆ scaleByValue()

void Vector::scaleByValue ( CMFD_PRECISION  val)

Scales the vector by a given value.

Parameters
valThe value to scale the vector by.

◆ setAll()

void Vector::setAll ( CMFD_PRECISION  val)

Fill vector with a value.

Parameters
valvalue to use to fill

◆ setValue()

void Vector::setValue ( int  cell,
int  group,
CMFD_PRECISION  val 
)

Set a value in the vector.

This method takes a cell and group and floating point value. The cell and group are used to compute the row and column in the vector. The location of the corresponding row is set to val.

Parameters
cellThe cell location.
groupThe group location.
valThe value used to set the row location.

◆ setValues()

void Vector::setValues ( int  cell,
int  group_first,
int  group_last,
CMFD_PRECISION *  vals 
)

Set values in the vector.

This method takes a cell, first group, last group, and floating point value. The cell and groups are used to compute the rows in the vector. If a value exist for the rows, the values are overwritten.

Parameters
cellThe cell location.
group_firstThe first group location to set.
group_lastThe last group location to set.
valsThe values used to set the row locations.

The documentation for this class was generated from the following files: