escript
Revision_
|
#include <SystemMatrix.h>
Public Member Functions | |
SystemMatrix (SystemMatrixType, SystemMatrixPattern_ptr, dim_t, dim_t, bool patternIsUnrolled) | |
~SystemMatrix () | |
void | nullifyRowsAndCols (double *mask_row, double *mask_col, double main_diagonal_value) |
void | nullifyRows (double *mask_row, double main_diagonal_value) |
void | add (dim_t, index_t *, dim_t, dim_t, index_t *, dim_t, double *) |
void | makeZeroRowSums (double *left_over) |
void | copyColCoupleBlock () |
void | copyRemoteCoupleBlock (bool recreatePattern) |
void | fillWithGlobalCoordinates (double f1) |
void | print () const |
SparseMatrix_ptr | mergeSystemMatrix () const |
void | mergeMainAndCouple (index_t **p_ptr, index_t **p_idx, double **p_val) const |
void | mergeMainAndCouple_CSR_OFFSET0 (index_t **p_ptr, index_t **p_idx, double **p_val) const |
void | mergeMainAndCouple_CSR_OFFSET0_Block (index_t **p_ptr, index_t **p_idx, double **p_val) const |
void | mergeMainAndCouple_CSC_OFFSET1 (index_t **p_ptr, index_t **p_idx, double **p_val) const |
void | copyMain_CSC_OFFSET1 (index_t **p_ptr, index_t **p_idx, double **p_val) |
void | extendedRowsForST (dim_t *degree_ST, index_t *offset_ST, index_t *ST) |
void | applyBalanceInPlace (double *x, bool RHS) const |
void | applyBalance (double *x_out, const double *x, bool RHS) const |
void | balance () |
double | getGlobalSize () const |
void | setPreconditioner (Options *options) |
void | solvePreconditioner (double *x, double *b) |
void | freePreconditioner () |
index_t * | borrowMainDiagonalPointer () const |
void | startCollect (const double *in) |
double * | finishCollect () |
void | startColCollect (const double *in) |
double * | finishColCollect () |
void | startRowCollect (const double *in) |
double * | finishRowCollect () |
dim_t | getNumRows () const |
dim_t | getNumCols () const |
dim_t | getTotalNumRows () const |
dim_t | getTotalNumCols () const |
dim_t | getRowOverlap () const |
dim_t | getColOverlap () const |
dim_t | getGlobalNumRows () const |
dim_t | getGlobalNumCols () const |
dim_t | getGlobalTotalNumRows () const |
dim_t | getGlobalTotalNumCols () const |
double | getSparsity () const |
dim_t | getNumOutput () const |
void | copyBlockFromMainDiagonal (double *out) const |
void | copyBlockToMainDiagonal (const double *in) |
void | copyFromMainDiagonal (double *out) const |
void | copyToMainDiagonal (const double *in) |
void | setValues (double value) |
void | saveMM (const char *filename) const |
void | saveHB (const char *filename) const |
void | rowSum (double *row_sum) const |
Static Public Member Functions | |
static SystemMatrix_ptr | loadMM_toCSR (const char *filename) |
static SystemMatrix_ptr | loadMM_toCSC (const char *filename) |
static index_t | getSystemMatrixTypeId (index_t solver, index_t preconditioner, index_t package, bool symmetry, Esys_MPIInfo *mpi_info) |
Public Attributes | |
SystemMatrixType | type |
SystemMatrixPattern_ptr | pattern |
dim_t | logical_row_block_size |
dim_t | logical_col_block_size |
dim_t | row_block_size |
dim_t | col_block_size |
dim_t | block_size |
Distribution_ptr | row_distribution |
Distribution_ptr | col_distribution |
Esys_MPIInfo * | mpi_info |
Coupler_ptr | col_coupler |
Coupler_ptr | row_coupler |
SparseMatrix_ptr | mainBlock |
main block | |
SparseMatrix_ptr | col_coupleBlock |
coupling to neighbouring processors (row - col) | |
SparseMatrix_ptr | row_coupleBlock |
coupling to neighbouring processors (col - row) | |
SparseMatrix_ptr | remote_coupleBlock |
coupling of rows-cols on neighbouring processors (may not be valid) | |
bool | is_balanced |
double * | balance_vector |
index_t * | global_id |
stores the global ids for all cols in col_coupleBlock | |
index_t | solver_package |
package code controlling the solver pointer | |
void * | solver_p |
pointer to data needed by a solver | |
void * | trilinos_data |
this is only used for a trilinos matrix |
paso::SystemMatrix::SystemMatrix | ( | SystemMatrixType | ntype, |
SystemMatrixPattern_ptr | npattern, | ||
dim_t | rowBlockSize, | ||
dim_t | colBlockSize, | ||
bool | patternIsUnrolled | ||
) |
Allocates a SystemMatrix of given type using the given matrix pattern. Values are initialized with zero. If patternIsUnrolled and type & MATRIX_FORMAT_BLK1, it is assumed that the pattern is already unrolled to match the requested block size and offsets. Otherwise unrolling and offset adjustment will be performed.
References balance_vector, block_size, col_block_size, col_coupleBlock, col_coupler, col_distribution, Esys_MPIInfo_getReference(), Esys_noError(), Esys_resetError(), Esys_setError(), mainBlock, MATRIX_FORMAT_BLK1, MATRIX_FORMAT_CSC, MATRIX_FORMAT_DEFAULT, MATRIX_FORMAT_DIAGONAL_BLOCK, MATRIX_FORMAT_OFFSET1, MATRIX_FORMAT_TRILINOS_CRS, MAX, MIN, mpi_info, pattern, row_block_size, row_coupleBlock, row_coupler, row_distribution, type, TYPE_ERROR, and XNOR.
Referenced by loadMM_toCSC(), and loadMM_toCSR().
References balance_vector, Esys_MPIInfo_free(), global_id, mpi_info, and paso::solve_free().
void paso::SystemMatrix::applyBalance | ( | double * | x_out, |
const double * | x, | ||
bool | RHS | ||
) | const |
References balance_vector, getTotalNumCols(), getTotalNumRows(), and is_balanced.
void paso::SystemMatrix::applyBalanceInPlace | ( | double * | x, |
bool | RHS | ||
) | const |
References balance_vector, getTotalNumCols(), getTotalNumRows(), and is_balanced.
void paso::SystemMatrix::balance | ( | ) |
References balance_vector, col_block_size, col_coupleBlock, Esys_noError(), Esys_setError(), finishCollect(), getGlobalNumCols(), getGlobalNumRows(), getTotalNumRows(), is_balanced, mainBlock, MATRIX_FORMAT_CSC, MATRIX_FORMAT_OFFSET1, row_block_size, row_coupleBlock, startCollect(), SYSTEM_ERROR, type, and TYPE_ERROR.
index_t * paso::SystemMatrix::borrowMainDiagonalPointer | ( | ) | const |
References Esys_MPIInfo::comm, Esys_setError(), mainBlock, mpi_info, MPI_INT, and VALUE_ERROR.
Referenced by makeZeroRowSums().
void paso::SystemMatrix::copyBlockFromMainDiagonal | ( | double * | out | ) | const [inline] |
References mainBlock.
void paso::SystemMatrix::copyBlockToMainDiagonal | ( | const double * | in | ) | [inline] |
References mainBlock.
copies the col_coupleBlock into row_coupleBlock. WARNING: this method uses mpi_requests of the coupler attached to the matrix. No reordering on the received columns is performed. In practice this means that components in row_coupleBlock->pattern->index and row_coupler->connector->recv->shared are ordered by increasing value. Note that send and receive row_coupler->connectors are swapping roles.
References block_size, col_coupleBlock, col_coupler, Esys_MPIInfo::comm, ESYS_MPI_INC_COUNTER, Esys_setError(), MPI_DOUBLE, mpi_info, Esys_MPIInfo::msg_tag_counter, pattern, Esys_MPIInfo::rank, row_coupleBlock, row_coupler, Esys_MPIInfo::size, SYSTEM_ERROR, and VALUE_ERROR.
void paso::SystemMatrix::copyFromMainDiagonal | ( | double * | out | ) | const [inline] |
References mainBlock.
void paso::SystemMatrix::copyMain_CSC_OFFSET1 | ( | index_t ** | p_ptr, |
index_t ** | p_idx, | ||
double ** | p_val | ||
) |
void paso::SystemMatrix::copyRemoteCoupleBlock | ( | bool | recreatePattern | ) |
References block_size, col_block_size, col_coupleBlock, col_coupler, col_distribution, Esys_MPIInfo::comm, ESYS_MPI_INC_COUNTER, global_id, mainBlock, MPI_DOUBLE, mpi_info, MPI_INT, Esys_MPIInfo::msg_tag_counter, pattern, Esys_MPIInfo::rank, remote_coupleBlock, row_block_size, row_coupleBlock, row_coupler, and Esys_MPIInfo::size.
void paso::SystemMatrix::copyToMainDiagonal | ( | const double * | in | ) | [inline] |
References mainBlock.
void paso::SystemMatrix::extendedRowsForST | ( | dim_t * | degree_ST, |
index_t * | offset_ST, | ||
index_t * | ST | ||
) |
void paso::SystemMatrix::fillWithGlobalCoordinates | ( | double | f1 | ) |
References block_size, col_coupleBlock, col_coupler, col_distribution, getNumCols(), getNumRows(), mainBlock, mpi_info, pattern, Esys_MPIInfo::rank, row_coupleBlock, and row_distribution.
double* paso::SystemMatrix::finishColCollect | ( | ) | [inline] |
References col_coupler.
Referenced by finishCollect(), and nullifyRowsAndCols().
double* paso::SystemMatrix::finishCollect | ( | ) | [inline] |
References finishColCollect().
Referenced by balance().
double* paso::SystemMatrix::finishRowCollect | ( | ) | [inline] |
References row_coupler.
Referenced by nullifyRows(), and nullifyRowsAndCols().
References paso::Preconditioner_free(), and solver_p.
Referenced by paso::Solver_free().
dim_t paso::SystemMatrix::getColOverlap | ( | ) | const [inline] |
References col_coupler.
dim_t paso::SystemMatrix::getGlobalNumCols | ( | ) | const [inline] |
References MATRIX_FORMAT_CSC, pattern, and type.
Referenced by balance(), and getGlobalTotalNumCols().
dim_t paso::SystemMatrix::getGlobalNumRows | ( | ) | const [inline] |
References MATRIX_FORMAT_CSC, pattern, and type.
Referenced by balance(), getGlobalTotalNumRows(), and mergeSystemMatrix().
double paso::SystemMatrix::getGlobalSize | ( | ) | const |
References col_coupleBlock, Esys_MPIInfo::comm, mainBlock, MPI_DOUBLE, mpi_info, and Esys_MPIInfo::size.
Referenced by getSparsity().
dim_t paso::SystemMatrix::getGlobalTotalNumCols | ( | ) | const [inline] |
References col_block_size, and getGlobalNumCols().
Referenced by getSparsity().
dim_t paso::SystemMatrix::getGlobalTotalNumRows | ( | ) | const [inline] |
References getGlobalNumRows(), and row_block_size.
Referenced by getSparsity().
dim_t paso::SystemMatrix::getNumCols | ( | ) | const [inline] |
References mainBlock.
Referenced by fillWithGlobalCoordinates(), and getTotalNumCols().
dim_t paso::SystemMatrix::getNumOutput | ( | ) | const [inline] |
References pattern.
dim_t paso::SystemMatrix::getNumRows | ( | ) | const [inline] |
References mainBlock.
Referenced by fillWithGlobalCoordinates(), getTotalNumRows(), and print().
dim_t paso::SystemMatrix::getRowOverlap | ( | ) | const [inline] |
References row_coupler.
double paso::SystemMatrix::getSparsity | ( | ) | const [inline] |
References getGlobalSize(), getGlobalTotalNumCols(), and getGlobalTotalNumRows().
index_t paso::SystemMatrix::getSystemMatrixTypeId | ( | index_t | solver, |
index_t | preconditioner, | ||
index_t | package, | ||
bool | symmetry, | ||
Esys_MPIInfo * | mpi_info | ||
) | [static] |
dim_t paso::SystemMatrix::getTotalNumCols | ( | ) | const [inline] |
References col_block_size, and getNumCols().
Referenced by applyBalance(), and applyBalanceInPlace().
dim_t paso::SystemMatrix::getTotalNumRows | ( | ) | const [inline] |
References getNumRows(), and row_block_size.
Referenced by applyBalance(), applyBalanceInPlace(), and balance().
SystemMatrix_ptr paso::SystemMatrix::loadMM_toCSC | ( | const char * | filename | ) | [static] |
References Esys_MPIInfo_alloc(), Esys_MPIInfo_free(), Esys_resetError(), Esys_setError(), IO_ERROR, paso::M, MATRIX_FORMAT_CSC, MATRIX_FORMAT_DEFAULT, mm_is_general, mm_is_real, mm_is_sparse, mm_read_banner(), mm_read_mtx_crd_size(), MPI_COMM_WORLD, mpi_info, paso::N, paso::nz, pattern, paso::q_sort(), Esys_MPIInfo::size, SystemMatrix(), and TYPE_ERROR.
SystemMatrix_ptr paso::SystemMatrix::loadMM_toCSR | ( | const char * | filename | ) | [static] |
References Esys_MPIInfo_alloc(), Esys_MPIInfo_free(), Esys_resetError(), Esys_setError(), IO_ERROR, paso::M, MATRIX_FORMAT_DEFAULT, mm_is_general, mm_is_real, mm_is_sparse, mm_read_banner(), mm_read_mtx_crd_size(), MPI_COMM_WORLD, mpi_info, paso::N, paso::nz, pattern, paso::q_sort(), Esys_MPIInfo::size, SystemMatrix(), and TYPE_ERROR.
void paso::SystemMatrix::makeZeroRowSums | ( | double * | left_over | ) |
References block_size, borrowMainDiagonalPointer(), mainBlock, pattern, row_block_size, and rowSum().
void paso::SystemMatrix::mergeMainAndCouple | ( | index_t ** | p_ptr, |
index_t ** | p_idx, | ||
double ** | p_val | ||
) | const |
void paso::SystemMatrix::mergeMainAndCouple_CSC_OFFSET1 | ( | index_t ** | p_ptr, |
index_t ** | p_idx, | ||
double ** | p_val | ||
) | const |
References Esys_setError(), and TYPE_ERROR.
Referenced by mergeMainAndCouple().
void paso::SystemMatrix::mergeMainAndCouple_CSR_OFFSET0 | ( | index_t ** | p_ptr, |
index_t ** | p_idx, | ||
double ** | p_val | ||
) | const |
References col_coupleBlock, col_coupler, col_distribution, Esys_setError(), global_id, mainBlock, mergeMainAndCouple_CSR_OFFSET0_Block(), mpi_info, Esys_MPIInfo::rank, row_distribution, Esys_MPIInfo::size, and TYPE_ERROR.
Referenced by mergeMainAndCouple().
void paso::SystemMatrix::mergeMainAndCouple_CSR_OFFSET0_Block | ( | index_t ** | p_ptr, |
index_t ** | p_idx, | ||
double ** | p_val | ||
) | const |
References block_size, col_coupleBlock, col_coupler, col_distribution, Esys_setError(), global_id, mainBlock, mpi_info, Esys_MPIInfo::rank, row_distribution, Esys_MPIInfo::size, and TYPE_ERROR.
Referenced by mergeMainAndCouple_CSR_OFFSET0().
Merges the system matrix which is distributed on several MPI ranks into a complete sparse matrix on rank 0. Used by the Merged Solver.
References block_size, Esys_MPIInfo::comm, ESYS_MPI_INC_COUNTER, ESYS_MPI_SET_COUNTER, getGlobalNumRows(), mainBlock, mergeMainAndCouple(), MPI_DOUBLE, mpi_info, MPI_INT, Esys_MPIInfo::msg_tag_counter, Esys_MPIInfo::rank, row_distribution, and Esys_MPIInfo::size.
void paso::SystemMatrix::nullifyRows | ( | double * | mask_row, |
double | main_diagonal_value | ||
) |
Nullifies rows in the matrix. The rows are marked by positive values in mask_row. Values on the main diagonal which are marked to set to zero by mask_row are set to main_diagonal_value.
References col_block_size, col_coupleBlock, Esys_setError(), finishRowCollect(), mainBlock, MATRIX_FORMAT_CSC, MATRIX_FORMAT_TRILINOS_CRS, row_block_size, row_coupleBlock, startRowCollect(), SYSTEM_ERROR, and type.
void paso::SystemMatrix::nullifyRowsAndCols | ( | double * | mask_row, |
double * | mask_col, | ||
double | main_diagonal_value | ||
) |
Nullifies rows and columns in the matrix. The rows and columns are marked by positive values in mask_row and mask_col. Values on the main diagonal which are marked to set to zero by both mask_row and mask_col are set to main_diagonal_value.
References col_block_size, col_coupleBlock, Esys_setError(), finishColCollect(), finishRowCollect(), mainBlock, MATRIX_FORMAT_CSC, MATRIX_FORMAT_TRILINOS_CRS, mpi_info, row_block_size, row_coupleBlock, Esys_MPIInfo::size, startColCollect(), startRowCollect(), SYSTEM_ERROR, and type.
void paso::SystemMatrix::print | ( | void | ) | const |
References block_size, col_coupleBlock, getNumRows(), global_id, mainBlock, mpi_info, pattern, Esys_MPIInfo::rank, remote_coupleBlock, row_coupleBlock, and Esys_MPIInfo::size.
void paso::SystemMatrix::rowSum | ( | double * | row_sum | ) | const [inline] |
References col_coupleBlock, Esys_setError(), mainBlock, MATRIX_FORMAT_CSC, MATRIX_FORMAT_OFFSET1, row_block_size, type, and TYPE_ERROR.
Referenced by makeZeroRowSums().
void paso::SystemMatrix::saveHB | ( | const char * | filename | ) | const [inline] |
References Esys_setError(), mainBlock, MATRIX_FORMAT_CSC, mpi_info, Esys_MPIInfo::size, type, and TYPE_ERROR.
void paso::SystemMatrix::saveMM | ( | const char * | filename | ) | const [inline] |
References Esys_setError(), IO_ERROR, mainBlock, mpi_info, and Esys_MPIInfo::size.
void paso::SystemMatrix::setPreconditioner | ( | Options * | options | ) |
References paso::Preconditioner_alloc(), and solver_p.
void paso::SystemMatrix::setValues | ( | double | value | ) | [inline] |
References col_coupleBlock, is_balanced, mainBlock, and row_coupleBlock.
void paso::SystemMatrix::solvePreconditioner | ( | double * | x, |
double * | b | ||
) |
Applies the preconditioner. This method needs to be called within a parallel region. Barrier synchronization is performed before the evaluation to make sure that the input vector is available
References paso::Preconditioner_solve(), and solver_p.
void paso::SystemMatrix::startColCollect | ( | const double * | in | ) | [inline] |
References col_coupler.
Referenced by nullifyRowsAndCols(), and startCollect().
void paso::SystemMatrix::startCollect | ( | const double * | in | ) | [inline] |
References startColCollect().
Referenced by balance().
void paso::SystemMatrix::startRowCollect | ( | const double * | in | ) | [inline] |
References row_coupler.
Referenced by nullifyRows(), and nullifyRowsAndCols().
matrix may be balanced by a diagonal matrix D=diagonal(balance_vector) if is_balanced is true, the matrix stored is D*A*D where A is the original matrix. When the system of linear equations is solved we solve D*A*D*y=c. So to solve A*x=b one needs to set c=D*b and x=D*y.
Referenced by applyBalance(), applyBalanceInPlace(), balance(), SystemMatrix(), and ~SystemMatrix().
Referenced by balance(), copyRemoteCoupleBlock(), getGlobalTotalNumCols(), getTotalNumCols(), nullifyRows(), nullifyRowsAndCols(), and SystemMatrix().
coupling to neighbouring processors (row - col)
Referenced by balance(), copyColCoupleBlock(), copyRemoteCoupleBlock(), extendedRowsForST(), fillWithGlobalCoordinates(), getGlobalSize(), mergeMainAndCouple_CSR_OFFSET0(), mergeMainAndCouple_CSR_OFFSET0_Block(), nullifyRows(), nullifyRowsAndCols(), print(), rowSum(), setValues(), and SystemMatrix().
index_t* paso::SystemMatrix::global_id [mutable] |
stores the global ids for all cols in col_coupleBlock
Referenced by copyRemoteCoupleBlock(), extendedRowsForST(), mergeMainAndCouple_CSR_OFFSET0(), mergeMainAndCouple_CSR_OFFSET0_Block(), print(), and ~SystemMatrix().
Referenced by applyBalance(), applyBalanceInPlace(), balance(), and setValues().
main block
Referenced by balance(), borrowMainDiagonalPointer(), copyBlockFromMainDiagonal(), copyBlockToMainDiagonal(), copyFromMainDiagonal(), copyRemoteCoupleBlock(), copyToMainDiagonal(), extendedRowsForST(), fillWithGlobalCoordinates(), getGlobalSize(), getNumCols(), getNumRows(), makeZeroRowSums(), mergeMainAndCouple_CSR_OFFSET0(), mergeMainAndCouple_CSR_OFFSET0_Block(), mergeSystemMatrix(), nullifyRows(), nullifyRowsAndCols(), print(), rowSum(), saveHB(), saveMM(), setValues(), paso::solve_free(), and SystemMatrix().
Referenced by borrowMainDiagonalPointer(), copyColCoupleBlock(), copyRemoteCoupleBlock(), extendedRowsForST(), fillWithGlobalCoordinates(), getGlobalSize(), loadMM_toCSC(), loadMM_toCSR(), mergeMainAndCouple_CSR_OFFSET0(), mergeMainAndCouple_CSR_OFFSET0_Block(), mergeSystemMatrix(), nullifyRowsAndCols(), print(), saveHB(), saveMM(), SystemMatrix(), and ~SystemMatrix().
coupling of rows-cols on neighbouring processors (may not be valid)
Referenced by copyRemoteCoupleBlock(), and print().
coupling to neighbouring processors (col - row)
Referenced by balance(), copyColCoupleBlock(), copyRemoteCoupleBlock(), extendedRowsForST(), fillWithGlobalCoordinates(), nullifyRows(), nullifyRowsAndCols(), print(), setValues(), and SystemMatrix().
pointer to data needed by a solver
Referenced by freePreconditioner(), setPreconditioner(), paso::solve_free(), and solvePreconditioner().
package code controlling the solver pointer
Referenced by paso::solve_free().
this is only used for a trilinos matrix
Referenced by balance(), getGlobalNumCols(), getGlobalNumRows(), mergeMainAndCouple(), nullifyRows(), nullifyRowsAndCols(), rowSum(), saveHB(), and SystemMatrix().