The SystemSolver class provides methods for building and solving large linear systems. More...
Public Types | |
typedef SystemMatrixAssembler | Assembler |
enum | FileFormat { FILE_BINARY , FILE_ASCII } |
Public Member Functions | |
SystemSolver (bool debug=false) | |
SystemSolver (bool flatten, bool transpose, bool debug) | |
SystemSolver (bool transpose, bool debug) | |
SystemSolver (const std::string &prefix, bool debug=false) | |
SystemSolver (const std::string &prefix, bool flatten, bool transpose, bool debug) | |
SystemSolver (const std::string &prefix, bool transpose, bool debug) | |
virtual | ~SystemSolver () |
void | assembly (const Assembler &assembler) |
void | assembly (const Assembler &assembler, const SystemMatrixOrdering &reordering) |
void | assembly (const SparseMatrix &matrix) |
void | assembly (const SparseMatrix &matrix, const SystemMatrixOrdering &reordering) |
virtual void | clear () |
virtual void | clearWorkspace () |
void | dumpSystem (const std::string &header, const std::string &directory, const std::string &prefix="") const |
void | enableForceConsistency (bool enable) |
virtual void | exportMatrix (const std::string &filePath, FileFormat exportFormat=FILE_BINARY) const |
virtual void | exportRHS (const std::string &filePath, FileFormat exportFormat=FILE_BINARY) const |
virtual void | exportSolution (const std::string &filePath, FileFormat exportFormat=FILE_BINARY) const |
virtual int | getBlockSize () const |
long | getColCount () const |
long | getColElementCount () const |
long | getColGlobalCount () const |
long | getColGlobalElementCount () const |
KSPOptions & | getKSPOptions () |
const KSPOptions & | getKSPOptions () const |
const KSPStatus & | getKSPStatus () const |
double * | getRHSRawPtr () |
const double * | getRHSRawPtr () const |
const double * | getRHSRawReadPtr () const |
long | getRowCount () const |
long | getRowElementCount () const |
long | getRowGlobalCount () const |
long | getRowGlobalElementCount () const |
double * | getSolutionRawPtr () |
const double * | getSolutionRawPtr () const |
const double * | getSolutionRawReadPtr () const |
bool | getTranspose () const |
virtual void | importMatrix (const std::string &filePath) |
virtual void | importRHS (const std::string &filePath) |
virtual void | importSolution (const std::string &filePath) |
bool | isAssembled () const |
bool | isForceConsistencyEnabled () const |
bool | isPartitioned () const |
bool | isSetUp () const |
void | restoreRHSRawPtr (double *raw_rhs) |
void | restoreRHSRawReadPtr (const double *raw_rhs) const |
void | restoreSolutionRawPtr (double *raw_solution) |
void | restoreSolutionRawReadPtr (const double *raw_solution) const |
void | restoreSystem (MPI_Comm communicator, bool redistribute, const std::string &directory, const std::string &prefix="") |
virtual void | setNullSpace () |
void | setTranspose (bool transpose) |
void | setUp () |
void | solve () |
void | solve (const std::vector< double > &rhs, std::vector< double > *solution) |
void | unsetNullSpace () |
void | update (const Assembler &assembler) |
void | update (const SparseMatrix &elements) |
void | update (long nRows, const long *rows, const Assembler &assembler) |
void | update (long nRows, const long *rows, const SparseMatrix &elements) |
Protected Types | |
enum | VectorSide { VECTOR_SIDE_RIGHT , VECTOR_SIDE_LEFT } |
Protected Member Functions | |
template<typename DerivedSystemSolver > | |
void | assembly (const typename DerivedSystemSolver::Assembler &assembler, const SystemMatrixOrdering &reordering) |
void | clearReordering () |
virtual void | createKSP () |
void | createMatrix (int rowBlockSize, int colBlockSize, int nNestRows, int nNestCols, Mat *subMatrices, Mat *matrix) const |
void | createMatrix (int rowBlockSize, int colBlockSize, Mat *matrix) const |
void | createVector (int blockSize, int nestSize, Vec *subVectors, Vec *vector) const |
void | createVector (int blockSize, Vec *vector) const |
virtual void | destroyKSP () |
virtual void | destroyKSPOptions () |
virtual void | destroyKSPStatus () |
void | destroyMatrix (Mat *matrix) const |
void | destroyVector (Vec *vector) const |
virtual void | dumpInfo (std::ostream &stream) const |
void | dumpMatrix (Mat matrix, const std::string &directory, const std::string &name) const |
void | dumpVector (Vec vector, const std::string &directory, const std::string &name) const |
void | dumpVector (Vec vector, VectorSide side, const std::string &directory, const std::string &name) const |
void | exportMatrix (Mat matrix, const std::string &filePath, FileFormat fileFormat) const |
void | exportVector (Vec vector, const std::string &filePath, FileFormat fileFormat) const |
void | exportVector (Vec vector, std::vector< double > *data) const |
virtual void | fillKSPStatus () |
virtual void | fillKSPStatus (KSP ksp, KSPStatus *status) const |
void | fillMatrix (Mat matrix, const std::string &filePath) const |
void | fillVector (Vec vector, const std::string &filePath) const |
void | fillVector (Vec vector, const std::vector< double > &data) const |
virtual void | finalizeKSP () |
const MPI_Comm & | getCommunicator () const |
std::string | getDataFilePath (const std::string &directory, const std::string &name) const |
virtual int | getDumpVersion () const |
std::string | getFilePath (const std::string &directory, const std::string &name) const |
std::string | getInfoFilePath (const std::string &directory, const std::string &name) const |
virtual void | initializeKSPOptions () |
virtual void | initializeKSPStatus () |
void | matrixAssembly (const Assembler &assembler) |
virtual void | matrixDestroy () |
virtual void | matrixDump (std::ostream &systemStream, const std::string &directory, const std::string &prefix) const |
virtual void | matrixFill (const std::string &filePath) |
virtual void | matrixRestore (std::istream &systemStream, const std::string &directory, const std::string &prefix, bool redistribute) |
void | matrixUpdate (long nRows, const long *rows, const Assembler &assembler) |
virtual void | postKrylovSetupActions () |
virtual void | postKSPSolveActions () |
virtual void | postPreconditionerSetupActions () |
virtual void | preKrylovSetupActions () |
virtual void | preKSPSolveActions () |
virtual void | prepareKSP () |
virtual void | prePreconditionerSetupActions () |
void | reorderVector (Vec vector, IS permutations, bool invert) const |
virtual void | resetKSPOptions (KSPOptions *options) const |
virtual void | resetKSPStatus () |
virtual void | resetKSPStatus (KSPStatus *status) const |
virtual void | restoreInfo (std::istream &stream) |
void | restoreMatrix (const std::string &directory, const std::string &name, bool redistribute, Mat *matrix) const |
void | restoreVector (const std::string &directory, const std::string &name, bool redistribute, Vec *vector) const |
void | restoreVector (const std::string &directory, const std::string &name, Mat matrix, VectorSide side, Vec *vector) const |
void | restoreVector (const std::string &directory, const std::string &name, std::size_t localSize, std::size_t globalSize, Vec *vector) const |
void | setReordering (long nRows, long nCols, const SystemMatrixOrdering &reordering) |
virtual void | setupKrylov () |
virtual void | setupKrylov (KSP ksp, const KSPOptions &options) const |
virtual void | setupPreconditioner () |
virtual void | setupPreconditioner (PC pc, const KSPOptions &options) const |
virtual void | solveKSP () |
template<typename DerivedSystemSolver > | |
void | update (long nRows, const long *rows, const typename DerivedSystemSolver::Assembler &assembler) |
virtual void | vectorsCreate () |
virtual void | vectorsDestroy () |
virtual void | vectorsDump (std::ostream &systemStream, const std::string &directory, const std::string &prefix) const |
virtual void | vectorsFill (const std::string &rhsFilePath, const std::string &solutionFilePath) |
virtual void | vectorsFill (const std::vector< double > &rhs, const std::vector< double > &solution) |
virtual void | vectorsReorder (bool invert) |
virtual void | vectorsRestore (std::istream &systemStream, const std::string &directory, const std::string &prefix) |
Protected Attributes | |
Mat | m_A |
IS | m_colReordering |
bool | m_convergenceMonitorEnabled |
bool | m_flatten |
KSP | m_KSP |
bool | m_KSPDirty |
KSPOptions | m_KSPOptions |
KSPStatus | m_KSPStatus |
Vec | m_rhs |
IS | m_rowReordering |
Vec | m_solution |
bool | m_transpose |
The SystemSolver class provides methods for building and solving large linear systems.
Rather than working with individual elements in the system matrix, it is possible to employ blocks of elements. The size of the blocks can be defined during assembly. When a size different that one is provided, the matrix will store elements by fixed-sized dense nb × nb blocks, where nb is the size of the blocks. Blocking may be advantageous when solving PDE-based simulations that leads to matrices with a naturally blocked structure (with a block size equal to the number of degrees of freedom per cell).
When blocking is used, row and column indexes will count the number of blocks in the row/column direction, not the number of rows/columns of the matrix.
Definition at line 264 of file system_solvers_large.hpp.
Definition at line 267 of file system_solvers_large.hpp.
enum bitpit::SystemSolver::FileFormat |
Definition at line 269 of file system_solvers_large.hpp.
|
protected |
Definition at line 361 of file system_solvers_large.hpp.
bitpit::SystemSolver::SystemSolver | ( | bool | debug = false | ) |
Constructor.
debug | if set to true, debug information will be printed |
Definition at line 770 of file system_solvers_large.cpp.
bitpit::SystemSolver::SystemSolver | ( | bool | transpose, |
bool | debug ) |
Constuctor
transpose | if set to true, transposed system will be solved |
debug | if set to true, debug information will be printed |
Definition at line 781 of file system_solvers_large.cpp.
bitpit::SystemSolver::SystemSolver | ( | bool | flatten, |
bool | transpose, | ||
bool | debug ) |
Constuctor
flatten | if set to true, block size will not be taken into account when allocating the internal storage of the system matrix. Even when the internal storage is flat, block size information are available and can be used by the solver to speed up the solution of the system. However, since the internal storage doesn't take blocks into account, some low level operations (e.g., matrix-matrix multiplications) cannot use block information. Some algorithms for the solution of the system (e.g., multigrid) requires a flat storage. |
transpose | if set to true, transposed system will be solved |
debug | if set to true, debug information will be printed |
Definition at line 799 of file system_solvers_large.cpp.
bitpit::SystemSolver::SystemSolver | ( | const std::string & | prefix, |
bool | debug = false ) |
Constructor.
prefix | is the prefix string to prepend to all option requests |
debug | if set to true, debug information will be printed |
Definition at line 810 of file system_solvers_large.cpp.
bitpit::SystemSolver::SystemSolver | ( | const std::string & | prefix, |
bool | transpose, | ||
bool | debug ) |
Constructor.
prefix | is the prefix string to prepend to all option requests |
debug | if set to true, debug information will be printed |
Definition at line 821 of file system_solvers_large.cpp.
bitpit::SystemSolver::SystemSolver | ( | const std::string & | prefix, |
bool | flatten, | ||
bool | transpose, | ||
bool | debug ) |
Constuctor
prefix | is the prefix string to prepend to all option requests |
flatten | if set to true, block size will not be taken into account when allocating the internal storage of the system matrix. Even when the internal storage is flat, block size information are available and can be used by the solver to speed up the solution of the system. However, since the internal storage doesn't take blocks into account, some low level operations (e.g., matrix-matrix multiplications) cannot use block information. Some algorithms for the solution of the system (e.g., multigrid) requires a flat storage. |
transpose | if set to true, transposed system will be solved |
debug | if set to true, debug information will be printed |
Definition at line 839 of file system_solvers_large.cpp.
|
virtual |
Destructor.
Definition at line 863 of file system_solvers_large.cpp.
void bitpit::SystemSolver::assembly | ( | const Assembler & | assembler | ) |
Assembly the system.
After assembying th system solver, its options will be reset.
assembler | is the matrix assembler |
Definition at line 949 of file system_solvers_large.cpp.
void bitpit::SystemSolver::assembly | ( | const Assembler & | assembler, |
const SystemMatrixOrdering & | reordering ) |
Assembly the system.
After assembying th system solver, its options will be reset.
assembler | is the matrix assembler |
reordering | is the reordering that will be applied when assembling the system |
Definition at line 962 of file system_solvers_large.cpp.
void bitpit::SystemSolver::assembly | ( | const SparseMatrix & | matrix | ) |
Assembly the system.
After assembying th system solver, its options will be reset.
matrix | is the matrix |
Definition at line 917 of file system_solvers_large.cpp.
void bitpit::SystemSolver::assembly | ( | const SparseMatrix & | matrix, |
const SystemMatrixOrdering & | reordering ) |
Assembly the system.
After assembying th system solver, its options will be reset.
matrix | is the matrix |
reordering | is the reordering that will be applied when assembling the system |
Definition at line 930 of file system_solvers_large.cpp.
|
protected |
Assembly the system.
After assembying th system solver, its options will be reset.
assembler | is the matrix assembler |
reordering | is the reordering that will be applied when assemblying the system |
Definition at line 95 of file system_solvers_large.tpp.
|
virtual |
Clear the system
Reimplemented in bitpit::DiscretizationStencilSolver< stencil_t, solver_kernel_t >.
Definition at line 875 of file system_solvers_large.cpp.
|
protected |
Clear the reordering that will be applied when assembling the matrix.
The function will clear any reordering previously set. With no reordering defined, the matrix will be assembled using its natural ordering.
Definition at line 3146 of file system_solvers_large.cpp.
|
virtual |
Clear and release the memory of all data structures needed for the solution of the system.
These data structures will be re-created the next time the system will be solved.
Definition at line 899 of file system_solvers_large.cpp.
|
protectedvirtual |
Create the KSP.
Definition at line 3239 of file system_solvers_large.cpp.
|
protected |
Create a nest matrix.
rowBlockSize | is the row block size of the matrix |
colBlockSize | is the column block size of the matrix |
nNestRows | is the number of rows in the nest, i.e. the number of submatrices along the rows of the nest |
nNestCols | is the number of columns in the nest, i.e. the number of submatrices along the columns of the nest |
subMatrices | are the submatrices stored in row-major order, empty submatrices can be passed using nullptr |
vector | on output will contain the newly created matrix |
Definition at line 2321 of file system_solvers_large.cpp.
|
protected |
Create a matrix.
rowBlockSize | is the row block size of the matrix |
colBlockSize | is the column block size of the matrix |
matrix | on output will contain the newly created matrix |
Definition at line 2266 of file system_solvers_large.cpp.
|
protected |
Create a nest vector.
blockSize | is the block size of the vector |
nestSize | is the number of subvectors that will be contained in the nest |
subVectors | are the subvectors, empty subvectors can be passed using nullptr |
vector | on output will contain the newly created vector |
Definition at line 2626 of file system_solvers_large.cpp.
|
protected |
Create a vector.
blockSize | is the block size of the vector |
vector | on output will contain the newly created vector |
Definition at line 2593 of file system_solvers_large.cpp.
|
protectedvirtual |
Destroy the KSP.
Definition at line 3257 of file system_solvers_large.cpp.
|
protectedvirtual |
Destroy the options associated with the KSP.
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 3465 of file system_solvers_large.cpp.
|
protectedvirtual |
Destroy the status of the KSP.
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 3538 of file system_solvers_large.cpp.
|
protected |
Destroy the specified matrix.
matrix | is the matrix that will be destroyed |
Definition at line 2579 of file system_solvers_large.cpp.
|
protected |
Destroy the specified vector.
vector | is the vector that will be destroyed |
Definition at line 3010 of file system_solvers_large.cpp.
|
protectedvirtual |
Dump system information.
systemStream | is the stream in which system information is written |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 2230 of file system_solvers_large.cpp.
|
protected |
Dump the specified matrix.
In addition to the file that contains the contant of the matrix, some other files will be created:
a file with the information about the partitioning (called "<NAME>.partitioning"), this file is created only if the system is partitioned and bitpit MPI support is enabled.
matrix | is the matrix that will be dumped |
directory | is the directory in which the matrix data file will be written |
name | is the name of the matrix that will be dumped |
Definition at line 2390 of file system_solvers_large.cpp.
void bitpit::SystemSolver::dumpSystem | ( | const std::string & | header, |
const std::string & | directory, | ||
const std::string & | prefix = "" ) const |
Dump the system to files.
Only the contents of the system will be dumped, this include the matrix, the RHS vector, the solution vector, and the information needed to properly restore the aforementioned data structures (e.g., the block size or the transpose flag).
header | is the header that will be written in the system information archive |
directory | is the directory where the files will be saved |
prefix | is the prefix that will be added to the files |
Definition at line 2132 of file system_solvers_large.cpp.
|
protected |
Dump the specified vector.
In addition to the file that contains the contant of the vector, some other files will be created:
a file with the information about the partitioning (called "<NAME>.partitioning"), this file is created only if the system is partitioned and bitpit MPI support is enabled.
vector | is the vector that will be dumped |
directory | is the directory in which the vector data file will be written |
name | is the name of the vector that will be dumped |
Definition at line 2711 of file system_solvers_large.cpp.
void bitpit::SystemSolver::enableForceConsistency | ( | bool | enable | ) |
Enable or disable forcing right hand side consistency.
enable | if set to true, right hand side consistency will be forced before solving the system |
Definition at line 3617 of file system_solvers_large.cpp.
|
virtual |
Export the matrix to the specified file.
filePath | is the path of the file |
fileFormat | is the file format that will be used for exporting the matrix, note that the ASCII format may not be able to handle large matrices |
Reimplemented in bitpit::SplitSystemSolver, and bitpit::SplitSystemSolver.
Definition at line 1980 of file system_solvers_large.cpp.
|
protected |
Export the given matrix to the specified file.
matrix | is the matrix that will be filled |
filePath | is the path of the file that will contain matrix data |
fileFormat | is the file format that will be used for exporting the matrix, note that the ASCII format may not be able to handle large matrices |
Definition at line 2531 of file system_solvers_large.cpp.
|
virtual |
Export the RHS vector to the specified file.
filePath | is the path of the file |
fileFormat | is the file format that will be used for exporting the RHS vector, note that the ASCII format may not be able to handle large vectors |
Definition at line 2022 of file system_solvers_large.cpp.
|
virtual |
Export the solution vector to the specified file.
filePath | is the path of the file |
fileFormat | is the file format that will be used for exporting the solution vector, note that the ASCII format may not be able to handle large vectors |
Definition at line 2075 of file system_solvers_large.cpp.
|
protected |
Export the specified vector to the file given file.
vector | is the vector that will be exported |
filePath | is the path of the file |
fileFormat | is the file format that will be used for exporting the vector, note that the ASCII format may not be able to handle large vectors |
Definition at line 2943 of file system_solvers_large.cpp.
|
protected |
Export the specified vector into the given container.
vector | is the vector that will be exported |
data | on output it will contain the data of the vector of the linear system |
Definition at line 2992 of file system_solvers_large.cpp.
|
protectedvirtual |
Fill the status of the KSP.
Reimplemented in bitpit::SplitSystemSolver, and bitpit::SplitSystemSolver.
Definition at line 3497 of file system_solvers_large.cpp.
|
protectedvirtual |
Fill the status of the specified KSP.
ksp | is the KSP the status will be fetched from |
status | on output will contain the status of the KSP |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 3508 of file system_solvers_large.cpp.
|
protected |
Fill the given matrix reading its contents from the specified file.
The input file should contain a compatible matrix stored in PETSc binary format. If the data file cannot be read an exception is thrown.
matrix | is the matrix that will be filled |
filePath | is the path of the file that contains matrix data |
Definition at line 2348 of file system_solvers_large.cpp.
|
protected |
Fill the given vector reading its contents from the specified file.
The input file should contain a compatible vector stored in PETSc binary format. If the data file cannot be read an exception is thrown.
vector | is the vector that will be filled |
filePath | is the path of the file that contains vector data |
Definition at line 2650 of file system_solvers_large.cpp.
|
protected |
Fill the specified vector with the given data.
vector | is the vector that will be filled |
data | is the data that will be copied into the vector |
Definition at line 2679 of file system_solvers_large.cpp.
|
protectedvirtual |
Finalize the KSP after the solution of the system.
Definition at line 3231 of file system_solvers_large.cpp.
|
virtual |
Get the block size of the system.
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 1022 of file system_solvers_large.cpp.
long bitpit::SystemSolver::getColCount | ( | ) | const |
Get the number of columns of the system.
If the matrix is a block matrix (i.e., the block size is greater than one), this function will return the number of block columns, where a block column is defined as a group of block-size matrix columns.
Definition at line 1065 of file system_solvers_large.cpp.
long bitpit::SystemSolver::getColElementCount | ( | ) | const |
Get the number of elements in the columns of the system.
This function will return the effective number of columns of the system matrix. This value is the same as the local size used in creating the x vector for the matrix-vector product y = Ax.
Definition at line 1108 of file system_solvers_large.cpp.
long bitpit::SystemSolver::getColGlobalCount | ( | ) | const |
Get number of global (block) columns.
If the matrix is a block matrix (i.e., the block size is greater than one), this function will return the global number of block columns, where a block column is defined as a group of block-size matrix columns.
Definition at line 1152 of file system_solvers_large.cpp.
long bitpit::SystemSolver::getColGlobalElementCount | ( | ) | const |
Get the number of global elements in the columns of the system.
This function will return the effective global number of columns of the system matrix.
Definition at line 1193 of file system_solvers_large.cpp.
|
protected |
Gets the MPI communicator associated to the system.
Definition at line 3549 of file system_solvers_large.cpp.
|
protected |
Get the path of the specified data file.
directory | is the directory that contains the file |
name | is the name, without extension, of the file |
Definition at line 3037 of file system_solvers_large.cpp.
|
protectedvirtual |
Get the version associated with the binary dumps.
Definition at line 1334 of file system_solvers_large.cpp.
|
protected |
Get the path of the specified file.
directory | is the directory that contains the file |
name | is the name of the file |
Definition at line 3049 of file system_solvers_large.cpp.
|
protected |
Get the path of the specified info file.
directory | is the directory that contains the file |
name | is the name, without extension, of the file |
Definition at line 3025 of file system_solvers_large.cpp.
KSPOptions & bitpit::SystemSolver::getKSPOptions | ( | ) |
Get a reference to the options associated with the Krylov solver.
The options associated with the Krylov solver can only be accessed after assembling the system.
Definition at line 3419 of file system_solvers_large.cpp.
const KSPOptions & bitpit::SystemSolver::getKSPOptions | ( | ) | const |
Get a constant reference to the options associated with the Krylov solver.
The options associated with the Krylov solver can only be accessed after assembling the system.
Definition at line 3435 of file system_solvers_large.cpp.
const KSPStatus & bitpit::SystemSolver::getKSPStatus | ( | ) | const |
Get a constant reference to the status of the Krylov solver.
The status of the Krylov solver can only be accessed after assembling the system.
Definition at line 3477 of file system_solvers_large.cpp.
double * bitpit::SystemSolver::getRHSRawPtr | ( | ) |
Get a raw pointer to the solution vector.
Definition at line 1862 of file system_solvers_large.cpp.
const double * bitpit::SystemSolver::getRHSRawPtr | ( | ) | const |
Get a constant raw pointer to the solution vector.
Definition at line 1875 of file system_solvers_large.cpp.
const double * bitpit::SystemSolver::getRHSRawReadPtr | ( | ) | const |
Get a constant raw pointer to the solution vector.
Definition at line 1885 of file system_solvers_large.cpp.
long bitpit::SystemSolver::getRowCount | ( | ) | const |
Get the number of rows of the system.
If the matrix is a block matrix (i.e., the block size is greater than one), this function will return the number of block rows, where a block row is defined as a group of block-size matrix rows.
Definition at line 1043 of file system_solvers_large.cpp.
long bitpit::SystemSolver::getRowElementCount | ( | ) | const |
Get the number of elements in the rows of the system.
This function will return the effective number of rows of the system matrix. This value is the same as the local size used in creating the y vector for the matrix-vector product y = Ax.
Definition at line 1087 of file system_solvers_large.cpp.
long bitpit::SystemSolver::getRowGlobalCount | ( | ) | const |
Get number of global (block) rows.
If the matrix is a block matrix (i.e., the block size is greater than one), this function will return the global number of block rows, where a block row is defined as a group of block-size matrix rows.
Definition at line 1130 of file system_solvers_large.cpp.
long bitpit::SystemSolver::getRowGlobalElementCount | ( | ) | const |
Get the number of global elements in the rows of the system.
This function will return the effective global number of rows of the system matrix.
Definition at line 1173 of file system_solvers_large.cpp.
double * bitpit::SystemSolver::getSolutionRawPtr | ( | ) |
Get a raw pointer to the solution vector.
Definition at line 1920 of file system_solvers_large.cpp.
const double * bitpit::SystemSolver::getSolutionRawPtr | ( | ) | const |
Get a constant raw pointer to the solution vector.
Definition at line 1933 of file system_solvers_large.cpp.
const double * bitpit::SystemSolver::getSolutionRawReadPtr | ( | ) | const |
Get a constant raw pointer to the solution vector.
Definition at line 1943 of file system_solvers_large.cpp.
bool bitpit::SystemSolver::getTranspose | ( | ) | const |
Get the transpose flag.
Definition at line 165 of file system_solvers_large.cpp.
|
virtual |
Import the matrix reading its contents form the specified file.
The input file should contain a compatible matrix stored in PETSc binary format. It's up to the caller of this routine to make sure the loaded matrix is compatible with the system. If the matrix file cannot be read an exception is thrown.
filePath | is the path of the file |
Definition at line 1994 of file system_solvers_large.cpp.
|
virtual |
Import the RHS vector reading its contents from the specified file.
The input file should contain a compatible vector stored in PETSc binary format. If the size of the vector stored in the file is not compatible with the matrix, an exception is thrown. An exception is also raised if the file cannot be read.
It is possible to fill the RHS vector only after the system has been assembled.
filePath | is the path of the file that contains RHS vector data |
Definition at line 2038 of file system_solvers_large.cpp.
|
virtual |
Import the solution vector reading its contents from the specified file.
The input file should contain a compatible vector stored in PETSc binary format. If the size of the vector stored in the file is not compatible with the matrix, an exception is thrown. An exception is also raised if the file cannot be read.
It is possible to fill the solution vector only after the system has been assembled.
filePath | is the path of the file that contains solution vector data |
Definition at line 2091 of file system_solvers_large.cpp.
|
protectedvirtual |
Initialize the options associated with the KSP.
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 3447 of file system_solvers_large.cpp.
|
protectedvirtual |
Initialize the status of the KSP.
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 3489 of file system_solvers_large.cpp.
bool bitpit::SystemSolver::isAssembled | ( | ) | const |
Check if the system is assembled.
Definition at line 1221 of file system_solvers_large.cpp.
bool bitpit::SystemSolver::isForceConsistencyEnabled | ( | ) | const |
Check if right hand side consistency is forced before solving the system.
In order to force right hand side consistency, null space components are removed from the right hand side before solving the system.
Definition at line 3606 of file system_solvers_large.cpp.
bool bitpit::SystemSolver::isPartitioned | ( | ) | const |
Checks if the matrix is partitioned.
Definition at line 1210 of file system_solvers_large.cpp.
bool bitpit::SystemSolver::isSetUp | ( | ) | const |
Check if the system is set up.
This function is deprecated, it will always return true.
Definition at line 1233 of file system_solvers_large.cpp.
|
protected |
Assemble the matrix.
assembler | is the matrix assembler |
Definition at line 1346 of file system_solvers_large.cpp.
|
protectedvirtual |
Destroy the matrix.
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 1743 of file system_solvers_large.cpp.
|
protectedvirtual |
Dump the matrix.
systemStream | is the stream in which system information is written |
directory | is the directory in which the matrix data file will be written |
prefix | is the prefix added to the name of the file containing matrix data |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 1703 of file system_solvers_large.cpp.
|
protectedvirtual |
Fill the matrix reading its contents form the specified file.
The input file should contain a compatible vector stored in PETSc binary format. It's up to the caller of this routine to make sure the loaded vector is compatible with the matrix. If the matrix file cannot be read an exception is thrown.
filePath | is the path of the file |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 1491 of file system_solvers_large.cpp.
|
protectedvirtual |
Restore the matrix.
systemStream | is the stream from which system information is read |
directory | is the directory from which the matrix data file will be read |
prefix | is the prefix that will be was added to the files during |
redistribute | if set to true, the matrix will be redistributed among the available processes, allowing to restore the matrix with a different number of processes than those used to dump it |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 1724 of file system_solvers_large.cpp.
|
protected |
Update the specified rows of the matrix.
The contents of the specified rows will be replaced by the data provided by the given assembler. If the matrix has not been assembled yet, both the pattern and the values of the matrix will be updated. After the matrix has been assembled only the values will be updated.
The block size of the assembler should be equal to the block size of the matrix.
nRows | is the number of rows that will be updated |
rows | are the local indices of the rows that will be updated, if a null pointer is passed, the rows that will be updated are the rows from 0 to (nRows - 1). |
assembler | is the matrix assembler for the rows that will be updated |
Definition at line 1518 of file system_solvers_large.cpp.
|
protectedvirtual |
Perform actions after Krylov subspace method setup.
Definition at line 3408 of file system_solvers_large.cpp.
|
protectedvirtual |
Post-solve actions.
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 1317 of file system_solvers_large.cpp.
|
protectedvirtual |
Perform actions after preconditioner setup.
Definition at line 3351 of file system_solvers_large.cpp.
|
protectedvirtual |
Perform actions before Krylov subspace method setup.
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 3389 of file system_solvers_large.cpp.
|
protectedvirtual |
Pre-solve actions.
Definition at line 1300 of file system_solvers_large.cpp.
|
protectedvirtual |
Prepare the KSP before the solution of the system.
Definition at line 3170 of file system_solvers_large.cpp.
|
protectedvirtual |
Perform actions before preconditioner setup.
Definition at line 3343 of file system_solvers_large.cpp.
|
protected |
Reorder the specified vector.
invert | is a flag for inverting the ordering |
Definition at line 2919 of file system_solvers_large.cpp.
|
protectedvirtual |
Reset the specified KSP options.
options | are the options that will be reset |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 3457 of file system_solvers_large.cpp.
|
protectedvirtual |
Reset the status of the KSP.
Reimplemented in bitpit::SplitSystemSolver, and bitpit::SplitSystemSolver.
Definition at line 3518 of file system_solvers_large.cpp.
|
protectedvirtual |
Reset the status of the specified KSP.
status | on output will contain the status of the KSP |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 3528 of file system_solvers_large.cpp.
|
protectedvirtual |
Restore system information.
systemStream | is the stream from which system information is read |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 2245 of file system_solvers_large.cpp.
|
protected |
Restore the specified matrix.
directory | is the directory from which the matrix data file will be read | |
name | is the name of the matrix that will be dumped | |
redistribute | if set to true, the matrix will be redistributed among the available processes, allowing to restore the matrix with a different number of processes than those used to dump it | |
[out] | matrix | on output will contain the restored matrix |
Definition at line 2465 of file system_solvers_large.cpp.
void bitpit::SystemSolver::restoreRHSRawPtr | ( | double * | raw_rhs | ) |
Restores the solution vector after getRHSRawPtr() has been called.
raw_rhs | is the location of pointer to array obtained from getRHSRawPtr() |
Definition at line 1899 of file system_solvers_large.cpp.
void bitpit::SystemSolver::restoreRHSRawReadPtr | ( | const double * | raw_rhs | ) | const |
Restores the solution vector after getRHSRawReadPtr() has been called.
raw_rhs | is the location of pointer to array obtained from getRHSRawReadPtr() |
Definition at line 1910 of file system_solvers_large.cpp.
void bitpit::SystemSolver::restoreSolutionRawPtr | ( | double * | raw_solution | ) |
Restores the solution vector after getSolutionRawPtr() has been called.
raw_solution | is the location of pointer to array obtained from getSolutionRawPtr() |
Definition at line 1957 of file system_solvers_large.cpp.
void bitpit::SystemSolver::restoreSolutionRawReadPtr | ( | const double * | raw_solution | ) | const |
Restores the solution vector after getSolutionRawReadPtr() has been called.
raw_solution | is the location of pointer to array obtained from getSolutionRawReadPtr() |
Definition at line 1968 of file system_solvers_large.cpp.
void bitpit::SystemSolver::restoreSystem | ( | MPI_Comm | communicator, |
bool | redistribute, | ||
const std::string & | directory, | ||
const std::string & | prefix = "" ) |
Restore the system from files.
Only the contents of the system will be restored, this include the matrix, the RHS vector, the solution vector, and the information needed to properly create the aforementioned data structures (e.g., the block size or the transpose flag).
Matrix file is mandatory, whereas solution and RHS files are not. If no solution or RHS files are found they will be re-created from scratch (but they will not be initialized).
communicator | is the MPI communicator |
redistribute | if set to true, the system will be redistributed among the available processes, allowing to restore the system with a different number of processes than those used to dump it |
directory | is the directory where the files will be read from |
prefix | is the prefix that will be was added to the files during |
Definition at line 2180 of file system_solvers_large.cpp.
|
protected |
Restore the specified vector.
directory | is the directory from which the vector data file will be read | |
name | is the name of the vector that will be dumped | |
redistribute | if set to true, the vector will be redistributed among the available processes, allowing to restore the vector with a different number of processes than those used to dump it | |
[out] | vector | on output will contain the restored vector |
Definition at line 2828 of file system_solvers_large.cpp.
|
protected |
Restore the specified vector.
directory | is the directory from which the vector data file will be read | |
name | is the name of the vector that will be dumped | |
matrix | is the matrix the vectors should be compatible with | |
side | specifies whether the vector can be multiplied by the matrix, or whether the matrix-vector product can be stored in it | |
[out] | vector | on output will contain the restored vector |
Definition at line 2775 of file system_solvers_large.cpp.
|
protected |
Restore the specified vector.
directory | is the directory from which the vector data file will be read | |
name | is the name of the vector that will be dumped | |
localSize | is the local size of the restored vector | |
globalSize | is the global size of the restored vector | |
[out] | vector | on output will contain the restored vector |
Definition at line 2868 of file system_solvers_large.cpp.
|
virtual |
Attaches a null space to the system matrix.
Definition at line 3059 of file system_solvers_large.cpp.
|
protected |
Set the reordering that will be applied when assembling the matrix.
Reordering will be applied when the system is assembled and its sole purpose is to speed up the resolution of the system (e.g., reorder can be used to reduce the fill-in of the LU factorization).
Reordering is only applied internally, all public functions expects row and column indices to be in natural matrix order (i.e., not reordered).
If the system is partitioned, each process can reorder only it's local part of the matrix.
nRows | is the number of rows of the system matrix |
nCols | is the number of columns of the system matrix |
reordering | is the reordering that will be applied |
Definition at line 3096 of file system_solvers_large.cpp.
void bitpit::SystemSolver::setTranspose | ( | bool | transpose | ) |
Set the transpose flag.
If the system is already assembled and the transpose flag needs to be changed, both the solution vector and the RHS one will be destroyed and re-created.
If the transpose flag needs to be changed, the workspaces associated wit the system will be cleared.
transpose | if set to true, transposed system will be solved |
Definition at line 181 of file system_solvers_large.cpp.
void bitpit::SystemSolver::setUp | ( | ) |
Setup the system.
This function is deprecated, there is no need to call it.
Definition at line 3162 of file system_solvers_large.cpp.
|
protectedvirtual |
Set up the Krylov subspace method used to solve the system.
Reimplemented in bitpit::SplitSystemSolver, and bitpit::SplitSystemSolver.
Definition at line 3359 of file system_solvers_large.cpp.
|
protectedvirtual |
Set up the Krylov subspace method using the given options.
This function is in charge of only setting the properties of the Krylov subspace method that will be used to solve the system. There is a dedicated function to set up the preconditioner.
ksp | is the KSP whose Krylov subspace method will be setup |
options | are the options that will be used to set up the KSP |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 3374 of file system_solvers_large.cpp.
|
protectedvirtual |
Set up the preconditioner.
Reimplemented in bitpit::SplitSystemSolver, and bitpit::SplitSystemSolver.
Definition at line 3267 of file system_solvers_large.cpp.
|
protectedvirtual |
Set up the specified preconditioner using the given options.
pc | is the preconditioner to set up |
options | are the options that will be used to set up the preconditioner |
Reimplemented in bitpit::SplitSystemSolver, AMGSystemSolver, and AMGSplitSystemSolver.
Definition at line 3280 of file system_solvers_large.cpp.
void bitpit::SystemSolver::solve | ( | ) |
Solve the system
Definition at line 1241 of file system_solvers_large.cpp.
void bitpit::SystemSolver::solve | ( | const std::vector< double > & | rhs, |
std::vector< double > * | solution ) |
Solve the system
rhs | is the right-hand-side of the system |
solution | in input should contain the initial solution, on output it contains the solution of the linear system |
Definition at line 1265 of file system_solvers_large.cpp.
|
protectedvirtual |
Solve KSP.
Definition at line 1280 of file system_solvers_large.cpp.
void bitpit::SystemSolver::unsetNullSpace | ( | ) |
Removes the null space from the system matrix.
Definition at line 3074 of file system_solvers_large.cpp.
void bitpit::SystemSolver::update | ( | const Assembler & | assembler | ) |
Update all the rows of the system.
Only the values of the system matrix can be updated, once the system is assembled its pattern cannot be modified.
assembler | is the matrix assembler for the rows that will be updated |
Definition at line 997 of file system_solvers_large.cpp.
void bitpit::SystemSolver::update | ( | long | nRows, |
const long * | rows, | ||
const Assembler & | assembler ) |
Update the system.
Only the values of the system matrix can be updated, once the system is assembled its pattern cannot be modified.
nRows | is the number of rows that will be updated |
rows | are the indices of the rows that will be updated |
assembler | is the matrix assembler for the rows that will be updated |
Definition at line 1012 of file system_solvers_large.cpp.
void bitpit::SystemSolver::update | ( | long | nRows, |
const long * | rows, | ||
const SparseMatrix & | elements ) |
Update the system.
Only the values of the system matrix can be updated, once the system is assembled its pattern cannot be modified.
nRows | is the number of rows that will be updated |
rows | are the indices of the rows that will be updated |
elements | are the elements that will be used to update the rows |
Definition at line 977 of file system_solvers_large.cpp.
|
protected |
Update the system.
Only the values of the system matrix can be updated, once the system is assembled its pattern cannot be modified.
nRows | is the number of rows that will be updated |
rows | are the indices of the rows that will be updated |
assembler | is the matrix assembler for the rows that will be updated |
Definition at line 139 of file system_solvers_large.tpp.
|
protectedvirtual |
Create RHS and solution vectors.
Vectors will be created, but they will not be initialized.
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 1753 of file system_solvers_large.cpp.
|
protectedvirtual |
Destroy RHS and solution vectors.
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 1851 of file system_solvers_large.cpp.
|
protectedvirtual |
Dump RHS and solution vectors.
systemStream | is the stream from which system information is read |
directory | is the directory in which the vectors data file will be written |
prefix | is the prefix added to the names of the files containing vector data |
Definition at line 1823 of file system_solvers_large.cpp.
|
protectedvirtual |
Fill RHS and solution vectors reading their contents from the specified file.
rhsFilePath | is the file path containing the content of the RHS vector, if the path is empty the function will leave the RHS vector unaltered |
solutionFilePath | is the file path containing the content of the solution vector, if the path is empty the function will leave the solution vector unaltered |
Definition at line 1789 of file system_solvers_large.cpp.
|
protectedvirtual |
Fill RHS and solution vectors using the given data.
rhs | contains the that that will be copied into the RHS vector, if the vector is empty no data will be copied and function will leave the RHS vector unaltered |
solution | contains the that that will be copied into the solution vector, if the vector is empty no data will be copied and function will leave the RHS vector unaltered |
Definition at line 1770 of file system_solvers_large.cpp.
|
protectedvirtual |
Reorder RHS and solution vectors to match the order of the system matrix.
invert | is a flag for inverting the ordering |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 1805 of file system_solvers_large.cpp.
|
protectedvirtual |
Restore RHS and solution vectors.
systemStream | is the stream that contains system information |
directory | is the directory from which the vector data file will be read |
prefix | is the prefix added to the name of the file containing vectors data |
Reimplemented in bitpit::SplitSystemSolver.
Definition at line 1839 of file system_solvers_large.cpp.
|
protected |
Definition at line 369 of file system_solvers_large.hpp.
|
protected |
Definition at line 374 of file system_solvers_large.hpp.
|
protected |
Definition at line 376 of file system_solvers_large.hpp.
|
protected |
Definition at line 366 of file system_solvers_large.hpp.
|
protected |
Definition at line 378 of file system_solvers_large.hpp.
|
protected |
Definition at line 379 of file system_solvers_large.hpp.
|
protected |
Definition at line 380 of file system_solvers_large.hpp.
|
protected |
Definition at line 381 of file system_solvers_large.hpp.
|
protected |
Definition at line 370 of file system_solvers_large.hpp.
|
protected |
Definition at line 373 of file system_solvers_large.hpp.
|
protected |
Definition at line 371 of file system_solvers_large.hpp.
|
protected |
Definition at line 367 of file system_solvers_large.hpp.