|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | -# PolySolve |
6 | | - |
7 | | -This library contains a cross-platform Eigen wrapper for many different external linear solvers including (but not limited to): |
8 | | - |
9 | | - - CHOLMOD |
10 | | - - Hypre |
11 | | - - AMGCL |
12 | | - - Pardiso |
13 | | - |
14 | | - |
15 | | -## Example Usage |
16 | | - |
17 | | -```c++ |
18 | | -const std::string solver_name = "Hypre" |
19 | | -auto solver = LinearSolver::create(solver_name, ""); |
20 | | - |
21 | | -// Configuration parameters like iteration or accuracy for iterative solvers |
22 | | -// solver->setParameters(params); |
23 | | - |
24 | | -// System sparse matrix |
25 | | -Eigen::SparseMatrix<double> A; |
26 | | - |
27 | | -// Right-hand side |
28 | | -Eigen::VectorXd b; |
29 | | - |
30 | | -// Solution |
31 | | -Eigen::VectorXd x(b.size()); |
32 | | - |
33 | | -solver->analyzePattern(A, A.rows()); |
34 | | -solver->factorize(A); |
35 | | -solver->solve(b, x); |
36 | | -``` |
37 | | -
|
38 | | -You can use `LinearSolver::availableSolvers()` to obtain the list of available solvers. |
39 | | -
|
40 | | -## Parameters |
41 | | -
|
42 | | -Polysolve uses a json file to provide parameters to the individual solvers. The following template can be used as a starting points, and a more detailed explanation of the parameters is below. |
43 | | -
|
44 | | -```json |
45 | | -{ |
46 | | - "Eigen::LeastSquaresConjugateGradient": { |
47 | | - "max_iter": 1000, |
48 | | - "tolerance": 1e-6 |
49 | | - }, |
50 | | - "Eigen::DGMRES": { |
51 | | - "max_iter": 1000, |
52 | | - "tolerance": 1e-6 |
53 | | - }, |
54 | | - "Eigen::ConjugateGradient": { |
55 | | - "max_iter": 1000, |
56 | | - "tolerance": 1e-6 |
57 | | - }, |
58 | | - "Eigen::BiCGSTAB": { |
59 | | - "max_iter": 1000, |
60 | | - "tolerance": 1e-6 |
61 | | - }, |
62 | | - "Eigen::GMRES": { |
63 | | - "max_iter": 1000, |
64 | | - "tolerance": 1e-6 |
65 | | - }, |
66 | | - "Eigen::MINRES": { |
67 | | - "max_iter": 1000, |
68 | | - "tolerance": 1e-6 |
69 | | - }, |
70 | | - "Pardiso": { |
71 | | - "mtype": -1 |
72 | | - }, |
73 | | - "Hypre": { |
74 | | - "max_iter": 1000, |
75 | | - "pre_max_iter": 1000, |
76 | | - "tolerance": 1e-6 |
77 | | - }, |
78 | | - "AMGCL": { |
79 | | - "precond": { |
80 | | - "relax": { |
81 | | - "degree": 16, |
82 | | - "type": "chebyshev", |
83 | | - "power_iters": 100, |
84 | | - "higher": 2, |
85 | | - "lower": 0.008333333333, |
86 | | - "scale": true |
87 | | - }, |
88 | | - "class": "amg", |
89 | | - "max_levels": 6, |
90 | | - "direct_coarse": false, |
91 | | - "ncycle": 2, |
92 | | - "coarsening": { |
93 | | - "type": "smoothed_aggregation", |
94 | | - "estimate_spectral_radius": true, |
95 | | - "relax": 1, |
96 | | - "aggr": { |
97 | | - "eps_strong": 0 |
98 | | - } |
99 | | - } |
100 | | - }, |
101 | | - "solver": { |
102 | | - "tol": 1e-10, |
103 | | - "maxiter": 1000, |
104 | | - "type": "cg" |
105 | | - } |
106 | | - } |
107 | | -} |
108 | | -``` |
109 | | - |
110 | | -### Iterative solvers (AMGCL, Eigen Internal Solvers, HYPRE) |
111 | | - |
112 | | - - `max_iter` controls the solver's iterations, default `1000` |
113 | | - - `conv_tol`, `tolerance` controls the convergence tolerance, default `1e-10` |
114 | | - |
115 | | -#### Hypre Only |
116 | | - |
117 | | -- `pre_max_iter`, number of pre iterations, default `1` |
118 | | - |
119 | | -#### AMGCL Only |
120 | | - |
121 | | -The default parameters of the AMGCL solver are: |
122 | | -```json |
123 | | -{ |
124 | | - "precond": { |
125 | | - "relax": { |
126 | | - "degree": 16, |
127 | | - "type": "chebyshev", |
128 | | - "power_iters": 100, |
129 | | - "higher": 2, |
130 | | - "lower": 0.008333333333, |
131 | | - "scale": true |
132 | | - }, |
133 | | - "class": "amg", |
134 | | - "max_levels": 6, |
135 | | - "direct_coarse": false, |
136 | | - "ncycle": 2, |
137 | | - "coarsening": { |
138 | | - "type": "smoothed_aggregation", |
139 | | - "estimate_spectral_radius": true, |
140 | | - "relax": 1, |
141 | | - "aggr": { |
142 | | - "eps_strong": 0 |
143 | | - } |
144 | | - } |
145 | | - }, |
146 | | - "solver": { |
147 | | - "tol": 1e-10, |
148 | | - "maxiter": 1000, |
149 | | - "type": "cg" |
150 | | - } |
151 | | -} |
152 | | -``` |
153 | | - |
154 | | -For a more details and options refer to the [AMGCL documentation](https://amgcl.readthedocs.io/en/latest/components.html). |
155 | | - |
156 | | -### Pardiso |
157 | | - |
158 | | -`mtype`, sets the matrix type, default 11 |
159 | | - |
160 | | -| mtype | Description | |
161 | | -| ----- | --------------------------------------- | |
162 | | -| 1 | real and structurally symmetric | |
163 | | -| 2 | real and symmetric positive definite | |
164 | | -| -2 | real and symmetric indefinite | |
165 | | -| 3 | complex and structurally symmetric | |
166 | | -| 4 | complex and Hermitian positive definite | |
167 | | -| -4 | complex and Hermitian indefinite | |
168 | | -| 6 | complex and symmetric | |
169 | | -| 11 | real and nonsymmetric | |
170 | | -| 13 | complex and nonsymmetric | |
0 commit comments