Seismo-VLAB  1.3
An Open-Source Finite Element Software for Meso-Scale Simulations
PetscSolver Class Reference

Class for solving a linear system using an iterative solver assuming the matrix can be symmetric positive-definite, general symmetric or asymmetric. More...

#include <PetscSolver.hpp>

Inheritance diagram for PetscSolver:
Collaboration diagram for PetscSolver:

Public Member Functions

 PetscSolver (unsigned int dnz, unsigned int onz, double tol=1E-12, unsigned int kspnum=0)
 Creates a PetscSolver object. More...
 
 ~PetscSolver ()
 Destroys this PetscSolver object. More...
 
bool SolveSystem (Eigen::SparseMatrix< double > &A, Eigen::VectorXd &b)
 Solve the linear system. More...
 
const Eigen::VectorXd & GetSolution ()
 Gets the soultion vector. More...
 
- Public Member Functions inherited from LinearSystem
 LinearSystem ()
 Creates a LinearSystem object. More...
 
virtual ~LinearSystem ()=0
 Destroys this LinearSystem object. More...
 

Protected Attributes

unsigned int d_nz
 Number of nonzero in diagonal per row. More...
 
unsigned int o_nz
 Number of nonzero in off-diagonal per row. More...
 
double Tolerance
 Residual tolerance error. More...
 
Eigen::VectorXd x
 Vector of unknowns. More...
 

Detailed Description

Class for solving a linear system using an iterative solver assuming the matrix can be symmetric positive-definite, general symmetric or asymmetric.

See also
LinearSystem.hpp Algorithm.hpp

Constructor & Destructor Documentation

◆ PetscSolver()

PetscSolver::PetscSolver ( unsigned int  dnz,
unsigned int  onz,
double  tol = 1E-12,
unsigned int  kspnum = 0 
)

Creates a PetscSolver object.

Parameters
dnzNumber of nonzero in diagonal per row.
onzNumber of nonzero in off-diagonal per row.
tolThe tolerance at which convergence is reached.
kspnumThe iterative algorithm to be employed.
Note
More details can be found at PetscSolver.
See also
PetscSolver::n, PetscSolver::d_nz, PetscSolver::o_nz, PetscSolver::Tolerance.

◆ ~PetscSolver()

PetscSolver::~PetscSolver ( )

Destroys this PetscSolver object.

Member Function Documentation

◆ GetSolution()

const Eigen::VectorXd& PetscSolver::GetSolution ( )
virtual

Gets the soultion vector.

Returns
The solution vector.
See also
PetscSolver::x.

Implements LinearSystem.

◆ SolveSystem()

bool PetscSolver::SolveSystem ( Eigen::SparseMatrix< double > &  A,
Eigen::VectorXd &  b 
)
virtual

Solve the linear system.

Parameters
AThe matrix with the left-hand side.
bThe vector with the right-hand side.
Returns
Whether or not the system was successfully solved.
Note
More details can be found at PetscSolver.
See also
Integrator::ComputeEffectiveForce(), Integrator::ComputeEffectiveStiffness().

Implements LinearSystem.

Member Data Documentation

◆ d_nz

unsigned int PetscSolver::d_nz
protected

Number of nonzero in diagonal per row.

◆ o_nz

unsigned int PetscSolver::o_nz
protected

Number of nonzero in off-diagonal per row.

◆ Tolerance

double PetscSolver::Tolerance
protected

Residual tolerance error.

◆ x

Eigen::VectorXd PetscSolver::x
protected

Vector of unknowns.