AMDiS 2.11-git
The Adaptive Multi-Dimensional Simulation Toolbox
 
Loading...
Searching...
No Matches
Preconditioners.hpp
1#pragma once
2
3#include <type_traits>
4
5#include <dune/istl/preconditioners.hh>
6#include <dune/istl/novlpschwarz.hh>
7#include <dune/istl/schwarz.hh>
8
9#include <amdis/CreatorInterface.hpp>
10#include <amdis/CreatorMap.hpp>
11#include <amdis/common/TypeTraits.hpp>
12#include <amdis/linearalgebra/istl/ISTLPreconCreator.hpp>
13
14#if AMDIS_ENABLE_PAMG
15#include <amdis/linearalgebra/istl/AMGPrecon.hpp>
16#endif
17
18namespace AMDiS
19{
21
35 template <class Traits>
36 class DefaultCreators<tag::preconditioner<Traits>>
37 {
38 using M = typename Traits::M;
39 using X = typename Traits::X;
40 using Y = typename Traits::Y;
41
42 template <class Precon>
44
46 using FTraits = Dune::FieldTraits<typename M::field_type>;
47
48 public:
49 static void init()
50 {
51 auto jacobi = new Creator<Dune::SeqJac<M,X,Y>>;
52 Map::addCreator("diag", jacobi);
53 Map::addCreator("jacobi", jacobi);
54
55 auto gs = new Creator<Dune::SeqGS<M,X,Y>>;
56 Map::addCreator("gs", gs);
57 Map::addCreator("gauss_seidel", gs);
58
59 auto sor = new Creator<Dune::SeqSOR<M,X,Y>>;
60 Map::addCreator("sor", sor);
61
62 auto ssor = new Creator<Dune::SeqSSOR<M,X,Y>>;
63 Map::addCreator("ssor", ssor);
64
65 init_ilu(std::is_arithmetic<typename FTraits::field_type>{});
66
67#if AMDIS_ENABLE_PAMG
68 init_amg(std::is_same<typename FTraits::real_type, double>{});
69#endif
70
71 auto richardson = new Creator<Dune::Richardson<X,Y>>;
72 Map::addCreator("richardson", richardson);
73 Map::addCreator("default", richardson);
74
75 auto solver = new Creator<tag::solver<Traits>>;
76 Map::addCreator("solver", solver);
77
78 init_bjacobi(Types<TYPEOF(std::declval<typename Traits::Comm>().impl())>{}, Dune::PriorityTag<10>{});
79 }
80
81 static void init_ilu(std::false_type)
82 {
83 warning("ILU preconditioners not created for the matrix with field_type = {}.",
84 Dune::className<typename FTraits::field_type>());
85 }
86
87 static void init_ilu(std::true_type)
88 {
89 auto ilu = new Creator<Dune::SeqILU<M,X,Y>>;
90 Map::addCreator("ilu", ilu);
91 Map::addCreator("ilu0", ilu);
92
93 auto ildl = new Creator<Dune::SeqILDL<M,X,Y>>;
94 Map::addCreator("ildl", ildl);
95 }
96
97 static void init_amg(std::false_type)
98 {
99 warning("AMG preconditioners not created for the matrix with real_type = {}.",
100 Dune::className<typename FTraits::real_type>());
101 }
102
103#if AMDIS_ENABLE_PAMG
104 static void init_amg(std::true_type)
105 {
107 Map::addCreator("amg", amg);
109 Map::addCreator("fastamg", fastamg);
111 Map::addCreator("kamg", kamg);
112 }
113#endif
114
115 static void init_bjacobi(Types<Dune::Amg::SequentialInformation>, Dune::PriorityTag<2>) {}
116
117 template <class Comm>
118 static void init_bjacobi(Types<Comm>, Dune::PriorityTag<1>)
119 {
120 auto pssor = new Creator<Dune::ParSSOR<M,X,Y,Comm>>;
121 Map::addCreator("pssor", pssor);
122
123 auto bjacobi = new Creator<tag::bjacobi>;
124 Map::addCreator("bjacobi", bjacobi);
125 }
126 };
127
128} // end namespace AMDiS
Definition AMGPrecon.hpp:188
A CreatorMap is used to construct objects, which types depends on key words determined at run time....
Definition CreatorMap.hpp:30
Definition CreatorMap.hpp:16
Default precon creator.
Definition ISTLPreconCreator.hpp:72
A variadic type list.
Definition TypeTraits.hpp:146