PolyDiM
C++ library for POLYtopal DIscretization Methods
Loading...
Searching...
No Matches
Eigen_PCGSolver.hpp
Go to the documentation of this file.
1// _LICENSE_HEADER_
2//
3// Copyright (C) 2019 - 2025.
4// Terms register on the GPL-3.0 license.
5//
6// This file can be redistributed and/or modified under the license terms.
7//
8// See top level LICENSE file for more details.
9//
10// This file can be used citing references in CITATION.cff file.
11
12#ifndef __EIGENPCGSOLVER_H
13#define __EIGENPCGSOLVER_H
14
15#include "Eigen/Eigen"
16#include "ILinearSolver.hpp"
17
18namespace Gedim
19{
21template <typename Eigen_ArrayType = Eigen::VectorXd,
22 typename Eigen_SparseArrayType = Eigen::SparseMatrix<double>,
23 typename Eigen_SolverType = Eigen::ConjugateGradient<Eigen_SparseArrayType, Eigen::Lower, Eigen::DiagonalPreconditioner<double>>>
25{
26 private:
27 Eigen_SolverType linearSolver;
28 const IArray *_rightHandSide;
29 IArray *_solution;
30 Configuration _config;
31
32 public:
34 {
35 _rightHandSide = nullptr;
36 _solution = nullptr;
37 }
39 {
40 _rightHandSide = nullptr;
41 _solution = nullptr;
42 }
43
44 void Initialize(const ISparseArray &matrix, const IArray &rightHandSide, IArray &solution, const Configuration &config = {100, 1e-6});
45
46 void Initialize(const IArray &rightHandSide, IArray &solution, const Configuration &config = {100, 1e-6});
47
48 ILinearSolver::SolutionInfo Solve() const;
49
50 void Initialize(const ISparseArray &matrix, const Configuration &config = {100, 1e-6});
51 ILinearSolver::SolutionInfo Solve(const IArray &rightHandSide, IArray &solution) const;
52};
53} // namespace Gedim
54
55#endif // __EIGENPCGSOLVER_H
Eigen column vector.
Definition Eigen_Array.hpp:23
Eigen PCG Linear solver.
Definition Eigen_PCGSolver.hpp:25
~Eigen_PCGSolver()
Definition Eigen_PCGSolver.hpp:38
void Initialize(const ISparseArray &matrix, const IArray &rightHandSide, IArray &solution, const Configuration &config={100, 1e-6})
Initialize the linear solver Ax = b.
Definition Eigen_PCGSolver.cpp:28
Eigen_PCGSolver()
Definition Eigen_PCGSolver.hpp:33
ILinearSolver::SolutionInfo Solve() const
Compute the solution.
Definition Eigen_PCGSolver.cpp:50
Interface used for column double Array.
Definition IArray.hpp:23
Interface used for algebra linear solvers.
Definition ILinearSolver.hpp:22
Interface used for sparse Array of double.
Definition ISparseArray.hpp:25
Definition Eigen_Array.cpp:22
Definition ILinearSolver.hpp:25