Seismo-VLAB  1.3
An Open-Source Finite Element Software for Meso-Scale Simulations
PetscSolver.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // Seismo Virtual Laboratory
4 // Module for Serial and Parallel Analysis of seismic
5 // wave propagation and soil-structure interaction simulation
6 // Copyright (C) 2018-2021, The California Institute of Technology
7 // All Rights Reserved.
8 //
9 // Commercial use of this program without express permission of the California
10 // Institute of Technology, is strictly prohibited. See file "COPYRIGHT" in
11 // main directory for information on usage and redistribution, and for a
12 // DISCLAIMER OF ALL WARRANTIES.
13 //
14 //==============================================================================
15 //
16 // Written by:
17 // Danilo S. Kusanovic (dkusanov@caltech.edu)
18 // Elnaz E. Seylabi (elnaze@unr.edu)
19 //
20 // Supervised by:
21 // Domniki M. Asimaki (domniki@caltech.edu)
22 //
23 // References :
24 // [1] Kris Buschelman, Lisandro Dalcin, Alp Dener, Victor Eijkhout, William D.
25 // Gropp, Dmitry Karpeyev, Dinesh Kaushik, Matthew G. Knepley, Dave A.
26 // May, Lois Curfman McInnes, Richard Tran Mills, Todd Munson, Karl Rupp,
27 // Patrick Sanan, Barry F. Smith, Stefano Zampini, Hong Zhang, and Hong
28 // Zhang. PETSc Web page. https://www.mcs.anl.gov/petsc, 2019.
29 // URL https://www.mcs.anl.gov/petsc
30 //
31 // [2] Satish Balay, Shrirang Abhyankar, Mark F. Adams, Jed Brown, Peter Brune,
32 // Kris Buschelman, Lisandro Dalcin, Alp Dener, Victor Eijkhout, William D.
33 // Gropp, Dmitry Karpeyev, Dinesh Kaushik, Matthew G. Knepley, Dave A.
34 // May, Lois Curfman McInnes, Richard Tran Mills, Todd Munson, Karl Rupp,
35 // Patrick Sanan, Barry F. Smith, Stefano Zampini, Hong Zhang, and Hong
36 // Zhang. PETSc users manual. Technical Report ANL-95/11 - Revision 3.12,
37 // Argonne National Laboratory, 2019. URL https://www.mcs.anl.gov/petsc
38 //
39 // Description:
43 //------------------------------------------------------------------------------
44 
45 #ifndef _PETSCSOLVER_HPP_
46 #define _PETSCSOLVER_HPP_
47 
48 #include <Eigen/Dense>
49 #include <Eigen/SparseCore>
50 
51 #include "LinearSystem.hpp"
52 
60 class PetscSolver : public LinearSystem {
61 
62  public:
70  PetscSolver(unsigned int dnz, unsigned int onz, double tol=1E-12, unsigned int kspnum=0);
71 
73  ~PetscSolver();
74 
81  bool SolveSystem(Eigen::SparseMatrix<double> &A, Eigen::VectorXd &b);
82 
86  const Eigen::VectorXd& GetSolution();
87 
88  protected:
90  unsigned int d_nz;
91 
93  unsigned int o_nz;
94 
96  double Tolerance;
97 
99  Eigen::VectorXd x;
100 };
101 
102 #endif
unsigned int o_nz
Number of nonzero in off-diagonal per row.
Definition: PetscSolver.hpp:93
This file contains the abstract "LinearSystem object" declarations, which defines the library to solv...
double Tolerance
Residual tolerance error.
Definition: PetscSolver.hpp:96
PetscSolver(unsigned int dnz, unsigned int onz, double tol=1E-12, unsigned int kspnum=0)
Creates a PetscSolver object.
unsigned int d_nz
Number of nonzero in diagonal per row.
Definition: PetscSolver.hpp:90
bool SolveSystem(Eigen::SparseMatrix< double > &A, Eigen::VectorXd &b)
Solve the linear system.
Class for solving a linear system using an iterative solver assuming the matrix can be symmetric posi...
Definition: PetscSolver.hpp:60
Virtual class for solving a linear system of the form Ax = b.
Definition: LinearSystem.hpp:44
const Eigen::VectorXd & GetSolution()
Gets the soultion vector.
Eigen::VectorXd x
Vector of unknowns.
Definition: PetscSolver.hpp:99
~PetscSolver()
Destroys this PetscSolver object.