OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
MueLuPreconditioner.hpp
Go to the documentation of this file.
1//
2// Class MueLuPreconditioner
3// Interface to the SAAMG solver of MueLu. Here it is used as preconditioner for Belos
4// iterative solvers.
5//
6// Copyright (c) 2017 - 2020, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
7// All rights reserved
8//
9// Implemented as part of the PhD thesis
10// "Precise Simulations of Multibunches in High Intensity Cyclotrons"
11//
12// This file is part of OPAL.
13//
14// OPAL is free software: you can redistribute it and/or modify
15// it under the terms of the GNU General Public License as published by
16// the Free Software Foundation, either version 3 of the License, or
17// (at your option) any later version.
18//
19// You should have received a copy of the GNU General Public License
20// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
21//
22#include <AMReX.H>
23
24#include <MueLu_CreateTpetraPreconditioner.hpp>
25
26template <class Level>
28 : prec_mp(Teuchos::null)
29{
30 this->init_m(reuse);
31}
32
33
34template <class Level>
35void MueLuPreconditioner<Level>::create(const Teuchos::RCP<amr::matrix_t>& A,
36 Level* /*level_p*/)
37{
38 typedef Tpetra::Operator<scalar_t, lo_t, go_t, amr::node_t> TpetraOperator_t;
39 Teuchos::RCP<TpetraOperator_t> At = Teuchos::rcp_dynamic_cast<TpetraOperator_t>(A);
40 prec_mp = MueLu::CreateTpetraPreconditioner(At, params_m);
41}
42
43
44template <class Level>
45Teuchos::RCP<amr::operator_t> MueLuPreconditioner<Level>::get() {
46 return prec_mp;
47}
48
49
50template <class Level>
52 map["SA"] = Preconditioner::SA;
53}
54
55
56template <class Level>
57std::string
59
60 std::map<std::string, std::string> map;
61 map["NONE"] = "none";
62 map["RP"] = "RP";
63 map["RAP"] = "RAP";
64 map["SYMBOLIC"] = "S";
65 map["FULL"] = "full";
66
67 auto muelu = map.find(reuse);
68
69 if ( muelu == map.end() )
70 throw OpalException("MueLuPreconditioner::convertToMueLuReuseOption()",
71 "No MueLu reuse option '" + reuse + "'.");
72
73 return muelu->second;
74}
75
76
77template <class Level>
78void MueLuPreconditioner<Level>::init_m(const std::string& reuse) {
79 params_m.set("problem: type", "Poisson-3D");
80 params_m.set("verbosity", "none");
81 params_m.set("number of equations", 1);
82 params_m.set("max levels", 8);
83 params_m.set("cycle type", "V");
84
85 params_m.set("coarse: max size", 200);
86 params_m.set("multigrid algorithm", "sa");
87 params_m.set("sa: damping factor", 1.33); // default: 1.33
88 params_m.set("sa: use filtered matrix", true);
89 params_m.set("filtered matrix: reuse eigenvalue", false); // false: more expensive
90
91 params_m.set("repartition: enable", false);
92 params_m.set("repartition: rebalance P and R", false);
93 params_m.set("repartition: partitioner", "zoltan2");
94 params_m.set("repartition: min rows per proc", 800);
95 params_m.set("repartition: start level", 2);
96
97 Teuchos::ParameterList reparms;
98 reparms.set("algorithm", "multijagged"); // rcb
99 // reparms.set("partitioning_approach", "partition");
100
101 params_m.set("repartition: params", reparms);
102
103 params_m.set("smoother: type", "CHEBYSHEV");
104 params_m.set("smoother: pre or post", "both");
105 Teuchos::ParameterList smparms;
106 smparms.set("chebyshev: degree", 3);
107 smparms.set("chebyshev: assume matrix does not change", false);
108 smparms.set("chebyshev: zero starting solution", true);
109 params_m.set("smoother: params", smparms);
110
111 params_m.set("smoother: type", "CHEBYSHEV");
112 params_m.set("smoother: pre or post", "both");
113
114 params_m.set("coarse: type", "KLU2");
115
116 params_m.set("aggregation: type", "uncoupled");
117 params_m.set("aggregation: min agg size", 3);
118 params_m.set("aggregation: max agg size", 27);
119
120 params_m.set("transpose: use implicit", false);
121
122 params_m.set("reuse: type", reuse); // none
123}
@ SA
smoothed aggregation multigrid
static std::string convertToMueLuReuseOption(const std::string &reuse)
void init_m(const std::string &reuse)
void create(const Teuchos::RCP< amr::matrix_t > &A, Level *level_p=nullptr)
MueLuPreconditioner(const std::string &reuse)
std::map< std::string, Preconditioner > map_t
static void fillMap(map_t &map)
Teuchos::RCP< amr::operator_t> get()
The base class for all OPAL exceptions.
Definition: OpalException.h:28