G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsTrilinosSolvers.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <gsTrilinos/Vector.h>
17#include <gsIO/gsOptionList.h>
18
19
20
21namespace gismo
22{
23
24namespace trilinos
25{
26
32namespace solver
33{
34
36class AmesosSolver;
37class AztecSolver;
38class BelosSolver;
39class MLSolver;
40
43{
44 enum {
45 Lapack = 1,
46 KLU = 2,
47 Umfpack = 3,
48 Pardiso = 4,
49 Taucs = 5,
50 SuperLU = 6,
52 Mumps = 8,
53 Dscpack = 9
54 };
55};
56
57//constants for solver types - from az_aztec_defs.h
58#define AZ_cg 0 /* preconditioned conjugate gradient method */
59#define AZ_gmres 1 /* preconditioned gmres method */
60#define AZ_cgs 2 /* preconditioned cg squared method */
61#define AZ_tfqmr 3 /* preconditioned transpose-free qmr method */
62#define AZ_bicgstab 4 /* preconditioned stabilized bi-cg method */
63#define AZ_slu 5 /* super LU direct method. */
64#define AZ_symmlq 6 /* indefinite symmetric like symmlq */
65#define AZ_GMRESR 7 /* recursive GMRES (not supported) */
66#define AZ_fixed_pt 8 /* fixed point iteration */
67#define AZ_analyze 9 /* fixed point iteration */
68#define AZ_lu 10 /* sparse LU direct method. Also used for a */
69#define AZ_cg_condnum 11
70#define AZ_gmres_condnum 12
71
72//constants for preconditioners - from az_aztec_defs.h
73#define AZ_none 0 /* no preconditioning. Note: also used for */
74/* scaling, output, overlap options options */
75#define AZ_Jacobi 1 /* Jacobi preconditioning. Note: also used for */
76/* scaling options */
77#define AZ_sym_GS 2 /* symmetric Gauss-Siedel preconditioning */
78#define AZ_Neumann 3 /* Neumann series polynomial preconditioning */
79#define AZ_ls 4 /* least-squares polynomial preconditioning */
80#define AZ_ilu 6 /* domain decomp with ilu in subdomains */
81#define AZ_bilu 7 /* domain decomp with block ilu in subdomains */
82/* #define AZ_lu 10 domain decomp with lu in subdomains */
83#define AZ_icc 8 /* domain decomp with incomp Choleski in domains*/
84#define AZ_ilut 9 /* domain decomp with ilut in subdomains */
85#define AZ_rilu 11 /* domain decomp with rilu in subdomains */
86#define AZ_recursive 12 /* Recursive call to AZ_iterate() */
87#define AZ_smoother 13 /* Recursive call to AZ_iterate() */
88#define AZ_dom_decomp 14 /* Domain decomposition using subdomain solver */
89/* given by options[AZ_subdomain_solve] */
90#define AZ_multilevel 15 /* Do multiplicative domain decomp with coarse */
91/* grid (not supported). */
92#define AZ_user_precond 16 /* user's preconditioning */
93/* Begin Aztec 2.1 mheroux mod */
94#define AZ_bilu_ifp 17 /* dom decomp with bilu using ifpack in subdom */
95/* End Aztec 2.1 mheroux mod */
96
99{
100 enum {
101 CG = AZ_cg,
102 CGCondNum = AZ_cg_condnum,
103 Gmres = AZ_gmres,
104 GmresCondNum = AZ_gmres_condnum,
105 GmresR = AZ_GMRESR,
106 CGS = AZ_cgs,
107 TFQMR = AZ_tfqmr,
108 BiCGStab = AZ_bicgstab,
109 LU = AZ_lu,
110 SLU = AZ_slu,
111 SymmLQ = AZ_symmlq,
112 FixedPoint = AZ_fixed_pt,
113 Analyze = AZ_analyze
114 };
115};
116
119{
120 enum {
121 None = AZ_none,
122 Jacobi = AZ_Jacobi,
123 Neumann = AZ_Neumann,
124 LS = AZ_ls,
125 GS = AZ_sym_GS,
126 DD = AZ_dom_decomp,
127 ILU = AZ_ilu,
128 BILU = AZ_bilu,
129 ICC = AZ_icc,
130 ILUT = AZ_ilut,
131 RILU = AZ_rilu,
132 Recursive = AZ_recursive,
133 Smoother = AZ_smoother,
134 Multilevel = AZ_multilevel,
135 UserDefined = AZ_user_precond,
136 IfpackBILU = AZ_bilu_ifp
137 };
138};
139
142{
143 enum {
144 LU = AZ_lu,
145 ILUT = AZ_ilut,
146 ILU = AZ_ilu,
147 RILU = AZ_rilu,
148 BILU = AZ_bilu,
149 ICC = AZ_icc
150 };
151};
152
153#undef AZ_cg
154#undef AZ_gmres
155#undef AZ_cgs
156#undef AZ_tfqmr
157#undef AZ_bicgstab
158#undef AZ_slu
159#undef AZ_symmlq
160#undef AZ_GMRESR
161#undef AZ_fixed_pt
162#undef AZ_analyze
163#undef AZ_lu
164#undef AZ_cg_condnum
165#undef AZ_gmres_condnum
166//
167#undef AZ_none
168#undef AZ_Jacobi
169#undef AZ_sym_GS
170#undef AZ_Neumann
171#undef AZ_ls
172#undef AZ_ilu
173#undef AZ_bilu
174#undef AZ_icc
175#undef AZ_ilut
176#undef AZ_rilu
177#undef AZ_recursive
178#undef AZ_smoother
179#undef AZ_dom_decomp
180#undef AZ_multilevel
181#undef AZ_user_precond
182#undef AZ_bilu_ifp
183
184
187{
188 enum {
191#ifdef Belos_ENABLE_Experimental
192 BlockGCRODR = 3,
193#endif
196 GCRODR = 6,
198 LSQR = 8,
199 Minres = 9,
200 PCPG = 10,
205 RCG = 15,
206 TFQMR = 16
207 };
208};
209
210struct MLSolvers
211{
212 enum {
213 SA = 1,
214 NSSA = 2,
215 DD = 3,
217 DDLU = 4,
218 DDML = 5,
220 DDMLLU = 6
223 };
224};
225
226struct AbstractSolverPrivate;
227
233class GISMO_EXPORT AbstractSolver
234{
235 public:
236
239 explicit AbstractSolver(const SparseMatrix & A);
240
243
245 const Vector & solve(const Vector & b);
246
248 void getSolution(gsVector<real_t> & sol, const int rank = 0) const;
249
251 virtual std::string validParams() const = 0;
252
254 virtual std::string currentParams() const = 0;
255
257 virtual std::string status() const = 0;
258
260 virtual std::string timing() const = 0;
261
263 virtual void set(const std::string & name, const int & value) = 0;
264 virtual void set(const std::string & name, const bool & value) = 0;
265 virtual void set(const std::string & name, const double & value) = 0;
266 virtual void set(const std::string & name, const std::string & value) = 0;
267
269 void setOptions(const gsOptionList & opt);
270
273
274 protected:
276 virtual void solveProblem() = 0;
277
278 protected:
279 AbstractSolverPrivate * my;
280};
281
287class GISMO_EXPORT AbstractDirectSolver : public AbstractSolver
288{
289 public:
290
292 explicit AbstractDirectSolver(const SparseMatrix & A)
293 : AbstractSolver(A) { }
294
295};
296
302class GISMO_EXPORT AbstractIterativeSolver : public AbstractSolver
303{
304 public:
305
308 explicit AbstractIterativeSolver(const SparseMatrix & A);
309
310 protected:
311
313 virtual int numIterations() const = 0;
314
315protected:
316
318 double tolerance;
319
322};
323
324/* --- Amesos solver --- */
325
326struct AmesosSolverPrivate;
327
332class GISMO_EXPORT AmesosSolver : public AbstractDirectSolver
333{
334 public:
336
337 public:
338
340 explicit AmesosSolver(const SparseMatrix & A,
341 const int solver = AmesosSolvers::KLU);
342
345
347 std::string validParams() const;
348 std::string currentParams() const;
349
351 std::string status() const;
352 std::string timing() const;
353
355 void set(const std::string & name, const int & value);
356 void set(const std::string & name, const bool & value);
357 void set(const std::string & name, const double & value);
358 void set(const std::string & name, const std::string & value);
359
360 private:
361
363 void solveProblem();
364 void solveProblem(const bool noSymbolicFactorization,
365 const bool noNumericFactorization);
366
367private:
368
369 AmesosSolverPrivate * myAmesos;
370};
371
372/* --- Aztec solver --- */
373
374struct AztecSolverPrivate;
375
380class GISMO_EXPORT AztecSolver : public AbstractIterativeSolver
381{
382 public:
384
385 public:
386
388 explicit AztecSolver(const SparseMatrix & A,
389 const int solver = AztecSolvers::Gmres,
390 const int precond = AztecPreconds::None,
391 const int subdomain_solver = AztecSubdomainSolvers::ILUT);
392
394 ~AztecSolver();
395
397 void setPreconditioner(const BelosSolver & Belos);
398
400 void setPreconditioner(const MLSolver & ML);
401
403 std::string validParams() const;
404 std::string currentParams() const;
405
407 std::string status() const;
408 std::string timing() const;
409
411 void set(const std::string & name, const int & value);
412 void set(const std::string & name, const bool & value);
413 void set(const std::string & name, const double & value);
414 void set(const std::string & name, const std::string & value);
415
417 void set(const int & option, const int & value);
418 void set(const int & param, const double & value);
419
421 int numIterations() const;
422
423 private:
424
426 void solveProblem();
427
428 private:
429
430 AztecSolverPrivate * myAztec;
431};
432
433/* --- Belos solver --- */
434
435struct BelosSolverPrivate;
436
441class GISMO_EXPORT BelosSolver : public AbstractIterativeSolver
442{
443 public:
445
447 explicit BelosSolver(const SparseMatrix & A,
448 const int solver = BelosSolvers::BiCGStab);
449
451 ~BelosSolver();
452
454 std::string validParams() const;
455 std::string currentParams() const;
456
458 std::string status() const;
459 std::string timing() const;
460
462 void set(const std::string & name, const int & value);
463 void set(const std::string & name, const bool & value);
464 void set(const std::string & name, const double & value);
465 void set(const std::string & name, const std::string & value);
466
469 void setHermitian();
470
472 int setPreconditioner(const std::string & precType, const SparseMatrix &A,
473 const bool & leftprec, const int & OverlapLevel=0);
474
475 // void setMLPreconditioner(const SparseMatrix &A);
476
478 int numIterations() const;
479
480 private:
481
483 void solveProblem();
484
485 private:
486
487 BelosSolverPrivate * myBelos;
488
489public:
490
492 Epetra_Operator * getPrecOperator() const;
493};
494
495/* --- Multi Level (ML) --- */
496
497struct MLSolverPrivate;
498
503class GISMO_EXPORT MLSolver : public AbstractIterativeSolver
504{
505
506 public:
508
509 public:
510
512 explicit MLSolver(const SparseMatrix &A,
513 const int solver = MLSolvers::SA);
514
516 ~MLSolver();
517
519 std::string validParams() const;
520 std::string currentParams() const;
521
523 std::string status() const;
524 std::string timing() const;
525
527 void set(const std::string & name, const int & value);
528 void set(const std::string & name, const bool & value);
529 void set(const std::string & name, const double & value);
530 void set(const std::string & name, const std::string & value);
531
533 void set(const int & option, const int & value);
534
536 int numIterations() const;
537
538 private:
539
541 void solveProblem();
542
543 private:
544
545 MLSolverPrivate * myML;
546
547 public:
548
550 Epetra_Operator * getPrecOperator() const;
551};
552
553}// namespace solver
554}// namespace trilinos
555}// namespace gismo
Wrapper for Trilinos/Epetra vector.
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
Abstract direct solver base class.
Definition gsTrilinosSolvers.h:288
Abstract iterative solver base class.
Definition gsTrilinosSolvers.h:303
virtual int numIterations() const =0
Returns number of iterations.
int maxIter
Default maximum number of iterations for all iterative solvers.
Definition gsTrilinosSolvers.h:321
double tolerance
Default tolerance for all iterative solvers.
Definition gsTrilinosSolvers.h:318
Abstract solver base class.
Definition gsTrilinosSolvers.h:234
virtual std::string timing() const =0
Returns timing of the solver.
virtual std::string currentParams() const =0
Returns information about current parameters.
virtual void set(const std::string &name, const int &value)=0
Sets parameters.
virtual std::string status() const =0
Returns status of the solver.
virtual void solveProblem()=0
Solves problem.
virtual std::string validParams() const =0
Returns information about valid parameters.
Amesos solver class.
Definition gsTrilinosSolvers.h:333
Actez solver class.
Definition gsTrilinosSolvers.h:381
Belos solver class.
Definition gsTrilinosSolvers.h:442
ML solver class.
Definition gsTrilinosSolvers.h:504
Provides a list of labeled parameters/options that can be set and accessed easily.
The G+Smo namespace, containing all definitions for the library.
Amesos sparse direct solvers.
Definition gsTrilinosSolvers.h:43
@ SuperLU
SuperLU (serial)
Definition gsTrilinosSolvers.h:50
@ Lapack
Lapack (serial)
Definition gsTrilinosSolvers.h:45
@ Pardiso
Pardiso (serial/OpenMP)
Definition gsTrilinosSolvers.h:48
@ Taucs
Taucs (serial)
Definition gsTrilinosSolvers.h:49
@ Umfpack
Umfpack (serial)
Definition gsTrilinosSolvers.h:47
@ Mumps
Mumps (parallel)
Definition gsTrilinosSolvers.h:52
@ KLU
KLU (serial)
Definition gsTrilinosSolvers.h:46
@ SuperLUDist
SuperLU (parallel)
Definition gsTrilinosSolvers.h:51
@ Dscpack
Dscpack (parallel)
Definition gsTrilinosSolvers.h:53
Aztec preconditioners.
Definition gsTrilinosSolvers.h:119
@ LS
Least-squares polynomial.
Definition gsTrilinosSolvers.h:124
@ ILU
DD with ILU in subdomains.
Definition gsTrilinosSolvers.h:127
@ ILUT
DD with ILUT in subdomains.
Definition gsTrilinosSolvers.h:130
@ Neumann
Neumann series polynomial.
Definition gsTrilinosSolvers.h:123
@ RILU
DD with RILU in subdomains.
Definition gsTrilinosSolvers.h:131
@ Smoother
Recursive call to iteration.
Definition gsTrilinosSolvers.h:133
@ IfpackBILU
DD with BILU (Ifpack version)
Definition gsTrilinosSolvers.h:136
@ GS
Symmetric Gauss-Seidel.
Definition gsTrilinosSolvers.h:125
@ BILU
DD with block-ILU in subdomains.
Definition gsTrilinosSolvers.h:128
@ Multilevel
DD with coarse grid.
Definition gsTrilinosSolvers.h:134
@ None
No preconditioning.
Definition gsTrilinosSolvers.h:121
@ Jacobi
Jacobi.
Definition gsTrilinosSolvers.h:122
@ Recursive
Recursive call to iteration.
Definition gsTrilinosSolvers.h:132
@ ICC
DD with incomplete Choleski in subdomains.
Definition gsTrilinosSolvers.h:129
@ DD
Non-overlapping domain decomposition.
Definition gsTrilinosSolvers.h:126
@ UserDefined
User defined preconditioner.
Definition gsTrilinosSolvers.h:135
Aztec solvers.
Definition gsTrilinosSolvers.h:99
@ SymmLQ
Indefinite symmetric like SymmLQ.
Definition gsTrilinosSolvers.h:111
@ LU
Sparse direct LU solver.
Definition gsTrilinosSolvers.h:109
@ CGCondNum
CG solver with cond. num. estimation.
Definition gsTrilinosSolvers.h:102
@ Gmres
GMRES solver.
Definition gsTrilinosSolvers.h:103
@ CGS
CG squared solver.
Definition gsTrilinosSolvers.h:106
@ Analyze
Fixed-point iteration.
Definition gsTrilinosSolvers.h:113
@ GmresR
recursive GMRES
Definition gsTrilinosSolvers.h:105
@ GmresCondNum
GMRES solver with cond.num. estimation.
Definition gsTrilinosSolvers.h:104
@ SLU
Super LU direct solver.
Definition gsTrilinosSolvers.h:110
@ TFQMR
TFQMR solver.
Definition gsTrilinosSolvers.h:107
@ CG
CG solver.
Definition gsTrilinosSolvers.h:101
@ FixedPoint
Fixed-point iteration.
Definition gsTrilinosSolvers.h:112
@ BiCGStab
BiCGStab solver.
Definition gsTrilinosSolvers.h:108
Aztec subdomain solver.
Definition gsTrilinosSolvers.h:142
@ LU
Sparse LU decomposition.
Definition gsTrilinosSolvers.h:144
@ ILU
Sparse ILU(k) decomposition.
Definition gsTrilinosSolvers.h:146
@ ILUT
Sparse ILUT decomposition (Saad)
Definition gsTrilinosSolvers.h:145
@ RILU
Sparse ILU(k,w) decomposition.
Definition gsTrilinosSolvers.h:147
@ BILU
Sparse block ILU(k) decomposition.
Definition gsTrilinosSolvers.h:148
@ ICC
Sparse ICC(k) decomposition.
Definition gsTrilinosSolvers.h:149
Belos solvers.
Definition gsTrilinosSolvers.h:187
@ PCPG
PCPG solver.
Definition gsTrilinosSolvers.h:200
@ GCRODR
Recycling GMRES solver.
Definition gsTrilinosSolvers.h:196
@ PseudoBlockCG
Pseudo Block CG solver.
Definition gsTrilinosSolvers.h:201
@ GmresPoly
Hybrid block GMRES solver.
Definition gsTrilinosSolvers.h:197
@ Minres
Minres solver.
Definition gsTrilinosSolvers.h:199
@ PseudoBlockStochasticCG
Pseudo Block CG solver.
Definition gsTrilinosSolvers.h:203
@ BlockGmres
Block GMRES solver.
Definition gsTrilinosSolvers.h:194
@ TFQMR
TFQMR solver.
Definition gsTrilinosSolvers.h:206
@ RCG
RCG solver.
Definition gsTrilinosSolvers.h:205
@ LSQR
LSQR solver.
Definition gsTrilinosSolvers.h:198
@ FixedPoint
Fixed-point solver.
Definition gsTrilinosSolvers.h:195
@ BlockCG
Block GC solver.
Definition gsTrilinosSolvers.h:190
@ PseudoBlockTFQMR
Pseudo Block TFQMR solver.
Definition gsTrilinosSolvers.h:204
@ PseudoBlockGmres
Pseudo Block GMRES solver.
Definition gsTrilinosSolvers.h:202
@ BiCGStab
BiCGStab solver.
Definition gsTrilinosSolvers.h:189