Documentation 6b54b78464
Loading...
Searching...
No Matches
CSysSolve.hpp
Go to the documentation of this file.
1/*!
2 * \file CSysSolve.hpp
3 * \brief Headers for the classes related to linear solvers (CG, FGMRES, etc)
4 * The subroutines and functions are in the <i>CSysSolve.cpp</i> file.
5 * \author J. Hicken, F. Palacios, T. Economon, P. Gomes
6 * \version 8.5.0 "Harrier"
7 *
8 * SU2 Project Website: https://su2code.github.io
9 *
10 * The SU2 Project is maintained by the SU2 Foundation
11 * (http://su2foundation.org)
12 *
13 * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)
14 *
15 * SU2 is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2.1 of the License, or (at your option) any later version.
19 *
20 * SU2 is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with SU2. If not, see <http://www.gnu.org/licenses/>.
27 */
28
29#pragma once
30
31#include "../containers/C2DContainer.hpp"
32
33#include <cmath>
34#include <memory>
35#include <vector>
36#include <iostream>
37#include <cstdlib>
38#include <iomanip>
39#include <string>
40
41#include "CSysVector.hpp"
42#include "../option_structure.hpp"
43
44SU2_IGNORE_WARNING("-Wmaybe-uninitialized")
45#include "Eigen/Core"
46#include "Eigen/Dense"
48
49class CConfig;
50class CGeometry;
51template <class T>
52class CSysMatrix;
53template <class T>
55template <class T>
56class CPreconditioner;
57
58/*--- Relative tolerance, target residual is tol*||b-Ax||,
59 * Absolute tolerance, target residual is tol*||b||. ---*/
61
62/*!
63 * \brief Modes of using FGCRODR.
64 * \ingroup SpLinSys
65 */
66enum class FgcrodrMode {
67 NORMAL, /*!< \brief Solve the linear system. */
68 SAME_MAT, /*!< \brief "NORMAL" but knowing the matrix did not change. */
69};
70
71/*!
72 * \class CSysSolve
73 * \ingroup SpLinSys
74 * \brief Class for solving linear systems using classical and Krylov-subspace iterative methods
75 *
76 * The individual solvers could be stand-alone subroutines, but by
77 * creating CSysSolve objects we can more easily assign different
78 * matrix-vector products and preconditioners to different problems
79 * that may arise in a hierarchical solver (i.e. multigrid).
80 *
81 * The methods of this class are designed to be called by multiple OpenMP threads.
82 * Beware of writes to class member variables, for example "Residual" should only
83 * be modified by one thread.
84 */
85template <class ScalarType>
86class CSysSolve {
87 public:
88 /*--- Some aliases for simplicity. ---*/
89 using Scalar = ScalarType;
94
95 private:
96 const ScalarType eps; /*!< \brief Machine epsilon used in this class. */
97 ScalarType Residual = 1e-20; /*!< \brief Residual at the end of a call to Solve or Solve_b. */
98 unsigned long Iterations = 0; /*!< \brief Iterations done in Solve or Solve_b. */
99
100 /*!< \brief Type of operation for the linear system solver, changes the source of solver options. */
101 LINEAR_SOLVER_MODE lin_sol_mode;
102
103 mutable bool cg_ready; /*!< \brief Indicate if memory used by CG is allocated. */
104 mutable bool bcg_ready; /*!< \brief Indicate if memory used by BCGSTAB is allocated. */
105 mutable bool smooth_ready; /*!< \brief Indicate if memory used by SMOOTHER is allocated. */
106
107 mutable VectorType r; /*!< \brief Residual in CG and BCGSTAB. */
108 mutable VectorType A_x; /*!< \brief Result of matrix-vector product in CG and BCGSTAB. */
109 mutable VectorType p; /*!< \brief Direction in CG and BCGSTAB. */
110 mutable VectorType z; /*!< \brief Preconditioned residual/direction in CG/BCGSTAB. */
111
112 mutable VectorType r_0; /*!< \brief The "arbitrary" vector in BCGSTAB. */
113 mutable VectorType v; /*!< \brief BCGSTAB "v" vector (v = A * M^-1 * p). */
114 mutable VectorType x_best; /*!< \brief BCGSTAB iterate with the smallest residual. */
115
116 mutable bool ritz_failed = false;
117 mutable unsigned long k = 0, k_new = 0;
118 mutable std::vector<VectorType> Z, V; /*!< \brief Large matrices used by FGMRES, v^i+1 = A * z^i. */
119 mutable std::vector<VectorType> W, T; /*!< \brief Large matrices used by FGCRODR for deflation vectors. */
120 mutable Eigen::Matrix<ScalarType, Eigen::Dynamic, Eigen::Dynamic> VkWk, Q, PinvR;
121
122 /*!< \brief Temporary used when it is necessary to interface between active and passive types. */
123 VectorType LinSysSol_tmp;
124 /*!< \brief Temporary used when it is necessary to interface between active and passive types. */
125 VectorType LinSysRes_tmp;
126 /*!< \brief Pointer to appropriate LinSysSol (set to original or temporary in call to Solve). */
127 VectorType* LinSysSol_ptr;
128 /*!< \brief Pointer to appropriate LinSysRes (set to original or temporary in call to Solve). */
129 const VectorType* LinSysRes_ptr;
130
131 /*!< \brief How the linear solvers interpret the tolerance. */
133 mutable bool xIsZero = false; /*!< \brief If true assume the initial solution is always 0. */
134 bool recomputeRes = false; /*!< \brief Recompute the residual after inner iterations, if monitoring. */
135 unsigned long monitorFreq = 10; /*!< \brief Monitoring frequency. */
136
137 /*!< \brief Inner solver for nested preconditioning. */
138 std::unique_ptr<CSysSolve<ScalarType>> inner_solver;
139
140 /*!
141 * \brief sign transfer function
142 * \param[in] x - value having sign prescribed
143 * \param[in] y - value that defined the sign
144 *
145 * this may already be defined as a global function somewhere, if
146 * so, feel free to delete this and replace it as needed with the
147 * appropriate global function
148 */
149 static inline ScalarType Sign(ScalarType x, ScalarType y) {
150 if (y == 0.0) return 0.0;
151 return fabs(x) * (y < 0.0 ? -1.0 : 1.0);
152 }
153
154 /*!
155 * \brief applys a Givens rotation to a 2-vector
156 * \param[in] s - sine of the Givens rotation angle
157 * \param[in] c - cosine of the Givens rotation angle
158 * \param[in,out] h1 - first element of 2x1 vector being transformed
159 * \param[in,out] h2 - second element of 2x1 vector being transformed
160 */
161 void ApplyGivens(ScalarType s, ScalarType c, ScalarType& h1, ScalarType& h2) const;
162
163 /*!
164 * \brief generates the Givens rotation matrix for a given 2-vector
165 * \param[in,out] dx - element of 2x1 vector being transformed
166 * \param[in,out] dy - element of 2x1 vector being set to zero
167 * \param[in,out] s - sine of the Givens rotation angle
168 * \param[in,out] c - cosine of the Givens rotation angle
169 *
170 * Based on givens() of SPARSKIT, which is based on p.202 of
171 * "Matrix Computations" by Golub and van Loan.
172 */
173 void GenerateGivens(ScalarType& dx, ScalarType& dy, ScalarType& s, ScalarType& c) const;
174
175 /*!
176 * \brief finds the solution of the upper triangular system Hsbg*x = rhs
177 *
178 * \param[in] n - size of the reduced system
179 * \param[in] Hsbg - upper triangular matrix
180 * \param[in] rhs - right-hand side of the reduced system
181 * \param[out] x - solution of the reduced system
182 *
183 * \pre the upper Hessenberg matrix has been transformed into a
184 * triangular matrix.
185 */
186 void SolveReduced(int n, const su2matrix<ScalarType>& Hsbg, const su2vector<ScalarType>& rhs,
187 su2vector<ScalarType>& x) const;
188
189 /*!
190 * \brief Modified Gram-Schmidt orthogonalization
191 * \author Based on Kesheng John Wu's mgsro subroutine in Saad's SPARSKIT
192 *
193 * \param[in] shared_hsbg - if the Hessenberg matrix is shared by multiple threads
194 * \param[in] i - index indicating which vector in w is being orthogonalized
195 * \param[in,out] Hsbg - the upper Hessenberg begin updated
196 * \param[in,out] w - the (i+1)th vector of w is orthogonalized against the
197 * previous vectors in w
198 *
199 * \pre the vectors w[0:i] are orthonormal
200 * \post the vectors w[0:i+1] are orthonormal
201 *
202 * Reothogonalization is performed if the cosine of the angle between
203 * w[i+1] and w[k], k < i+1, is greater than 0.98. The norm of the "new"
204 * vector is kept in nrm0 and updated after operating with each vector
205 *
206 */
207 bool ModGramSchmidt(bool shared_hsbg, int i, su2matrix<ScalarType>& Hsbg, std::vector<VectorType>& w) const;
208
209 /*!
210 * \brief writes header information for a CSysSolve residual history
211 * \param[in] solver - string describing the solver
212 * \param[in] restol - the target tolerance to solve to
213 * \param[in] resinit - the initial residual norm (absolute)
214 *
215 * \pre the ostream object os should be open
216 */
217 void WriteHeader(const std::string& solver, ScalarType restol, ScalarType resinit) const;
218
219 /*!
220 * \brief writes residual convergence data for one iteration to a stream
221 * \param[in] iter - current iteration
222 * \param[in] res - the residual norm to display
223 *
224 * \pre the ostream object os should be open
225 */
226 void WriteHistory(unsigned long iter, ScalarType res) const;
227
228 /*!
229 * \brief writes final residual convergence information
230 * \param[in] solver - string describing the solver
231 * \param[in] iter - current iteration
232 * \param[in] res - the residual norm
233 */
234 void WriteFinalResidual(const std::string& solver, unsigned long iter, ScalarType res) const;
235
236 /*!
237 * \brief writes the convergence warning
238 * \param[in] res_calc - the residual norm computed iteratively
239 * \param[in] res_true - the recomputed residual norm
240 * \param[in] tol - the residual norm
241 */
242 void WriteWarning(ScalarType res_calc, ScalarType res_true, ScalarType tol) const;
243
244 /*!
245 * \brief Moves the linear system to the device, if the GPU path is in use.
246 * \note This and DownloadSolution are the only places where b and x cross the bus. The
247 * work vectors of the solvers never do, they are allocated on the device and read back
248 * only through the reductions.
249 */
250 void UploadSystem(bool useCuda) const {
251#ifdef SU2_ENABLE_CUDA_KERNELS
252 if constexpr (su2_gpu_capable_v<ScalarType>) {
253 if (!useCuda) return;
255 LinSysRes_ptr->HtDTransfer();
256 LinSysSol_ptr->HtDTransfer();
258 }
260 }
261#endif
262 }
263
264 /*!
265 * \brief Brings the solution back from the device and returns to host evaluation.
266 */
267 void DownloadSolution(bool useCuda) const {
268#ifdef SU2_ENABLE_CUDA_KERNELS
269 if constexpr (su2_gpu_capable_v<ScalarType>) {
270 if (!useCuda) return;
272 LinSysSol_ptr->DtHTransfer();
274 }
276 }
277#endif
278 }
279
280 /*!
281 * \brief Used by Solve for compatibility between passive and active CSysVector.
282 * \param[in] LinSysRes - Linear system residual
283 * \param[in,out] LinSysSol - Linear system solution
284 * \param[in] useCuda - Whether to move the system to the device for the solve.
285 */
286 template <class OtherType>
287 void HandleTemporariesIn(const CSysVector<OtherType>& LinSysRes, CSysVector<OtherType>& LinSysSol, bool useCuda) {
289 if constexpr (std::is_same_v<ScalarType, OtherType>) {
290 /*--- Same type specialization, temporary variables are not required. ---*/
292 LinSysRes_ptr = &LinSysRes;
293 LinSysSol_ptr = &LinSysSol;
294 }
296 UploadSystem(useCuda);
297 } else {
298 /*--- Copy data, the solution is also copied as it serves as initial condition. ---*/
299 LinSysRes_tmp.PassiveCopy(LinSysRes);
300 LinSysSol_tmp.PassiveCopy(LinSysSol);
301
302 /*--- Set the pointers. ---*/
304 LinSysRes_ptr = &LinSysRes_tmp;
305 LinSysSol_ptr = &LinSysSol_tmp;
306 }
308 UploadSystem(useCuda);
309 }
310 }
311
312 /*!
313 * \brief Used by Solve for compatibility between passive and active CSysVector.
314 * \param[out] LinSysSol - Linear system solution
315 * \param[in] useCuda - Whether the system was solved on the device.
316 */
317 template <class OtherType>
318 void HandleTemporariesOut(CSysVector<OtherType>& LinSysSol, bool useCuda) {
320 DownloadSolution(useCuda);
321 if constexpr (std::is_same_v<ScalarType, OtherType>) {
322 /*--- Same type specialization, temporary variables are not required. ---*/
324 LinSysRes_ptr = nullptr;
325 LinSysSol_ptr = nullptr;
326 }
328 } else {
329 /*--- Copy data, only the temporary solution needs to be copied. ---*/
330 LinSysSol.PassiveCopy(LinSysSol_tmp);
331
332 /*--- Reset the pointers. ---*/
334 LinSysRes_ptr = nullptr;
335 LinSysSol_ptr = nullptr;
336 }
338 }
339 }
340
341 /*--- TODO(pedro): The deflation part using Eigen does not compile in forward AD mode.
342 * So we need a dummy template to avoid instantiating this function for directdiff. ---*/
343 template <class Dummy = int>
344 unsigned long FGCRODR_LinSolverImpl(const VectorType& b, VectorType& x, const ProductType& mat_vec,
345 const PrecondType& precond, ScalarType tol, unsigned long max_iter,
346 ScalarType& residual, bool monitoring, const CConfig* config, FgcrodrMode mode,
347 unsigned long custom_m) const;
348
349 /*!
350 * \brief Creates the inner solver for nested preconditioning if the settings allow it.
351 * \returns True if the inner solver can be used.
352 */
353 bool SetupInnerSolver(unsigned short kind_solver, const CConfig* config);
354
355 public:
356 /*!
357 * \brief default constructor of the class.
358 * \param[in] linear_solver_mode - enum, to let CSysSolve know in what context it is
359 */
361
362 /*! \brief Conjugate Gradient method
363 * \param[in] b - the right hand size vector
364 * \param[in,out] x - on entry the intial guess, on exit the solution
365 * \param[in] mat_vec - object that defines matrix-vector product
366 * \param[in] precond - object that defines preconditioner
367 * \param[in] tol - tolerance with which to solve the system
368 * \param[in] m - maximum size of the search subspace
369 * \param[out] residual - final normalized residual
370 * \param[in] monitoring - turn on priting residuals from solver to screen
371 * \param[in] config - Definition of the particular problem.
372 */
373 unsigned long CG_LinSolver(const VectorType& b, VectorType& x, const ProductType& mat_vec, const PrecondType& precond,
374 ScalarType tol, unsigned long m, ScalarType& residual, bool monitoring,
375 const CConfig* config) const;
376
377 /*!
378 * \brief Flexible Generalized Minimal Residual method
379 * \param[in] b - the right hand size vector
380 * \param[in,out] x - on entry the intial guess, on exit the solution
381 * \param[in] mat_vec - object that defines matrix-vector product
382 * \param[in] precond - object that defines preconditioner
383 * \param[in] tol - tolerance with which to solve the system
384 * \param[in] m - maximum size of the search subspace
385 * \param[out] residual - final normalized residual
386 * \param[in] monitoring - turn on priting residuals from solver to screen
387 * \param[in] config - Definition of the particular problem.
388 */
389 unsigned long FGMRES_LinSolver(const VectorType& b, VectorType& x, const ProductType& mat_vec,
390 const PrecondType& precond, ScalarType tol, unsigned long m, ScalarType& residual,
391 bool monitoring, const CConfig* config) const;
392
393 /*!
394 * \brief Flexible Generalized Minimal Residual method with restarts (frequency comes from config).
395 */
396 unsigned long RFGMRES_LinSolver(const VectorType& b, VectorType& x, const ProductType& mat_vec,
397 const PrecondType& precond, ScalarType tol, unsigned long m, ScalarType& residual,
398 bool monitoring, const CConfig* config) const;
399
400 /*!
401 * \brief Flexible Generalized Conjugate Residual Method with Inner Orthogonalization and Deflated Restarting.
402 * \param[in] b - the right hand size vector
403 * \param[in,out] x - on entry the intial guess, on exit the solution
404 * \param[in] mat_vec - object that defines matrix-vector product
405 * \param[in] precond - object that defines preconditioner
406 * \param[in] tol - tolerance with which to solve the system
407 * \param[in] max_iter - maximum number of iterations
408 * \param[out] residual - final normalized residual
409 * \param[in] monitoring - turn on priting residuals from solver to screen
410 * \param[in] config - Definition of the particular problem.
411 * \param[in] mode - See FgcrodrMode.
412 * \param[in] custom_m - alternative maximum size of the search subspace, overrides the config value if != 0.
413 */
414 unsigned long FGCRODR_LinSolver(const VectorType& b, VectorType& x, const ProductType& mat_vec,
415 const PrecondType& precond, ScalarType tol, unsigned long max_iter,
416 ScalarType& residual, bool monitoring, const CConfig* config,
417 FgcrodrMode mode = FgcrodrMode::NORMAL, unsigned long custom_m = 0) const;
418
419 /*!
420 * \brief Biconjugate Gradient Stabilized Method (BCGSTAB)
421 * \param[in] b - the right hand size vector
422 * \param[in,out] x - on entry the intial guess, on exit the solution
423 * \param[in] mat_vec - object that defines matrix-vector product
424 * \param[in] precond - object that defines preconditioner
425 * \param[in] tol - tolerance with which to solve the system
426 * \param[in] m - maximum size of the search subspace
427 * \param[out] residual - final normalized residual
428 * \param[in] monitoring - turn on priting residuals from solver to screen
429 * \param[in] config - Definition of the particular problem.
430 */
431 unsigned long BCGSTAB_LinSolver(const VectorType& b, VectorType& x, const ProductType& mat_vec,
432 const PrecondType& precond, ScalarType tol, unsigned long m, ScalarType& residual,
433 bool monitoring, const CConfig* config) const;
434
435 /*!
436 * \brief Generic smoother (modified Richardson iteration with preconditioner)
437 * \param[in] b - the right hand size vector
438 * \param[in,out] x - on entry the intial guess, on exit the solution
439 * \param[in] mat_vec - object that defines matrix-vector product
440 * \param[in] precond - object that defines preconditioner
441 * \param[in] tol - tolerance with which to solve the system
442 * \param[in] m - maximum number of iterations
443 * \param[out] residual - final normalized residual
444 * \param[in] monitoring - turn on priting residuals from solver to screen
445 * \param[in] config - Definition of the particular problem.
446 */
447 unsigned long Smoother_LinSolver(const VectorType& b, VectorType& x, const ProductType& mat_vec,
448 const PrecondType& precond, ScalarType tol, unsigned long m, ScalarType& residual,
449 bool monitoring, const CConfig* config) const;
450
451 /*!
452 * \brief Solve the linear system using a Krylov subspace method
453 * \param[in] Jacobian - Jacobian Matrix for the linear system
454 * \param[in] LinSysRes - Linear system residual
455 * \param[in,out] LinSysSol - Linear system solution
456 * \param[in] geometry - Geometrical definition of the problem.
457 * \param[in] config - Definition of the particular problem.
458 */
459 unsigned long Solve(MatrixType& Jacobian, const CSysVector<su2double>& LinSysRes, CSysVector<su2double>& LinSysSol,
460 CGeometry* geometry, const CConfig* config);
461
462 /*!
463 * \brief Solve the adjoint linear system using a Krylov subspace method
464 * \param[in] Jacobian - Jacobian Matrix for the linear system
465 * \param[in] LinSysRes - Linear system residual
466 * \param[in,out] LinSysSol - Linear system solution
467 * \param[in] geometry - Geometrical definition of the problem.
468 * \param[in] config - Definition of the particular problem.
469 * \param[in] directCall - If this method is called directly, or in AD context.
470 */
471 unsigned long Solve_b(MatrixType& Jacobian, const VectorType& LinSysRes, VectorType& LinSysSol, CGeometry* geometry,
472 const CConfig* config, bool directCall = true);
473
474 template <class OtherType, su2enable_if<!std::is_same_v<ScalarType, OtherType>> = 0>
475 unsigned long Solve_b(MatrixType& Jacobian, const CSysVector<OtherType>& LinSysRes, CSysVector<OtherType>& LinSysSol,
476 CGeometry* geometry, const CConfig* config, bool directCall = true) {
477 HandleTemporariesIn(LinSysRes, LinSysSol, false);
478 auto iter = Solve_b(Jacobian, *LinSysRes_ptr, *LinSysSol_ptr, geometry, config, directCall);
479 HandleTemporariesOut(LinSysSol, false);
480 return iter;
481 }
482
483 /*!
484 * \brief Get the number of iterations.
485 * \return The number of iterations done by Solve or Solve_b
486 */
487 inline unsigned long GetIterations() const { return Iterations; }
488
489 /*!
490 * \brief Get the final residual.
491 * \return The residual at the end of Solve or Solve_b
492 */
493 inline ScalarType GetResidual() const { return Residual; }
494
495 /*!
496 * \brief Set the type of the tolerance for stoping the linear solvers (RELATIVE or ABSOLUTE).
497 */
498 inline void SetToleranceType(LinearToleranceType type) { tol_type = type; }
499
500 /*!
501 * \brief Assume the initial solution is 0 to save one product, or don't.
502 */
503 inline void SetxIsZero(bool isZero) { xIsZero = isZero; }
504
505 /*!
506 * \brief Set whether to recompute residuals at the end (while monitoring only).
507 */
508 inline void SetRecomputeResidual(bool recompRes) { recomputeRes = recompRes; }
509
510 /*!
511 * \brief Set the screen output frequency during monitoring.
512 */
513 inline void SetMonitoringFrequency(bool frequency) { monitorFreq = frequency; }
514
515 /*!
516 * \brief Discard FGCRODR's deflation vectors for the next solve.
517 */
518 inline void ResetDeflation() const { k = 0; }
519};
LinearToleranceType
Definition CSysSolve.hpp:60
Declararion and inlines of the vector class used in the solution of large, distributed,...
#define BEGIN_SU2_DEVICE_REGION
Definition CSysVector.hpp:101
#define END_SU2_DEVICE_REGION
Definition CSysVector.hpp:102
A templated matrix/vector-like object.
Definition C2DContainer.hpp:374
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Parent class for defining the geometry of the problem (complete geometry, multigrid agglomerated geom...
Definition CGeometry.hpp:75
Abstract base class for defining matrix-vector products.
Definition CMatrixVectorProduct.hpp:56
Abstract base class for defining a preconditioning operation.
Definition CPreconditioner.hpp:103
Main class for defining block-compressed-row-storage sparse matrices.
Definition CSysMatrix.hpp:256
Class for solving linear systems using classical and Krylov-subspace iterative methods.
Definition CSysSolve.hpp:86
void SetToleranceType(LinearToleranceType type)
Set the type of the tolerance for stoping the linear solvers (RELATIVE or ABSOLUTE).
Definition CSysSolve.hpp:498
ScalarType Scalar
Definition CSysSolve.hpp:89
unsigned long Solve_b(MatrixType &Jacobian, const CSysVector< OtherType > &LinSysRes, CSysVector< OtherType > &LinSysSol, CGeometry *geometry, const CConfig *config, bool directCall=true)
Definition CSysSolve.hpp:475
unsigned long FGCRODR_LinSolver(const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long max_iter, ScalarType &residual, bool monitoring, const CConfig *config, FgcrodrMode mode=FgcrodrMode::NORMAL, unsigned long custom_m=0) const
Flexible Generalized Conjugate Residual Method with Inner Orthogonalization and Deflated Restarting.
Definition CSysSolve.cpp:1045
unsigned long Smoother_LinSolver(const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long m, ScalarType &residual, bool monitoring, const CConfig *config) const
Generic smoother (modified Richardson iteration with preconditioner)
Definition CSysSolve.cpp:1248
unsigned long Solve_b(MatrixType &Jacobian, const VectorType &LinSysRes, VectorType &LinSysSol, CGeometry *geometry, const CConfig *config, bool directCall=true)
Solve the adjoint linear system using a Krylov subspace method.
Definition CSysSolve.cpp:1639
ScalarType GetResidual() const
Get the final residual.
Definition CSysSolve.hpp:493
void ResetDeflation() const
Discard FGCRODR's deflation vectors for the next solve.
Definition CSysSolve.hpp:518
void SetMonitoringFrequency(bool frequency)
Set the screen output frequency during monitoring.
Definition CSysSolve.hpp:513
CSysMatrix< ScalarType > MatrixType
Definition CSysSolve.hpp:91
unsigned long BCGSTAB_LinSolver(const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long m, ScalarType &residual, bool monitoring, const CConfig *config) const
Biconjugate Gradient Stabilized Method (BCGSTAB)
Definition CSysSolve.cpp:1059
void SetxIsZero(bool isZero)
Assume the initial solution is 0 to save one product, or don't.
Definition CSysSolve.hpp:503
unsigned long CG_LinSolver(const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long m, ScalarType &residual, bool monitoring, const CConfig *config) const
Conjugate Gradient method.
Definition CSysSolve.cpp:270
CPreconditioner< ScalarType > PrecondType
Definition CSysSolve.hpp:93
unsigned long RFGMRES_LinSolver(const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long m, ScalarType &residual, bool monitoring, const CConfig *config) const
Flexible Generalized Minimal Residual method with restarts (frequency comes from config).
Definition CSysSolve.cpp:627
unsigned long Solve(MatrixType &Jacobian, const CSysVector< su2double > &LinSysRes, CSysVector< su2double > &LinSysSol, CGeometry *geometry, const CConfig *config)
Solve the linear system using a Krylov subspace method.
Definition CSysSolve.cpp:1406
CSysVector< ScalarType > VectorType
Definition CSysSolve.hpp:90
unsigned long FGMRES_LinSolver(const VectorType &b, VectorType &x, const ProductType &mat_vec, const PrecondType &precond, ScalarType tol, unsigned long m, ScalarType &residual, bool monitoring, const CConfig *config) const
Flexible Generalized Minimal Residual method.
Definition CSysSolve.cpp:421
unsigned long GetIterations() const
Get the number of iterations.
Definition CSysSolve.hpp:487
CMatrixVectorProduct< ScalarType > ProductType
Definition CSysSolve.hpp:92
void SetRecomputeResidual(bool recompRes)
Set whether to recompute residuals at the end (while monitoring only).
Definition CSysSolve.hpp:508
Class for holding and manipulating vectors needed by linear solvers.
Definition CSysVector.hpp:195
void DtHTransfer(bool trigger=true) const
Performs the memory copy from device to host.
Definition CSysVectorGPU.cu:200
void HtDTransfer(bool trigger=true) const
Performs the memory copy from host to device.
Definition CSysVectorGPU.cu:193
void PassiveCopy(const CSysVector< T > &other)
Set our values (resizing if required) by copying from other, the derivative information is lost.
Definition CSysVector.hpp:379
#define SU2_IGNORE_WARNING(WARNING)
Definition code_config.hpp:219
#define SU2_RESTORE_WARNING
Definition code_config.hpp:220
FgcrodrMode
Modes of using FGCRODR.
Definition CSysSolve.hpp:66
@ SAME_MAT
"NORMAL" but knowing the matrix did not change.
@ NORMAL
Solve the linear system.
void SetUseDeviceExpressions(bool)
Definition CSysVector.hpp:120
#define BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS
Definition omp_structure.hpp:187
#define END_SU2_OMP_SAFE_GLOBAL_ACCESS
Definition omp_structure.hpp:192
LINEAR_SOLVER_MODE
Type of operation for the linear system solver, changes the source of solver options.
Definition option_structure.hpp:3027
@ STANDARD
Operate in standard mode.
#define SU2_ZONE_SCOPED
Definition tracy_structure.hpp:39