Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
ILinearSolver.h
Go to the documentation of this file.
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7
8/*!
9 * \file ILinearSolver.h
10 * \brief ILinearSolver.h
11 */
12
13#pragma once
14
15#include <arccore/message_passing/MessagePassingGlobal.h>
16#include <alien/utils/Precomp.h>
17
18#include <memory>
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Alien
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29class ILinearAlgebra;
30class Space;
31class SolverStat;
32class VectorData;
33class IMatrix;
34class IVector;
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39/*!
40 * \ingroup expression
41 * \brief Structure to store a solver status
42 */
44{
45 //! Constructor
47 : succeeded(false)
48 , residual(0)
50 , error(0)
51 {}
52
53 //! Whether or not the solver succeeded
55 //! The residual
56 Arccore::Real residual;
57 //! The number of iterations
58 Arccore::Integer iteration_count;
59 //! The error
60 Arccore::Integer error;
61};
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66/*!
67 * \ingroup expression
68 * \brief Linear solver interface
69 */
71{
72 public:
73 /*!
74 * \brief Type of the solver status
75 * \todo Change to a more abstract implementation based on CaseOptions
76 */
78
79 public:
80 //! Constructor
82
83 //! Free resources
84 virtual ~ILinearSolver() {}
85
86 public:
87 /*
88 * \brief Get the back end name
89 * \returns The back end name
90 */
91 virtual Arccore::String getBackEndName() const = 0;
92
93 //! Initialization
94 virtual void init() = 0;
95
96 //! Finalization
97 virtual void end() = 0;
98
99 /*!
100 * \brief update parallel_mng, required for redistribution
101 * \param[in] pm : new parallel mng
102 */
103 virtual void updateParallelMng(Arccore::MessagePassing::IMessagePassingMng* pm) = 0;
104
105 /*!
106 * \brief Solves a linear system
107 * \param[in] A The matrix
108 * \param[in] b The rhs
109 * \param[in, out] The solution
110 * \returns Whether or not the solver succeeded
111 */
112 virtual bool solve(const IMatrix& A, const IVector& b, IVector& x) = 0;
113
114 /*
115 * \brief Get statistics on the solve process
116 * \returns Statistics on the solve process
117 */
118 virtual SolverStat const& getSolverStat() const = 0;
119
120 /*!
121 * \brief Get a compatible linear algebra, i.e. a linear algebra matching the solver
122 * kernel \returns A compatible linear algebra
123 */
124 virtual std::shared_ptr<ILinearAlgebra> algebra() const = 0;
125
126 /*!
127 * \brief Whether or not the solver support parallel solve
128 * \returns Whether or not the solver is parallel
129 */
130 virtual bool hasParallelSupport() const = 0;
131
132 /*!
133 * \brief Get resolution information
134 * \returns Information about the solve process
135 */
136 virtual const SolverStatus& getStatus() const = 0;
137
138 /*!
139 * \brief Option to add an extra-equation
140 *
141 * Option to add an extra-equation to the linear system such as a constraint equation
142 *
143 * \param[in] flag If the option is activated
144 *
145 * \todo Implement this method
146 */
147 virtual void setNullSpaceConstantOption(bool flag) = 0;
148
149#ifdef USE_MULTI_SOLVER_INSTANCE
150 /*!
151 * \brief Creates a new linear solver instance
152 * \returns A new linear solver instance
153 * \todo Maybe returning a nullptr is not such a smart thing ?
154 */
155 virtual ILinearSolver* create() const { return NULL; }
156#endif /* USE_MULTI_SOLVER_INSTANCE */
157
158};
159
161{
162 public:
163
164 //! Constructor
166
167 //! Free resources
169
170 virtual void setDiagScaling(const IMatrix& matrix) = 0 ;
171
172} ;
173/*---------------------------------------------------------------------------*/
174/*---------------------------------------------------------------------------*/
175
176} // namespace Alien
177
178/*---------------------------------------------------------------------------*/
179/*---------------------------------------------------------------------------*/
Interface for linear algebra.
virtual ~ILinearSolverWithDiagScaling()
Free resources.
virtual void updateParallelMng(Arccore::MessagePassing::IMessagePassingMng *pm)=0
update parallel_mng, required for redistribution
SolverStatus Status
Type of the solver status.
virtual void init()=0
Initialization.
virtual ~ILinearSolver()
Free resources.
ILinearSolver()
Constructor.
virtual void end()=0
Finalization.
virtual bool solve(const IMatrix &A, const IVector &b, IVector &x)=0
Solves a linear system.
virtual std::shared_ptr< ILinearAlgebra > algebra() const =0
Get a compatible linear algebra, i.e. a linear algebra matching the solver kernel.
virtual bool hasParallelSupport() const =0
Whether or not the solver support parallel solve.
virtual void setNullSpaceConstantOption(bool flag)=0
Option to add an extra-equation.
virtual const SolverStatus & getStatus() const =0
Get resolution information.
Interface for all matrices.
Definition IMatrix.h:51
Interface for all vectors.
Definition IVector.h:51
Implementation of an algebraic space.
Definition Space.h:47
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17
Structure to store a solver status.
Arccore::Integer iteration_count
The number of iterations.
Arccore::Real residual
The residual.
bool succeeded
Whether or not the solver succeeded.
SolverStatus()
Constructor.
Arccore::Integer error
The error.