Fluid structure interaction suite
amg.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2022 by Luca Heltai
4 //
5 // This file is part of the FSI-suite platform, based on the deal.II library.
6 //
7 // The FSI-suite platform is free software; you can use it, redistribute it,
8 // and/or modify it under the terms of the GNU Lesser General Public License as
9 // published by the Free Software Foundation; either version 3.0 of the License,
10 // or (at your option) any later version. The full text of the license can be
11 // found in the file LICENSE at the top level of the FSI-suite platform
12 // distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #include "parsed_lac/amg.h"
17 
18 #ifdef DEAL_II_WITH_TRILINOS
19 
20 # include <deal.II/dofs/dof_tools.h>
21 
23 
24 using namespace dealii;
25 
26 namespace ParsedLAC
27 {
28  AMGPreconditioner::AMGPreconditioner(const std::string &name,
29  const bool &elliptic,
30  const bool &higher_order_elements,
31  const unsigned int &n_cycles,
32  const bool &w_cycle,
33  const double &aggregation_threshold,
34  const unsigned int &smoother_sweeps,
35  const unsigned int &smoother_overlap,
36  const bool &output_details,
37  const std::string &smoother_type,
38  const std::string &coarse_type)
39  : ParameterAcceptor(name)
40  , PreconditionAMG()
41  , elliptic(elliptic)
42  , higher_order_elements(higher_order_elements)
43  , n_cycles(n_cycles)
44  , w_cycle(w_cycle)
45  , aggregation_threshold(aggregation_threshold)
46  , smoother_sweeps(smoother_sweeps)
47  , smoother_overlap(smoother_overlap)
48  , output_details(output_details)
49  , smoother_type(smoother_type)
50  , coarse_type(coarse_type)
51  {
53  }
54 
55  void
57  {
59  "Elliptic",
60  elliptic,
61  "Determines whether the AMG preconditioner should be optimized for "
62  "elliptic problems (ML option smoothed aggregation SA, using a "
63  "Chebyshev smoother) or for non-elliptic problems (ML option "
64  "non-symmetric smoothed aggregation NSSA, smoother is SSOR with "
65  "underrelaxation");
66 
68  "High Order Elements",
70  "Determines whether the matrix that the preconditioner is built upon is "
71  "generated from linear or higher-order elements.");
72 
74  "Number of cycles",
75  n_cycles,
76  "Defines how many multigrid cycles should be performed by the "
77  "preconditioner.");
78 
80  "w-cycle",
81  w_cycle,
82  "defines whether a w-cycle should be used instead of the standard "
83  "setting of a v-cycle.");
84 
86  "Aggregation threshold",
88  "This threshold tells the AMG setup how the coarsening should be "
89  "performed. In the AMG used by ML, all points that strongly couple with "
90  "the tentative coarse-level point form one aggregate. The term strong "
91  "coupling is controlled by the variable aggregation_threshold, meaning "
92  "that all elements that are not smaller than aggregation_threshold "
93  "times the diagonal element do couple strongly.");
94 
96  "Smoother sweeps",
98  "Determines how many sweeps of the smoother should be performed. When "
99  "the flag elliptic is set to true, i.e., for elliptic or almost "
100  "elliptic problems, the polynomial degree of the Chebyshev smoother is "
101  "set to smoother_sweeps. The term sweeps refers to the number of "
102  "matrix-vector products performed in the Chebyshev case. In the "
103  "non-elliptic case, smoother_sweeps sets the number of SSOR relaxation "
104  "sweeps for post-smoothing to be performed.");
105 
107  "Smoother overlap",
109  "Determines the overlap in the SSOR/Chebyshev error smoother when run "
110  "in parallel.");
111 
113  "Output details",
115  "If this flag is set to true, then internal information from the ML "
116  "preconditioner is printed to screen. This can be useful when debugging "
117  "the preconditioner.");
118 
120  "Smoother type",
122  "Determines which smoother to use for the AMG cycle.",
123  this->prm,
125  "|Aztec|IFPACK|Jacobi"
126  "|ML symmetric Gauss-Seidel|symmetric Gauss-Seidel"
127  "|ML Gauss-Seidel|Gauss-Seidel|block Gauss-Seidel"
128  "|symmetric block Gauss-Seidel|Chebyshev|MLS|Hiptmair"
129  "|Amesos-KLU|Amesos-Superlu|Amesos-UMFPACK|Amesos-Superludist"
130  "|Amesos-MUMPS|user-defined|SuperLU|IFPACK-Chebyshev|self"
131  "|do-nothing|IC|ICT|ILU|ILUT|Block Chebyshev"
132  "|IFPACK-Block Chebyshev"));
133 
135  "Coarse type",
136  coarse_type,
137  "Determines which solver to use on the coarsest level. The same "
138  "settings as for the smoother type are possible.",
139  this->prm,
141  "|Aztec|IFPACK|Jacobi"
142  "|ML symmetric Gauss-Seidel|symmetric Gauss-Seidel"
143  "|ML Gauss-Seidel|Gauss-Seidel|block Gauss-Seidel"
144  "|symmetric block Gauss-Seidel|Chebyshev|MLS|Hiptmair"
145  "|Amesos-KLU|Amesos-Superlu|Amesos-UMFPACK|Amesos-Superludist"
146  "|Amesos-MUMPS|user-defined|SuperLU|IFPACK-Chebyshev|self"
147  "|do-nothing|IC|ICT|ILU|ILUT|Block Chebyshev"
148  "|IFPACK-Block Chebyshev"));
149  }
150 
151 
152 
153  void
155  const std::vector<std::vector<bool>> &constant_modes)
156  {
158  }
159 
160 
161 
162  template <typename Matrix>
163  void
164  AMGPreconditioner::initialize(const Matrix &matrix)
165  {
167 
168  data.elliptic = elliptic;
170  data.n_cycles = n_cycles;
171  data.w_cycle = w_cycle;
177  data.smoother_type = smoother_type.c_str();
178  data.coarse_type = coarse_type.c_str();
180  }
181 } // namespace ParsedLAC
182 
183 template void
185  dealii::TrilinosWrappers::SparseMatrix>(
186  const dealii::TrilinosWrappers::SparseMatrix &);
187 
188 
189 template void
190 ParsedLAC::AMGPreconditioner::initialize<dealii::SparseMatrix<double>>(
191  const dealii::SparseMatrix<double> &);
192 
193 #endif
static ParameterHandler prm
void add_parameter(const std::string &entry, ParameterType &parameter, const std::string &documentation="", ParameterHandler &prm_=prm, const Patterns::PatternBase &pattern=*Patterns::Tools::Convert< ParameterType >::to_pattern())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
bool elliptic
Determines whether the AMG preconditioner should be optimized for elliptic problems (ML option smooth...
Definition: amg.h:83
double aggregation_threshold
This threshold tells the AMG setup how the coarsening should be performed.
Definition: amg.h:112
void add_parameters()
Declare preconditioner options.
Definition: amg.cc:56
unsigned int n_cycles
Defines how many multigrid cycles should be performed by the preconditioner.
Definition: amg.h:95
std::string smoother_type
Determines which smoother to use for the AMG cycle.
Definition: amg.h:157
std::string coarse_type
Determines which solver to use on the coarsest level.
Definition: amg.h:163
bool w_cycle
Defines whether a w-cycle should be used instead of the standard setting of a v-cycle.
Definition: amg.h:101
std::vector< std::vector< bool > > constant_modes
Constant modes of the matrix.
Definition: amg.h:168
bool output_details
If this flag is set to true, then internal information from the ML preconditioner is printed to scree...
Definition: amg.h:144
unsigned int smoother_overlap
Determines the overlap in the SSOR/Chebyshev error smoother when run in parallel.
Definition: amg.h:137
void set_constant_modes(const std::vector< std::vector< bool >> &constant_modes)
Set the constant modes of the AMG preconditioner.
Definition: amg.cc:154
void initialize(const Matrix &matrix)
Initialize the preconditioner using matrix.
Definition: amg.cc:164
bool higher_order_elements
Determines whether the matrix that the preconditioner is built upon is generated from linear or highe...
Definition: amg.h:89
unsigned int smoother_sweeps
Determines how many sweeps of the smoother should be performed.
Definition: amg.h:131
Definition: amg.h:28
std::vector< std::vector< bool > > constant_modes