cyqlone develop
Fast, parallel and vectorized solver for linear systems with optimal control structure.
Loading...
Searching...
No Matches
cyqlone-params.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cyqlone/config.hpp>
4#include <limits>
5#include <stdexcept>
6
7namespace cyqlone {
8
9/// Defines how to solve the small linear system that remains after cyclic reduction.
10/// @ingroup topic-block-tridiag-solvers
11enum class SolveMethod {
12 StairPCG, ///< Preconditioned Conjugate Gradient with staircase preconditioner (iterative)
13 JacobiPCG, ///< Preconditioned Conjugate Gradient with Jacobi preconditioner (iterative)
14 PCR, ///< Parallel Cyclic Reduction (direct)
15};
16
17inline const char *enum_name(SolveMethod s) {
18 switch (s) {
19 case SolveMethod::StairPCG: return "StairPCG";
20 case SolveMethod::JacobiPCG: return "JacobiPCG";
21 case SolveMethod::PCR: return "PCR";
22 default:;
23 }
24 throw std::out_of_range("invalid value for cyqlone::SolveMethod");
25}
26
27/// Parameters and settings for the Tricyqle block-tridiagonal solver.
28/// @ingroup topic-block-tridiag-solvers
29template <class T = real_t>
31 using value_type = T;
32
33 /// Use prefetching during the reverse CR solve phase.
34 bool enable_prefetching = true;
35 /// Maximum number of preconditioned conjugate gradient iterations.
36 index_t pcg_max_iter = 100;
37 /// Tolerance for the preconditioned conjugate gradient solver.
38 value_type pcg_tolerance = std::numeric_limits<value_type>::epsilon() / 10;
39 /// Enable printing of the residuals during PCG.
40 bool pcg_print_resid = false;
41 /// Algorithm to use for solving the final reduced block tridiagonal system.
43 /// Tuning parameter for deciding when to update or re-factor the PCR factorization.
44 /// If the update rank exceeds this fraction of nx, the PCR factorization is recomputed
46 /// Tuning parameter for deciding when to update or re-factor the last subdiagonal blocks in the
47 /// CR factorization.
48 /// If the update rank exceeds this fraction of nx, the last subdiagonal blocks are
49 /// recomputed.
50 /// @todo Add option to switch at any level of CR, not just the last one.
52 /// Threshold on nx for switching to a serial implementation of the reverse CR solve.
54 /// Threshold on nx for switching to a serial implementation of the PCR factorization.
56};
57
58/// Parameters and settings for the Cyqlone solver.
59/// @ingroup topic-ocp-solvers
60template <class T = real_t>
62 using value_type = T;
63
64 // Currently empty, but kept for future Cyqlone-specific parameters
65};
66
67} // namespace cyqlone
SolveMethod
Defines how to solve the small linear system that remains after cyclic reduction.
@ JacobiPCG
Preconditioned Conjugate Gradient with Jacobi preconditioner (iterative).
@ StairPCG
Preconditioned Conjugate Gradient with staircase preconditioner (iterative).
@ PCR
Parallel Cyclic Reduction (direct).
Parameters and settings for the Tricyqle block-tridiagonal solver.
Parameters and settings for the Cyqlone solver.
const char * enum_name(SolveMethod s)