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 Total, S.A
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 GEOSX_LINEARALGEBRA_INTERFACES_PETSCSOLVER_HPP_
20 #define GEOSX_LINEARALGEBRA_INTERFACES_PETSCSOLVER_HPP_
21 
24 
25 namespace geosx
26 {
27 
28 class DofManager;
29 class PetscVector;
30 class PetscMatrix;
31 
36 {
37 public:
38 
43  PetscSolver( LinearSolverParameters parameters );
44 
49  virtual ~PetscSolver() = default;
50 
60  void solve( PetscMatrix & mat,
61  PetscVector & sol,
62  PetscVector & rhs,
63  DofManager const * const dofManager = nullptr );
64 
70  {
71  return m_result;
72  }
73 
74 private:
75 
76  LinearSolverParameters m_parameters;
77  LinearSolverResult m_result;
78 
79  void solve_direct( PetscMatrix & mat,
80  PetscVector & sol,
81  PetscVector & rhs );
82 
83  void solve_krylov( PetscMatrix & mat,
84  PetscVector & sol,
85  PetscVector & rhs );
86 
87 };
88 
89 } // end geosx namespace
90 
91 #endif /* PETSCSOLVER_HPP_ */
This class creates and provides basic support for PETSc solvers.
Definition: PetscSolver.hpp:35
void solve(PetscMatrix &mat, PetscVector &sol, PetscVector &rhs, DofManager const *const dofManager=nullptr)
Solve system with an iterative solver.
Set of parameters for a linear solver or preconditioner.
Results/stats of a linear solve.
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns, and generally simplifying the interaction between PhysicsSolvers and linear algebra operations.
Definition: DofManager.hpp:42
This class creates and provides basic support for Vec vector object type used in PETSc.
Definition: PetscVector.hpp:44
This class creates and provides basic support for the Mat matrix object type used in PETSc...
Definition: PetscMatrix.hpp:47
PetscSolver(LinearSolverParameters parameters)
Solver constructor, with parameter list reference.
virtual ~PetscSolver()=default
Virtual destructor.
LinearSolverResult const & result()
Get the result of previous solve.
Definition: PetscSolver.hpp:69