hypre_solver.h
Go to the documentation of this file.
1// LIC// ====================================================================
2// LIC// This file forms part of oomph-lib, the object-oriented,
3// LIC// multi-physics finite-element library, available
4// LIC// at http://www.oomph-lib.org.
5// LIC//
6// LIC// Copyright (C) 2006-2025 Matthias Heil and Andrew Hazel
7// LIC//
8// LIC// This library is free software; you can redistribute it and/or
9// LIC// modify it under the terms of the GNU Lesser General Public
10// LIC// License as published by the Free Software Foundation; either
11// LIC// version 2.1 of the License, or (at your option) any later version.
12// LIC//
13// LIC// This library is distributed in the hope that it will be useful,
14// LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// LIC// Lesser General Public License for more details.
17// LIC//
18// LIC// You should have received a copy of the GNU Lesser General Public
19// LIC// License along with this library; if not, write to the Free Software
20// LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21// LIC// 02110-1301 USA.
22// LIC//
23// LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24// LIC//
25// LIC//====================================================================
26#ifndef OOMPH_HYPRE_SOLVER_HEADER
27#define OOMPH_HYPRE_SOLVER_HEADER
28
29// Headers required for hypre
30#include "_hypre_utilities.h"
31#include "HYPRE.h"
32#include "HYPRE_parcsr_ls.h"
33#include "HYPRE_krylov.h"
34#include "HYPRE_IJ_mv.h"
35#include "HYPRE_parcsr_mv.h"
36
37// OOMPH-LIB includes
39#include "linear_solver.h"
40#include "preconditioner.h"
41
42// hypre's global error flag
43extern hypre_Error hypre__global_error;
44
45
46namespace oomph
47{
48 //==================================================================
49 /// Helper functions for use with the Hypre library
50 //==================================================================
51 namespace HypreHelpers
52 {
53 /// Number of active Hypre solvers (smart pointer like behaviuor
54 /// to make sure that the initialise/finalize functions are only
55 /// called the required number of times
56 extern unsigned Number_of_active_hypre_solvers;
57
58 /// Default for AMG strength (0.25 recommended for 2D problems;
59 /// larger (0.5-0.75, say) for 3D
60 extern double AMG_strength;
61
62 /// Default AMG coarsening strategy. Coarsening types include:
63 /// 0 = CLJP (parallel coarsening using independent sets)
64 /// 1 = classical RS with no boundary treatment (not recommended
65 /// in parallel)
66 /// 3 = modified RS with 3rd pass to add C points on the boundaries
67 /// 6 = Falgout (uses 1 then CLJP using interior coarse points as
68 /// first independent set)
69 /// 8 = PMIS (parallel coarsening using independent sets - lower
70 /// complexities than 0, maybe also slower convergence)
71 /// 10= HMIS (one pass RS on each processor then PMIS on interior
72 /// coarse points as first independent set)
73 /// 11= One pass RS on each processor (not recommended)
74 extern unsigned AMG_coarsening;
75
76 /// AMG interpolation truncation factor
77 extern double AMG_truncation; // 0.0;
78
79 /// Helper function to check the Hypre error flag, return the
80 /// message associated with any error, and reset the error flag to zero.
81 int check_HYPRE_error_flag(std::ostringstream& message);
82
83 /// Helper function to create a HYPRE_IJVector and HYPRE_ParVector.
84 /// + If no MPI then serial vectors are created
85 /// + If MPI and serial input vector then distributed hypre vectors are
86 /// created
87 /// + If MPI and distributed input vector the distributed output vectors
88 /// are created.
89 extern void create_HYPRE_Vector(const DoubleVector& oomph_vec,
90 const LinearAlgebraDistribution* dist_pt,
91 HYPRE_IJVector& hypre_ij_vector,
92 HYPRE_ParVector& hypre_par_vector);
93
94 /// Helper function to create an empty HYPRE_IJVector and
95 /// HYPRE_ParVector.
96 /// + If no MPI then serial vectors are created
97 /// + If MPI and serial distribution then distributed hypre vectors are
98 /// created
99 /// + If MPI and distributed input distribution the distributed output
100 /// vectors are created.
101 void create_HYPRE_Vector(const LinearAlgebraDistribution* oomph_vec,
102 HYPRE_IJVector& hypre_ij_vector,
103 HYPRE_ParVector& hypre_par_vector);
104
105 /// Helper function to create a serial HYPRE_IJMatrix and
106 /// HYPRE_ParCSRMatrix from a CRDoubleMatrix
107 void create_HYPRE_Matrix(CRDoubleMatrix* oomph_matrix,
108 HYPRE_IJMatrix& hypre_ij_matrix,
109 HYPRE_ParCSRMatrix& hypre_par_matrix,
110 LinearAlgebraDistribution* dist_pt);
111
112 /// Helper function to set Euclid options using a command line
113 /// like array.
114 void euclid_settings_helper(const bool& use_block_jacobi,
115 const bool& use_row_scaling,
116 const bool& use_ilut,
117 const int& level,
118 const double& drop_tol,
119 const int& print_level,
120 HYPRE_Solver& euclid_object);
121
122 } // namespace HypreHelpers
123
124
125 //=====================================================================
126 /// An interface class to the suite of Hypre solvers and preconditioners
127 /// to allow use of:
128 ///
129 /// BoomerAMG (AMG), CG, GMRES or BiCGStab, Euclid (ILU) or
130 /// ParaSails (Approximate inverse)
131 ///
132 /// Hypre's Krylov subspace solvers (CG, GMRES and BiCGStab) may be
133 /// preconditioned using:
134 ///
135 /// BoomerAMG, Euclid or ParaSails
136 ///
137 //====================================================================
139 {
140 public:
141 /// Constructor
143 {
144#ifdef PARANOID
145#ifndef HYPRE_SEQUENTIAL
146 // For the MPI version of Hypre, check MPI_Helpers::setup has been called
148 {
149 std::ostringstream error_message;
150 error_message << "When using the MPI version of Hypre please first\n"
151 << "call function MPI_Helpers::setup()\n";
152 throw OomphLibError(error_message.str(),
155 }
156#endif
157#endif
158
159 // Track number of instances of hypre solvers
161 {
163 }
165
166 // setup the distribution
168
169 // These keep track of which solver and preconditioner
170 // (if any) currently exist
173
174 // Do we want to output info and results of timings?
175 Output_info = true;
176
177 // General control paramaters
178 Tolerance = 1e-10;
179 Max_iter = 100;
182
183 // Default AMG control parameters -- these seem OK;
184 // see hypre documenation for details.
187 {
188 // Jacobi in parallel
190 }
191 else
192 {
193 // Gauss Seidel in serial
195 }
198 AMG_damping = 1.0;
202 AMG_max_levels = 100;
203 AMG_max_row_sum = 1.0;
204 AMG_print_level = 0;
205
206 // Parameters for using Euclicd as an AMG smoother (defaults copied
207 // from the normal defaults listed in the manual).
212 AMGEuclidSmoother_drop_tol = 0; // No dropping
214
215 // Print level for CG, GMRES and BiCGStab
217
218 // Set ParaSails default values
221 ParaSails_thresh = 0.1;
222 ParaSails_filter = 0.1;
223
224 // Set Euclid default values
225 Euclid_droptol = 0.0;
226 Euclid_rowScale = false;
227 Euclid_using_ILUT = false;
228 Euclid_using_BJ = false;
229 Euclid_level = 1;
231
232 // Set to true to periodically check the hypre error flag
233 // and output any messages
234 Hypre_error_messages = false;
235 }
236
237 /// Destructor.
239 {
240 // call function to delete solver data
242
243 // delete teh oomph-lib distribution
245
246 // Track number of instances of hypre solvers
248 {
250 }
251#ifdef PARANOID
253 {
254 std::ostringstream error_message;
255 error_message << "What? HypreHelpers::Number_of_active_hypre_solvers = "
257 << std::endl;
258 throw OomphLibError(error_message.str(),
261 }
262#endif
264 }
265
266 /// Broken copy constructor.
268
269 /// Broken assignment operator.
270 void operator=(const HypreInterface&) = delete;
271
272 /// Turn on the hypre error messages
274 {
276 }
277
278 /// Turn off hypre error messages
280 {
281 Hypre_error_messages = false;
282 }
283
284 /// Enumerated flag to define which Hypre methods are used
285 /// CAREFUL: DON'T CHANGE THE ORDER OF THESE!
296
297 /// Function to return value of which solver (if any) is currently stored.
299 {
300 return Existing_solver;
301 }
302
303 /// Function return value of which preconditioner (if any) is stored.
305 {
307 }
308
309
310 protected:
311 /// Function deletes all solver data.
313
314 /// Function which sets values of First_global_row,
315 /// Last_global_row and other partitioning data and creates the distributed
316 /// Hypre matrix (stored in Matrix_ij/Matrix_par) from the CRDoubleMatrix.
317 void hypre_matrix_setup(CRDoubleMatrix* matrix_pt);
318
319 /// Sets up the data required for to use as an oomph-lib
320 /// LinearSolver or Preconditioner. This must be called after
321 /// the Hypre matrix has been generated using hypre_matrix_setup(...).
322 void hypre_solver_setup();
323
324 /// Helper function performs a solve if any solver
325 /// exists.
327
328 /// Flag is true to output info and results of timings
330
331 /// Maximum number of iterations used in solver.
332 unsigned Max_iter;
333
334 /// Tolerance used to terminate solver.
335 double Tolerance;
336
337 /// Hypre method flag. Valid values are specified in enumeration
338 unsigned Hypre_method;
339
340 /// Preconditioner method flag used with Hypre's PCG,
341 /// GMRES and BiCGStab in solve(...) or resolve(...). Valid values
342 /// are BoomerAMG, Euclid, ParaSails or None (all enumerated above),
343 /// for any other value no preconditioner is set.
345
346 /// Used to set the Hypre printing level for AMG
347 /// 0: no printout
348 /// 1: print setup information
349 /// 2: print solve information
350 /// 3: print setup and solve information
352
353 /// Maximum number of levels used in AMG
355
356 /// Parameter to identify diagonally dominant parts of the matrix in AMG
358
359 /// Flag to determine whether simple smoothers (determined by the
360 /// AMG_simple_smoother flag) or complex smoothers (determined by the
361 /// AMG_complex_smoother flag are used in AMG
363
364 /// Simple smoothing methods used in BoomerAMG.
365 /// To use these methods set AMG_using_simple_smoothing to true.
366 /// Here are the current options (from hypre's HYPRE_parcsr_ls.h):
367 ///
368 /// (Optional) Defines the smoother to be used. It uses the given
369 /// smoother on the fine grid, the up and
370 /// the down cycle and sets the solver on the coarsest level to Gaussian
371 /// elimination (9). The default is \f$\ell_1\f$-Gauss-Seidel, forward solve (13)
372 /// on the down cycle and backward solve (14) on the up cycle.
373 ///
374 /// There are the following options for \e relax_type:
375 ///
376 /// - 0 : Jacobi
377 /// - 1 : Gauss-Seidel, sequential (very slow!)
378 /// - 2 : Gauss-Seidel, interior points in parallel, boundary
379 /// sequential (slow!)
380 /// - 3 : hybrid Gauss-Seidel or SOR, forward solve
381 /// - 4 : hybrid Gauss-Seidel or SOR, backward solve
382 /// - 5 : hybrid chaotic Gauss-Seidel (works only with OpenMP)
383 /// - 6 : hybrid symmetric Gauss-Seidel or SSOR
384 /// - 7 : Jacobi (uses Matvec)
385 /// - 8 : \f$\ell_1\f$-scaled hybrid symmetric Gauss-Seidel
386 /// - 9 : Gaussian elimination (only on coarsest level)
387 /// - 10 : On-processor direct forward solve for matrices with
388 /// triangular structure
389 /// - 11 : Two Stage approximation to GS. Uses the strict lower
390 /// part of the diagonal matrix
391 /// - 12 : Two Stage approximation to GS. Uses the strict lower
392 /// part of the diagonal matrix and a second iteration
393 /// for additional error approximation
394 /// - 13 : \f$\ell_1\f$ Gauss-Seidel, forward solve
395 /// - 14 : \f$\ell_1\f$ Gauss-Seidel, backward solve
396 /// - 15 : CG (warning - not a fixed smoother - may require FGMRES)
397 /// - 16 : Chebyshev
398 /// - 17 : FCF-Jacobi
399 /// - 18 : \f$\ell_1\f$-scaled jacobi
400 /// - 19 : Gaussian elimination (old version)
401 /// - 21 : The same as 8 except forcing serialization on CPU
402 /// ( # OMP-thread = 1)
403 /// - 29 : Direct solve: use Gaussian elimination & BLAS
404 /// (with pivoting) (old version)
405 /// - 30 : Kaczmarz
406 /// - 88: The same methods as 8 with a convergent l1-term
407 /// - 89: Symmetric l1-hybrid Gauss-Seidel (i.e., 13 followed by 14)
408 /// - 98 : LU with pivoting
409 /// - 99 : LU with pivoting
410 /// -199 : Matvec with the inverse
412
413 /// Complex smoothing methods used in BoomerAMG.
414 /// To use these methods set AMG_using_simple_smoothing to false
415 /// Here are the current options (from hypre's HYPRE_parcsr_ls.h):
416 ///
417 /// - 4 : FSAI (routines needed to set: HYPRE_BoomerAMGSetFSAIMaxSteps,
418 /// HYPRE_BoomerAMGSetFSAIMaxStepSize,
419 /// HYPRE_BoomerAMGSetFSAIEigMaxIters,
420 /// HYPRE_BoomerAMGSetFSAIKapTolerance)
421 /// - 5 : ParILUK (routines needed to set: HYPRE_ILUSetLevelOfFill,
422 /// HYPRE_ILUSetType)
423 /// - 6 : Schwarz (routines needed to set: HYPRE_BoomerAMGSetDomainType,
424 /// HYPRE_BoomerAMGSetOverlap, HYPRE_BoomerAMGSetVariant,
425 /// HYPRE_BoomerAMGSetSchwarzRlxWeight)
426 /// - 7 : Pilut (routines needed to set: HYPRE_BoomerAMGSetDropTol,
427 /// HYPRE_BoomerAMGSetMaxNzPerRow)
428 /// - 8 : ParaSails (routines needed to set: HYPRE_BoomerAMGSetSym,
429 /// HYPRE_BoomerAMGSetLevel, HYPRE_BoomerAMGSetFilter,
430 /// HYPRE_BoomerAMGSetThreshold)
431 /// - 9 : Euclid (routines needed to set: HYPRE_BoomerAMGSetEuclidFile)
432 ///
434
435 /// The number of smoother iterations to apply
437
438 /// Damping factor for BoomerAMG smoothed Jacobi or hybrid SOR
440
441 /// Connection strength threshold parameter for BoomerAMG
443
444 /// Interpolation truncation factor for BoomerAMG
446
447 /// AMG coarsening strategy. Coarsening types include:
448 /// 0 = CLJP (parallel coarsening using independent sets)
449 /// 1 = classical RS with no boundary treatment (not recommended
450 /// in parallel)
451 /// 3 = modified RS with 3rd pass to add C points on the boundaries
452 /// 6 = Falgout (uses 1 then CLJP using interior coarse points as
453 /// first independent set)
454 /// 8 = PMIS (parallel coarsening using independent sets - lower
455 /// complexities than 0, maybe also slower convergence)
456 /// 10= HMIS (one pass RS on each processor then PMIS on interior
457 /// coarse points as first independent set)
458 /// 11= One pass RS on each processor (not recommended)
460
461 /// ParaSails symmetry flag, used to inform ParaSails of
462 /// Symmetry of definitenss of problem and type of ParaSails
463 /// preconditioner:
464 /// 0 = nonsymmetric and/or indefinite problem, nonsymmetric preconditioner
465 /// 1 = SPD problem, and SPD (factored preconditioner)
466 /// 2 = nonsymmetric, definite problem and SDP (factored preconditoner)
468
469 /// ParaSails nlevel parameter
471
472 /// ParaSails thresh parameter
474
475 /// ParaSails filter parameter
477
478 /// Euclid drop tolerance for ILU(k) and ILUT factorization
480
481 /// Flag to switch on Euclid row scaling
483
484 /// Flag to determine if ILUT (if true) or ILU(k) is used in Euclid
486
487 /// Flag to determine if Block Jacobi is used instead of PILU
489
490 /// Euclid level parameter for ILU(k) factorization
492
493 /// Flag to set the level of printing from Euclid
494 /// when the Euclid destructor is called
495 /// 0: no printing (default)
496 /// 1: prints summary of runtime settings and timings
497 /// 2: as 1 plus prints memory usage
499
500
501 // If these are used comment and write access functions
508
509 /// Used to set the Hypre printing level for the Krylov
510 /// subspace solvers
512
513 /// Doc parameters used in hypre solver
515 {
516 oomph_info << " " << std::endl;
517 oomph_info << " " << std::endl;
518 oomph_info << "Hypre parameters:" << std::endl;
519 oomph_info << "=================" << std::endl;
520 oomph_info << "- Maximum number of iterations used in solver: Max_iter = "
521 << Max_iter << std::endl;
522
523 oomph_info << "- Tolerance used to terminate solver: Tolerance = "
524 << Tolerance << std::endl;
525
526 oomph_info << "- Hypre method flag. Valid values are specified in "
527 "enumeration: Hypre_method = "
528 << Hypre_method << std::endl;
529
530 oomph_info << "- Preconditioner method flag used with Hypre's PCG,"
531 << std::endl;
533 << " GMRES and BiCGStab in solve(...) or resolve(...). Valid values"
534 << std::endl;
536 << " are BoomerAMG, Euclid, ParaSails or None (all enumerated above),"
537 << std::endl;
538 oomph_info << " for any other value no preconditioner is set. "
539 << std::endl;
540 oomph_info << " Internal_preconditioner = " << Internal_preconditioner
541 << std::endl;
542
544 << "- Flag to set the Hypre printing level for AMG: AMG_print_level = "
545 << AMG_print_level << std::endl;
546
547 oomph_info << "- Maximum number of levels used in AMG: AMG_max_levels = "
548 << AMG_max_levels << std::endl;
549
550
551 oomph_info << "- Parameter to identify diagonally dominant parts of the "
552 "matrix in AMG:"
553 << std::endl;
554 oomph_info << " AMG_max_row_sum = " << AMG_max_row_sum << std::endl;
555
556
558 << "- Flag to determine whether simple smoothers (determined by the"
559 << std::endl;
561 << " AMG_simple_smoother flag) or complex smoothers (determined by the"
562 << std::endl;
563 oomph_info << " AMG_complex_smoother flag are used in AMG" << std::endl;
564 oomph_info << " AMG_using_simple_smoothing ="
565 << AMG_using_simple_smoothing << std::endl;
566
567 oomph_info << "- Simple smoothing method used in BoomerAMG. "
568 << std::endl;
569 oomph_info << " (only used if AMG_using_simple_smoothing is true"
570 << std::endl;
571 oomph_info << " AMG_simple_smoother = " << AMG_simple_smoother
572 << std::endl;
573
574
575 oomph_info << "- Complex smoothing method used in BoomerAMG. "
576 << std::endl;
577 oomph_info << " (only used if AMG_using_simple_smoothing is false"
578 << std::endl;
579 oomph_info << " AMG_complex_smoother = " << AMG_complex_smoother
580 << std::endl;
581
582 oomph_info << "- The number of smoother iterations to apply: "
583 "AMG_smoother_iterations = "
584 << AMG_smoother_iterations << std::endl;
585
587 << "- Damping factor for BoomerAMG smoothed Jacobi or hybrid SOR: "
588 << "AMG_damping = " << AMG_damping << std::endl;
589
590
591 oomph_info << "- Connection strength threshold parameter for BoomerAMG: "
592 "AMG_strength = "
593 << AMG_strength << std::endl;
594
595
597 << "- Interpolation truncation factor for BoomerAMG: AMG_truncation = "
598 << AMG_truncation << std::endl;
599
600 oomph_info << "- AMG coarsening strategy: AMG_coarsening = "
601 << AMG_coarsening << std::endl;
602
603
604 oomph_info << "NOTE: Skipping parameters for ParaSails and Euclid"
605 << std::endl;
606 oomph_info << " feel free to document these if you use thes solvers"
607 << std::endl;
608
609 oomph_info << "- Flag to control the Hypre printing level for the Krylov"
610 << std::endl;
611 oomph_info << " subspace solvers: Krylov_print_level = "
612 << Krylov_print_level << std::endl;
613
614
615 oomph_info << " " << std::endl;
616 oomph_info << " " << std::endl;
617 }
618
619
620 /// Flag to determine if non-zero values of the Hypre error flag
621 /// plus Hypre error messages are output to screen at various points
622 /// in the solve function, i.e. after:
623 /// 1. setting up the Hypre matrix
624 /// 2. setting up the preconditioner
625 /// 3. setting up the solver
626 /// 4. setting up the Hypre vectors
627 /// 5. solving
628 /// 6. getting the solution vector
629 /// 7. deallocation of solver data
631
632 /// Internal flag which is true when hypre_setup or hypre_solve
633 /// can delete input matrix.
635
636#ifdef OOMPH_HAS_MPI
637 /// Internal flag which tell the solver if the rhs Vector is
638 /// distributed or not
640
641 /// Internal flag which tell the solver if the solution Vector to
642 /// be returned is distributed or not
644#endif
645
646 private:
647 /// Hypre copies matrix data from oomph-lib's CRDoubleMatrix
648 /// into its own data structures, doubling the memory requirements.
649 /// As far as the Hypre solvers are concerned the oomph-lib matrix
650 /// is no longer required and could be deleted to save memory.
651 /// However, this will not be the expected behaviour and therefore
652 /// needs to be requested explicitly by the user by changing this
653 /// flag from false (its default) to true.
655
656 /// The Hypre_IJMatrix version of the matrix used in solve(...),
657 /// resolve(...) or preconditioner_solve(...).
659
660 /// The Hypre_ParCSRMatrix version of the matrix used in solve(...),
661 /// resolve(...) or preconditioner_solve(...).
663
664 /// The Hypre solver used in solve(...), resolve(...) or
665 /// preconditioner_solve(...). [This is a C structure!]
667
668 /// The internal Hypre preconditioner used in conjunction with
669 /// Solver. [This is a C structure!]
671
672 /// Used to keep track of which solver (if any) is currently stored.
674
675 /// Used to keep track of which preconditioner (if any) is currently stored.
677
678 /// the distribution for this helpers-
680 };
681
682
683 ////////////////////////////////////////////////////////////////////////
684 ////////////////////////////////////////////////////////////////////////
685 ////////////////////////////////////////////////////////////////////////
686
687 //=====================================================================
688 /// An LinearSolver class using the suite of Hypre solvers
689 /// to allow
690 ///
691 /// BoomerAMG (AMG), CG, GMRES or BiCGStab
692 ///
693 /// to be used for LinearSolver::solve(...) or LinearSolver::resolve(...).
694 ///
695 /// The Krylov subspace solvers (CG, GMRES and BiCGStab) may be
696 /// preconditioned using:
697 ///
698 /// BoomerAMG, Euclid or ParaSails
699 ///
700 /// By default GMRES without preconditioning is used.
701 //====================================================================
703 {
704 public:
705 /// Constructor
707 {
708 // Hypre copies matrix data from oomph-lib's CRDoubleMatrix
709 // and Distributed CRDoubleMatrix into its own data structures,
710 // doubling the memory requirements for the matrix.
711 // As far as the Hypre solvers are concerned the oomph-lib matrix
712 // is no longer required and could be deleted to save memory.
713 // However, this will not be the expected behaviour and therefore
714 // needs to be requested explicitly by the user by changing this
715 // flag from false (its default) to true.
716 Delete_matrix = false;
717
718 // Do we want to output results of timings?
719 Doc_time = true;
720 }
721
722 /// Empty destructor.
724
725 /// Broken copy constructor.
726 HypreSolver(const HypreSolver&) = delete;
727
728 /// Broken assignment operator.
729 void operator=(const HypreSolver&) = delete;
730
731 /// Disable resolve function (overloads the LinearSolver
732 /// disable_resolve function).
734 {
735 Enable_resolve = false;
737 }
738
739 /// Access function to Max_iter
740 unsigned& max_iter()
741 {
742 return Max_iter;
743 }
744
745 /// Access function to Tolerance
746 double& tolerance()
747 {
748 return Tolerance;
749 }
750
751 /// Access function to Hypre_method flag -- specified via enumeration.
752 unsigned& hypre_method()
753 {
754 return Hypre_method;
755 }
756
757 /// Access function to Internal_preconditioner flag -- specified
758 /// via enumeration.
760 {
762 }
763
764 /// Function to select use of 'simple' AMG smoothers as controlled
765 /// by AMG_simple_smoother flag
770
771 /// Access function to AMG_simple_smoother flag
773 {
774 return AMG_simple_smoother;
775 }
776
777 /// Function to select use of 'complex' AMG smoothers as controlled
778 /// by AMG_complex_smoother flag
783
784 /// Access function to AMG_complex_smoother flag
786 {
788 }
789
790 /// Access function to AMG_print_level
791 unsigned& amg_print_level()
792 {
793 return AMG_print_level;
794 }
795
796 /// Access function to AMG_smoother_iterations
798 {
800 }
801
802 /// Access function to AMG_coarsening flag
803 unsigned& amg_coarsening()
804 {
805 return AMG_coarsening;
806 }
807
808 /// Access function to AMG_max_levels
809 unsigned& amg_max_levels()
810 {
811 return AMG_max_levels;
812 }
813
814 /// Access function to AMG_damping parameter
815 double& amg_damping()
816 {
817 return AMG_damping;
818 }
819
820 /// Access function to AMG_strength
821 double& amg_strength()
822 {
823 return AMG_strength;
824 }
825
826 /// Access function to AMG_max_row_sum
828 {
829 return AMG_max_row_sum;
830 }
831
832 /// Access function to AMG_truncation
834 {
835 return AMG_truncation;
836 }
837
838 /// Access function to ParaSails symmetry flag
840 {
841 return ParaSails_symmetry;
842 }
843
844 /// Access function to ParaSails nlevel parameter
846 {
847 return ParaSails_nlevel;
848 }
849
850 /// Access function to ParaSails thresh parameter
852 {
853 return ParaSails_thresh;
854 }
855
856 /// Access function to ParaSails filter parameter
858 {
859 return ParaSails_filter;
860 }
861
862 /// Access function to Euclid drop tolerance parameter
864 {
865 return Euclid_droptol;
866 }
867
868 /// Access function to Euclid level parameter
869 /// for ILU(k) factorization
871 {
872 return Euclid_level;
873 }
874
875 /// Enable euclid rowScaling
877 {
878 Euclid_rowScale = true;
879 }
880
881 /// Disable euclid row scaling
883 {
884 Euclid_rowScale = false;
885 }
886
887 /// Enable use of Block Jacobi
888 /// as opposed to PILU
890 {
891 Euclid_using_BJ = true;
892 }
893
894 /// Disable use of Block Jacobi,
895 /// so PILU will be used
897 {
898 Euclid_using_BJ = false;
899 }
900
901 /// Function to switch on ILU(k) factorization for Euclid
902 /// (default is ILU(k) factorization)
904 {
905 Euclid_using_ILUT = false;
906 }
907
908 /// Function to switch on ILUT factorization for Euclid
909 /// (default is ILU(k) factorization)
911 {
912 Euclid_using_ILUT = true;
913 }
914
915 /// Function to set the level of printing from Euclid
916 /// when the Euclid destructor is called
917 /// 0: no printing (default)
918 /// 1: prints summary of runtime settings and timings
919 /// 2: as 1 plus prints memory usage
921 {
922 return Euclid_print_level;
923 }
924
925 /// Access function to Krylov_print_level
927 {
928 return Krylov_print_level;
929 }
930
931 /// Hypre copies matrix data from oomph-lib's CRDoubleMatrix
932 /// or DistributedCRDoubleMatrix into its own data structures,
933 /// doubling the memory requirements for the matrix.
934 /// As far as the Hypre solvers are concerned the oomph-lib matrix
935 /// is no longer required and could be deleted to save memory.
936 /// However, this will not be the expected behaviour and therefore
937 /// needs to be requested explicitly by the user by calling this function
938 /// which changes the
939 /// flag from false (its default) to true.
941 {
942 Delete_matrix = true;
943 }
944
945 /// Hypre copies matrix data from oomph-lib's CRDoubleMatrix
946 /// or DistributedCRDoubleMatrix into its own data structures,
947 /// doubling the memory requirements for the matrix.
948 /// Calling this function ensures that the matrix is not deleted.
950 {
951 Delete_matrix = false;
952 }
953
954
955 /// Function which uses problem_pt's get_jacobian(...) function to
956 /// generate a linear system which is then solved. This function deletes
957 /// any existing internal data and then generates a new Hypre solver.
958 void solve(Problem* const& problem_pt, DoubleVector& solution);
959
960 /// Function to solve the linear system defined by matrix_pt
961 /// and rhs. This function will delete any existing internal data
962 /// and generate a new Hypre solver.
963 /// \b Note: The matrix has to be of type CRDoubleMatrix or
964 /// Distributed CRDoubleMatrix.
965 /// \b Note: Hypre copies matrix data from oomph-lib's CRDoubleMatrix
966 /// or DistributedCRDoubleMatrix into its own data structures,
967 /// doubling the memory requirements for the matrix.
968 /// As far as the Hypre solvers are concerned, the oomph-lib matrix
969 /// is no longer required and could be deleted to save memory.
970 /// However, this will not be the expected behaviour and therefore
971 /// needs to be requested explicitly by the user by calling the
972 /// enable_delete_matrix() function.
973 void solve(DoubleMatrixBase* const& matrix_pt,
974 const DoubleVector& rhs,
976
977 /// Function to resolve a linear system using the existing solver
978 /// data, allowing a solve with a new right hand side vector. This
979 /// function must be used after a call to solve(...) with
980 /// enable_resolve set to true.
982
983 /// Function deletes all solver data.
984 void clean_up_memory();
985
986 private:
987 /// Hypre copies matrix data from oomph-lib's CRDoubleMatrix
988 /// or DistributedCRDoubleMatrix into its own data structures,
989 /// doubling the memory requirements for the matrix.
990 /// As far as the Hypre solvers are concerned the oomph-lib matrix
991 /// is no longer required and could be deleted to save memory.
992 /// However, this will not be the expected behaviour and therefore
993 /// needs to be requested explicitly by the user by changing this
994 /// flag from false (its default) to true.
996 };
997
998
999 ////////////////////////////////////////////////////////////////////////
1000 ////////////////////////////////////////////////////////////////////////
1001 ////////////////////////////////////////////////////////////////////////
1002
1003 //=====================================================================
1004 /// An Preconditioner class using the suite of Hypre preconditioners
1005 /// to allow
1006 ///
1007 /// BoomerAMG (Algebraic Multi Grid),
1008 /// Euclid (ILU) or
1009 /// ParaSails (Approximate inverse)
1010 ///
1011 /// to be used for Preconditioner::preconditioner_solve(...).
1012 /// By default BoomerAMG is used.
1013 //====================================================================
1015 {
1016 public:
1017 /// Constructor. Provide optional string that is used
1018 /// in annotation of performance
1019 HyprePreconditioner(const std::string& context_string = "")
1020 {
1022
1023 // Hypre copies matrix data from oomph-lib's CRDoubleMatrix
1024 // or DistributedCRDoubleMatrix into its own data structures,
1025 // doubling the memory requirements for the matrix.
1026 // As far as the Hypre solvers are concerned the oomph-lib matrix
1027 // is no longer required and could be deleted to save memory.
1028 // However, this will not be the expected behaviour and therefore
1029 // needs to be requested explicitly by the user by changing this
1030 // flag from false (its default) to true.
1031 Delete_matrix = false;
1032
1033 // Do we want to output results of timings?
1034 Doc_time = true;
1035
1036 // General control paramaters for using HYPRE as preconditioner
1037 Tolerance = 0.0;
1038 Max_iter = 1;
1041
1042 // Initialise private double that accumulates the preconditioner
1043 // solve time of thi instantiation of this class. Is reported
1044 // in destructor if Report_my_cumulative_preconditioner_solve_time
1045 // is set to true
1048 }
1049
1050 /// Destructor.
1052 {
1054 {
1055 oomph_info << "~HyprePreconditioner() in context \" " << Context_string
1056 << "\": My_cumulative_preconditioner_solve_time = "
1058 }
1059 }
1060
1061 /// Broken copy constructor.
1063
1064 /// Broken assignment operator.
1065 void operator=(const HyprePreconditioner&) = delete;
1066
1067 /// Static double that accumulates the preconditioner
1068 /// solve time of all instantiations of this class. Reset
1069 /// it manually, e.g. after every Newton solve, using
1070 /// reset_cumulative_solve_times().
1072
1073 /// Static double that accumulates the preconditioner
1074 /// solve time of all instantiations of this class, labeled by
1075 /// context string. Reset
1076 /// it manually, e.g. after every Newton solve, using
1077 /// reset_cumulative_solve_times().
1078 static std::map<std::string, double> Context_based_cumulative_solve_time;
1079
1080
1081 /// Static unsigned that accumulates the number of preconditioner
1082 /// solves of all instantiations of this class. Reset
1083 /// it manually, e.g. after every Newton solve, using
1084 /// reset_cumulative_solve_times().
1086
1087 /// Static unsigned that accumulates the number of preconditioner
1088 /// solves of all instantiations of this class, labeled by
1089 /// context string. Reset
1090 /// it manually, e.g. after every Newton solve, using
1091 /// reset_cumulative_solve_times().
1092 static std::map<std::string, unsigned>
1094
1095 /// Static unsigned that stores nrow for the most recent
1096 /// instantiations of this class, labeled by
1097 /// context string. Reset
1098 /// it manually, e.g. after every Newton solve, using
1099 /// reset_cumulative_solve_times().
1100 static std::map<std::string, unsigned> Context_based_nrow;
1101
1102 /// Report cumulative solve times of all instantiations of this
1103 /// class
1104 static void report_cumulative_solve_times();
1105
1106 /// Reset cumulative solve times
1107 static void reset_cumulative_solve_times();
1108
1109 /// Enable reporting of cumulative solve time in destructor
1114
1115 /// Disable reporting of cumulative solve time in destructor
1120
1121 /// Enable documentation of preconditioner timings
1123 {
1124 Doc_time = true;
1125 }
1126
1127 /// Disable documentation of preconditioner timings
1129 {
1130 Doc_time = false;
1131 }
1132
1133 /// Access function to Hypre_method flag -- specified via enumeration.
1134 unsigned& hypre_method()
1135 {
1136 return Hypre_method;
1137 }
1138
1139 /// Access function to Internal_preconditioner flag -- specified
1140 /// via enumeration.
1142 {
1144 }
1145
1146 /// Function to select BoomerAMG as the preconditioner
1148 {
1150 }
1151
1152 /// Function to set the number of times to apply BoomerAMG
1154 {
1156 }
1157
1158 /// Return function for Max_iter
1159 unsigned& amg_iterations()
1160 {
1161 return Max_iter;
1162 }
1163
1164 /// Function to select use of 'simple' AMG smoothers as controlled
1165 /// by the flag AMG_simple_smoother
1170
1171 /// Access function to AMG_simple_smoother flag
1173 {
1174 return AMG_simple_smoother;
1175 }
1176
1177 /// Function to select use of 'complex' AMG smoothers as controlled
1178 /// by the flag AMG_complex_smoother
1183
1184 /// Access function to AMG_complex_smoother flag
1186 {
1187 return AMG_complex_smoother;
1188 }
1189
1190 /// Return function for the AMG_using_simple_smoothing_flag
1195
1196 /// Access function to AMG_print_level
1198 {
1199 return AMG_print_level;
1200 }
1201
1202 /// Access function to AMG_smoother_iterations
1204 {
1206 }
1207
1208 /// Access function to AMG_coarsening flag
1209 unsigned& amg_coarsening()
1210 {
1211 return AMG_coarsening;
1212 }
1213
1214 /// Access function to AMG_max_levels
1215 unsigned& amg_max_levels()
1216 {
1217 return AMG_max_levels;
1218 }
1219
1220 /// Access function to AMG_damping parameter
1221 double& amg_damping()
1222 {
1223 return AMG_damping;
1224 }
1225
1226 /// Access function to AMG_strength
1228 {
1229 return AMG_strength;
1230 }
1231
1232 /// Access function to AMG_max_row_sum
1234 {
1235 return AMG_max_row_sum;
1236 }
1237
1238 /// Access function to AMG_truncation
1240 {
1241 return AMG_truncation;
1242 }
1243
1244 /// Function to select ParaSails as the preconditioner
1246 {
1248 }
1249
1250 /// Access function to ParaSails symmetry flag
1252 {
1253 return ParaSails_symmetry;
1254 }
1255
1256 /// Access function to ParaSails nlevel parameter
1258 {
1259 return ParaSails_nlevel;
1260 }
1261
1262 /// Access function to ParaSails thresh parameter
1264 {
1265 return ParaSails_thresh;
1266 }
1267
1268 /// Access function to ParaSails filter parameter
1270 {
1271 return ParaSails_filter;
1272 }
1273
1274 /// Function to select use Euclid as the preconditioner
1276 {
1278 }
1279
1280 /// Access function to Euclid drop tolerance parameter
1282 {
1283 return Euclid_droptol;
1284 }
1285
1286 /// Access function to Euclid level parameter for ILU(k) factorization
1288 {
1289 return Euclid_level;
1290 }
1291
1292 /// Enable euclid rowScaling
1294 {
1295 Euclid_rowScale = true;
1296 }
1297
1298 /// Disable euclid row scaling
1300 {
1301 Euclid_rowScale = false;
1302 }
1303
1304 /// Enable use of Block Jacobi
1305 /// as opposed to PILU
1307 {
1308 Euclid_using_BJ = true;
1309 }
1310
1311 /// Disable use of Block Jacobi,
1312 /// so PILU will be used
1314 {
1315 Euclid_using_BJ = false;
1316 }
1317
1318 /// Function to switch on ILU(k) factorization for Euclid
1319 /// (default is ILU(k) factorization)
1321 {
1322 Euclid_using_ILUT = false;
1323 }
1324
1325 /// Function to switch on ILUT factorization for Euclid
1326 /// (default is ILU(k) factorization)
1328 {
1329 Euclid_using_ILUT = true;
1330 }
1331
1332 /// Function to set the level of printing from Euclid
1333 /// when the Euclid destructor is called
1334 /// 0: no printing (default)
1335 /// 1: prints summary of runtime settings and timings
1336 /// 2: as 1 plus prints memory usage
1338 {
1339 return Euclid_print_level;
1340 }
1341
1342 /// Hypre copies matrix data from oomph-lib's CRDoubleMatrix
1343 /// or DistributedCRDoubleMatrix into its own data structures,
1344 /// doubling the memory requirements for the matrix.
1345 /// As far as the Hypre solvers are concerned the oomph-lib matrix
1346 /// is no longer required and could be deleted to save memory.
1347 /// However, this will not be the expected behaviour and therefore
1348 /// needs to be requested explicitly by the user by calling this function
1349 /// which changes the
1350 /// flag from false (its default) to true.
1352 {
1353 Delete_matrix = true;
1354 }
1355
1356 /// Hypre copies matrix data from oomph-lib's CRDoubleMatrix
1357 /// or DistributedCRDoubleMatrix into its own data structures,
1358 /// doubling the memory requirements for the matrix.
1359 /// Calling this function ensures that the matrix is not deleted.
1361 {
1362 Delete_matrix = false;
1363 }
1364
1365 /// Function to set up a preconditioner for the linear
1366 /// system defined by matrix_pt. This function is required when
1367 /// preconditioning and must be called before using the
1368 /// preconditioner_solve(...) function. This interface allows
1369 /// HyprePreconditioner to be used as a Preconditioner object
1370 /// for oomph-lib's own IterativeLinearSolver class.
1371 /// \b Note: matrix_pt must point to an object of type
1372 /// CRDoubleMatrix or DistributedCRDoubleMatrix.
1373 /// \b Note: Hypre copies matrix data from oomph-lib's CRDoubleMatrix
1374 /// and DistributedCRDoubleMatrix into its own data structures,
1375 /// doubling the memory requirements for the matrix.
1376 /// As far as the Hypre solvers are concerned, the oomph-lib matrix
1377 /// is no longer required and could be deleted to save memory.
1378 /// However, this will not be the expected behaviour and therefore
1379 /// needs to be requested explicitly by the user by calling the
1380 /// enable_delete_matrix() function.
1381 void setup();
1382
1383 /// Function applies solver to vector r for preconditioning.
1384 /// This requires a call to setup(...) first.
1385 /// \b Note: Hypre copies matrix data from oomph-lib's CRDoubleMatrix
1386 /// or DistributedCRDoubleMatrix into its own data structures,
1387 /// doubling the memory requirements for the matrix.
1388 /// As far as the Hypre solvers are concerned, the oomph-lib matrix
1389 /// is no longer required and could be deleted to save memory.
1390 /// However, this will not be the expected behaviour and therefore
1391 /// needs to be requested explicitly by the user with the
1392 /// delete_matrix() function.
1394
1395 /// Function deletes all solver data.
1396 void clean_up_memory();
1397
1398 private:
1399 /// Hypre copies matrix data from oomph-lib's CRDoubleMatrix
1400 /// or DistributedCRDoubleMatrix into its own data structures,
1401 /// doubling the memory requirements for the matrix.
1402 /// As far as the Hypre solvers are concerned the oomph-lib matrix
1403 /// is no longer required and could be deleted to save memory.
1404 /// However, this will not be the expected behaviour and therefore
1405 /// needs to be requested explicitly by the user by changing this
1406 /// flag from false (its default) to true.
1408
1409 // Flag is true to output results of timings
1411
1412 /// Private double that accumulates the preconditioner
1413 /// solve time of thi instantiation of this class. Is reported
1414 /// in destructor if Report_my_cumulative_preconditioner_solve_time
1415 /// is set to true
1417
1418 /// Bool to request report of My_cumulative_preconditioner_solve_time
1419 /// in destructor
1421
1422 /// String can be used to provide context for annotation
1423 std::string Context_string;
1424 };
1425
1426
1427 ////////////////////////////////////////////////////////////////////////
1428 ////////////////////////////////////////////////////////////////////////
1429 ////////////////////////////////////////////////////////////////////////
1430
1431 //==================================================================
1432 /// Default settings for various uses of the Hypre solver
1433 //==================================================================
1434 namespace Hypre_default_settings
1435 {
1436 /// Set default parameters for use as preconditioner in
1437 /// for momentum block in Navier-Stokes problem
1440
1441 /// Set default parameters for use as preconditioner in
1442 /// 2D Poisson-type problem.
1445
1446 /// Set default parameters for use as preconditioner in
1447 /// 3D Poisson-type problem.
1450
1451 } // namespace Hypre_default_settings
1452} // namespace oomph
1453
1454#endif
e
Definition cfortran.h:571
A class for compressed row matrices. This is a distributable object.
Definition matrices.h:888
Abstract base class for matrices of doubles – adds abstract interfaces for solving,...
Definition matrices.h:261
A vector in the mathematical sense, initially developed for linear algebra type applications....
An interface class to the suite of Hypre solvers and preconditioners to allow use of:
bool Output_info
Flag is true to output info and results of timings.
bool Delete_input_data
Internal flag which is true when hypre_setup or hypre_solve can delete input matrix.
unsigned AMG_coarsening
AMG coarsening strategy. Coarsening types include: 0 = CLJP (parallel coarsening using independent se...
int Euclid_level
Euclid level parameter for ILU(k) factorization.
bool Euclid_using_BJ
Flag to determine if Block Jacobi is used instead of PILU.
bool Euclid_rowScale
Flag to switch on Euclid row scaling.
bool Returning_distributed_solution
Internal flag which tell the solver if the solution Vector to be returned is distributed or not.
double AMG_strength
Connection strength threshold parameter for BoomerAMG.
HypreInterface(const HypreInterface &)=delete
Broken copy constructor.
void enable_hypre_error_messages()
Turn on the hypre error messages.
LinearAlgebraDistribution * Hypre_distribution_pt
the distribution for this helpers-
int ParaSails_nlevel
ParaSails nlevel parameter.
double ParaSails_filter
ParaSails filter parameter.
unsigned AMGEuclidSmoother_level
HYPRE_Solver Solver
The Hypre solver used in solve(...), resolve(...) or preconditioner_solve(...). [This is a C structur...
int ParaSails_symmetry
ParaSails symmetry flag, used to inform ParaSails of Symmetry of definitenss of problem and type of P...
bool Using_distributed_rhs
Internal flag which tell the solver if the rhs Vector is distributed or not.
HypreInterface()
Constructor.
unsigned existing_preconditioner()
Function return value of which preconditioner (if any) is stored.
HYPRE_ParCSRMatrix Matrix_par
The Hypre_ParCSRMatrix version of the matrix used in solve(...), resolve(...) or preconditioner_solve...
void operator=(const HypreInterface &)=delete
Broken assignment operator.
void disable_hypre_error_messages()
Turn off hypre error messages.
unsigned Internal_preconditioner
Preconditioner method flag used with Hypre's PCG, GMRES and BiCGStab in solve(...) or resolve(....
void hypre_solve(const DoubleVector &rhs, DoubleVector &solution)
Helper function performs a solve if any solver exists.
Hypre_method_types
Enumerated flag to define which Hypre methods are used CAREFUL: DON'T CHANGE THE ORDER OF THESE!
~HypreInterface()
Destructor.
HYPRE_Solver Preconditioner
The internal Hypre preconditioner used in conjunction with Solver. [This is a C structure!...
unsigned AMGEuclidSmoother_print_level
bool AMGEuclidSmoother_use_block_jacobi
unsigned AMG_complex_smoother
Complex smoothing methods used in BoomerAMG. To use these methods set AMG_using_simple_smoothing to f...
bool Delete_matrix
Hypre copies matrix data from oomph-lib's CRDoubleMatrix into its own data structures,...
double ParaSails_thresh
ParaSails thresh parameter.
double AMG_truncation
Interpolation truncation factor for BoomerAMG.
unsigned Krylov_print_level
Used to set the Hypre printing level for the Krylov subspace solvers.
unsigned AMG_smoother_iterations
The number of smoother iterations to apply.
unsigned existing_solver()
Function to return value of which solver (if any) is currently stored.
void hypre_clean_up_memory()
Function deletes all solver data.
void doc_hypre_parameters()
Doc parameters used in hypre solver.
bool Hypre_error_messages
Flag to determine if non-zero values of the Hypre error flag plus Hypre error messages are output to ...
double Tolerance
Tolerance used to terminate solver.
bool AMG_using_simple_smoothing
Flag to determine whether simple smoothers (determined by the AMG_simple_smoother flag) or complex sm...
unsigned Existing_solver
Used to keep track of which solver (if any) is currently stored.
unsigned Max_iter
Maximum number of iterations used in solver.
double AMG_damping
Damping factor for BoomerAMG smoothed Jacobi or hybrid SOR.
unsigned AMG_simple_smoother
Simple smoothing methods used in BoomerAMG. To use these methods set AMG_using_simple_smoothing to tr...
unsigned AMG_print_level
Used to set the Hypre printing level for AMG 0: no printout 1: print setup information 2: print solve...
HYPRE_IJMatrix Matrix_ij
The Hypre_IJMatrix version of the matrix used in solve(...), resolve(...) or preconditioner_solve(....
unsigned Euclid_print_level
Flag to set the level of printing from Euclid when the Euclid destructor is called 0: no printing (de...
unsigned AMG_max_levels
Maximum number of levels used in AMG.
unsigned Hypre_method
Hypre method flag. Valid values are specified in enumeration.
void hypre_matrix_setup(CRDoubleMatrix *matrix_pt)
Function which sets values of First_global_row, Last_global_row and other partitioning data and creat...
double AMG_max_row_sum
Parameter to identify diagonally dominant parts of the matrix in AMG.
double Euclid_droptol
Euclid drop tolerance for ILU(k) and ILUT factorization.
unsigned Existing_preconditioner
Used to keep track of which preconditioner (if any) is currently stored.
bool Euclid_using_ILUT
Flag to determine if ILUT (if true) or ILU(k) is used in Euclid.
void hypre_solver_setup()
Sets up the data required for to use as an oomph-lib LinearSolver or Preconditioner....
An Preconditioner class using the suite of Hypre preconditioners to allow.
bool & amg_using_simple_smoothing_flag()
Return function for the AMG_using_simple_smoothing_flag.
unsigned & amg_simple_smoother()
Access function to AMG_simple_smoother flag.
static void reset_cumulative_solve_times()
Reset cumulative solve times.
unsigned & amg_print_level()
Access function to AMG_print_level.
static std::map< std::string, unsigned > Context_based_cumulative_npreconditioner_solve
Static unsigned that accumulates the number of preconditioner solves of all instantiations of this cl...
void disable_euclid_using_BJ()
Disable use of Block Jacobi, so PILU will be used.
std::string Context_string
String can be used to provide context for annotation.
void enable_delete_matrix()
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
void disable_report_my_cumulative_preconditioner_solve_time()
Disable reporting of cumulative solve time in destructor.
unsigned & internal_preconditioner()
Access function to Internal_preconditioner flag – specified via enumeration.
void set_amg_iterations(const unsigned &amg_iterations)
Function to set the number of times to apply BoomerAMG.
void clean_up_memory()
Function deletes all solver data.
unsigned & amg_max_levels()
Access function to AMG_max_levels.
void disable_delete_matrix()
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
static double Cumulative_preconditioner_solve_time
Static double that accumulates the preconditioner solve time of all instantiations of this class....
void euclid_using_ILUT()
Function to switch on ILUT factorization for Euclid (default is ILU(k) factorization)
void setup()
Function to set up a preconditioner for the linear system defined by matrix_pt. This function is requ...
void enable_euclid_rowScale()
Enable euclid rowScaling.
double & parasails_filter()
Access function to ParaSails filter parameter.
void euclid_using_ILUK()
Function to switch on ILU(k) factorization for Euclid (default is ILU(k) factorization)
bool Report_my_cumulative_preconditioner_solve_time
Bool to request report of My_cumulative_preconditioner_solve_time in destructor.
void amg_using_complex_smoothing()
Function to select use of 'complex' AMG smoothers as controlled by the flag AMG_complex_smoother.
static std::map< std::string, double > Context_based_cumulative_solve_time
Static double that accumulates the preconditioner solve time of all instantiations of this class,...
void enable_euclid_using_BJ()
Enable use of Block Jacobi as opposed to PILU.
bool Delete_matrix
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
void enable_doc_time()
Enable documentation of preconditioner timings.
double & amg_max_row_sum()
Access function to AMG_max_row_sum.
void disable_doc_time()
Disable documentation of preconditioner timings.
static std::map< std::string, unsigned > Context_based_nrow
Static unsigned that stores nrow for the most recent instantiations of this class,...
void amg_using_simple_smoothing()
Function to select use of 'simple' AMG smoothers as controlled by the flag AMG_simple_smoother.
double My_cumulative_preconditioner_solve_time
Private double that accumulates the preconditioner solve time of thi instantiation of this class....
void use_Euclid()
Function to select use Euclid as the preconditioner.
double & amg_damping()
Access function to AMG_damping parameter.
void disable_euclid_rowScale()
Disable euclid row scaling.
void operator=(const HyprePreconditioner &)=delete
Broken assignment operator.
void use_BoomerAMG()
Function to select BoomerAMG as the preconditioner.
unsigned & amg_coarsening()
Access function to AMG_coarsening flag.
unsigned & amg_smoother_iterations()
Access function to AMG_smoother_iterations.
double & parasails_thresh()
Access function to ParaSails thresh parameter.
static void report_cumulative_solve_times()
Report cumulative solve times of all instantiations of this class.
void use_ParaSails()
Function to select ParaSails as the preconditioner.
double & amg_strength()
Access function to AMG_strength.
double & amg_truncation()
Access function to AMG_truncation.
unsigned & euclid_print_level()
Function to set the level of printing from Euclid when the Euclid destructor is called 0: no printing...
unsigned & amg_complex_smoother()
Access function to AMG_complex_smoother flag.
static unsigned Cumulative_npreconditioner_solve
Static unsigned that accumulates the number of preconditioner solves of all instantiations of this cl...
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Function applies solver to vector r for preconditioning. This requires a call to setup(....
unsigned & hypre_method()
Access function to Hypre_method flag – specified via enumeration.
unsigned & amg_iterations()
Return function for Max_iter.
int & euclid_level()
Access function to Euclid level parameter for ILU(k) factorization.
int & parasails_nlevel()
Access function to ParaSails nlevel parameter.
HyprePreconditioner(const HyprePreconditioner &)=delete
Broken copy constructor.
double & euclid_droptol()
Access function to Euclid drop tolerance parameter.
HyprePreconditioner(const std::string &context_string="")
Constructor. Provide optional string that is used in annotation of performance.
int & parasails_symmetry()
Access function to ParaSails symmetry flag.
void enable_report_my_cumulative_preconditioner_solve_time()
Enable reporting of cumulative solve time in destructor.
An LinearSolver class using the suite of Hypre solvers to allow.
void disable_euclid_using_BJ()
Disable use of Block Jacobi, so PILU will be used.
void disable_euclid_rowScale()
Disable euclid row scaling.
unsigned & krylov_print_level()
Access function to Krylov_print_level.
void enable_euclid_using_BJ()
Enable use of Block Jacobi as opposed to PILU.
unsigned & hypre_method()
Access function to Hypre_method flag – specified via enumeration.
int & parasails_nlevel()
Access function to ParaSails nlevel parameter.
void solve(Problem *const &problem_pt, DoubleVector &solution)
Function which uses problem_pt's get_jacobian(...) function to generate a linear system which is then...
HypreSolver(const HypreSolver &)=delete
Broken copy constructor.
~HypreSolver()
Empty destructor.
unsigned & amg_max_levels()
Access function to AMG_max_levels.
int & euclid_level()
Access function to Euclid level parameter for ILU(k) factorization.
double & euclid_droptol()
Access function to Euclid drop tolerance parameter.
void clean_up_memory()
Function deletes all solver data.
unsigned & amg_simple_smoother()
Access function to AMG_simple_smoother flag.
unsigned & internal_preconditioner()
Access function to Internal_preconditioner flag – specified via enumeration.
double & amg_truncation()
Access function to AMG_truncation.
double & amg_max_row_sum()
Access function to AMG_max_row_sum.
HypreSolver()
Constructor.
unsigned & max_iter()
Access function to Max_iter.
int & parasails_symmetry()
Access function to ParaSails symmetry flag.
bool Delete_matrix
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
void amg_using_complex_smoothing()
Function to select use of 'complex' AMG smoothers as controlled by AMG_complex_smoother flag.
void euclid_using_ILUT()
Function to switch on ILUT factorization for Euclid (default is ILU(k) factorization)
unsigned & amg_print_level()
Access function to AMG_print_level.
void amg_using_simple_smoothing()
Function to select use of 'simple' AMG smoothers as controlled by AMG_simple_smoother flag.
void resolve(const DoubleVector &rhs, DoubleVector &solution)
Function to resolve a linear system using the existing solver data, allowing a solve with a new right...
void enable_euclid_rowScale()
Enable euclid rowScaling.
unsigned & amg_complex_smoother()
Access function to AMG_complex_smoother flag.
unsigned & amg_coarsening()
Access function to AMG_coarsening flag.
unsigned & euclid_print_level()
Function to set the level of printing from Euclid when the Euclid destructor is called 0: no printing...
double & parasails_filter()
Access function to ParaSails filter parameter.
double & amg_strength()
Access function to AMG_strength.
void euclid_using_ILUK()
Function to switch on ILU(k) factorization for Euclid (default is ILU(k) factorization)
void operator=(const HypreSolver &)=delete
Broken assignment operator.
double & amg_damping()
Access function to AMG_damping parameter.
double & tolerance()
Access function to Tolerance.
unsigned & amg_smoother_iterations()
Access function to AMG_smoother_iterations.
void disable_resolve()
Disable resolve function (overloads the LinearSolver disable_resolve function).
void enable_delete_matrix()
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
void disable_delete_matrix()
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
double & parasails_thresh()
Access function to ParaSails thresh parameter.
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
Base class for all linear solvers. This merely defines standard interfaces for linear solvers,...
bool Doc_time
Boolean flag that indicates whether the time taken.
bool Enable_resolve
Boolean that indicates whether the matrix (or its factors, in the case of direct solver) should be st...
static bool mpi_has_been_initialised()
return true if MPI has been initialised
static OomphCommunicator * communicator_pt()
access to global communicator. This is the oomph-lib equivalent of MPI_COMM_WORLD
An OomphLibError object which should be thrown when an run-time error is encountered....
Preconditioner base class. Gives an interface to call all other preconditioners through and stores th...
////////////////////////////////////////////////////////////////// //////////////////////////////////...
Definition problem.h:154
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
hypre_Error hypre__global_error
void create_HYPRE_Matrix(CRDoubleMatrix *oomph_matrix, HYPRE_IJMatrix &hypre_ij_matrix, HYPRE_ParCSRMatrix &hypre_par_matrix, LinearAlgebraDistribution *dist_pt)
Helper function to create a serial HYPRE_IJMatrix and HYPRE_ParCSRMatrix from a CRDoubleMatrix NOTE: ...
void create_HYPRE_Vector(const DoubleVector &oomph_vec, const LinearAlgebraDistribution *dist_pt, HYPRE_IJVector &hypre_ij_vector, HYPRE_ParVector &hypre_par_vector)
Helper function to create a HYPRE_IJVector and HYPRE_ParVector.
int check_HYPRE_error_flag(std::ostringstream &message)
Helper function to check the Hypre error flag, return the message associated with any error,...
unsigned Number_of_active_hypre_solvers
Number of active Hypre solvers (smart pointer like behaviuor to make sure that the initialise/finaliz...
unsigned AMG_coarsening
Default AMG coarsening strategy. Coarsening types include: 0 = CLJP (parallel coarsening using indepe...
double AMG_truncation
AMG interpolation truncation factor.
double AMG_strength
Default for AMG strength (0.25 recommended for 2D problems; larger (0.5-0.75, say) for 3D.
void euclid_settings_helper(const bool &use_block_jacobi, const bool &use_row_scaling, const bool &use_ilut, const int &level, const double &drop_tol, const int &print_level, HYPRE_Solver &euclid_object)
Helper function to set Euclid options using a command line like array.
void set_defaults_for_navier_stokes_momentum_block(HyprePreconditioner *hypre_preconditioner_pt)
Set default parameters for use as preconditioner in for momentum block in Navier-Stokes problem.
void set_defaults_for_3D_poisson_problem(HyprePreconditioner *hypre_preconditioner_pt)
Set default parameters for use as preconditioner in 3D Poisson-type problem.
void set_defaults_for_2D_poisson_problem(HyprePreconditioner *hypre_preconditioner_pt)
Set default parameters for use as preconditioner in 2D Poisson-type problem.
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...