GEOSX
PetscSolver.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 TotalEnergies
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOS_LINEARALGEBRA_INTERFACES_PETSCSOLVER_HPP_
20 #define GEOS_LINEARALGEBRA_INTERFACES_PETSCSOLVER_HPP_
21 
25 
27 extern "C" struct _p_KSP;
28 
29 namespace geos
30 {
31 
35 class PetscSolver final : public LinearSolverBase< PetscInterface >
36 {
37 public:
38 
41 
47 
51  virtual ~PetscSolver();
52 
56  virtual void setup( PetscMatrix const & mat ) override;
57 
61  virtual void apply( PetscVector const & src,
62  PetscVector & dst ) const override;
63 
67  virtual void solve( PetscVector const & rhs,
68  PetscVector & sol ) const override;
69 
73  virtual void clear() override;
74 
75 private:
76 
77  using KSP = struct _p_KSP *;
78 
79  using Base::m_params;
80  using Base::m_result;
81 
83  PetscPreconditioner m_precond;
84 
86  KSP m_solver{};
87 };
88 
89 } // end geosx namespace
90 
91 #endif /* PETSCSOLVER_HPP_ */
Simple interface for linear solvers that allows to extract solution results.
LinearSolverResult m_result
Result of most recent solve (status, timings)
LinearSolverParameters m_params
Parameters for the solver.
LinearSolverParameters const & parameters() const
This class creates and provides basic support for the Mat matrix object type used in PETSc.
Definition: PetscMatrix.hpp:50
Wrapper around PETSc-based preconditioners.
This class creates and provides basic support for PETSc solvers.
Definition: PetscSolver.hpp:36
virtual void solve(PetscVector const &rhs, PetscVector &sol) const override
Solve preconditioned system.
virtual void apply(PetscVector const &src, PetscVector &dst) const override
Apply operator to a vector, dst = this(src).
virtual void setup(PetscMatrix const &mat) override
Compute the preconditioner from a matrix.
virtual void clear() override
Clean up the preconditioner setup.
PetscSolver(LinearSolverParameters parameters)
Solver constructor, with parameter list reference.
virtual ~PetscSolver()
Destructor.
This class creates and provides basic support for Vec vector object type used in PETSc.
Definition: PetscVector.hpp:45
Set of parameters for a linear solver or preconditioner.