Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
IEigenSolver.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 IFPEN-CEA
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
19/*!
20 * \file IEigenSolver.h
21 * \brief IEigenSolver.h
22 */
23
24#pragma once
25
26#include <alien/utils/Precomp.h>
27#include <vector>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Alien
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38class IMatrix;
39
40class IVector;
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
45/*!
46 * \ingroup solver
47 * \brief Defines an eigen problem
48 */
50{
51 public:
52 /*!
53 * \brief Constructor
54 * \param[in] A The matrix
55 */
57 : m_A(A)
58 {}
59
60 //! Free resources
61 virtual ~EigenProblem() {}
62
63 /*!
64 * \brief Get the matrix
65 * \returns The matrix
66 */
67 IMatrix const& getA() const { return m_A; }
68
69 /*!
70 * \brief Get real eigen values
71 * \returns The real eigen values
72 */
73 std::vector<Arccore::Real> const& getRealEigenValues() const
74 {
76 }
77
78 /*!
79 * \brief Get real eigen values
80 * \returns The real eigen values
81 */
82 std::vector<Arccore::Real>& getRealEigenValues() { return m_real_eigen_values; }
83
84 /*!
85 * \brief Get imaginary eigen values
86 * \returns The imaginary eigen values
87 */
88 std::vector<Arccore::Real> const& getImaginaryEigenValues() const
89 {
91 }
92
93 /*!
94 * \brief Get imaginary eigen values
95 * \returns The imaginary eigen values
96 */
97 std::vector<Arccore::Real>& getImaginaryEigenValues()
98 {
100 }
101
102 /*!
103 * \brief Get the number of eigen vectors
104 * \returns The number of eigen vectors
105 */
106 virtual Arccore::Integer getNbEigenVectors() const = 0;
107
108 protected:
109 //! The eigen matrix
110 IMatrix const& m_A;
111 //! The real eigen values
112 std::vector<Arccore::Real> m_real_eigen_values;
113 //! The imaginary eigen values
114 std::vector<Arccore::Real> m_imaginary_eigen_values;
115};
116
117/*---------------------------------------------------------------------------*/
118/*---------------------------------------------------------------------------*/
119
120/*!
121 * \ingroup solver
122 * \brief Defines a generalized eigen problem
123 */
125{
126 public:
127 /*!
128 * \brief Constructor
129 * \param[in] A The first matrix
130 * \param[in] B The second matrix
131 */
133 : EigenProblem(A)
134 , m_B(B)
135 {}
136
137 //! Free resources
139
140 /*!
141 * \brief Get the second matrix
142 * \returns The second matrix
143 */
144 IMatrix const& getB() const { return m_B; }
145
146 protected:
147 //! The second matrix
148 IMatrix const& m_B;
149};
150
151/*---------------------------------------------------------------------------*/
152/*---------------------------------------------------------------------------*/
153
154/*!
155 * \ingroup expression
156 * \brief Eigen solver interface
157 */
159{
160 public:
161 //! Eigen solver status
162 struct Status
163 {
164 bool m_succeeded = false;
165 Integer m_nconv = 0;
166 Real m_residual = -1.;
167 Integer m_iteration_count = 0;
168 Integer m_error = 0;
169 };
170
171 //! Eigen values order
172 typedef enum
173 {
174 SmallestMagnitude,
175 LargestMagnitude,
176 SmallestReal,
177 LargestReal,
178 SmallestImaginary,
179 LargestImaginary
181
182 public:
183 //! Constructor
185
186 //! Free resources
187 virtual ~IEigenSolver(){};
188
189 public:
190 /*!
191 * \brief Get back end name
192 * \returns The back end name
193 */
194 virtual Arccore::String getBackEndName() const = 0;
195
196 //! Initialization
197 virtual void init() = 0;
198
199 /*!
200 * \brief Solves an eigen problem
201 * \param[in] problem The eigen problem
202 * \returns Whether or not the solver succeeded
203 */
204 virtual bool solve(EigenProblem& problem) = 0;
205
206 /*
207 * \brief Whether or not the solver is parallel
208 * \returns Parallel support of the solver
209 */
210 virtual bool hasParallelSupport() const = 0;
211
212 /*!
213 * \brief Get solves status
214 * \returns Solver status
215 */
216 virtual const Status& getStatus() const = 0;
217};
218
219/*---------------------------------------------------------------------------*/
220/*---------------------------------------------------------------------------*/
221
222/*!
223 * \ingroup expression
224 * \brief Interface for generalized eigen solver
225 */
227{
228 public:
229 //! Constructor
233
234 //! Free resources
236
237 public:
238 /*!
239 * \brief Solve an eigen problem
240 * \param[in] problem The eigen problem
241 * \returns Whether or not the problem was solved
242 */
243 virtual bool solve(EigenProblem& problem) = 0;
244
245 /*!
246 * \brief Solve a generalized eigen problem
247 * \param[in] problem The generalized eigen problem
248 * \returns Whether or not the problem was solved
249 */
250 virtual bool solve(GeneralizedEigenProblem& problem) = 0;
251};
252
253/*---------------------------------------------------------------------------*/
254/*---------------------------------------------------------------------------*/
255
256} // namespace Alien
257
258/*---------------------------------------------------------------------------*/
259/*---------------------------------------------------------------------------*/
Defines an eigen problem.
virtual Arccore::Integer getNbEigenVectors() const =0
Get the number of eigen vectors.
std::vector< Arccore::Real > & getRealEigenValues()
Get real eigen values.
IMatrix const & m_A
The eigen matrix.
std::vector< Arccore::Real > const & getImaginaryEigenValues() const
Get imaginary eigen values.
IMatrix const & getA() const
Get the matrix.
virtual ~EigenProblem()
Free resources.
std::vector< Arccore::Real > m_imaginary_eigen_values
The imaginary eigen values.
std::vector< Arccore::Real > m_real_eigen_values
The real eigen values.
std::vector< Arccore::Real > & getImaginaryEigenValues()
Get imaginary eigen values.
std::vector< Arccore::Real > const & getRealEigenValues() const
Get real eigen values.
EigenProblem(IMatrix const &A)
Constructor.
Defines a generalized eigen problem.
IMatrix const & getB() const
Get the second matrix.
IMatrix const & m_B
The second matrix.
GeneralizedEigenProblem(IMatrix const &A, IMatrix const &B)
Constructor.
virtual ~GeneralizedEigenProblem()
Free resources.
virtual Arccore::String getBackEndName() const =0
Get back end name.
virtual void init()=0
Initialization.
IEigenSolver()
Constructor.
eEigenValuesOrder
Eigen values order.
virtual bool solve(EigenProblem &problem)=0
Solves an eigen problem.
virtual ~IEigenSolver()
Free resources.
virtual const Status & getStatus() const =0
Get solves status.
virtual bool solve(EigenProblem &problem)=0
Solve an eigen problem.
virtual bool solve(GeneralizedEigenProblem &problem)=0
Solve a generalized eigen problem.
virtual ~IGeneralizedEigenSolver()
Free resources.
Interface for all matrices.
Definition IMatrix.h:51
Interface for all vectors.
Definition IVector.h:51
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17
Eigen solver status.