[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
parameters_linear_solver.cpp
1 #include "parameters/parameters_linear_solver.h"
2 
3 namespace PHiLiP {
4 namespace Parameters {
5 
6 void LinearSolverParam::declare_parameters (dealii::ParameterHandler &prm)
7 {
8  prm.enter_subsection("linear solver");
9  {
10  prm.declare_entry("linear_solver_output", "quiet",
11  dealii::Patterns::Selection("quiet|verbose"),
12  "State whether output from linear solver should be printed. "
13  "Choices are <quiet|verbose>.");
14 
15  prm.declare_entry("linear_solver_type", "gmres",
16  dealii::Patterns::Selection("direct|gmres"),
17  "Enum of linear solver"
18  "Choices are <direct|gmres>.");
19 
20  prm.enter_subsection("gmres options");
21  {
22  prm.declare_entry("linear_residual_tolerance", "1e-4",
23  dealii::Patterns::Double(),
24  "Linear residual tolerance for convergence of the linear system");
25  prm.declare_entry("max_iterations", "1000",
26  dealii::Patterns::Integer(),
27  "Maximum number of iterations for linear solver");
28  prm.declare_entry("restart_number", "30",
29  dealii::Patterns::Integer(),
30  "Number of iterations before restarting GMRES");
31 
32  // ILU with threshold parameters
33  prm.declare_entry("ilut_fill", "1",
34  dealii::Patterns::Integer(),
35  "Amount of additional fill-in elements besides the sparse matrix structure."
36  "For ilut_fill >= 1.0, "
37  "Number of entries to keep in the strict upper triangle of the "
38  " current row, and in the strict lower triangle of the current "
39  " row. It does NOT correspond to the $p$ parameter in Saad's original. "
40  " description. This parameter represents a maximum fill fraction. "
41  " In this implementation, the L and U factors always contains nonzeros corresponding "
42  " to the original sparsity pattern of A, so this value should be >= 1.0. "
43  " Letting $fill = \frac{(level-of-fill - 1)*nnz(A)}{2*N}$, "
44  " each row of the computed L and U factors contains at most $fill$ "
45  " nonzero elements in addition to those from the sparsity pattern of A."
46  " For ilut_fill >= 1.0, "
47  " Typical graph-based level of-fill of the factorization such that the pattern corresponds to A^(p+1). ");
48  prm.declare_entry("ilut_drop", "0.0",
49  dealii::Patterns::Double(),
50  "relative size of elements which should be dropped when forming an incomplete lu decomposition with threshold");
51  prm.declare_entry("ilut_rtol", "1.0",
52  dealii::Patterns::Double(),
53  "Amount of an absolute perturbation that will be added to the diagonal of the matrix, "
54  "which sometimes can help to get better preconditioners");
55  prm.declare_entry("ilut_atol", "0.0",
56  dealii::Patterns::Double(),
57  "Factor by which the diagonal of the matrix will be scaled, "
58  "which sometimes can help to get better preconditioners");
59  }
60  prm.leave_subsection();
61 
62  prm.enter_subsection("JFNK options");
63  {
64  prm.declare_entry("newton_residual", "1E-7",
65  dealii::Patterns::Double(),
66  "Convergence tolerance for Newton iterations");
67  prm.declare_entry("newton_max_iterations", "100",
68  dealii::Patterns::Integer(),
69  "Maximum number of Newton iterations");
70  prm.declare_entry("perturbation_magnitude", "1.490116119384765625e-8",
71  dealii::Patterns::Double(),
72  "Small perturbation for Jacobian-free methods."
73  " Default value is the square root of machine epsilon.");
74  }
75  prm.leave_subsection();
76 
77  }
78  prm.leave_subsection();
79 }
80 
81 void LinearSolverParam ::parse_parameters (dealii::ParameterHandler &prm)
82 {
83  prm.enter_subsection("linear solver");
84  {
85  const std::string output_string = prm.get("linear_solver_output");
86  if (output_string == "verbose") linear_solver_output = verbose;
87  if (output_string == "quiet") linear_solver_output = quiet;
88 
89  const std::string solver_string = prm.get("linear_solver_type");
90  if (solver_string == "direct") linear_solver_type = LinearSolverEnum::direct;
91 
92  if (solver_string == "gmres")
93  {
94  linear_solver_type = LinearSolverEnum::gmres;
95  prm.enter_subsection("gmres options");
96  {
97  max_iterations = prm.get_integer("max_iterations");
98  restart_number = prm.get_integer("restart_number");
99  linear_residual = prm.get_double("linear_residual_tolerance");
100 
101  ilut_fill = prm.get_integer("ilut_fill");
102  ilut_drop = prm.get_double("ilut_drop");
103  ilut_rtol = prm.get_double("ilut_rtol");
104  ilut_atol = prm.get_double("ilut_atol");
105  }
106  prm.leave_subsection();
107  }
108 
109  prm.enter_subsection("JFNK options");
110  {
111  newton_residual = prm.get_double("newton_residual");
112  newton_max_iterations = prm.get_integer("newton_max_iterations");
113  perturbation_magnitude = prm.get_double("perturbation_magnitude");
114  }
115  prm.leave_subsection();
116 
117  }
118  prm.leave_subsection();
119 }
120 
121 } // Parameters namespace
122 } // PHiLiP namespace
double ilut_drop
Threshold to drop terms close to zero.
static void declare_parameters(dealii::ParameterHandler &prm)
Declares the possible variables and sets the defaults.
double ilut_atol
Add ilu_rtol to diagonal for more diagonal dominance.
Files for the baseline physics.
Definition: ADTypes.hpp:10
int newton_max_iterations
Maximum number of Newton iterations (for Jacobian-free Newton-Krylov)
int restart_number
Number of iterations before restarting GMRES.
double linear_residual
Tolerance for linear residual.
LinearSolverEnum linear_solver_type
direct or gmres.
double ilut_rtol
Multiplies diagonal by ilut_rtol for more diagonal dominance.
int max_iterations
Maximum number of linear iteration.
void parse_parameters(dealii::ParameterHandler &prm)
Parses input file and sets the variables.
double perturbation_magnitude
Small perturbation magnitude for Jacobian-free methods.
double newton_residual
Tolerance for Newton iteration residual (for Jacobian-free Newton-Krylov)
OutputEnum linear_solver_output
Can either be verbose or quiet.