OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Ifpack2Preconditioner.hpp
Go to the documentation of this file.
1//
2// Class Ifpack2Preconditioner
3// Interface to Ifpack2 preconditioners.
4//
5// Copyright (c) 2017 - 2020, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// Implemented as part of the PhD thesis
9// "Precise Simulations of Multibunches in High Intensity Cyclotrons"
10//
11// This file is part of OPAL.
12//
13// OPAL is free software: you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation, either version 3 of the License, or
16// (at your option) any later version.
17//
18// You should have received a copy of the GNU General Public License
19// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20//
22
23template <class Level>
25 : prec_mp(Teuchos::null)
26{
27 this->init_m(prec);
28}
29
30
31template <class Level>
32void Ifpack2Preconditioner<Level>::create(const Teuchos::RCP<amr::matrix_t>& A,
33 Level* /*level_p*/)
34{
35 Ifpack2::Factory factory;
36
37 prec_mp = factory.create(prectype_m, A.getConst());
38 prec_mp->setParameters(*params_mp);
39 prec_mp->initialize();
40 prec_mp->compute();
41}
42
43
44template <class Level>
45Teuchos::RCP<amr::operator_t> Ifpack2Preconditioner<Level>::get() {
46 return prec_mp;
47}
48
49
50template <class Level>
52 map["ILUT"] = Preconditioner::ILUT;
53 map["CHEBYSHEV"] = Preconditioner::CHEBYSHEV;
54 map["RILUK"] = Preconditioner::RILUK;
55 map["JACOBI"] = Preconditioner::JACOBI;
56 map["BLOCK_JACOBI"] = Preconditioner::BLOCK_JACOBI;
57 map["GS"] = Preconditioner::GS;
58 map["BLOCK_GS"] = Preconditioner::BLOCK_GS;
59}
60
61
62template <class Level>
64{
65 params_mp = Teuchos::parameterList();
66
67 switch ( prec ) {
69 // inclomplete LU
70 prectype_m = "ILUT";
71
72 params_mp->set("fact: ilut level-of-fill", 5.0);
73 params_mp->set("fact: drop tolerance", 0.0);
74
75 break;
77 prectype_m = "CHEBYSHEV";
78 params_mp->set("chebyshev: degree", 1);
79 break;
81 prectype_m = "RILUK";
82 params_mp->set("fact: iluk level-of-fill", 0);
83 params_mp->set("fact: relax value", 0.0);
84 params_mp->set("fact: absolute threshold", 0.0);
85 params_mp->set("fact: relative threshold", 1.0);
86 break;
88 prectype_m = "RELAXATION";
89 params_mp->set("relaxation: type", "Jacobi");
90 params_mp->set("relaxation: sweeps", 12);
91 params_mp->set("relaxation: zero starting solution", false);
92 params_mp->set("relaxation: damping factor", 6.0 / 7.0);
93 params_mp->set("relaxation: use l1", true);
94 params_mp->set("relaxation: l1 eta", 1.5);
95 params_mp->set("relaxation: backward mode", false);
96 params_mp->set("relaxation: fix tiny diagonal entries", true);
97 params_mp->set("relaxation: min diagonal value", 1.0e-5);
98 params_mp->set("relaxation: check diagonal entries", true);
99 break;
101 prectype_m = "BLOCK_RELAXATION";
102 params_mp->set("relaxation: type", "Jacobi");
103 params_mp->set("relaxation: sweeps", 12);
104 params_mp->set("relaxation: zero starting solution", false);
105 params_mp->set("relaxation: damping factor", 6.0 / 7.0);
106 params_mp->set("relaxation: backward mode", false);
107
108 params_mp->set("partitioner: type", "linear");
109 params_mp->set("partitioner: overlap", 0);
110 params_mp->set("partitioner: local parts", 1);
111
112 break;
114 prectype_m = "RELAXATION";
115 params_mp->set("relaxation: type", "Gauss-Seidel");
116 params_mp->set("relaxation: sweeps", 12);
117 params_mp->set("relaxation: zero starting solution", false);
118 params_mp->set("relaxation: damping factor", 1.0);
119 params_mp->set("relaxation: use l1", true);
120 params_mp->set("relaxation: l1 eta", 1.5);
121 params_mp->set("relaxation: backward mode", false);
122 params_mp->set("relaxation: fix tiny diagonal entries", true);
123 params_mp->set("relaxation: min diagonal value", 1.0e-5);
124 params_mp->set("relaxation: check diagonal entries", true);
125 break;
127 prectype_m = "BLOCK_RELAXATION";
128 params_mp->set("relaxation: type", "Gauss-Seidel");
129 params_mp->set("relaxation: sweeps", 12);
130 params_mp->set("relaxation: zero starting solution", false);
131 params_mp->set("relaxation: damping factor", 6.0 / 7.0);
132 params_mp->set("relaxation: backward mode", false);
133
134 params_mp->set("partitioner: type", "linear");
135 params_mp->set("partitioner: overlap", 0);
136 params_mp->set("partitioner: local parts", 1);
137 break;
138 case Preconditioner::NONE:
139 prectype_m = "";
140 break;
141 default:
142 throw OpalException("Ifpack2Preconditioner::init_m()",
143 "This type of Ifpack2 preconditioner not supported.");
144 }
145}
@ GS
Gauss-Seidel point relaxation.
@ JACOBI
Jacobi point relaxation.
@ RILUK
ILU(k)
@ ILUT
incomplete LU
@ BLOCK_JACOBI
Jacobi block relaxation.
@ BLOCK_GS
Gauss-Seidel block relaxation.
Ifpack2Preconditioner(Preconditioner prec)
void create(const Teuchos::RCP< amr::matrix_t > &A, Level *level_p=nullptr)
std::map< std::string, Preconditioner > map_t
static void fillMap(map_t &map)
Teuchos::RCP< amr::operator_t> get()
void init_m(Preconditioner prec)
The base class for all OPAL exceptions.
Definition: OpalException.h:28