Fluid structure interaction suite
amg_petsc.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 #include <deal.II/base/config.h>
16 
17 #include "parsed_tools/enum.h"
18 
19 #ifdef DEAL_II_WITH_PETSC
20 
21 # include <deal.II/dofs/dof_tools.h>
22 
24 
25 # include "parsed_lac/amg_petsc.h"
26 
27 
28 using namespace dealii;
29 
30 namespace ParsedLAC
31 {
32  PETScAMGPreconditioner::PETScAMGPreconditioner(
33  const std::string &name,
34  const bool symmetric_operator,
35  const double strong_threshold,
36  const double max_row_sum,
37  const unsigned int aggressive_coarsening_num_levels,
38  const bool output_details,
39  const RelaxationType relaxation_type_up,
40  const RelaxationType relaxation_type_down,
41  const RelaxationType relaxation_type_coarse,
42  const unsigned int n_sweeps_coarse,
43  const double tol,
44  const unsigned int max_iter,
45  const bool w_cycle)
46  : ParameterAcceptor(name)
47  , PETScWrappers::PreconditionBoomerAMG()
48  , symmetric_operator(symmetric_operator)
49  , strong_threshold(strong_threshold)
50  , max_row_sum(max_row_sum)
51  , aggressive_coarsening_num_levels(aggressive_coarsening_num_levels)
52  , output_details(output_details)
53  , relaxation_type_up(relaxation_type_up)
54  , relaxation_type_down(relaxation_type_down)
55  , relaxation_type_coarse(relaxation_type_coarse)
56  , n_sweeps_coarse(n_sweeps_coarse)
57  , tol(tol)
58  , max_iter(max_iter)
59  , w_cycle(w_cycle)
60  {
62  }
63 
64  void
66  {
68  "Symmetric operator",
70  "Set this flag to true if you have a symmetric system matrix and you want "
71  "to use a solver which assumes a symmetric preconditioner like CG.");
72 
74  "Strong threshold",
76  "Threshold of when nodes are considered strongly connected. See "
77  "HYPRE_BoomerAMGSetStrongThreshold(). Recommended values are 0.25 for 2d "
78  "and 0.5 for 3d problems, but it is problem dependent.");
79 
81  "Max row sum",
83  "If set to a value smaller than 1.0 then diagonally dominant parts "
84  "of the matrix are treated as having no strongly connected nodes. If "
85  "the row sum weighted by the diagonal entry is bigger than the given "
86  "value, it is considered diagonally dominant. This feature is turned "
87  "of by setting the value to 1.0. This is the default as some matrices "
88  "can result in having only diagonally dominant entries and thus no "
89  "multigrid levels are constructed. The default in BoomerAMG for this "
90  "is 0.9. When you try this, check for a reasonable number of levels "
91  "created.");
92 
94  "Aggressive coarsening num levels",
96  "Number of levels of aggressive coarsening. Increasing this value "
97  "reduces the construction time and memory requirements but may "
98  "decrease effectiveness.");
99 
101  "Output details",
103  "Setting this flag to true produces debug output from HYPRE, when the "
104  "preconditioner is constructed.");
105 
106  add_parameter("Relaxation type up", relaxation_type_up);
107  add_parameter("Relaxation type down", relaxation_type_down);
108  add_parameter("Relaxation type coarse", relaxation_type_coarse);
109  add_parameter("Number of sweeps coarse", n_sweeps_coarse);
110  add_parameter("Tolerance", tol);
111  add_parameter("Max iterations", max_iter);
112  add_parameter("W-cycle", w_cycle);
113  }
114 
115 
116 
117  void
119  const dealii::PETScWrappers::MatrixBase &matrix)
120  {
121  dealii::PETScWrappers::PreconditionBoomerAMG::AdditionalData data;
122 
123  data.symmetric_operator = symmetric_operator;
124  data.strong_threshold = strong_threshold;
125  data.max_row_sum = max_row_sum;
126  data.aggressive_coarsening_num_levels = aggressive_coarsening_num_levels;
127  data.output_details = output_details;
128  data.relaxation_type_up = relaxation_type_up;
129  data.relaxation_type_down = relaxation_type_down;
130  data.relaxation_type_coarse = relaxation_type_coarse;
131  data.n_sweeps_coarse = n_sweeps_coarse;
132  data.tol = tol;
133  data.max_iter = max_iter;
134  data.w_cycle = w_cycle;
135 
137  }
138 } // namespace ParsedLAC
139 
140 #endif
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())
double strong_threshold
Threshold of when nodes are considered strongly connected.
Definition: amg_petsc.h:86
unsigned int aggressive_coarsening_num_levels
Number of levels of aggressive coarsening.
Definition: amg_petsc.h:106
bool symmetric_operator
Set this flag to true if you have a symmetric system matrix and you want to use a solver which assume...
Definition: amg_petsc.h:79
RelaxationType relaxation_type_coarse
Choose relaxation type coarse.
Definition: amg_petsc.h:127
PETScWrappers::PreconditionBoomerAMG::AdditionalData::RelaxationType RelaxationType
Definition: amg_petsc.h:41
unsigned int n_sweeps_coarse
Choose number of sweeps on coarse grid.
Definition: amg_petsc.h:132
RelaxationType relaxation_type_up
Choose relaxation type up.
Definition: amg_petsc.h:117
double tol
Choose BommerAMG tolerance.
Definition: amg_petsc.h:137
void add_parameters()
Declare preconditioner options.
Definition: amg_petsc.cc:65
double max_row_sum
If set to a value smaller than 1.0 then diagonally dominant parts of the matrix are treated as having...
Definition: amg_petsc.h:99
bool w_cycle
Defines whether a w-cycle should be used instead of the standard setting of a v-cycle.
Definition: amg_petsc.h:148
unsigned int max_iter
Choose BommerAMG maximum number of cycles.
Definition: amg_petsc.h:142
RelaxationType relaxation_type_down
Choose relaxation type down.
Definition: amg_petsc.h:122
bool output_details
Setting this flag to true produces debug output from HYPRE, when the preconditioner is constructed.
Definition: amg_petsc.h:112
Definition: amg.h:28