#include <PetscLinearSolver.h>
Public Member Functions | |
PetscLinearSolver () | |
void | LinearSolver (int matrixSize, real **valueAMatrix, int **columnAMatrix, int totalColumn, real *rhs, real *Sol, PCType preCond, KSPType KrylovM, real tol, int &zeroInitialGuess) |
Linear system solver. | |
int | finalize () |
~PetscLinearSolver () |
This class use PETSC to solve the linear system A x = b, which results from the pressure Poisson equation. A is the matrix, x is the soultion of pressure, and b is the source terms. Note that A is represented by a sparse matrix for efficiency. The performace of the solver is mainly determined by this part, because the Poisson equation is the most expensive part to solve.
Include "petscksp.h" so that we can use KSP solvers. Note that this file automatically includes:
petsc.h - base PETSc routines, petscvec.h - vectors , petscsys.h - system routines , petscmat.h - matrices, petscis.h - index sets , petscksp.h - Krylov subspace methods, petscviewer.h - viewers , petscpc.h - preconditioners,
PetscLinearSolver::PetscLinearSolver | ( | ) |
constructor
PetscLinearSolver::~PetscLinearSolver | ( | ) |
destructor
void PetscLinearSolver::LinearSolver | ( | int | matrixSize, | |
real ** | valueAMatrix, | |||
int ** | columnAMatrix, | |||
int | totalColumn, | |||
real * | rhs, | |||
real * | Sol, | |||
PCType | preCond, | |||
KSPType | KrylovM, | |||
real | tol, | |||
int & | zeroInitialGuess | |||
) |
Linear system solver.
This class use PETSC to solve the linear system A x = b, which results from the pressure Poisson equation. A is the matrix, x is the soultion of pressure, and b is the source terms. Note that A is represented by a sparse matrix for efficiency. The performace of the solver is mainly determined by this part, because the Poisson equation is the most expensive part to solve.
Concepts: KSP^solving a system of linear equations: AMatrix x = rhs
Processors: 1
matrixSize | matrix size |
valueAMatrix | matrix elements |
columnAMatrix | matrix index |
totalColumn | total number of columns |
rhs | mright hand side of the matrix |
Sol | solution of the linear system |
preCond | preconditioner for PETSC |
KrylovM | Krylov method |
tol | tolerance |
zeroInitialGuess | if use zero as the initial guess for pressure |
int PetscLinearSolver::finalize | ( | ) |
clean up the memory assigned for PETSC