Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
EigenSolver.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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#pragma once
8
9#include <arccore/message_passing/MessagePassingGlobal.h>
10#include <alien/utils/Precomp.h>
11
12#include <memory>
13#include <vector>
14
15#include <alien/core/backend/BackEnd.h>
17
18/*---------------------------------------------------------------------------*/
19/*---------------------------------------------------------------------------*/
20
21namespace Alien
22{
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27class IVector;
28class IMatrix;
29class IOptions;
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
44// FIXME: not implemented !
45template <class Tag, typename VectorT>
47{
48 public:
54 : EigenProblem(A)
55 {}
56
58 virtual ~EigenProblemT() {}
59
64
69 Arccore::Integer localSize() const;
70
75 KernelMatrix const& getA() const;
76
81 Arccore::Integer getNbEigenVectors() const { return m_eigen_vectors.size(); }
82
87 std::vector<VectorT>& getEigenVectors() { return m_eigen_vectors; }
88
89 // TOCHECK: Commentaire
90 /*
91 void setEigenVectors(std::vector<std::vector<Real>>& ev_vectors)
92 {
93 auto const& vdist = this->m_A.impl()->distribution().rowDistribution() ;
94 for(auto const ev : ev_vectors)
95 {
96 VectorT v(vdist) ;
97 Alien::LocalVectorWriter vv(v) ;
98 for(auto i=0;i<vdist.localSize();++i)
99 {
100 vv[i] = ev[i] ;
101 m_eigen_vectors.add(v) ;
102 }
103 }
104 }*/
105
106 private:
108 std::vector<VectorT> m_eigen_vectors;
109};
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
113
124template <class Tag, typename VectorT>
126{
127 public:
135 {}
136
139
144
149 Arccore::Integer localSize() const;
150
155 KernelMatrix const& getA() const;
156
161 KernelMatrix const& getB() const;
162
167 Arccore::Integer getNbEigenVectors() const { return m_eigen_vectors.size(); }
168
173 std::vector<VectorT>& getEigenVectors() { return m_eigen_vectors; }
174
175 private:
177 std::vector<VectorT> m_eigen_vectors;
178};
179
180/*---------------------------------------------------------------------------*/
181/*---------------------------------------------------------------------------*/
182
191template <class Tag>
193{
194 public:
197
198 public:
204 EigenSolver(Arccore::MessagePassing::IMessagePassingMng* parallel_mng = nullptr,
205 IOptions* options = nullptr);
206
208 virtual ~EigenSolver() {}
209
214 Arccore::String getBackEndName() const;
215
217 void init();
218
224 bool solve(EigenProblem& p);
225
230 bool hasParallelSupport() const;
231
236 const IEigenSolver::Status& getStatus() const;
237
243
244 private:
250 std::unique_ptr<KernelSolver> m_solver;
251};
252
253/*---------------------------------------------------------------------------*/
254/*---------------------------------------------------------------------------*/
255
264template <class Tag>
266{
267 public:
270
271 public:
278 IMessagePassingMng* parallel_mng = nullptr, IOptions* options = nullptr);
279
282
287 Arccore::String getBackEndName() const;
288
290 void init();
291
298
303 bool hasParallelSupport() const;
304
309 const IEigenSolver::Status& getStatus() const;
310
316
317 private:
323 std::unique_ptr<KernelSolver> m_solver;
324};
325
326/*---------------------------------------------------------------------------*/
327/*---------------------------------------------------------------------------*/
328
329} // namespace Alien
330
331/*---------------------------------------------------------------------------*/
332/*---------------------------------------------------------------------------*/
IEigenSolver.h.
AlgebraTraits< Tag >::vector_type KernelVector
Type of the vector used.
Definition EigenSolver.h:63
AlgebraTraits< Tag >::matrix_type KernelMatrix
Type of the matrix used.
Definition EigenSolver.h:61
EigenProblemT(IMatrix const &A)
Eigen problem constructor.
Definition EigenSolver.h:53
KernelMatrix const & getA() const
Get the eigen matrix.
std::vector< VectorT > & getEigenVectors()
Get the eigen vectors.
Definition EigenSolver.h:87
virtual ~EigenProblemT()
Free resources.
Definition EigenSolver.h:58
Arccore::Integer getNbEigenVectors() const
Get the number of eigen vectors.
Definition EigenSolver.h:81
std::vector< VectorT > m_eigen_vectors
Eigen vectors.
Arccore::Integer localSize() const
Get the local size of the problem.
Defines an eigen problem.
EigenProblem(IMatrix const &A)
Constructor.
bool hasParallelSupport() const
Indicates if the kernel is parallel.
AlgebraTraits< Tag >::eigen_solver_type KernelSolver
Type of the eigen solver used.
KernelSolver * implem()
Get kernel solver implementation.
AlgebraTraits< Tag >::vector_type KernelVector
Type of the vector used.
const IEigenSolver::Status & getStatus() const
Get solver resolution status.
Arccore::String getBackEndName() const
Get kernel back end name.
virtual ~EigenSolver()
Free resources.
void init()
Initialize the eigen solver.
std::unique_ptr< KernelSolver > m_solver
The eigen solver.
AlgebraTraits< Tag >::matrix_type KernelMatrix
Type of the matrix used.
bool solve(EigenProblem &p)
Solve the eigen problem.
EigenSolver(Arccore::MessagePassing::IMessagePassingMng *parallel_mng=nullptr, IOptions *options=nullptr)
Eigen solver constructor.
virtual ~GeneralizedEigenProblemT()
Free resources.
GeneralizedEigenProblemT(IMatrix const &A, IMatrix const &B)
Generalized eigen problem constructor.
AlgebraTraits< Tag >::matrix_type KernelMatrix
Type of the matrix used.
KernelMatrix const & getB() const
Get the second eigen matrix of the generalized eigen problem.
AlgebraTraits< Tag >::vector_type KernelVector
Type of the vector used.
Arccore::Integer getNbEigenVectors() const
Get the number of eigen vectors.
Arccore::Integer localSize() const
Get the local size of the problem.
KernelMatrix const & getA() const
Get the first eigen matrix of the generalized eigen problem.
std::vector< VectorT > m_eigen_vectors
Eigen vectors.
std::vector< VectorT > & getEigenVectors()
Get the eigen vectors.
Defines a generalized eigen problem.
GeneralizedEigenProblem(IMatrix const &A, IMatrix const &B)
Constructor.
const IEigenSolver::Status & getStatus() const
Get solver resolution status.
bool hasParallelSupport() const
Indicates if the kernel is parallel.
std::unique_ptr< KernelSolver > m_solver
The generalized eigen solver.
AlgebraTraits< Tag >::generalized_eigen_solver_type KernelSolver
Type of the eigen solver used.
bool solve(GeneralizedEigenProblem &A)
Solve the eigen problem.
AlgebraTraits< Tag >::vector_type KernelVector
Type of the vector used.
virtual ~GeneralizedEigenSolver()
Free resources.
AlgebraTraits< Tag >::matrix_type KernelMatrix
Type of the matrix used.
GeneralizedEigenSolver(IMessagePassingMng *parallel_mng=nullptr, IOptions *options=nullptr)
Eigen solver constructor.
KernelSolver * implem()
Get kernel solver implementation.
Arccore::String getBackEndName() const
Get kernel back end name.
void init()
Initialize the eigen solver.
IEigenSolver()
Constructor.
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.