MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
solvers.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_SOLVERS
13#define MFEM_SOLVERS
14
15#include "../config/config.hpp"
16#include "densemat.hpp"
17#include "handle.hpp"
18#include <memory>
19
20#ifdef MFEM_USE_MPI
21#include <mpi.h>
22#endif
23
24#ifdef MFEM_USE_SUITESPARSE
25#include "sparsemat.hpp"
26#include <umfpack.h>
27#include <klu.h>
28#endif
29
30namespace mfem
31{
32
33class BilinearForm;
34
35/// Abstract base class for an iterative solver monitor
37{
38protected:
39 /// The last IterativeSolver to which this monitor was attached.
41
42public:
44
46
47 /// Monitor the residual vector r
48 virtual void MonitorResidual(int it, real_t norm, const Vector &r,
49 bool final)
50 {
51 }
52
53 /// Monitor the solution vector x
54 virtual void MonitorSolution(int it, real_t norm, const Vector &x,
55 bool final)
56 {
57 }
58
59 /** @brief This method is invoked by IterativeSolver::SetMonitor, informing
60 the monitor which IterativeSolver is using it. */
62 { iter_solver = &solver; }
63};
64
65/// Abstract base class for iterative solver
66class IterativeSolver : public Solver
67{
68public:
69 /** @brief Settings for the output behavior of the IterativeSolver.
70
71 By default, all output is suppressed. The construction of the desired
72 print level can be achieved through a builder pattern, for example
73
74 PrintLevel().Errors().Warnings()
75
76 constructs the print level with only errors and warnings enabled.
77 */
79 {
80 /** @brief If a fatal problem has been detected the failure will be
81 reported to @ref mfem::err. */
82 bool errors = false;
83 /** @brief If a non-fatal problem has been detected some context-specific
84 information will be reported to @ref mfem::out */
85 bool warnings = false;
86 /** @brief Detailed information about each iteration will be reported to
87 @ref mfem::out */
88 bool iterations = false;
89 /** @brief A summary of the solver process will be reported after the last
90 iteration to @ref mfem::out */
91 bool summary = false;
92 /** @brief Information about the first and last iteration will be printed
93 to @ref mfem::out */
94 bool first_and_last = false;
95
96 /// Initializes the print level to suppress
97 PrintLevel() = default;
98
99 /** @name Builder
100 These methods are utilized to construct PrintLevel objects through a
101 builder approach by chaining the function calls in this group. */
102 ///@{
103 PrintLevel &None() { *this = PrintLevel(); return *this; }
104 PrintLevel &Warnings() { warnings=true; return *this; }
105 PrintLevel &Errors() { errors=true; return *this; }
106 PrintLevel &Iterations() { iterations=true; return *this; }
107 PrintLevel &FirstAndLast() { first_and_last=true; return *this; }
108 PrintLevel &Summary() { summary=true; return *this; }
111 ///@}
112 };
113
114#ifdef MFEM_USE_MPI
115private:
116 int dot_prod_type; // 0 - local, 1 - global over 'comm'
117 MPI_Comm comm = MPI_COMM_NULL;
118#endif
119
120protected:
124
125 /// @name Reporting (protected attributes and member functions)
126 ///@{
127
128 /** @brief (DEPRECATED) Legacy print level definition, which is left for
129 compatibility with custom iterative solvers.
130 @deprecated #print_options should be used instead. */
131 int print_level = -1;
132
133 /** @brief Output behavior for the iterative solver.
134
135 This primarily controls the output behavior of the iterative solvers
136 provided by this library. This member must be synchronized with
137 #print_level to ensure compatibility with custom iterative solvers. */
139
140 /// Convert a legacy print level integer to a PrintLevel object
142
143 /// @brief Use some heuristics to guess a legacy print level corresponding to
144 /// the given PrintLevel.
146 ///@}
147
148 /// @name Convergence (protected attributes)
149 ///@{
150
151 /// Limit for the number of iterations the solver is allowed to do
153
154 /// Relative tolerance.
156
157 /// Absolute tolerance.
159
160 ///@}
161
162 /// @name Solver statistics (protected attributes)
163 /// Every IterativeSolver is expected to define these in its Mult() call.
164 ///@{
165
166 mutable int final_iter = -1;
167 mutable bool converged = false;
168 mutable real_t initial_norm = -1.0, final_norm = -1.0;
169
170 ///@}
171
172 /** @brief Return the standard (l2, i.e., Euclidean) inner product of
173 @a x and @a y
174 @details Overriding this method in a derived class enables a
175 custom inner product.
176 */
177 virtual real_t Dot(const Vector &x, const Vector &y) const;
178
179 /// Return the inner product norm of @a x, using the inner product defined by Dot()
180 real_t Norm(const Vector &x) const { return sqrt(Dot(x, x)); }
181
182 /// Monitor both the residual @a r and the solution @a x
183 void Monitor(int it, real_t norm, const Vector& r, const Vector& x,
184 bool final=false) const;
185
186public:
188
189#ifdef MFEM_USE_MPI
190 IterativeSolver(MPI_Comm comm_);
191#endif
192
193 /** @name Convergence
194 @brief Termination criteria for the iterative solvers.
195
196 @details While the convergence criterion is solver specific, most of the
197 provided iterative solvers use one of the following criteria
198
199 $ ||r||_X \leq tol_{rel}||r_0||_X $,
200
201 $ ||r||_X \leq tol_{abs} $,
202
203 $ ||r||_X \leq \max\{ tol_{abs}, tol_{rel} ||r_0||_X \} $,
204
205 where X denotes the space in which the norm is measured. The choice of
206 X depends on the specific iterative solver.
207 */
208 ///@{
209 void SetRelTol(real_t rtol) { rel_tol = rtol; }
210 void SetAbsTol(real_t atol) { abs_tol = atol; }
211 void SetMaxIter(int max_it) { max_iter = max_it; }
212 ///@}
213
214 /** @name Reporting
215 These options control the internal reporting behavior into ::mfem::out
216 and ::mfem::err of the iterative solvers.
217 */
218 ///@{
219
220 /// @brief Legacy method to set the level of verbosity of the solver output.
221 /** This is the old way to control what information will be printed to
222 ::mfem::out and ::mfem::err. The behavior for the print level for all
223 iterative solvers is:
224
225 - -1: Suppress all outputs.
226 - 0: Print information about all detected issues (e.g. no convergence).
227 - 1: Same as level 0, but with detailed information about each
228 iteration.
229 - 2: Print detected issues and a summary when the solver terminates.
230 - 3: Same as 2, but print also the first and last iterations.
231 - >3: Custom print options which are dependent on the specific solver.
232
233 In parallel, only rank 0 produces output.
234
235 @note It is recommended to use @ref SetPrintLevel(PrintLevel) instead.
236
237 @note Some derived classes, like KINSolver, redefine this method and use
238 their own set of print level constants. */
239 virtual void SetPrintLevel(int print_lvl);
240
241 /// @brief Set the level of verbosity of the solver output.
242 /** In parallel, only rank 0 produces outputs. Errors are output to
243 ::mfem::err and all other information to ::mfem::out.
244
245 @note Not all subclasses of IterativeSolver support all possible options.
246
247 @note Some derived classes, like KINSolver, disable this method in favor
248 of SetPrintLevel(int).
249
250 @sa PrintLevel for possible options.
251 */
252 virtual void SetPrintLevel(PrintLevel);
253 ///@}
254
255 /// @name Solver statistics.
256 /// These are valid after the call to Mult().
257 ///@{
258
259 /// Returns the number of iterations taken during the last call to Mult()
260 int GetNumIterations() const { return final_iter; }
261 /// Returns true if the last call to Mult() converged successfully.
262 bool GetConverged() const { return converged; }
263 /// @brief Returns the initial residual norm from the last call to Mult().
264 ///
265 /// This function returns the norm of the residual (or preconditioned
266 /// residual, depending on the solver), computed before the start of the
267 /// iteration.
269 /// @brief Returns the final residual norm after termination of the solver
270 /// during the last call to Mult().
271 ///
272 /// This function returns the norm of the residual (or preconditioned
273 /// residual, depending on the solver), corresponding to the returned
274 /// solution.
275 real_t GetFinalNorm() const { return final_norm; }
276 /// @brief Returns the final residual norm after termination of the solver
277 /// during the last call to Mult(), divided by the initial residual norm.
278 /// Returns -1 if one of these norms is left undefined by the solver.
279 ///
280 /// @sa GetFinalNorm(), GetInitialNorm()
282 {
283 if (final_norm < 0.0 || initial_norm < 0.0) { return -1.0; }
284 return final_norm / initial_norm;
285 }
286
287 ///@}
288
289 /// This should be called before SetOperator
290 virtual void SetPreconditioner(Solver &pr);
291
292 /// Also calls SetOperator for the preconditioner if there is one
293 virtual void SetOperator(const Operator &op) override;
294
295 /// Set the iterative solver monitor
298
299#ifdef MFEM_USE_MPI
300 /** @brief Return the associated MPI communicator, or MPI_COMM_NULL if no
301 communicator is set. */
302 MPI_Comm GetComm() const
303 { return dot_prod_type == 0 ? MPI_COMM_NULL : comm; }
304#endif
305};
306
307
308/// Jacobi smoothing for a given bilinear form (no matrix necessary).
309/** Useful with tensorized, partially assembled operators. Can also be defined
310 by given diagonal vector. This is basic Jacobi iteration; for tolerances,
311 iteration control, etc. wrap with SLISolver. */
313{
314public:
315 /** @brief Default constructor: the diagonal will be computed by subsequent
316 calls to SetOperator() using the Operator method AssembleDiagonal. */
317 /** In this case the array of essential tdofs will be empty. */
318 OperatorJacobiSmoother(const real_t damping=1.0);
319
320 /** Setup a Jacobi smoother with the diagonal of @a a obtained by calling
321 a.AssembleDiagonal(). It is assumed that the underlying operator acts as
322 the identity on entries in ess_tdof_list, corresponding to (assembled)
323 DIAG_ONE policy or ConstrainedOperator in the matrix-free setting.
324
325 @note For objects created with this constructor, calling SetOperator()
326 will only set the internal Operator pointer to the given new Operator
327 without any other changes to the object. This is done to preserve the
328 original behavior of this class. */
330 const Array<int> &ess_tdof_list,
331 const real_t damping=1.0);
332
333 /** Application is by the *inverse* of the given vector. It is assumed that
334 the underlying operator acts as the identity on entries in ess_tdof_list,
335 corresponding to (assembled) DIAG_ONE policy or ConstrainedOperator in
336 the matrix-free setting.
337
338 @note For objects created with this constructor, calling SetOperator()
339 will only set the internal Operator pointer to the given new Operator
340 without any other changes to the object. This is done to preserve the
341 original behavior of this class. */
343 const Array<int> &ess_tdof_list,
344 const real_t damping=1.0);
345
347
348 /// Replace diagonal entries with their absolute values.
349 void SetPositiveDiagonal(bool pos_diag = true) { use_abs_diag = pos_diag; }
350
351 /// Approach the solution of the linear system by applying Jacobi smoothing.
352 void Mult(const Vector &x, Vector &y) const;
353
354 /** @brief Approach the solution of the transposed linear system by applying
355 Jacobi smoothing. */
356 void MultTranspose(const Vector &x, Vector &y) const { Mult(x, y); }
357
358 /** @brief Recompute the diagonal using the method AssembleDiagonal of the
359 given new Operator, @a op. */
360 /** Note that (Par)BilinearForm operators are treated similar to the way they
361 are treated in the constructor that takes a BilinearForm parameter.
362 Specifically, this means that the OperatorJacobiSmoother will work with
363 true-dof vectors even though the size of the BilinearForm may be
364 different.
365
366 When the new Operator, @a op, is not a (Par)BilinearForm, any previously
367 set array of essential true-dofs will be thrown away because in this case
368 any essential b.c. will be handled by the AssembleDiagonal method. */
369 void SetOperator(const Operator &op);
370
371private:
372 Vector dinv;
373 const real_t damping;
374 const Array<int> *ess_tdof_list; // not owned; may be NULL
375 mutable Vector residual;
376 /// Uses absolute values of the diagonal entries.
377 bool use_abs_diag = false;
378
379 const Operator *oper; // not owned
380
381 // To preserve the original behavior, some constructors set this flag to
382 // false to disallow updating the OperatorJacobiSmoother with SetOperator.
383 const bool allow_updates;
384
385public:
386 void Setup(const Vector &diag);
387};
388
389/// Chebyshev accelerated smoothing with given vector, no matrix necessary
390/** Potentially useful with tensorized operators, for example. This is just a
391 very basic Chebyshev iteration, if you want tolerances, iteration control,
392 etc. wrap this with SLISolver. */
394{
395public:
396 /** Application is by *inverse* of the given vector. It is assumed the
397 underlying operator acts as the identity on entries in ess_tdof_list,
398 corresponding to (assembled) DIAG_ONE policy or ConstrainedOperator in
399 the matrix-free setting. The estimated largest eigenvalue of the
400 diagonally preconditoned operator must be provided via
401 max_eig_estimate. */
402 OperatorChebyshevSmoother(const Operator &oper_, const Vector &d,
403 const Array<int>& ess_tdof_list,
404 int order, real_t max_eig_estimate);
405
406 /// Deprecated: see pass-by-reference version above
407 MFEM_DEPRECATED
408 OperatorChebyshevSmoother(const Operator* oper_, const Vector &d,
409 const Array<int>& ess_tdof_list,
410 int order, real_t max_eig_estimate);
411
412 /** Application is by *inverse* of the given vector. It is assumed the
413 underlying operator acts as the identity on entries in ess_tdof_list,
414 corresponding to (assembled) DIAG_ONE policy or ConstrainedOperator in
415 the matrix-free setting. The largest eigenvalue of the diagonally
416 preconditoned operator is estimated internally via a power method. The
417 accuracy of the estimated eigenvalue may be controlled via
418 power_iterations and power_tolerance. */
419#ifdef MFEM_USE_MPI
420 OperatorChebyshevSmoother(const Operator &oper_, const Vector &d,
421 const Array<int>& ess_tdof_list,
422 int order, MPI_Comm comm = MPI_COMM_NULL,
423 int power_iterations = 10,
424 real_t power_tolerance = 1e-8);
425
426 /// Deprecated: see pass-by-reference version above
427 MFEM_DEPRECATED
428 OperatorChebyshevSmoother(const Operator* oper_, const Vector &d,
429 const Array<int>& ess_tdof_list,
430 int order, MPI_Comm comm = MPI_COMM_NULL,
431 int power_iterations = 10,
432 real_t power_tolerance = 1e-8);
433#else
435 const Array<int>& ess_tdof_list,
436 int order, int power_iterations = 10,
437 real_t power_tolerance = 1e-8);
438
439 /// Deprecated: see pass-by-reference version above
440 MFEM_DEPRECATED
441 OperatorChebyshevSmoother(const Operator* oper_, const Vector &d,
442 const Array<int>& ess_tdof_list,
443 int order, int power_iterations = 10,
444 real_t power_tolerance = 1e-8);
445#endif
446
448
449 /** @brief Approach the solution of the linear system by applying Chebyshev
450 smoothing. */
451 void Mult(const Vector &x, Vector &y) const;
452
453 /** @brief Approach the solution of the transposed linear system by applying
454 Chebyshev smoothing. */
455 void MultTranspose(const Vector &x, Vector &y) const { Mult(x, y); }
456
457 void SetOperator(const Operator &op_)
458 {
459 oper = &op_;
460 }
461
462 void Setup();
463
464private:
465 const int order;
466 real_t max_eig_estimate;
467 const int N;
468 Vector dinv;
469 const Vector &diag;
470 Array<real_t> coeffs;
471 const Array<int>& ess_tdof_list;
472 mutable Vector residual;
473 mutable Vector helperVector;
474 const Operator* oper;
475};
476
477
478/// Stationary linear iteration: x <- x + B (b - A x)
480{
481protected:
482 mutable Vector r, z;
483
484 void UpdateVectors();
485
486public:
488
489#ifdef MFEM_USE_MPI
490 SLISolver(MPI_Comm comm_) : IterativeSolver(comm_) { }
491#endif
492
493 virtual void SetOperator(const Operator &op)
495
496 /// Iterative solution of the linear system using Stationary Linear Iteration
497 virtual void Mult(const Vector &b, Vector &x) const;
498};
499
500/// Stationary linear iteration. (tolerances are squared)
501void SLI(const Operator &A, const Vector &b, Vector &x,
502 int print_iter = 0, int max_num_iter = 1000,
503 real_t RTOLERANCE = 1e-12, real_t ATOLERANCE = 1e-24);
504
505/// Preconditioned stationary linear iteration. (tolerances are squared)
506void SLI(const Operator &A, Solver &B, const Vector &b, Vector &x,
507 int print_iter = 0, int max_num_iter = 1000,
508 real_t RTOLERANCE = 1e-12, real_t ATOLERANCE = 1e-24);
509
510
511/// Conjugate gradient method
513{
514protected:
515 mutable Vector r, d, z;
516
517 void UpdateVectors();
518
519public:
521
522#ifdef MFEM_USE_MPI
523 CGSolver(MPI_Comm comm_) : IterativeSolver(comm_) { }
524#endif
525
526 virtual void SetOperator(const Operator &op)
528
529 /** @brief Iterative solution of the linear system using the Conjugate
530 Gradient method. */
531 virtual void Mult(const Vector &b, Vector &x) const;
532};
533
534/// Conjugate gradient method. (tolerances are squared)
535void CG(const Operator &A, const Vector &b, Vector &x,
536 int print_iter = 0, int max_num_iter = 1000,
537 real_t RTOLERANCE = 1e-12, real_t ATOLERANCE = 1e-24);
538
539/// Preconditioned conjugate gradient method. (tolerances are squared)
540void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x,
541 int print_iter = 0, int max_num_iter = 1000,
542 real_t RTOLERANCE = 1e-12, real_t ATOLERANCE = 1e-24);
543
544
545/// GMRES method
547{
548protected:
549 int m; // see SetKDim()
550
551public:
552 GMRESSolver() { m = 50; }
553
554#ifdef MFEM_USE_MPI
555 GMRESSolver(MPI_Comm comm_) : IterativeSolver(comm_) { m = 50; }
556#endif
557
558 /// Set the number of iteration to perform between restarts, default is 50.
559 void SetKDim(int dim) { m = dim; }
560
561 /// Iterative solution of the linear system using the GMRES method
562 virtual void Mult(const Vector &b, Vector &x) const;
563};
564
565/// FGMRES method
567{
568protected:
569 int m;
570
571public:
572 FGMRESSolver() { m = 50; }
573
574#ifdef MFEM_USE_MPI
575 FGMRESSolver(MPI_Comm comm_) : IterativeSolver(comm_) { m = 50; }
576#endif
577
578 void SetKDim(int dim) { m = dim; }
579
580 /// Iterative solution of the linear system using the FGMRES method.
581 virtual void Mult(const Vector &b, Vector &x) const;
582};
583
584/// GMRES method. (tolerances are squared)
585int GMRES(const Operator &A, Vector &x, const Vector &b, Solver &M,
586 int &max_iter, int m, real_t &tol, real_t atol, int printit);
587
588/// GMRES method. (tolerances are squared)
589void GMRES(const Operator &A, Solver &B, const Vector &b, Vector &x,
590 int print_iter = 0, int max_num_iter = 1000, int m = 50,
591 real_t rtol = 1e-12, real_t atol = 1e-24);
592
593
594/// BiCGSTAB method
596{
597protected:
598 mutable Vector p, phat, s, shat, t, v, r, rtilde;
599
600 void UpdateVectors();
601
602public:
604
605#ifdef MFEM_USE_MPI
606 BiCGSTABSolver(MPI_Comm comm_) : IterativeSolver(comm_) { }
607#endif
608
609 virtual void SetOperator(const Operator &op)
611
612 /// Iterative solution of the linear system using the BiCGSTAB method
613 virtual void Mult(const Vector &b, Vector &x) const;
614};
615
616/// BiCGSTAB method. (tolerances are squared)
617int BiCGSTAB(const Operator &A, Vector &x, const Vector &b, Solver &M,
618 int &max_iter, real_t &tol, real_t atol, int printit);
619
620/// BiCGSTAB method. (tolerances are squared)
621void BiCGSTAB(const Operator &A, Solver &B, const Vector &b, Vector &x,
622 int print_iter = 0, int max_num_iter = 1000,
623 real_t rtol = 1e-12, real_t atol = 1e-24);
624
625
626/// MINRES method
628{
629protected:
630 mutable Vector v0, v1, w0, w1, q;
631 mutable Vector u1; // used in the preconditioned version
632
633public:
635
636#ifdef MFEM_USE_MPI
637 MINRESSolver(MPI_Comm comm_) : IterativeSolver(comm_) { }
638#endif
639
640 virtual void SetPreconditioner(Solver &pr)
641 {
643 if (oper) { u1.SetSize(width); }
644 }
645
646 virtual void SetOperator(const Operator &op);
647
648 /// Iterative solution of the linear system using the MINRES method
649 virtual void Mult(const Vector &b, Vector &x) const;
650};
651
652/// MINRES method without preconditioner. (tolerances are squared)
653void MINRES(const Operator &A, const Vector &b, Vector &x, int print_it = 0,
654 int max_it = 1000, real_t rtol = 1e-12, real_t atol = 1e-24);
655
656/// MINRES method with preconditioner. (tolerances are squared)
657void MINRES(const Operator &A, Solver &B, const Vector &b, Vector &x,
658 int print_it = 0, int max_it = 1000,
659 real_t rtol = 1e-12, real_t atol = 1e-24);
660
661
662/// Newton's method for solving F(x)=b for a given operator F.
663/** The method GetGradient() must be implemented for the operator F.
664 The preconditioner is used (in non-iterative mode) to evaluate
665 the action of the inverse gradient of the operator. */
667{
668protected:
669 mutable Vector r, c;
670 mutable Operator *grad;
671
672 // Adaptive linear solver rtol variables
673
674 // Method to determine rtol, 0 means the adaptive algorithm is deactivated.
676 // rtol to use in first iteration
678 // Maximum rtol
680 // Function norm ||F(x)|| of the previous iterate
681 mutable real_t fnorm_last = 0.0;
682 // Linear residual norm of the previous iterate
683 mutable real_t lnorm_last = 0.0;
684 // Forcing term (linear residual rtol) from the previous iterate
685 mutable real_t eta_last = 0.0;
686 // Eisenstat-Walker factor gamma
688 // Eisenstat-Walker factor alpha
690
691 /** @brief Method for the adaptive linear solver rtol invoked before the
692 linear solve. */
693 void AdaptiveLinRtolPreSolve(const Vector &x,
694 const int it,
695 const real_t fnorm) const;
696
697 /** @brief Method for the adaptive linear solver rtol invoked after the
698 linear solve. */
699 void AdaptiveLinRtolPostSolve(const Vector &x,
700 const Vector &b,
701 const int it,
702 const real_t fnorm) const;
703
704public:
706
707#ifdef MFEM_USE_MPI
708 NewtonSolver(MPI_Comm comm_) : IterativeSolver(comm_) { }
709#endif
710 virtual void SetOperator(const Operator &op);
711
712 /// Set the linear solver for inverting the Jacobian.
713 /** This method is equivalent to calling SetPreconditioner(). */
714 virtual void SetSolver(Solver &solver) { prec = &solver; }
715
716 /// Solve the nonlinear system with right-hand side @a b.
717 /** If `b.Size() != Height()`, then @a b is assumed to be zero. */
718 virtual void Mult(const Vector &b, Vector &x) const;
719
720 /** @brief This method can be overloaded in derived classes to implement line
721 search algorithms. */
722 /** The base class implementation (NewtonSolver) simply returns 1. A return
723 value of 0 indicates a failure, interrupting the Newton iteration. */
724 virtual real_t ComputeScalingFactor(const Vector &x, const Vector &b) const
725 { return 1.0; }
726
727 /** @brief This method can be overloaded in derived classes to perform
728 computations that need knowledge of the newest Newton state. */
729 virtual void ProcessNewState(const Vector &x) const { }
730
731 /// Enable adaptive linear solver relative tolerance algorithm.
732 /** Compute a relative tolerance for the Krylov method after each nonlinear
733 iteration, based on the algorithm presented in [1].
734
735 The maximum linear solver relative tolerance @a rtol_max should be < 1. For
736 @a type 1 the parameters @a alpha and @a gamma are ignored. For @a type 2
737 @a alpha has to be between 0 and 1 and @a gamma between 1 and 2.
738
739 [1] Eisenstat, Stanley C., and Homer F. Walker. "Choosing the forcing terms
740 in an inexact Newton method."
741 */
742 void SetAdaptiveLinRtol(const int type = 2,
743 const real_t rtol0 = 0.5,
744 const real_t rtol_max = 0.9,
745 const real_t alpha = 0.5 * (1.0 + sqrt(5.0)),
746 const real_t gamma = 1.0);
747};
748
749/** L-BFGS method for solving F(x)=b for a given operator F, by minimizing
750 the norm of F(x) - b. Requires only the action of the operator F. */
752{
753protected:
754 int m = 10;
756
758 {
759 for (int i = 0; i < skArray.Size(); i++)
760 {
761 delete skArray[i];
762 delete ykArray[i];
763 }
764 }
765
767 {
769 skArray.SetSize(m);
770 ykArray.SetSize(m);
771 for (int i = 0; i < m; i++)
772 {
773 skArray[i] = new Vector(width);
774 ykArray[i] = new Vector(width);
775 skArray[i]->UseDevice(true);
776 ykArray[i]->UseDevice(true);
777 }
778 }
779
780public:
782
783#ifdef MFEM_USE_MPI
784 LBFGSSolver(MPI_Comm comm_) : NewtonSolver(comm_) { }
785#endif
786
787 virtual void SetOperator(const Operator &op)
788 {
791 }
792
794 {
795 m = dim;
797 }
798
799 /// Solve the nonlinear system with right-hand side @a b.
800 /** If `b.Size() != Height()`, then @a b is assumed to be zero. */
801 virtual void Mult(const Vector &b, Vector &x) const;
802
803 virtual void SetPreconditioner(Solver &pr)
804 { MFEM_WARNING("L-BFGS won't use the given preconditioner."); }
805 virtual void SetSolver(Solver &solver)
806 { MFEM_WARNING("L-BFGS won't use the given solver."); }
807
809};
810
811
812/** Adaptive restarted GMRES.
813 m_max and m_min(=1) are the maximal and minimal restart parameters.
814 m_step(=1) is the step to use for going from m_max and m_min.
815 cf(=0.4) is a desired convergence factor. */
816int aGMRES(const Operator &A, Vector &x, const Vector &b,
817 const Operator &M, int &max_iter,
818 int m_max, int m_min, int m_step, real_t cf,
819 real_t &tol, real_t &atol, int printit);
820
821#ifdef MFEM_USE_HIOP
822class HiopOptimizationProblem;
823#endif
824
825/** Defines operators and constraints for the following optimization problem:
826 *
827 * Find x that minimizes the objective function F(x), subject to
828 * C(x) = c_e,
829 * d_lo <= D(x) <= d_hi,
830 * x_lo <= x <= x_hi.
831 *
832 * The operators F, C, D must take input of the same size (same width).
833 * Gradients of F, C, D might be needed, depending on the OptimizationSolver.
834 * When used with Hiop, gradients of C and D must be DenseMatrices.
835 * F always returns a scalar value, see CalcObjective(), CalcObjectiveGrad().
836 * C and D can have arbitrary heights.
837 * C and D can be NULL, meaning that their constraints are not used.
838 *
839 * When used in parallel, all Vectors are assumed to be true dof vectors, and
840 * the operators are expected to be defined for tdof vectors. */
842{
843#ifdef MFEM_USE_HIOP
845#endif
846
847private:
848 /// See NewX().
849 mutable bool new_x = true;
850
851protected:
852 /// Not owned, some can remain unused (NULL).
853 const Operator *C, *D;
854 const Vector *c_e, *d_lo, *d_hi, *x_lo, *x_hi;
855
856 /// Implementations of CalcObjective() and CalcObjectiveGrad() can use this
857 /// method to check if the argument Vector x has been changed after the last
858 /// call to CalcObjective() or CalcObjectiveGrad().
859 /// The result is on by default, and gets set by the OptimizationSolver.
860 bool NewX() const { return new_x; }
861
862public:
863 const int input_size;
864
865 /// In parallel, insize is the number of the local true dofs.
866 OptimizationProblem(int insize, const Operator *C_, const Operator *D_);
867
868 /// Objective F(x). In parallel, the result should be reduced over tasks.
869 virtual real_t CalcObjective(const Vector &x) const = 0;
870 /// The result grad is expected to enter with the correct size.
871 virtual void CalcObjectiveGrad(const Vector &x, Vector &grad) const
872 { MFEM_ABORT("The objective gradient is not implemented."); }
873
874 void SetEqualityConstraint(const Vector &c);
875 void SetInequalityConstraint(const Vector &dl, const Vector &dh);
876 void SetSolutionBounds(const Vector &xl, const Vector &xh);
877
878 const Operator *GetC() const { return C; }
879 const Operator *GetD() const { return D; }
880 const Vector *GetEqualityVec() const { return c_e; }
881 const Vector *GetInequalityVec_Lo() const { return d_lo; }
882 const Vector *GetInequalityVec_Hi() const { return d_hi; }
883 const Vector *GetBoundsVec_Lo() const { return x_lo; }
884 const Vector *GetBoundsVec_Hi() const { return x_hi; }
885
886 int GetNumConstraints() const;
887};
888
889/// Abstract solver for OptimizationProblems.
891{
892protected:
894
895public:
897#ifdef MFEM_USE_MPI
898 OptimizationSolver(MPI_Comm comm_): IterativeSolver(comm_), problem(NULL) { }
899#endif
901
902 /** This function is virtual as solvers might need to perform some initial
903 * actions (e.g. validation) with the OptimizationProblem. */
906
907 virtual void Mult(const Vector &xt, Vector &x) const = 0;
908
909 virtual void SetPreconditioner(Solver &pr)
910 { MFEM_ABORT("Not meaningful for this solver."); }
911 virtual void SetOperator(const Operator &op)
912 { MFEM_ABORT("Not meaningful for this solver."); }
913};
914
915/** SLBQP optimizer:
916 * (S)ingle (L)inearly Constrained with (B)ounds (Q)uadratic (P)rogram
917 *
918 * Minimize || x-x_t ||, subject to
919 * sum w_i x_i = a,
920 * x_lo <= x <= x_hi.
921 */
923{
924protected:
927
928 /// Solve QP at fixed lambda
929 inline real_t solve(real_t l, const Vector &xt, Vector &x, int &nclip) const
930 {
931 add(xt, l, w, x);
932 if (problem == NULL) { x.median(lo,hi); }
933 else
934 {
937 }
938 nclip++;
939 if (problem == NULL) { return Dot(w, x) - a; }
940 else
941 {
942 Vector c(1);
943 // Includes parallel communication.
944 problem->GetC()->Mult(x, c);
945
946 return c(0) - (*problem->GetEqualityVec())(0);
947 }
948 }
949
950 inline void print_iteration(int it, real_t r, real_t l) const;
951
952public:
954
955#ifdef MFEM_USE_MPI
956 SLBQPOptimizer(MPI_Comm comm_) : OptimizationSolver(comm_) { }
957#endif
958
959 /** Setting an OptimizationProblem will overwrite the Vectors given by
960 * SetBounds and SetLinearConstraint. The objective function remains
961 * unchanged. */
963
964 void SetBounds(const Vector &lo_, const Vector &hi_);
965 void SetLinearConstraint(const Vector &w_, real_t a_);
966
967 /** We let the target values play the role of the initial vector xt, from
968 * which the operator generates the optimal vector x. */
969 virtual void Mult(const Vector &xt, Vector &x) const;
970};
971
972/** Block ILU solver:
973 * Performs a block ILU(k) approximate factorization with specified block
974 * size. Currently only k=0 is supported. This is useful as a preconditioner
975 * for DG-type discretizations, where the system matrix has a natural
976 * (elemental) block structure.
977 *
978 * In the case of DG discretizations, the block size should usually be set to
979 * either ndofs_per_element or vdim*ndofs_per_element (if the finite element
980 * space has Ordering::byVDIM). The block size must evenly divide the size of
981 * the matrix.
982 *
983 * Renumbering the blocks is also supported by specifying a reordering method.
984 * Currently greedy minimum discarded fill ordering and no reordering are
985 * supported. Renumbering the blocks can lead to a much better approximate
986 * factorization.
987 */
988class BlockILU : public Solver
989{
990public:
991
992 /// The reordering method used by the BlockILU factorization.
993 enum class Reordering
994 {
996 NONE
997 };
998
999 /** Create an "empty" BlockILU solver. SetOperator must be called later to
1000 * actually form the factorization
1001 */
1002 BlockILU(int block_size_,
1004 int k_fill_ = 0);
1005
1006 /** Create a block ILU approximate factorization for the matrix @a op.
1007 * @a op should be of type either SparseMatrix or HypreParMatrix. In the
1008 * case that @a op is a HypreParMatrix, the ILU factorization is performed
1009 * on the diagonal blocks of the parallel decomposition.
1010 */
1011 BlockILU(const Operator &op, int block_size_ = 1,
1013 int k_fill_ = 0);
1014
1015 /** Perform the block ILU factorization for the matrix @a op.
1016 * As in the constructor, @a op must either be a SparseMatrix or
1017 * HypreParMatrix
1018 */
1019 void SetOperator(const Operator &op);
1020
1021 /// Solve the system `LUx = b`, where `L` and `U` are the block ILU factors.
1022 void Mult(const Vector &b, Vector &x) const;
1023
1024 /** Get the I array for the block CSR representation of the factorization.
1025 * Similar to SparseMatrix::GetI(). Mostly used for testing.
1026 */
1027 int *GetBlockI() { return IB.GetData(); }
1028
1029 /** Get the J array for the block CSR representation of the factorization.
1030 * Similar to SparseMatrix::GetJ(). Mostly used for testing.
1031 */
1032 int *GetBlockJ() { return JB.GetData(); }
1033
1034 /** Get the data array for the block CSR representation of the factorization.
1035 * Similar to SparseMatrix::GetData(). Mostly used for testing.
1036 */
1037 real_t *GetBlockData() { return AB.Data(); }
1038
1039private:
1040 /// Set up the block CSR structure corresponding to a sparse matrix @a A
1041 void CreateBlockPattern(const class SparseMatrix &A);
1042
1043 /// Perform the block ILU factorization
1044 void Factorize();
1045
1046 int block_size;
1047
1048 /// Fill level for block ILU(k) factorizations. Only k=0 is supported.
1049 int k_fill;
1050
1051 Reordering reordering;
1052
1053 /// Temporary vector used in the Mult() function.
1054 mutable Vector y;
1055
1056 /// Permutation and inverse permutation vectors for the block reordering.
1057 Array<int> P, Pinv;
1058
1059 /** Block CSR storage of the factorization. The block upper triangular part
1060 * stores the U factor. The L factor implicitly has identity on the diagonal
1061 * blocks, and the rest of L is given by the strictly block lower triangular
1062 * part.
1063 */
1064 Array<int> IB, ID, JB;
1065 DenseTensor AB;
1066
1067 /// DB(i) stores the LU factorization of the i'th diagonal block
1068 mutable DenseTensor DB;
1069 /// Pivot arrays for the LU factorizations given by #DB
1070 mutable Array<int> ipiv;
1071};
1072
1073
1074/// Monitor that checks whether the residual is zero at a given set of dofs.
1075/** This monitor is useful for checking if the initial guess, rhs, operator, and
1076 preconditioner are properly setup for solving in the subspace with imposed
1077 essential boundary conditions. */
1079{
1080protected:
1081 const Array<int> *ess_dofs_list; ///< Not owned
1082
1083public:
1084 ResidualBCMonitor(const Array<int> &ess_dofs_list_)
1085 : ess_dofs_list(&ess_dofs_list_) { }
1086
1087 void MonitorResidual(int it, real_t norm, const Vector &r,
1088 bool final) override;
1089};
1090
1091
1092#ifdef MFEM_USE_SUITESPARSE
1093
1094/// Direct sparse solver using UMFPACK
1095class UMFPackSolver : public Solver
1096{
1097protected:
1100 void *Numeric;
1101 SuiteSparse_long *AI, *AJ;
1102
1103 void Init();
1104
1105public:
1106 real_t Control[UMFPACK_CONTROL];
1107 mutable real_t Info[UMFPACK_INFO];
1108
1109 /** @brief For larger matrices, if the solver fails, set the parameter @a
1110 use_long_ints_ = true. */
1111 UMFPackSolver(bool use_long_ints_ = false)
1112 : use_long_ints(use_long_ints_) { Init(); }
1113 /** @brief Factorize the given SparseMatrix using the defaults. For larger
1114 matrices, if the solver fails, set the parameter @a use_long_ints_ =
1115 true. */
1116 UMFPackSolver(SparseMatrix &A, bool use_long_ints_ = false)
1117 : use_long_ints(use_long_ints_) { Init(); SetOperator(A); }
1118
1119 /** @brief Factorize the given Operator @a op which must be a SparseMatrix.
1120
1121 The factorization uses the parameters set in the #Control data member.
1122 @note This method calls SparseMatrix::SortColumnIndices() with @a op,
1123 modifying the matrix if the column indices are not already sorted. */
1124 virtual void SetOperator(const Operator &op);
1125
1126 /// Set the print level field in the #Control data member.
1127 void SetPrintLevel(int print_lvl) { Control[UMFPACK_PRL] = print_lvl; }
1128
1129 /// Direct solution of the linear system using UMFPACK
1130 virtual void Mult(const Vector &b, Vector &x) const;
1131
1132 /// Direct solution of the transposed linear system using UMFPACK
1133 virtual void MultTranspose(const Vector &b, Vector &x) const;
1134
1135 virtual ~UMFPackSolver();
1136};
1137
1138/// Direct sparse solver using KLU
1139class KLUSolver : public Solver
1140{
1141protected:
1143 klu_symbolic *Symbolic;
1144 klu_numeric *Numeric;
1145
1146 void Init();
1147
1148public:
1150 : mat(0),Symbolic(0),Numeric(0)
1151 { Init(); }
1153 : mat(0),Symbolic(0),Numeric(0)
1154 { Init(); SetOperator(A); }
1155
1156 // Works on sparse matrices only; calls SparseMatrix::SortColumnIndices().
1157 virtual void SetOperator(const Operator &op);
1158
1159 /// Direct solution of the linear system using KLU
1160 virtual void Mult(const Vector &b, Vector &x) const;
1161
1162 /// Direct solution of the transposed linear system using KLU
1163 virtual void MultTranspose(const Vector &b, Vector &x) const;
1164
1165 virtual ~KLUSolver();
1166
1167 mutable klu_common Common;
1168};
1169
1170#endif // MFEM_USE_SUITESPARSE
1171
1172/// Block diagonal solver for A, each block is inverted by direct solver
1174{
1175 SparseMatrix& block_dof;
1176 mutable Array<int> local_dofs;
1177 mutable Vector sub_rhs;
1178 mutable Vector sub_sol;
1179 std::unique_ptr<DenseMatrixInverse[]> block_solvers;
1180public:
1181 /// block_dof is a boolean matrix, block_dof(i, j) = 1 if j-th dof belongs to
1182 /// i-th block, block_dof(i, j) = 0 otherwise.
1183 DirectSubBlockSolver(const SparseMatrix& A, const SparseMatrix& block_dof);
1184
1185 /// Direct solution of the block diagonal linear system
1186 virtual void Mult(const Vector &x, Vector &y) const;
1187 virtual void SetOperator(const Operator &op) { }
1188};
1189
1190/// Solver S such that I - A * S = (I - A * S1) * (I - A * S0).
1191/// That is, S = S0 + S1 - S1 * A * S0.
1192class ProductSolver : public Solver
1193{
1194 OperatorPtr A;
1195 OperatorPtr S0;
1196 OperatorPtr S1;
1197public:
1199 bool ownA, bool ownS0, bool ownS1)
1200 : Solver(A_->NumRows()), A(A_, ownA), S0(S0_, ownS0), S1(S1_, ownS1) { }
1201
1202 /// Solution of the linear system using a product of subsolvers
1203 virtual void Mult(const Vector &x, Vector &y) const;
1204
1205 /// Solution of the transposed linear system using a product of subsolvers
1206 virtual void MultTranspose(const Vector &x, Vector &y) const;
1207 virtual void SetOperator(const Operator &op) { }
1208};
1209
1210/// Solver wrapper which orthogonalizes the input and output vector
1211/**
1212 * OrthoSolver wraps an existing Solver and orthogonalizes the input vector
1213 * before passing it to the Mult() method of the Solver. This is a convenience
1214 * implementation to handle e.g. a Poisson problem with pure Neumann boundary
1215 * conditions, where this procedure removes the Nullspace.
1216 */
1217class OrthoSolver : public Solver
1218{
1219private:
1220#ifdef MFEM_USE_MPI
1221 MPI_Comm mycomm;
1222 mutable HYPRE_BigInt global_size;
1223 const bool parallel;
1224#else
1225 mutable int global_size;
1226#endif
1227
1228public:
1229 OrthoSolver();
1230#ifdef MFEM_USE_MPI
1231 OrthoSolver(MPI_Comm mycomm_);
1232#endif
1233
1234 /// Set the solver used by the OrthoSolver.
1235 /** The action of the OrthoSolver is given by P * s * P where P is the
1236 projection to the subspace of vectors with zero sum. Calling this method
1237 is required before calling SetOperator() or Mult(). */
1238 void SetSolver(Solver &s);
1239
1240 /// Set the Operator that is the OrthoSolver is to invert (approximately).
1241 /** The Operator @a op is simply forwarded to the solver object given by
1242 SetSolver() which needs to be called before this method. Calling this
1243 method is optional when the solver already has an associated Operator. */
1244 virtual void SetOperator(const Operator &op);
1245
1246 /** @brief Perform the action of the OrthoSolver: P * solver * P where P is
1247 the projection to the subspace of vectors with zero sum. */
1248 /** @note The projection P can be written as P = I - 1 1^T / (1^T 1) where
1249 I is the identity matrix and 1 is the column-vector with all components
1250 equal to 1. */
1251 void Mult(const Vector &b, Vector &x) const;
1252
1253private:
1254 Solver *solver = nullptr;
1255
1256 mutable Vector b_ortho;
1257
1258 void Orthogonalize(const Vector &v, Vector &v_ortho) const;
1259};
1260
1261#ifdef MFEM_USE_MPI
1262/** This smoother does relaxations on an auxiliary space (determined by a map
1263 from the original space to the auxiliary space provided by the user).
1264 The smoother on the auxiliary space is a HypreSmoother. Its options can be
1265 modified through GetSmoother.
1266 For example, the space can be the nullspace of div/curl, in which case the
1267 smoother can be used to construct a Hiptmair smoother. */
1269{
1270 OperatorPtr aux_map_;
1271 OperatorPtr aux_system_;
1272 OperatorPtr aux_smoother_;
1273 void Mult(const Vector &x, Vector &y, bool transpose) const;
1274public:
1276 bool op_is_symmetric = true, bool own_aux_map = false);
1277 virtual void Mult(const Vector &x, Vector &y) const { Mult(x, y, false); }
1278 virtual void MultTranspose(const Vector &x, Vector &y) const
1279 { Mult(x, y, true); }
1280 virtual void SetOperator(const Operator &op) { }
1281 HypreSmoother& GetSmoother() { return *aux_smoother_.As<HypreSmoother>(); }
1282 using Operator::Mult;
1283};
1284#endif // MFEM_USE_MPI
1285
1286#ifdef MFEM_USE_LAPACK
1287/** Non-negative least squares (NNLS) solver class, for computing a vector
1288 with non-negative entries approximately satisfying an under-determined
1289 linear system. */
1290class NNLSSolver : public Solver
1291{
1292public:
1293 NNLSSolver();
1294
1296
1297 /// The operator must be a DenseMatrix.
1298 void SetOperator(const Operator &op) override;
1299
1300 /** @brief Compute the non-negative least squares solution to the
1301 underdetermined system. */
1302 void Mult(const Vector &w, Vector &sol) const override;
1303
1304 /** @brief
1305 Set verbosity. If set to 0: print nothing; if 1: just print results;
1306 if 2: print short update on every iteration; if 3: print longer update
1307 each iteration.
1308 */
1309 void SetVerbosity(int v) { verbosity_ = v; }
1310
1311 /// Set the target absolute residual norm tolerance for convergence
1312 void SetTolerance(real_t tol) { const_tol_ = tol; }
1313
1314 /// Set the minimum number of nonzeros required for the solution.
1315 void SetMinNNZ(int min_nnz) { min_nnz_ = min_nnz; }
1316
1317 /** @brief Set the maximum number of nonzeros required for the solution, as
1318 an early termination condition. */
1319 void SetMaxNNZ(int max_nnz) { max_nnz_ = max_nnz; }
1320
1321 /** @brief Set threshold on relative change in residual over nStallCheck_
1322 iterations. */
1324 { res_change_termination_tol_ = tol; }
1325
1326 /** @brief Set the magnitude of projected residual entries that are
1327 considered zero. Increasing this value relaxes solution constraints. */
1328 void SetZeroTolerance(real_t tol) { zero_tol_ = tol; }
1329
1330 /// Set RHS vector constant shift, defining rhs_lb and rhs_ub in Solve().
1331 void SetRHSDelta(real_t d) { rhs_delta_ = d; }
1332
1333 /// Set the maximum number of outer iterations in Solve().
1334 void SetOuterIterations(int n) { n_outer_ = n; }
1335
1336 /// Set the maximum number of inner iterations in Solve().
1337 void SetInnerIterations(int n) { n_inner_ = n; }
1338
1339 /// Set the number of iterations to use for stall checking.
1340 void SetStallCheck(int n) { nStallCheck_ = n; }
1341
1342 /// Set a flag to determine whether to call NormalizeConstraints().
1343 void SetNormalize(bool n) { normalize_ = n; }
1344
1345 /** @brief
1346 * Enumerated types of QRresidual mode. Options are 'off': the residual is
1347 * calculated normally, 'on': the residual is calculated using the QR
1348 * method, 'hybrid': the residual is calculated normally until we experience
1349 * rounding errors, then the QR method is used. The default is 'hybrid',
1350 * which should see the best performance. Recommend using 'hybrid' or 'off'
1351 * only, since 'on' is computationally expensive.
1352 */
1353 enum class QRresidualMode {off, on, hybrid};
1354
1355 /** @brief
1356 * Set the residual calculation mode for the NNLS solver. See QRresidualMode
1357 * enum above for details.
1358 */
1359 void SetQRResidualMode(const QRresidualMode qr_residual_mode);
1360
1361 /**
1362 * @brief Solve the NNLS problem. Specifically, we find a vector @a soln,
1363 * such that rhs_lb < mat*soln < rhs_ub is satisfied, where mat is the
1364 * DenseMatrix input to SetOperator().
1365 *
1366 * The method by which we find the solution is the active-set method
1367 * developed by Lawson and Hanson (1974) using lapack. To decrease rounding
1368 * errors in the case of very tight tolerances, we have the option to compute
1369 * the residual using the QR factorization of A, by res = b - Q*Q^T*b. This
1370 * residual calculation results in less rounding error, but is more
1371 * computationally expensive. To select whether to use the QR residual method
1372 * or not, see set_qrresidual_mode above.
1373 */
1374 void Solve(const Vector& rhs_lb, const Vector& rhs_ub, Vector& soln) const;
1375
1376 /** @brief
1377 * Normalize the constraints such that the tolerances for each constraint
1378 * (i.e. (UB - LB)/2) are equal. This seems to help the performance in most
1379 * cases.
1380 */
1381 void NormalizeConstraints(Vector& rhs_lb, Vector& rhs_ub) const;
1382
1383private:
1384 const DenseMatrix *mat;
1385
1386 real_t const_tol_;
1387 int min_nnz_; // minimum number of nonzero entries
1388 mutable int max_nnz_; // maximum number of nonzero entries
1389 int verbosity_;
1390
1391 /**
1392 * @brief Threshold on relative change in residual over nStallCheck_
1393 * iterations, for stall sensing.
1394 */
1395 real_t res_change_termination_tol_;
1396
1397 real_t zero_tol_;
1398 real_t rhs_delta_;
1399 int n_outer_;
1400 int n_inner_;
1401 int nStallCheck_;
1402
1403 bool normalize_;
1404
1405 mutable bool NNLS_qrres_on_;
1406 QRresidualMode qr_residual_mode_;
1407
1408 mutable Vector row_scaling_;
1409};
1410#endif // MFEM_USE_LAPACK
1411
1412}
1413
1414#endif // MFEM_SOLVERS
T * GetData()
Returns the data.
Definition array.hpp:118
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Definition solvers.hpp:1278
HypreSmoother & GetSmoother()
Definition solvers.hpp:1281
AuxSpaceSmoother(const HypreParMatrix &op, HypreParMatrix *aux_map, bool op_is_symmetric=true, bool own_aux_map=false)
Definition solvers.cpp:3513
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
Definition solvers.hpp:1280
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
Definition solvers.hpp:1277
BiCGSTAB method.
Definition solvers.hpp:596
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the BiCGSTAB method.
Definition solvers.cpp:1380
BiCGSTABSolver(MPI_Comm comm_)
Definition solvers.hpp:606
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.hpp:609
A "square matrix" operator for the associated FE space and BLFIntegrators The sum of all the BLFInteg...
int * GetBlockJ()
Definition solvers.hpp:1032
Reordering
The reordering method used by the BlockILU factorization.
Definition solvers.hpp:994
BlockILU(int block_size_, Reordering reordering_=Reordering::MINIMUM_DISCARDED_FILL, int k_fill_=0)
Definition solvers.cpp:2749
real_t * GetBlockData()
Definition solvers.hpp:1037
void Mult(const Vector &b, Vector &x) const
Solve the system LUx = b, where L and U are the block ILU factors.
Definition solvers.cpp:2998
int * GetBlockI()
Definition solvers.hpp:1027
void SetOperator(const Operator &op)
Definition solvers.cpp:2767
Conjugate gradient method.
Definition solvers.hpp:513
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.hpp:526
CGSolver(MPI_Comm comm_)
Definition solvers.hpp:523
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the Conjugate Gradient method.
Definition solvers.cpp:718
void UpdateVectors()
Definition solvers.cpp:709
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
Rank 3 tensor (array of matrices)
Block diagonal solver for A, each block is inverted by direct solver.
Definition solvers.hpp:1174
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
Definition solvers.hpp:1187
DirectSubBlockSolver(const SparseMatrix &A, const SparseMatrix &block_dof)
Definition solvers.cpp:3360
virtual void Mult(const Vector &x, Vector &y) const
Direct solution of the block diagonal linear system.
Definition solvers.cpp:3375
FGMRES method.
Definition solvers.hpp:567
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the FGMRES method.
Definition solvers.cpp:1168
FGMRESSolver(MPI_Comm comm_)
Definition solvers.hpp:575
void SetKDim(int dim)
Definition solvers.hpp:578
GMRES method.
Definition solvers.hpp:547
void SetKDim(int dim)
Set the number of iteration to perform between restarts, default is 50.
Definition solvers.hpp:559
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the GMRES method.
Definition solvers.cpp:980
GMRESSolver(MPI_Comm comm_)
Definition solvers.hpp:555
Internal class - adapts the OptimizationProblem class to HiOp's interface.
Definition hiop.hpp:33
Wrapper for hypre's ParCSR matrix class.
Definition hypre.hpp:388
Parallel smoothers in hypre.
Definition hypre.hpp:1020
Abstract base class for an iterative solver monitor.
Definition solvers.hpp:37
void SetIterativeSolver(const IterativeSolver &solver)
This method is invoked by IterativeSolver::SetMonitor, informing the monitor which IterativeSolver is...
Definition solvers.hpp:61
const class IterativeSolver * iter_solver
The last IterativeSolver to which this monitor was attached.
Definition solvers.hpp:40
virtual void MonitorSolution(int it, real_t norm, const Vector &x, bool final)
Monitor the solution vector x.
Definition solvers.hpp:54
virtual void MonitorResidual(int it, real_t norm, const Vector &r, bool final)
Monitor the residual vector r.
Definition solvers.hpp:48
Abstract base class for iterative solver.
Definition solvers.hpp:67
real_t abs_tol
Absolute tolerance.
Definition solvers.hpp:158
void Monitor(int it, real_t norm, const Vector &r, const Vector &x, bool final=false) const
Monitor both the residual r and the solution x.
Definition solvers.cpp:190
real_t rel_tol
Relative tolerance.
Definition solvers.hpp:155
PrintLevel print_options
Output behavior for the iterative solver.
Definition solvers.hpp:138
real_t GetFinalNorm() const
Returns the final residual norm after termination of the solver during the last call to Mult().
Definition solvers.hpp:275
virtual void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.cpp:179
virtual real_t Dot(const Vector &x, const Vector &y) const
Return the standard (l2, i.e., Euclidean) inner product of x and y.
Definition solvers.cpp:55
const Operator * oper
Definition solvers.hpp:121
void SetRelTol(real_t rtol)
Definition solvers.hpp:209
real_t GetFinalRelNorm() const
Returns the final residual norm after termination of the solver during the last call to Mult(),...
Definition solvers.hpp:281
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Definition solvers.cpp:173
int print_level
(DEPRECATED) Legacy print level definition, which is left for compatibility with custom iterative sol...
Definition solvers.hpp:131
int GetNumIterations() const
Returns the number of iterations taken during the last call to Mult()
Definition solvers.hpp:260
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
Definition solvers.cpp:71
int max_iter
Limit for the number of iterations the solver is allowed to do.
Definition solvers.hpp:152
void SetMaxIter(int max_it)
Definition solvers.hpp:211
MPI_Comm GetComm() const
Return the associated MPI communicator, or MPI_COMM_NULL if no communicator is set.
Definition solvers.hpp:302
real_t GetInitialNorm() const
Returns the initial residual norm from the last call to Mult().
Definition solvers.hpp:268
static int GuessLegacyPrintLevel(PrintLevel)
Use some heuristics to guess a legacy print level corresponding to the given PrintLevel.
Definition solvers.cpp:149
IterativeSolverMonitor * monitor
Definition solvers.hpp:123
void SetMonitor(IterativeSolverMonitor &m)
Set the iterative solver monitor.
Definition solvers.hpp:296
bool GetConverged() const
Returns true if the last call to Mult() converged successfully.
Definition solvers.hpp:262
PrintLevel FromLegacyPrintLevel(int)
Convert a legacy print level integer to a PrintLevel object.
Definition solvers.cpp:114
void SetAbsTol(real_t atol)
Definition solvers.hpp:210
real_t Norm(const Vector &x) const
Return the inner product norm of x, using the inner product defined by Dot()
Definition solvers.hpp:180
Direct sparse solver using KLU.
Definition solvers.hpp:1140
virtual void MultTranspose(const Vector &b, Vector &x) const
Direct solution of the transposed linear system using KLU.
Definition solvers.cpp:3336
virtual ~KLUSolver()
Definition solvers.cpp:3350
klu_symbolic * Symbolic
Definition solvers.hpp:1143
virtual void Mult(const Vector &b, Vector &x) const
Direct solution of the linear system using KLU.
Definition solvers.cpp:3322
SparseMatrix * mat
Definition solvers.hpp:1142
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
Definition solvers.cpp:3291
klu_common Common
Definition solvers.hpp:1167
KLUSolver(SparseMatrix &A)
Definition solvers.hpp:1152
klu_numeric * Numeric
Definition solvers.hpp:1144
LBFGSSolver(MPI_Comm comm_)
Definition solvers.hpp:784
Array< Vector * > skArray
Definition solvers.hpp:755
void InitializeStorageVectors()
Definition solvers.hpp:766
virtual void SetSolver(Solver &solver)
Set the linear solver for inverting the Jacobian.
Definition solvers.hpp:805
void SetHistorySize(int dim)
Definition solvers.hpp:793
virtual ~LBFGSSolver()
Definition solvers.hpp:808
void DeleteStorageVectors()
Definition solvers.hpp:757
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.hpp:787
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Definition solvers.hpp:803
Array< Vector * > ykArray
Definition solvers.hpp:755
virtual void Mult(const Vector &b, Vector &x) const
Solve the nonlinear system with right-hand side b.
Definition solvers.cpp:2009
MINRES method.
Definition solvers.hpp:628
MINRESSolver(MPI_Comm comm_)
Definition solvers.hpp:637
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the MINRES method.
Definition solvers.cpp:1616
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.cpp:1595
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Definition solvers.hpp:640
void SetNormalize(bool n)
Set a flag to determine whether to call NormalizeConstraints().
Definition solvers.hpp:1343
void SetResidualChangeTolerance(real_t tol)
Set threshold on relative change in residual over nStallCheck_ iterations.
Definition solvers.hpp:1323
void SetRHSDelta(real_t d)
Set RHS vector constant shift, defining rhs_lb and rhs_ub in Solve().
Definition solvers.hpp:1331
void Solve(const Vector &rhs_lb, const Vector &rhs_ub, Vector &soln) const
Solve the NNLS problem. Specifically, we find a vector soln, such that rhs_lb < mat*soln < rhs_ub is ...
Definition solvers.cpp:3689
QRresidualMode
Enumerated types of QRresidual mode. Options are 'off': the residual is calculated normally,...
Definition solvers.hpp:1353
void SetZeroTolerance(real_t tol)
Set the magnitude of projected residual entries that are considered zero. Increasing this value relax...
Definition solvers.hpp:1328
void SetInnerIterations(int n)
Set the maximum number of inner iterations in Solve().
Definition solvers.hpp:1337
void Mult(const Vector &w, Vector &sol) const override
Compute the non-negative least squares solution to the underdetermined system.
Definition solvers.cpp:3641
void SetQRResidualMode(const QRresidualMode qr_residual_mode)
Set the residual calculation mode for the NNLS solver. See QRresidualMode enum above for details.
Definition solvers.cpp:3600
void SetOperator(const Operator &op) override
The operator must be a DenseMatrix.
Definition solvers.cpp:3587
void SetStallCheck(int n)
Set the number of iterations to use for stall checking.
Definition solvers.hpp:1340
void NormalizeConstraints(Vector &rhs_lb, Vector &rhs_ub) const
Normalize the constraints such that the tolerances for each constraint (i.e. (UB - LB)/2) are equal....
Definition solvers.cpp:3609
void SetTolerance(real_t tol)
Set the target absolute residual norm tolerance for convergence.
Definition solvers.hpp:1312
void SetOuterIterations(int n)
Set the maximum number of outer iterations in Solve().
Definition solvers.hpp:1334
void SetMinNNZ(int min_nnz)
Set the minimum number of nonzeros required for the solution.
Definition solvers.hpp:1315
void SetMaxNNZ(int max_nnz)
Set the maximum number of nonzeros required for the solution, as an early termination condition.
Definition solvers.hpp:1319
void SetVerbosity(int v)
Set verbosity. If set to 0: print nothing; if 1: just print results; if 2: print short update on ever...
Definition solvers.hpp:1309
Newton's method for solving F(x)=b for a given operator F.
Definition solvers.hpp:667
void SetAdaptiveLinRtol(const int type=2, const real_t rtol0=0.5, const real_t rtol_max=0.9, const real_t alpha=0.5 *(1.0+sqrt(5.0)), const real_t gamma=1.0)
Enable adaptive linear solver relative tolerance algorithm.
Definition solvers.cpp:1929
void AdaptiveLinRtolPreSolve(const Vector &x, const int it, const real_t fnorm) const
Method for the adaptive linear solver rtol invoked before the linear solve.
Definition solvers.cpp:1942
Operator * grad
Definition solvers.hpp:670
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.cpp:1810
NewtonSolver(MPI_Comm comm_)
Definition solvers.hpp:708
virtual real_t ComputeScalingFactor(const Vector &x, const Vector &b) const
This method can be overloaded in derived classes to implement line search algorithms.
Definition solvers.hpp:724
void AdaptiveLinRtolPostSolve(const Vector &x, const Vector &b, const int it, const real_t fnorm) const
Method for the adaptive linear solver rtol invoked after the linear solve.
Definition solvers.cpp:1989
virtual void ProcessNewState(const Vector &x) const
This method can be overloaded in derived classes to perform computations that need knowledge of the n...
Definition solvers.hpp:729
virtual void SetSolver(Solver &solver)
Set the linear solver for inverting the Jacobian.
Definition solvers.hpp:714
virtual void Mult(const Vector &b, Vector &x) const
Solve the nonlinear system with right-hand side b.
Definition solvers.cpp:1821
Chebyshev accelerated smoothing with given vector, no matrix necessary.
Definition solvers.hpp:394
void SetOperator(const Operator &op_)
Set/update the solver for the given operator.
Definition solvers.hpp:457
void Mult(const Vector &x, Vector &y) const
Approach the solution of the linear system by applying Chebyshev smoothing.
Definition solvers.cpp:485
OperatorChebyshevSmoother(const Operator &oper_, const Vector &d, const Array< int > &ess_tdof_list, int order, int power_iterations=10, real_t power_tolerance=1e-8)
void MultTranspose(const Vector &x, Vector &y) const
Approach the solution of the transposed linear system by applying Chebyshev smoothing.
Definition solvers.hpp:455
OperatorChebyshevSmoother(const Operator &oper_, const Vector &d, const Array< int > &ess_tdof_list, int order, real_t max_eig_estimate)
Definition solvers.cpp:331
Pointer to an Operator of a specified type.
Definition handle.hpp:34
OpType * As() const
Return the Operator pointer statically cast to a specified OpType. Similar to the method Get().
Definition handle.hpp:104
Jacobi smoothing for a given bilinear form (no matrix necessary).
Definition solvers.hpp:313
void Setup(const Vector &diag)
Definition solvers.cpp:277
OperatorJacobiSmoother(const real_t damping=1.0)
Default constructor: the diagonal will be computed by subsequent calls to SetOperator() using the Ope...
Definition solvers.cpp:200
void SetPositiveDiagonal(bool pos_diag=true)
Replace diagonal entries with their absolute values.
Definition solvers.hpp:349
void SetOperator(const Operator &op)
Recompute the diagonal using the method AssembleDiagonal of the given new Operator,...
Definition solvers.cpp:241
void MultTranspose(const Vector &x, Vector &y) const
Approach the solution of the transposed linear system by applying Jacobi smoothing.
Definition solvers.hpp:356
void Mult(const Vector &x, Vector &y) const
Approach the solution of the linear system by applying Jacobi smoothing.
Definition solvers.cpp:303
Abstract operator.
Definition operator.hpp:25
int width
Dimension of the input / number of columns in the matrix.
Definition operator.hpp:28
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
int NumRows() const
Get the number of rows (size of output) of the Operator. Synonym with Height().
Definition operator.hpp:69
virtual void CalcObjectiveGrad(const Vector &x, Vector &grad) const
The result grad is expected to enter with the correct size.
Definition solvers.hpp:871
const Vector * GetEqualityVec() const
Definition solvers.hpp:880
const Operator * C
Not owned, some can remain unused (NULL).
Definition solvers.hpp:853
void SetSolutionBounds(const Vector &xl, const Vector &xh)
Definition solvers.cpp:2334
void SetEqualityConstraint(const Vector &c)
Definition solvers.cpp:2316
int GetNumConstraints() const
Definition solvers.cpp:2342
virtual real_t CalcObjective(const Vector &x) const =0
Objective F(x). In parallel, the result should be reduced over tasks.
const Operator * D
Definition solvers.hpp:853
const Vector * GetInequalityVec_Hi() const
Definition solvers.hpp:882
const Operator * GetC() const
Definition solvers.hpp:878
const Vector * GetBoundsVec_Hi() const
Definition solvers.hpp:884
const Operator * GetD() const
Definition solvers.hpp:879
OptimizationProblem(int insize, const Operator *C_, const Operator *D_)
In parallel, insize is the number of the local true dofs.
Definition solvers.cpp:2306
const Vector * GetInequalityVec_Lo() const
Definition solvers.hpp:881
const Vector * GetBoundsVec_Lo() const
Definition solvers.hpp:883
void SetInequalityConstraint(const Vector &dl, const Vector &dh)
Definition solvers.cpp:2324
Abstract solver for OptimizationProblems.
Definition solvers.hpp:891
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.hpp:911
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Definition solvers.hpp:909
virtual ~OptimizationSolver()
Definition solvers.hpp:900
virtual void Mult(const Vector &xt, Vector &x) const =0
Operator application: y=A(x).
const OptimizationProblem * problem
Definition solvers.hpp:893
virtual void SetOptimizationProblem(const OptimizationProblem &prob)
Definition solvers.hpp:904
OptimizationSolver(MPI_Comm comm_)
Definition solvers.hpp:898
Solver wrapper which orthogonalizes the input and output vector.
Definition solvers.hpp:1218
void Mult(const Vector &b, Vector &x) const
Perform the action of the OrthoSolver: P * solver * P where P is the projection to the subspace of ve...
Definition solvers.cpp:3455
OrthoSolver(MPI_Comm mycomm_)
void SetSolver(Solver &s)
Set the solver used by the OrthoSolver.
Definition solvers.cpp:3436
virtual void SetOperator(const Operator &op)
Set the Operator that is the OrthoSolver is to invert (approximately).
Definition solvers.cpp:3445
ProductSolver(Operator *A_, Solver *S0_, Solver *S1_, bool ownA, bool ownS0, bool ownS1)
Definition solvers.hpp:1198
virtual void MultTranspose(const Vector &x, Vector &y) const
Solution of the transposed linear system using a product of subsolvers.
Definition solvers.cpp:3407
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
Definition solvers.hpp:1207
virtual void Mult(const Vector &x, Vector &y) const
Solution of the linear system using a product of subsolvers.
Definition solvers.cpp:3390
Monitor that checks whether the residual is zero at a given set of dofs.
Definition solvers.hpp:1079
void MonitorResidual(int it, real_t norm, const Vector &r, bool final) override
Monitor the residual vector r.
Definition solvers.cpp:3049
const Array< int > * ess_dofs_list
Not owned.
Definition solvers.hpp:1081
ResidualBCMonitor(const Array< int > &ess_dofs_list_)
Definition solvers.hpp:1084
virtual void Mult(const Vector &xt, Vector &x) const
Definition solvers.cpp:2384
virtual void SetOptimizationProblem(const OptimizationProblem &prob)
Definition solvers.cpp:2350
SLBQPOptimizer(MPI_Comm comm_)
Definition solvers.hpp:956
void SetBounds(const Vector &lo_, const Vector &hi_)
Definition solvers.cpp:2363
void SetLinearConstraint(const Vector &w_, real_t a_)
Definition solvers.cpp:2369
void print_iteration(int it, real_t r, real_t l) const
Definition solvers.cpp:2375
real_t solve(real_t l, const Vector &xt, Vector &x, int &nclip) const
Solve QP at fixed lambda.
Definition solvers.hpp:929
Stationary linear iteration: x <- x + B (b - A x)
Definition solvers.hpp:480
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using Stationary Linear Iteration.
Definition solvers.cpp:531
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.hpp:493
SLISolver(MPI_Comm comm_)
Definition solvers.hpp:490
void UpdateVectors()
Definition solvers.cpp:525
Base class for solvers.
Definition operator.hpp:683
Data type sparse matrix.
Definition sparsemat.hpp:51
Direct sparse solver using UMFPACK.
Definition solvers.hpp:1096
SuiteSparse_long * AJ
Definition solvers.hpp:1101
UMFPackSolver(bool use_long_ints_=false)
For larger matrices, if the solver fails, set the parameter use_long_ints_ = true.
Definition solvers.hpp:1111
virtual void SetOperator(const Operator &op)
Factorize the given Operator op which must be a SparseMatrix.
Definition solvers.cpp:3102
real_t Control[UMFPACK_CONTROL]
Definition solvers.hpp:1106
virtual void Mult(const Vector &b, Vector &x) const
Direct solution of the linear system using UMFPACK.
Definition solvers.cpp:3197
SparseMatrix * mat
Definition solvers.hpp:1099
virtual void MultTranspose(const Vector &b, Vector &x) const
Direct solution of the transposed linear system using UMFPACK.
Definition solvers.cpp:3232
SuiteSparse_long * AI
Definition solvers.hpp:1101
real_t Info[UMFPACK_INFO]
Definition solvers.hpp:1107
void SetPrintLevel(int print_lvl)
Set the print level field in the Control data member.
Definition solvers.hpp:1127
UMFPackSolver(SparseMatrix &A, bool use_long_ints_=false)
Factorize the given SparseMatrix using the defaults. For larger matrices, if the solver fails,...
Definition solvers.hpp:1116
virtual ~UMFPackSolver()
Definition solvers.cpp:3269
Vector data type.
Definition vector.hpp:80
void median(const Vector &lo, const Vector &hi)
v = median(v,lo,hi) entrywise. Implementation assumes lo <= hi.
Definition vector.cpp:554
void SetSize(int s)
Resize the vector to size s.
Definition vector.hpp:538
int dim
Definition ex24.cpp:53
prob_type prob
Definition ex25.cpp:156
HYPRE_Int HYPRE_BigInt
real_t b
Definition lissajous.cpp:42
real_t a
Definition lissajous.cpp:41
int BiCGSTAB(const Operator &A, Vector &x, const Vector &b, Solver &M, int &max_iter, real_t &tol, real_t atol, int printit)
BiCGSTAB method. (tolerances are squared)
Definition solvers.cpp:1572
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
Definition table.cpp:476
void add(const Vector &v1, const Vector &v2, Vector &v)
Definition vector.cpp:316
int GMRES(const Operator &A, Vector &x, const Vector &b, Solver &M, int &max_iter, int m, real_t &tol, real_t atol, int printit)
GMRES method. (tolerances are squared)
Definition solvers.cpp:1342
int aGMRES(const Operator &A, Vector &x, const Vector &b, const Operator &M, int &max_iter, int m_max, int m_min, int m_step, real_t cf, real_t &tol, real_t &atol, int printit)
Definition solvers.cpp:2151
void SLI(const Operator &A, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Stationary linear iteration. (tolerances are squared)
Definition solvers.cpp:677
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
Definition solvers.cpp:913
void CG(const Operator &A, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Conjugate gradient method. (tolerances are squared)
Definition solvers.cpp:898
void MINRES(const Operator &A, const Vector &b, Vector &x, int print_it, int max_it, real_t rtol, real_t atol)
MINRES method without preconditioner. (tolerances are squared)
Definition solvers.cpp:1782
float real_t
Definition config.hpp:43
RefCoord s[3]
Settings for the output behavior of the IterativeSolver.
Definition solvers.hpp:79
bool errors
If a fatal problem has been detected the failure will be reported to mfem::err.
Definition solvers.hpp:82
bool iterations
Detailed information about each iteration will be reported to mfem::out.
Definition solvers.hpp:88
PrintLevel()=default
Initializes the print level to suppress.
bool warnings
If a non-fatal problem has been detected some context-specific information will be reported to mfem::...
Definition solvers.hpp:85
bool first_and_last
Information about the first and last iteration will be printed to mfem::out.
Definition solvers.hpp:94
bool summary
A summary of the solver process will be reported after the last iteration to mfem::out.
Definition solvers.hpp:91