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

Public Member Functions

 Matrix (omp_lock_t *cell_locks, int num_x=1, int num_y=1, int num_z=1, int num_groups=1)
 Constructor initializes Matrix as a vector of maps and sets the matrix dimensions. More...
 
virtual ~Matrix ()
 Destructor clears list of lists and deletes the arrays used to represent the matrix in CSR form.
 
void incrementValue (int cell_from, int group_from, int cell_to, int group_to, CMFD_PRECISION val)
 Increment a value in the matrix. More...
 
void clear ()
 Clear all values in the matrix list of lists.
 
void printString ()
 Print the matrix object to the log file.
 
void transpose ()
 Transpose the matrix in place.
 
CMFD_PRECISION getValue (int cell_from, int group_from, int cell_to, int group_to)
 Get a value in the matrix. More...
 
CMFD_PRECISION * getA ()
 Get the A component of the CSR form of the matrix object. More...
 
int * getIA ()
 Get the IA component of the CSR form of the matrix object. More...
 
int * getJA ()
 Get the JA component of the CSR form of the matrix object. More...
 
CMFD_PRECISION * getDiag ()
 Get the diagonal component of the matrix object. 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 matrix. More...
 
int getNNZ ()
 Get the number of non-zero values in the matrix. More...
 
omp_lock_t * getCellLocks ()
 Return the array of cell locks for atomic cell operations. More...
 
void setValue (int cell_from, int group_from, int cell_to, int group_to, CMFD_PRECISION val)
 Set a value in the matrix. More...
 

Constructor & Destructor Documentation

◆ Matrix()

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

Constructor initializes Matrix as a vector of maps and sets the matrix dimensions.

The matrix object uses a "lists of lists" structure (implemented as a vector of maps) to allow for easy setting and incrementing of the values in the object. When the matrix is needed to perform linear algebra operations, it is converted to compressed row storage (CSR) form. The matrix is ordered by cell (as opposed to by group) on the outside. Locks are used to make the matrix thread-safe against concurrent writes the same value. One lock locks out multiple rows of the matrix at a time representing multiple groups in the same cell.

Parameters
cell_locksOmp 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

◆ getA()

CMFD_PRECISION * Matrix::getA ( )

Get the A component of the CSR form of the matrix object.

Returns
A pointer to the A component of the CSR form matrix object.

◆ getCellLocks()

omp_lock_t * Matrix::getCellLocks ( )

Return the array of cell locks for atomic cell operations.

Returns
an array of cell locks

◆ getDiag()

CMFD_PRECISION * Matrix::getDiag ( )

Get the diagonal component of the matrix object.

Returns
A pointer to the diagonal component of the matrix object.

◆ getIA()

int * Matrix::getIA ( )

Get the IA component of the CSR form of the matrix object.

Returns
A pointer to the IA component of the CSR form matrix object.

◆ getJA()

int * Matrix::getJA ( )

Get the JA component of the CSR form of the matrix object.

Returns
A pointer to the JA component of the CSR form matrix object.

◆ getNNZ()

int Matrix::getNNZ ( )

Get the number of non-zero values in the matrix.

Returns
The number of non-zero values in the matrix.

◆ getNumGroups()

int Matrix::getNumGroups ( )

Get the number of groups in each cell.

Returns
The number of groups in each cell.

◆ getNumRows()

int Matrix::getNumRows ( )

Get the number of rows in the matrix.

Returns
The number of rows in the matrix.

◆ getNumX()

int Matrix::getNumX ( )

Get the number of cells in the x dimension.

Returns
The number of cells in the x dimension.

◆ getNumY()

int Matrix::getNumY ( )

Get the number of cells in the y dimension.

Returns
The number of cells in the y dimension.

◆ getNumZ()

int Matrix::getNumZ ( )

Get the number of cells in the z dimension.

Returns
The number of cells in the z dimension.

◆ getValue()

CMFD_PRECISION Matrix::getValue ( int  cell_from,
int  group_from,
int  cell_to,
int  group_to 
)

Get a value in the matrix.

This method takes a cell and group of origin (cell/group from) and cell and group of destination (cell/group to). The origin and destination are used to compute the row and column in the matrix. The value at the location specified by the row/column is returned.

Parameters
cell_fromThe origin cell.
group_fromThe origin group.
cell_toThe destination cell.
group_toThe destination group.
Returns
The value at the corresponding row/column location.

◆ incrementValue()

void Matrix::incrementValue ( int  cell_from,
int  group_from,
int  cell_to,
int  group_to,
CMFD_PRECISION  val 
)

Increment a value in the matrix.

This method takes a cell and group of origin (cell/group from) and cell and group of destination (cell/group to) and a floating point value. The origin and destination are used to compute the row and column in the matrix. If a value exists for the row/column, the value is incremented by val; otherwise, it is set to val.

Parameters
cell_fromThe origin cell.
group_fromThe origin group.
cell_toThe destination cell.
group_toThe destination group.
valThe value used to increment the row/column location.

◆ setValue()

void Matrix::setValue ( int  cell_from,
int  group_from,
int  cell_to,
int  group_to,
CMFD_PRECISION  val 
)

Set a value in the matrix.

This method takes a cell and group of origin (cell/group from) and cell and group of destination (cell/group to) and floating point value. The origin and destination are used to compute the row and column in the matrix. The location specified by the row/column is set to val.

Parameters
cell_fromThe origin cell.
group_fromThe origin group.
cell_toThe destination cell.
group_toThe destination group.
valThe value used to set the row/column location.

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