PRISMS-PF Manual v3.0-pre
All Classes Functions Variables Enumerations Pages
linear_solve_parameters.h
1// SPDX-FileCopyrightText: © 2025 PRISMS Center at the University of Michigan
2// SPDX-License-Identifier: GNU Lesser General Public Version 2.1
3
4#ifndef linear_solve_parameters_h
5#define linear_solve_parameters_h
6
7#include <prismspf/config.h>
8#include <prismspf/core/conditional_ostreams.h>
9#include <prismspf/core/type_enums.h>
10#include <prismspf/core/types.h>
11
12#include <map>
13
14PRISMS_PF_BEGIN_NAMESPACE
15
20{
21public:
22 // Solver tolerance
23 double tolerance = defaults::tolerance;
24
25 // Solver tolerance type
26 solverToleranceType tolerance_type = solverToleranceType::RELATIVE_RESIDUAL_CHANGE;
27
28 // Max number of iterations for the linear solve
29 unsigned int max_iterations = defaults::iterations;
30
31 // Preconditioner
32 preconditionerType preconditioner = preconditionerType::GMG;
33
34 // Smoothing range for eigenvalues. This denotes the lower bound of eigenvalues that are
35 // smoothed [1.2 λ^max / smoothing_range, 1.2 λ^max], where λ^max is the estimated
36 // maximum eigenvalue. A choice between 5 and 20 is usually useful when the
37 // preconditioner is used as a smoother in multigrid.
38 double smoothing_range = 15.0;
39
40 // Polynomial degree for the Chebyshev smoother
41 unsigned int smoother_degree = 5;
42
43 // Maximum number of CG iterations used to find the maximum eigenvalue
44 unsigned int eig_cg_n_iterations = 10;
45};
46
51{
52public:
56 void
58
62 void
64
65 // Map of linear solve parameters for fields that require them
66 std::map<unsigned int, linearSolverParameters> linear_solve;
67};
68
69inline void
71{
72 // Nothing to do here for now
73}
74
75inline void
77{
78 if (!linear_solve.empty())
79 {
81 << "================================================\n"
82 << " Linear Solve Parameters\n"
83 << "================================================\n";
84
85 for (const auto &[index, linear_solver_parameters] : linear_solve)
86 {
88 << "Index: " << index << "\n"
89 << " Tolerance: " << linear_solver_parameters.tolerance << "\n"
90 << " Type: " << to_string(linear_solver_parameters.tolerance_type) << "\n"
91 << " Max iterations: " << linear_solver_parameters.max_iterations << "\n"
92 << " Preconditioner: " << to_string(linear_solver_parameters.preconditioner)
93 << "\n";
94
95 if (linear_solver_parameters.preconditioner == preconditionerType::GMG)
96 {
98 << " Smoothing range: " << linear_solver_parameters.smoothing_range
99 << "\n"
100 << " Smoother degree: " << linear_solver_parameters.smoother_degree
101 << "\n"
102 << " Max eigenvalue CG iterations: "
103 << linear_solver_parameters.eig_cg_n_iterations << "\n";
104 }
105 }
106
107 conditionalOStreams::pout_summary() << "\n" << std::flush;
108 }
109}
110
111PRISMS_PF_END_NAMESPACE
112
113#endif
static dealii::ConditionalOStream & pout_summary()
Log output stream for writing a summary.log file.
Definition conditional_ostreams.cc:22
Struct that holds linear solver parameters.
Definition linear_solve_parameters.h:51
void postprocess_and_validate()
Postprocess and validate parameters.
Definition linear_solve_parameters.h:70
void print_parameter_summary() const
Print parameters to summary.log.
Definition linear_solve_parameters.h:76
Struct that stores relevant linear solve information of a certain field.
Definition linear_solve_parameters.h:20