An open source method of characteristics neutron transport code.
linalg.h File Reference

Go to the source code of this file.

Classes

struct  ConvergenceData
 Verbose iteration information for the CMFD eigenvalue solver. More...
 
struct  DomainCommunicator
 Structure for communication of fluxes between neighbor domains. More...
 

Functions

double eigenvalueSolve (Matrix *A, Matrix *M, Vector *X, double k_eff, double tol, double SOR_factor=1.5, ConvergenceData *convergence_data=NULL, DomainCommunicator *comm=NULL)
 Get coupling fluxes and other information from neighbors. More...
 
bool linearSolve (Matrix *A, Matrix *M, Vector *X, Vector *B, double tol, double SOR_factor=1.5, ConvergenceData *convergence_data=NULL, DomainCommunicator *comm=NULL)
 Solves a linear system using Red-Black Gauss Seidel with successive over-relaxation. More...
 
bool ddLinearSolve (Matrix *A, Matrix *M, Vector *X, Vector *B, double tol, double SOR_factor, ConvergenceData *convergence_data, DomainCommunicator *comm)
 Solves a linear system using the linear solver above, but makes the loss and streaming matrix diagonally dominant first, to increase likelihood of convergence. More...
 
void matrixMultiplication (Matrix *A, Vector *X, Vector *B)
 Performs a matrix vector multiplication. More...
 
double computeRMSE (Vector *x, Vector *y, bool integrated, DomainCommunicator *comm=NULL)
 Computes the Root Mean Square Error of two Vectors. More...
 
template<typename T >
void matrix_transpose (T *matrix, int dim1, int dim2)
 Transpose a 2D matrix. More...
 

Detailed Description

This file contains a library of functions for performing linear algebra operations.

Date
July 3, 2015
Author
Samuel Shaner, MIT, Course 22 (shane.nosp@m.r@mi.nosp@m.t.edu)

Function Documentation

◆ computeRMSE()

double computeRMSE ( Vector X,
Vector Y,
bool  integrated,
DomainCommunicator comm 
)

Computes the Root Mean Square Error of two Vectors.

This function takes in two vectors (X and Y) and computes the Root Mean Square Error of the Vector Y with respect to Vector X. The boolean integrated must also be given to indicate whether the operation on the vector should be group-wise integrated before performing the RMSE operation.

Parameters
Xa Vector object
Ya second Vector object
integrateda boolean indicating whether to group-wise integrate.
comman MPI communicator to exchange residuals between domains

◆ ddLinearSolve()

bool ddLinearSolve ( Matrix A,
Matrix M,
Vector X,
Vector B,
double  tol,
double  SOR_factor,
ConvergenceData convergence_data,
DomainCommunicator comm 
)

Solves a linear system using the linear solver above, but makes the loss and streaming matrix diagonally dominant first, to increase likelihood of convergence.

This function takes in a loss + streaming Matrix (A), a fission gain Matrix (M), a flux Vector (X), a source Vector (B), a source convergence tolerance (tol) and a successive over-relaxation factor (SOR_factor) and makes (A) diagonally dominant before calling the linear solve routine to compute the solution to the linear system. The input X Vector is modified in place to be the solution vector. The transformation to make (A) diagonally dominant is compensated by another matrix multiplication.

Parameters
Athe loss + streaming Matrix object
Mthe fission gain Matrix object
Xthe flux Vector object
Bthe source Vector object
tolthe power method and linear solve source convergence threshold
SOR_factorthe successive over-relaxation factor
convergence_dataa summary of the convergence performance
comma communicator for exchanging data through MPI

◆ eigenvalueSolve()

double eigenvalueSolve ( Matrix A,
Matrix M,
Vector X,
double  k_eff,
double  tol,
double  SOR_factor,
ConvergenceData convergence_data,
DomainCommunicator comm 
)

Get coupling fluxes and other information from neighbors.

The information are transfered by reference.

Get coupling fluxes and other information from neighbors.

This function takes in a loss + streaming Matrix (A), a fission gain Matrix (M), a flux Vector (X), a tolerance used for both the power method and linear solve convergence (tol), and a successive over-relaxation factor (SOR_factor) and computes the dominant eigenvalue and eigenvector using the Power method. The eigenvalue is returned and the input X Vector is modified in place to be the corresponding eigenvector.

Parameters
Athe loss + streaming Matrix object
Mthe fission gain Matrix object
Xthe flux Vector object
k_effinitial k_effective
tolthe power method and linear solve source convergence threshold
SOR_factorthe successive over-relaxation factor
convergence_dataa summary of how to solver converged
comman MPI communicator for the domain-decomposed solver
Returns
k_eff the dominant eigenvalue

◆ linearSolve()

bool linearSolve ( Matrix A,
Matrix M,
Vector X,
Vector B,
double  tol,
double  SOR_factor,
ConvergenceData convergence_data,
DomainCommunicator comm 
)

Solves a linear system using Red-Black Gauss Seidel with successive over-relaxation.

This function takes in a loss + streaming Matrix (A), a fission gain Matrix (M), a flux Vector (X), a source Vector (B), a source convergence tolerance (tol) and a successive over-relaxation factor (SOR_factor) and computes the solution to the linear system. The input X Vector is modified in place to be the solution vector.

Parameters
Athe loss + streaming Matrix object
Mthe fission gain Matrix object
Xthe flux Vector object
Bthe source Vector object
tolthe power method and linear solve source convergence threshold
SOR_factorthe successive over-relaxation factor
convergence_dataa summary of how to solver converged
comman MPI communicator for the domain-decomposed solver

◆ matrix_transpose()

template<typename T >
void matrix_transpose ( T *  matrix,
int  dim1,
int  dim2 
)
inline

Transpose a 2D matrix.

Parameters
matrixarray to transpose
dim1first dimension length
dim2second dimension length

◆ matrixMultiplication()

void matrixMultiplication ( Matrix A,
Vector X,
Vector B 
)

Performs a matrix vector multiplication.

This function takes in a Matrix (A), a variable Vector (X), and a solution Vector (B) and computes the matrix vector product. The solution Vector is modified in place.

Parameters
Aa Matrix object
Xthe variable Vector object
Bthe solution Vector object