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