AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
SolverCreator.hpp
1 #pragma once
2 
3 #include <vector>
4 
5 #include <petscksp.h>
6 
7 #include <amdis/CreatorMap.hpp>
8 #include <amdis/linearalgebra/LinearSolver.hpp>
9 #include <amdis/linearalgebra/petsc/PetscRunner.hpp>
10 
11 namespace AMDiS
12 {
14  template <class Mat, class Vec>
15  class DefaultCreators< LinearSolverInterface<Mat,Vec> >
16  {
17  using Solver = typename LinearSolver<Mat, Vec, PetscRunner<Mat,Vec>>::Creator;
18  using Map = CreatorMap<LinearSolverInterface<Mat,Vec>>;
19 
20  public:
21  static void init()
22  {
23  // see https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPType.html
24  static const std::vector<std::string> kspTypes_ = {
25  KSPCG, KSPFCG, KSPGMRES, KSPFGMRES, KSPPREONLY, KSPMINRES, KSPCGS, KSPBCGS, KSPCGNE
26 #ifdef KSPCHEBYSHEV
27  , KSPCHEBYSHEV
28 #endif
29 #ifdef KSPGROPPCG
30  , KSPGROPPCG
31 #endif
32 #ifdef KSPPIPECG
33  , KSPPIPECG
34 #endif
35 #ifdef KSPPIPECGRR
36  , KSPPIPECGRR
37 #endif
38 #ifdef KSPPIPELCG
39  , KSPPIPELCG
40 #endif
41 #ifdef KSPCGNASH
42  , KSPCGNASH
43 #endif
44 #ifdef KSPCGSTCG
45  , KSPCGSTCG
46 #endif
47 #ifdef KSPCGGLTR
48  , KSPCGGLTR
49 #endif
50 #ifdef KSPPIPEFCG
51  , KSPPIPEFCG
52 #endif
53 #ifdef KSPPIPEFGMRES
54  , KSPPIPEFGMRES
55 #endif
56 #ifdef KSPLGMRES
57  , KSPLGMRES
58 #endif
59 #ifdef KSPDGMRES
60  , KSPDGMRES
61 #endif
62 #ifdef KSPPGMRES
63  , KSPPGMRES
64 #endif
65 #ifdef KSPTCQMR
66  , KSPTCQMR
67 #endif
68 #ifdef KSPIBCGS
69  , KSPIBCGS
70 #endif
71 #ifdef KSPFBCGS
72  , KSPFBCGS
73 #endif
74 #ifdef KSPFBCGSR
75  , KSPFBCGSR
76 #endif
77 #ifdef KSPBCGSL
78  , KSPBCGSL
79 #endif
80 #ifdef KSPPIPEBCGS
81  , KSPPIPEBCGS
82 #endif
83 #ifdef KSPTFQMR
84  , KSPTFQMR
85 #endif
86 #ifdef KSPCR
87  , KSPCR
88 #endif
89 #ifdef KSPPIPECR
90  , KSPPIPECR
91 #endif
92 #ifdef KSPLSQR
93  , KSPLSQR
94 #endif
95 #ifdef KSPQCG
96  , KSPQCG
97 #endif
98 #ifdef KSPBICG
99  , KSPBICG
100 #endif
101 #ifdef KSPSYMMLQ
102  , KSPSYMMLQ
103 #endif
104 #ifdef KSPLCD
105  , KSPLCD
106 #endif
107 #ifdef KSPPYTHON
108  , KSPPYTHON
109 #endif
110 #ifdef KSPGCR
111  , KSPGCR
112 #endif
113 #ifdef KSPPIPEGCR
114  , KSPPIPEGCR
115 #endif
116 #ifdef KSPTSIRM
117  , KSPTSIRM
118 #endif
119 #ifdef KSPCGLS
120  , KSPCGLS
121 #endif
122 #ifdef KSPFETIDP
123  , KSPFETIDP
124 #endif
125 #ifdef KSPRICHARDSON
126  , KSPRICHARDSON
127 #endif
128  };
129 
130  auto solver = new Solver;
131  Map::addCreator("default", solver);
132  Map::addCreator("direct", solver);
133  for (auto const& kspType : kspTypes_)
134  Map::addCreator(kspType, solver);
135  }
136  };
137 
138 } // end namespace AMDiS
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
void init(int &argc, char **&argv, std::string const &initFileName="")
Initialized the Environment for MPI.
Definition: AMDiS.hpp:29