GEOS
PetscSolver.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_LINEARALGEBRA_INTERFACES_PETSCSOLVER_HPP_
21 #define GEOS_LINEARALGEBRA_INTERFACES_PETSCSOLVER_HPP_
22 
26 
28 extern "C" struct _p_KSP;
29 
30 namespace geos
31 {
32 
36 class PetscSolver final : public LinearSolverBase< PetscInterface >
37 {
38 public:
39 
42 
48 
52  virtual ~PetscSolver();
53 
57  virtual void setup( PetscMatrix const & mat ) override;
58 
62  virtual void apply( PetscVector const & src,
63  PetscVector & dst ) const override;
64 
68  virtual void solve( PetscVector const & rhs,
69  PetscVector & sol ) const override;
70 
74  virtual void clear() override;
75 
76 private:
77 
78  using KSP = struct _p_KSP *;
79 
80  using Base::m_params;
81  using Base::m_result;
82 
84  PetscPreconditioner m_precond;
85 
87  KSP m_solver{};
88 };
89 
90 } // end geos namespace
91 
92 #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:51
Wrapper around PETSc-based preconditioners.
This class creates and provides basic support for PETSc solvers.
Definition: PetscSolver.hpp:37
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:46
Set of parameters for a linear solver or preconditioner.