GEOS
SuiteSparse.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 TotalEnergies
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_SUITESPARSE_HPP_
21 #define GEOS_LINEARALGEBRA_INTERFACES_SUITESPARSE_HPP_
22 
23 #include "common/DataTypes.hpp"
25 #include "common/PreconditionerBase.hpp"
28 
29 #include <memory>
30 
31 namespace geos
32 {
33 
35 struct SuiteSparseData;
36 
41 template< typename LAI >
42 class SuiteSparse final : public LinearSolverBase< LAI >
43 {
44 public:
45 
48 
51 
54 
60 
64  virtual ~SuiteSparse() override;
65 
66  using Base::ready;
67  using Base::matrix;
68 
73  virtual void setup( Matrix const & mat ) override;
74 
82  virtual void apply( Vector const & src, Vector & dst ) const override;
83 
91  void applyTranspose( Vector const & src, Vector & dst ) const;
92 
96  virtual void clear() override;
97 
103  virtual void solve( Vector const & rhs, Vector & sol ) const override;
104 
105 private:
106 
107  using Base::m_params;
108  using Base::m_result;
109 
116  void doSolve( Vector const & b, Vector & x, bool transpose ) const;
117 
122  real64 estimateConditionNumberBasic() const;
123 
128  real64 estimateConditionNumberAdvanced() const;
129 
131  std::unique_ptr< SuiteSparseData > m_data;
132 
134  int m_workingRank;
135 
137  std::unique_ptr< typename Matrix::Export > m_export;
138 
140  mutable real64 m_condEst;
141 };
142 
143 }
144 
145 #endif /*GEOS_LINEARALGEBRA_INTERFACES_SUITESPARSE_HPP_*/
Simple interface for linear solvers that allows to extract solution results.
typename Base::Vector Vector
Alias for vector type.
LinearSolverResult m_result
Result of most recent solve (status, timings)
LinearSolverParameters m_params
Parameters for the solver.
typename Base::Matrix Matrix
Alias for matrix type.
Common interface for preconditioning operators.
bool ready() const
Chech if preconditioner is ready to use.
Matrix const & matrix() const
Access the matrix the preconditioner was computed from.
typename Base::Vector Vector
Alias for vector type.
typename LAI::ParallelMatrix Matrix
Alias for matrix type.
Wrapper for UMFPACK direct solver from SuiteSparse package.
Definition: SuiteSparse.hpp:43
virtual void setup(Matrix const &mat) override
Compute the preconditioner from a matrix.
virtual void clear() override
Clean up the preconditioner setup.
virtual void solve(Vector const &rhs, Vector &sol) const override
Solve the system with a particular rhs.
virtual void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector, dst = this(src).
virtual ~SuiteSparse() override
Destructor.
SuiteSparse(LinearSolverParameters params)
Constructor with parameters.
void applyTranspose(Vector const &src, Vector &dst) const
Apply transpose operator to a vector, dst = this^T(src).
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
Set of parameters for a linear solver or preconditioner.