GEOSX
HyprePreconditioner.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_HYPREPRECONDITIONER_HPP
20 #define GEOSX_HYPREPRECONDITIONER_HPP
21 
22 #include "linearAlgebra/solvers/PreconditionerBase.hpp"
25 
26 #include <memory>
27 
34 
37 extern "C" struct hypre_Solver_struct;
38 
40 using HYPRE_Solver = hypre_Solver_struct *;
41 
43 
44 namespace geosx
45 {
46 
48 struct HyprePrecAuxData;
49 
51 struct HyprePrecFuncs;
52 
56 class HyprePreconditioner final : public PreconditionerBase< HypreInterface >
57 {
58 public:
59 
62 
64  using Vector = typename Base::Vector;
65 
67  using Matrix = typename Base::Matrix;
68 
70  using Base::compute;
71 
78  DofManager const * const dofManager = nullptr );
79 
87  array1d< HypreVector > const & nearNullKernel,
88  DofManager const * const dofManager = nullptr );
89 
93  virtual ~HyprePreconditioner() override;
94 
98  void create();
99 
104  virtual void compute( Matrix const & mat ) override;
105 
113  virtual void apply( Vector const & src, Vector & dst ) const override;
114 
115  virtual void clear() override;
116 
121  HYPRE_Solver const & unwrapped() const;
122 
129  HyprePrecFuncs const & unwrappedFuncs() const;
130 
131 private:
132 
133  void createHyprePreconditioner( DofManager const * const dofManager );
134 
135  void createAMG();
136 
137  void createMGR( DofManager const * const dofManager );
138 
139  void createILU();
140 
141  void createILUT();
142 
144  LinearSolverParameters m_parameters;
145 
147  HYPRE_Solver m_precond;
148 
150  HYPRE_Solver aux_precond;
151 
153  std::unique_ptr< HyprePrecFuncs > m_functions;
154 
156  std::unique_ptr< HyprePrecAuxData > m_auxData;
157 
159  DofManager const * const m_dofManager;
160 
162  bool m_ready;
163 
165  array1d< HypreVector > const * m_nearNullKernel;
166 };
167 
168 }
169 
170 #endif //GEOSX_HYPREPRECONDITIONER_HPP
virtual void clear() override
Clean up the preconditioner setup.
typename Base::Vector Vector
Alias for vector type.
Common interface for preconditioning operators.
virtual void compute(Matrix const &mat)
Compute the preconditioner from a matrix.
virtual ~HyprePreconditioner() override
Destructor.
Set of parameters for a linear solver or preconditioner.
void create()
Create the preconditioner from the input parameters.
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
Container for hypre preconditioner function pointers.
Definition: HypreUtils.hpp:73
HyprePrecFuncs const & unwrappedFuncs() const
Access the underlying implementation.
HYPRE_Solver const & unwrapped() const
Access the underlying implementation.
typename Base::Matrix Matrix
Alias for matrix type.
typename HypreInterface ::ParallelMatrix Matrix
Alias for matrix type.
virtual void compute(Matrix const &mat) override
Compute the preconditioner from a matrix.
Wrapper around hypre-based preconditioners.
hypre_Solver_struct * HYPRE_Solver
Solver pointer alias.
HyprePreconditioner(LinearSolverParameters params, DofManager const *const dofManager=nullptr)
Constructor.
virtual void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
typename Base::Vector Vector
Alias for vector type.
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55