GEOS
LinearSolverBase.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 
19 #ifndef GEOS_LINEARSOLVERBASE_HPP
20 #define GEOS_LINEARSOLVERBASE_HPP
21 
22 #include "PreconditionerBase.hpp"
25 #include "common/Stopwatch.hpp"
26 
27 #include <string>
28 
29 namespace geos
30 {
31 
39 {
52 };
53 
58 template< typename LAI >
59 class LinearSolverBase : public PreconditionerBase< LAI >
60 {
61 public:
62 
65 
67  using Vector = typename Base::Vector;
68 
70  using Matrix = typename Base::Matrix;
71 
77  : m_params( std::move( params ) )
78  {}
79 
85  virtual void solve( Vector const & rhs, Vector & sol ) const = 0;
86 
91  virtual void setExecutionContext( LinearSolverExecutionContext const & context )
92  {
93  GEOS_UNUSED_VAR( context );
94  }
95 
100  {
101  return m_params;
102  }
103 
107  LinearSolverResult const & result() const
108  {
109  return m_result;
110  }
111 
112 protected:
113 
116 
119 };
120 
121 }
122 
123 #endif //GEOS_LINEARSOLVERBASE_HPP
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Simple interface for linear solvers that allows to extract solution results.
typename Base::Vector Vector
Alias for vector type.
virtual void setExecutionContext(LinearSolverExecutionContext const &context)
Provide contextual execution metadata for backends that need it.
LinearSolverResult m_result
Result of most recent solve (status, timings)
virtual void solve(Vector const &rhs, Vector &sol) const =0
Solve preconditioned system.
LinearSolverParameters m_params
Parameters for the solver.
typename Base::Matrix Matrix
Alias for matrix type.
LinearSolverResult const & result() const
LinearSolverParameters const & parameters() const
LinearSolverBase(LinearSolverParameters params)
Constructor.
Common interface for preconditioning operators.
typename Base::Vector Vector
Alias for vector type.
typename LAI::ParallelMatrix Matrix
Alias for matrix type.
unsigned long long int Timestamp
Timestamp type (used to perform actions such a sparsity pattern computation after mesh modifications)
Definition: DataTypes.hpp:126
std::string string
String type.
Definition: DataTypes.hpp:90
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Execution metadata associated with a linear-solver invocation.
Timestamp systemSetupTimestamp
Timestamp of the last system assembly/setup used by this solve.
integer configurationAttempt
Current configuration-attempt index, or -1 when unavailable.
integer timeStepAttempt
Current timestep-attempt index, or -1 when unavailable.
std::string solverName
Human-readable name of the owning solver.
integer cycleNumber
Current outer cycle index, or -1 when unavailable.
integer nonlinearIteration
Current nonlinear-iteration index, or -1 when unavailable.
Set of parameters for a linear solver or preconditioner.
Results/stats of a linear solve.