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// Version 1.0; svn revision $LastChangedRevision$
7 //LIC//
8 //LIC// $LastChangedDate$
9 //LIC//
10 //LIC// Copyright (C) 2006-2016 Matthias Heil and Andrew Hazel
11 //LIC//
12 //LIC// This library is free software; you can redistribute it and/or
13 //LIC// modify it under the terms of the GNU Lesser General Public
14 //LIC// License as published by the Free Software Foundation; either
15 //LIC// version 2.1 of the License, or (at your option) any later version.
16 //LIC//
17 //LIC// This library is distributed in the hope that it will be useful,
18 //LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 //LIC// Lesser General Public License for more details.
21 //LIC//
22 //LIC// You should have received a copy of the GNU Lesser General Public
23 //LIC// License along with this library; if not, write to the Free Software
24 //LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 //LIC// 02110-1301 USA.
26 //LIC//
27 //LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
28 //LIC//
29 //LIC//====================================================================
30 #ifndef OOMPH_HYPRE_SOLVER_HEADER
31 #define OOMPH_HYPRE_SOLVER_HEADER
32 
33 // Headers required for hypre
34 #include "_hypre_utilities.h"
35 #include "HYPRE.h"
36 #include "HYPRE_parcsr_ls.h"
37 #include "HYPRE_krylov.h"
38 #include "HYPRE_IJ_mv.h"
39 #include "HYPRE_parcsr_mv.h"
40 
41 // OOMPH-LIB includes
43 #include "linear_solver.h"
44 #include "preconditioner.h"
45 
46 // hypre's global error flag
47 extern int hypre__global_error;
48 
49 
50 
51 namespace oomph
52 {
53 
54 //==================================================================
55 /// Helper functions for use with the Hypre library
56 //==================================================================
57  namespace HypreHelpers
58  {
59 
60  /// \short Default for AMG strength (0.25 recommended for 2D problems;
61  /// larger (0.5-0.75, say) for 3D
62  extern double AMG_strength;
63 
64  /// \short Default AMG coarsening strategy. Coarsening types include:
65  /// 0 = CLJP (parallel coarsening using independent sets)
66  /// 1 = classical RS with no boundary treatment (not recommended
67  /// in parallel)
68  /// 3 = modified RS with 3rd pass to add C points on the boundaries
69  /// 6 = Falgout (uses 1 then CLJP using interior coarse points as
70  /// first independent set)
71  /// 8 = PMIS (parallel coarsening using independent sets - lower
72  /// complexities than 0, maybe also slower convergence)
73  /// 10= HMIS (one pass RS on each processor then PMIS on interior
74  /// coarse points as first independent set)
75  /// 11= One pass RS on each processor (not recommended)
76  extern unsigned AMG_coarsening;
77 
78  /// AMG interpolation truncation factor
79  extern double AMG_truncation; // 0.0;
80 
81  /// \short Helper function to check the Hypre error flag, return the
82  /// message associated with any error, and reset the error flag to zero.
83  int check_HYPRE_error_flag(std::ostringstream& message);
84 
85  /// \short Helper function to create a HYPRE_IJVector and HYPRE_ParVector.
86  /// + If no MPI then serial vectors are created
87  /// + If MPI and serial input vector then distributed hypre vectors are
88  /// created
89  /// + If MPI and distributed input vector the distributed output vectors
90  /// are created.
91  extern void create_HYPRE_Vector(const DoubleVector& oomph_vec,
92  const LinearAlgebraDistribution* dist_pt,
93  HYPRE_IJVector& hypre_ij_vector,
94  HYPRE_ParVector& hypre_par_vector);
95 
96  /// \short Helper function to create an empty HYPRE_IJVector and
97  /// HYPRE_ParVector.
98  /// + If no MPI then serial vectors are created
99  /// + If MPI and serial distribution then distributed hypre vectors are
100  /// created
101  /// + If MPI and distributed input distribution the distributed output
102  /// vectors are created.
103  void create_HYPRE_Vector(const LinearAlgebraDistribution* oomph_vec,
104  HYPRE_IJVector& hypre_ij_vector,
105  HYPRE_ParVector& hypre_par_vector);
106 
107  /// \short Helper function to create a serial HYPRE_IJMatrix and
108  /// HYPRE_ParCSRMatrix from a CRDoubleMatrix
109  void create_HYPRE_Matrix(CRDoubleMatrix* oomph_matrix,
110  HYPRE_IJMatrix& hypre_ij_matrix,
111  HYPRE_ParCSRMatrix& hypre_par_matrix,
112  LinearAlgebraDistribution* dist_pt);
113 
114  /// \short Helper function to set Euclid options using a command line
115  /// like array.
116  void euclid_settings_helper(const bool &use_block_jacobi,
117  const bool &use_row_scaling,
118  const bool &use_ilut,
119  const int &level,
120  const double &drop_tol,
121  const int &print_level,
122  HYPRE_Solver &euclid_object);
123 
124  }
125 
126 
127 
128 //=====================================================================
129 /// An interface class to the suite of Hypre solvers and preconditioners
130 /// to allow use of:
131 ///
132 /// BoomerAMG (AMG), CG, GMRES or BiCGStab, Euclid (ILU) or
133 /// ParaSails (Approximate inverse)
134 ///
135 /// Hypre's Krylov subspace solvers (CG, GMRES and BiCGStab) may be
136 /// preconditioned using:
137 ///
138 /// BoomerAMG, Euclid or ParaSails
139 ///
140 //====================================================================
142  {
143  public:
144 
145  /// \short Constructor
147  {
148 #ifdef PARANOID
149 #ifndef HYPRE_SEQUENTIAL
150  // For the MPI version of Hypre, check MPI_Helpers::setup has been called
152  {
153  std::ostringstream error_message;
154  error_message << "When using the MPI version of Hypre please first\n"
155  << "call function MPI_Helpers::setup()\n";
156  throw OomphLibError(error_message.str(),
157  OOMPH_CURRENT_FUNCTION,
158  OOMPH_EXCEPTION_LOCATION);
159 
160  }
161 #endif
162 #endif
163 
164  // setup the distribution
165  Hypre_distribution_pt = new LinearAlgebraDistribution();
166 
167  // These keep track of which solver and preconditioner
168  // (if any) currently exist
169  Existing_solver = None;
170  Existing_preconditioner = None;
171 
172  // Do we want to output info and results of timings?
173  Output_info = true;
174 
175  // General control paramaters
176  Tolerance = 1e-10;
177  Max_iter = 100;
178  Hypre_method = GMRES;
179  Internal_preconditioner = None;
180 
181  // Default AMG control parameters -- these seem OK;
182  // see hypre documenation for details.
183  AMG_using_simple_smoothing=true;
184  if (MPI_Helpers::communicator_pt()->nproc()>1)
185  {
186  // Jacobi in parallel
187  AMG_simple_smoother = 0;
188  }
189  else
190  {
191  // Gauss Seidel in serial
192  AMG_simple_smoother = 1;
193  }
194  AMG_complex_smoother = 6;
196  AMG_damping = 1.0;
200  AMG_max_levels = 100;
201  AMG_max_row_sum = 1.0;
202  AMG_print_level = 0;
203 
204  // Parameters for using Euclicd as an AMG smoother (defaults copied
205  // from the normal defaults listed in the manual).
206  AMGEuclidSmoother_use_block_jacobi = false;
207  AMGEuclidSmoother_use_row_scaling = false;
208  AMGEuclidSmoother_use_ilut = false;
209  AMGEuclidSmoother_level = 1;
210  AMGEuclidSmoother_drop_tol = 0; // No dropping
211  AMGEuclidSmoother_print_level = 0;
212 
213  // Print level for CG, GMRES and BiCGStab
214  Krylov_print_level = 0;
215 
216  // Set ParaSails default values
217  ParaSails_symmetry = 2;
218  ParaSails_nlevel = 1;
219  ParaSails_thresh = 0.1;
220  ParaSails_filter = 0.1;
221 
222  // Set Euclid default values
223  Euclid_droptol = 0.0;
224  Euclid_rowScale = false;
225  Euclid_using_ILUT = false;
226  Euclid_using_BJ = false;
227  Euclid_level = 1;
228  Euclid_print_level = 0;
229 
230  // Set to true to periodically check the hypre error flag
231  // and output any messages
232  Hypre_error_messages = false;
233  }
234 
235  /// Destructor.
237  {
238  // call function to delete solver data
239  hypre_clean_up_memory();
240 
241  // delete teh oomph-lib distribution
242  delete Hypre_distribution_pt;
243  }
244 
245  /// Broken copy constructor.
247  {
248  BrokenCopy::broken_copy("HypreInterface");
249  }
250 
251  /// Broken assignment operator.
253  {
254  BrokenCopy::broken_assign("HypreInterface");
255  }
256 
257  /// Turn on the hypre error messages
258  void enable_hypre_error_messages() {Hypre_error_messages=true;}
259 
260  /// Turn off hypre error messages
261  void disable_hypre_error_messages() {Hypre_error_messages=false;}
262 
263  /// \short Enumerated flag to define which Hypre methods are used
264  /// CAREFUL: DON'T CHANGE THE ORDER OF THESE!
271  None};
272 
273  /// Function to return value of which solver (if any) is currently stored.
274  unsigned existing_solver() {return Existing_solver;}
275 
276  /// Function return value of which preconditioner (if any) is stored.
277  unsigned existing_preconditioner() {return Existing_preconditioner;}
278 
279  //??ds comment, write access functions and move to protected?
286 
287  protected:
288 
289  /// Function deletes all solver data.
290  void hypre_clean_up_memory();
291 
292  /// \short Function which sets values of First_global_row,
293  /// Last_global_row and other partitioning data and creates the distributed
294  /// Hypre matrix (stored in Matrix_ij/Matrix_par) from the CRDoubleMatrix.
295  void hypre_matrix_setup(CRDoubleMatrix* matrix_pt);
296 
297  /// \short Sets up the data required for to use as an oomph-lib
298  /// LinearSolver or Preconditioner. This must be called after
299  /// the Hypre matrix has been generated using hypre_matrix_setup(...).
300  void hypre_solver_setup();
301 
302  /// \short Helper function performs a solve if any solver
303  /// exists.
304  void hypre_solve(const DoubleVector &rhs, DoubleVector &solution);
305 
306  /// Flag is true to output info and results of timings
308 
309  /// Maximum number of iterations used in solver.
310  unsigned Max_iter;
311 
312  /// Tolerance used to terminate solver.
313  double Tolerance;
314 
315  /// \short Hypre method flag. Valid values are specified in enumeration
316  unsigned Hypre_method;
317 
318  /// \short Preconditioner method flag used with Hypre's PCG,
319  /// GMRES and BiCGStab in solve(...) or resolve(...). Valid values
320  /// are BoomerAMG, Euclid, ParaSails or None (all enumerated above),
321  /// for any other value no preconditioner is set.
323 
324  /// \short Used to set the Hypre printing level for AMG
325  /// 0: no printout
326  /// 1: print setup information
327  /// 2: print solve information
328  /// 3: print setup and solve information
329  unsigned AMG_print_level;
330 
331  /// Maximum number of levels used in AMG
332  unsigned AMG_max_levels;
333 
334  /// Parameter to identify diagonally dominant parts of the matrix in AMG
336 
337  /// \short Flag to determine whether simple smoothers (determined by the
338  /// AMG_simple_smoother flag) or complex smoothers (determined by the
339  /// AMG_complex_smoother flag are used in AMG
341 
342  /// \short Simple smoothing methods used in BoomerAMG. Relaxation types
343  /// include:
344  /// 0 = Jacobi
345  /// 1 = Gauss-Seidel, sequential
346  /// (very slow in parallel!)
347  /// 2 = Gauss-Seidel, interior points in parallel, boundary sequential
348  /// (slow in parallel!)
349  /// 3 = hybrid Gauss-Seidel or SOR, forward solve
350  /// 4 = hybrid Gauss-Seidel or SOR, backward solve
351  /// 6 = hybrid symmetric Gauss-Seidel or SSOR
352  /// To use these methods set AMG_using_simple_smoothing to true
354 
355  /// \short Complex smoothing methods used in BoomerAMG. Relaxation types
356  /// are:
357  /// 6 = Schwarz
358  /// 7 = Pilut
359  /// 8 = ParaSails
360  /// 9 = Euclid
361  /// To use these methods set AMG_using_simple_smoothing to false
363 
364  /// \short The number of smoother iterations to apply
366 
367  /// Damping factor for BoomerAMG smoothed Jacobi or hybrid SOR
368  double AMG_damping;
369 
370  /// Connection strength threshold parameter for BoomerAMG
371  double AMG_strength;
372 
373  /// Interpolation truncation factor for BoomerAMG
375 
376  /// \short AMG coarsening strategy. Coarsening types include:
377  /// 0 = CLJP (parallel coarsening using independent sets)
378  /// 1 = classical RS with no boundary treatment (not recommended
379  /// in parallel)
380  /// 3 = modified RS with 3rd pass to add C points on the boundaries
381  /// 6 = Falgout (uses 1 then CLJP using interior coarse points as
382  /// first independent set)
383  /// 8 = PMIS (parallel coarsening using independent sets - lower
384  /// complexities than 0, maybe also slower convergence)
385  /// 10= HMIS (one pass RS on each processor then PMIS on interior
386  /// coarse points as first independent set)
387  /// 11= One pass RS on each processor (not recommended)
388  unsigned AMG_coarsening;
389 
390  /// \short ParaSails symmetry flag, used to inform ParaSails of
391  /// Symmetry of definitenss of problem and type of ParaSails
392  /// preconditioner:
393  /// 0 = nonsymmetric and/or indefinite problem, nonsymmetric preconditioner
394  /// 1 = SPD problem, and SPD (factored preconditioner)
395  /// 2 = nonsymmetric, definite problem and SDP (factored preconditoner)
397 
398  /// ParaSails nlevel parameter
400 
401  /// ParaSails thresh parameter
403 
404  /// ParaSails filter parameter
406 
407  /// Euclid drop tolerance for ILU(k) and ILUT factorization
409 
410  /// Flag to switch on Euclid row scaling
412 
413  /// Flag to determine if ILUT (if true) or ILU(k) is used in Euclid
415 
416  /// Flag to determine if Block Jacobi is used instead of PILU
418 
419  /// Euclid level parameter for ILU(k) factorization
421 
422  /// \short Flag to set the level of printing from Euclid
423  /// when the Euclid destructor is called
424  /// 0: no printing (default)
425  /// 1: prints summary of runtime settings and timings
426  /// 2: as 1 plus prints memory usage
428 
429  /// \short Used to set the Hypre printing level for the Krylov
430  /// subspace solvers
432 
433  /// \short Flag to determine if non-zero values of the Hypre error flag
434  /// plus Hypre error messages are output to screen at various points
435  /// in the solve function, i.e. after:
436  /// 1. setting up the Hypre matrix
437  /// 2. setting up the preconditioner
438  /// 3. setting up the solver
439  /// 4. setting up the Hypre vectors
440  /// 5. solving
441  /// 6. getting the solution vector
442  /// 7. deallocation of solver data
444 
445  /// \short Internal flag which is true when hypre_setup or hypre_solve
446  /// can delete input matrix.
448 
449 #ifdef OOMPH_HAS_MPI
450  /// \short Internal flag which tell the solver if the rhs Vector is
451  /// distributed or not
453 
454  /// \short Internal flag which tell the solver if the solution Vector to
455  /// be returned is distributed or not
457 #endif
458 
459  private:
460 
461  /// \short Hypre copies matrix data from oomph-lib's CRDoubleMatrix
462  /// into its own data structures, doubling the memory requirements.
463  /// As far as the Hypre solvers are concerned the oomph-lib matrix
464  /// is no longer required and could be deleted to save memory.
465  /// However, this will not be the expected behaviour and therefore
466  /// needs to be requested explicitly by the user by changing this
467  /// flag from false (its default) to true.
469 
470  /// \short The Hypre_IJMatrix version of the matrix used in solve(...),
471  /// resolve(...) or preconditioner_solve(...).
472  HYPRE_IJMatrix Matrix_ij;
473 
474  /// \short The Hypre_ParCSRMatrix version of the matrix used in solve(...),
475  /// resolve(...) or preconditioner_solve(...).
476  HYPRE_ParCSRMatrix Matrix_par;
477 
478  /// \short The Hypre solver used in solve(...), resolve(...) or
479  /// preconditioner_solve(...). [This is a C structure!]
480  HYPRE_Solver Solver;
481 
482  /// \short The internal Hypre preconditioner used in conjunction with
483  /// Solver. [This is a C structure!]
484  HYPRE_Solver Preconditioner;
485 
486  /// Used to keep track of which solver (if any) is currently stored.
487  unsigned Existing_solver;
488 
489  /// Used to keep track of which preconditioner (if any) is currently stored.
491 
492  /// the distribution for this helpers-
494  };
495 
496 
497 
498 ////////////////////////////////////////////////////////////////////////
499 ////////////////////////////////////////////////////////////////////////
500 ////////////////////////////////////////////////////////////////////////
501 
502 //=====================================================================
503 /// An LinearSolver class using the suite of Hypre solvers
504 /// to allow
505 ///
506 /// BoomerAMG (AMG), CG, GMRES or BiCGStab
507 ///
508 /// to be used for LinearSolver::solve(...) or LinearSolver::resolve(...).
509 ///
510 /// The Krylov subspace solvers (CG, GMRES and BiCGStab) may be
511 /// preconditioned using:
512 ///
513 /// BoomerAMG, Euclid or ParaSails
514 ///
515 /// By default GMRES without preconditioning is used.
516 //====================================================================
517  class HypreSolver : public LinearSolver, public HypreInterface
518  {
519  public:
520 
521  /// \short Constructor
523  {
524  // Hypre copies matrix data from oomph-lib's CRDoubleMatrix
525  // and Distributed CRDoubleMatrix into its own data structures,
526  // doubling the memory requirements for the matrix.
527  // As far as the Hypre solvers are concerned the oomph-lib matrix
528  // is no longer required and could be deleted to save memory.
529  // However, this will not be the expected behaviour and therefore
530  // needs to be requested explicitly by the user by changing this
531  // flag from false (its default) to true.
532  Delete_matrix = false;
533 
534  // Do we want to output results of timings?
535  Doc_time = true;
536  }
537 
538  /// Empty destructor.
540 
541  /// Broken copy constructor.
543  {
544  BrokenCopy::broken_copy("HypreSolver");
545  }
546 
547  /// Broken assignment operator.
548  void operator=(const HypreSolver&)
549  {
550  BrokenCopy::broken_assign("HypreSolver");
551  }
552 
553  /// \short Disable resolve function (overloads the LinearSolver
554  /// disable_resolve function).
556  {
557  Enable_resolve=false;
558  clean_up_memory();
559  }
560 
561  /// Access function to Max_iter
562  unsigned& max_iter() {return Max_iter;}
563 
564  /// Access function to Tolerance
565  double& tolerance() {return Tolerance;}
566 
567  /// Access function to Hypre_method flag -- specified via enumeration.
568  unsigned& hypre_method() {return Hypre_method;}
569 
570  /// \short Access function to Internal_preconditioner flag -- specified
571  /// via enumeration.
572  unsigned& internal_preconditioner() {return Internal_preconditioner;}
573 
574  /// \short Function to select use of 'simple' AMG smoothers as controlled
575  /// by AMG_simple_smoother flag
576  void amg_using_simple_smoothing() {AMG_using_simple_smoothing = true;}
577 
578  /// Access function to AMG_simple_smoother flag
579  unsigned& amg_simple_smoother() {return AMG_simple_smoother;}
580 
581  /// \short Function to select use of 'complex' AMG smoothers as controlled
582  /// by AMG_complex_smoother flag
583  void amg_using_complex_smoothing() {AMG_using_simple_smoothing = false;}
584 
585  /// Access function to AMG_complex_smoother flag
586  unsigned& amg_complex_smoother() {return AMG_complex_smoother;}
587 
588  /// Access function to AMG_print_level
589  unsigned& amg_print_level() {return AMG_print_level;}
590 
591  /// Access function to AMG_smoother_iterations
593 
594  /// Access function to AMG_coarsening flag
595  unsigned& amg_coarsening() {return AMG_coarsening;}
596 
597  /// Access function to AMG_max_levels
598  unsigned& amg_max_levels() {return AMG_max_levels;}
599 
600  /// Access function to AMG_damping parameter
601  double& amg_damping() {return AMG_damping;}
602 
603  /// Access function to AMG_strength
604  double& amg_strength() {return AMG_strength;}
605 
606  /// Access function to AMG_max_row_sum
607  double& amg_max_row_sum() {return AMG_max_row_sum;}
608 
609  /// Access function to AMG_truncation
610  double& amg_truncation() {return AMG_truncation;}
611 
612  /// Access function to ParaSails symmetry flag
613  int& parasails_symmetry() {return ParaSails_symmetry;}
614 
615  /// Access function to ParaSails nlevel parameter
616  int& parasails_nlevel() {return ParaSails_nlevel;}
617 
618  /// Access function to ParaSails thresh parameter
619  double& parasails_thresh() {return ParaSails_thresh;}
620 
621  /// Access function to ParaSails filter parameter
622  double& parasails_filter() {return ParaSails_filter;}
623 
624  /// Access function to Euclid drop tolerance parameter
625  double& euclid_droptol() {return Euclid_droptol;}
626 
627  /// Access function to Euclid level parameter
628  /// for ILU(k) factorization
629  int& euclid_level() {return Euclid_level;}
630 
631  /// Enable euclid rowScaling
632  void enable_euclid_rowScale() {Euclid_rowScale=true;}
633 
634  /// Disable euclid row scaling
635  void disable_euclid_rowScale() {Euclid_rowScale=false;}
636 
637  /// \short Enable use of Block Jacobi
638  /// as opposed to PILU
639  void enable_euclid_using_BJ() {Euclid_using_BJ=true;}
640 
641  /// \short Disable use of Block Jacobi,
642  /// so PILU will be used
643  void disable_euclid_using_BJ() {Euclid_using_BJ=false;}
644 
645  /// \short Function to switch on ILU(k) factorization for Euclid
646  /// (default is ILU(k) factorization)
647  void euclid_using_ILUK() {Euclid_using_ILUT = false;}
648 
649  /// \short Function to switch on ILUT factorization for Euclid
650  /// (default is ILU(k) factorization)
651  void euclid_using_ILUT() {Euclid_using_ILUT = true;}
652 
653  /// \short Function to set the level of printing from Euclid
654  /// when the Euclid destructor is called
655  /// 0: no printing (default)
656  /// 1: prints summary of runtime settings and timings
657  /// 2: as 1 plus prints memory usage
658  unsigned& euclid_print_level() {return Euclid_print_level;}
659 
660  /// Access function to Krylov_print_level
661  unsigned& krylov_print_level() {return Krylov_print_level;}
662 
663  /// \short Hypre copies matrix data from oomph-lib's CRDoubleMatrix
664  /// or DistributedCRDoubleMatrix into its own data structures,
665  /// doubling the memory requirements for the matrix.
666  /// As far as the Hypre solvers are concerned the oomph-lib matrix
667  /// is no longer required and could be deleted to save memory.
668  /// However, this will not be the expected behaviour and therefore
669  /// needs to be requested explicitly by the user by calling this function
670  /// which changes the
671  /// flag from false (its default) to true.
672  void enable_delete_matrix() {Delete_matrix=true;}
673 
674  /// \short Hypre copies matrix data from oomph-lib's CRDoubleMatrix
675  /// or DistributedCRDoubleMatrix into its own data structures,
676  /// doubling the memory requirements for the matrix.
677  /// Calling this function ensures that the matrix is not deleted.
678  void disable_delete_matrix() {Delete_matrix=false;}
679 
680 
681  /// \short Function which uses problem_pt's get_jacobian(...) function to
682  /// generate a linear system which is then solved. This function deletes
683  /// any existing internal data and then generates a new Hypre solver.
684  void solve(Problem* const &problem_pt,
685  DoubleVector &solution);
686 
687  /// \short Function to solve the linear system defined by matrix_pt
688  /// and rhs. This function will delete any existing internal data
689  /// and generate a new Hypre solver.
690  /// \b Note: The matrix has to be of type CRDoubleMatrix or
691  /// Distributed CRDoubleMatrix.
692  /// \b Note: Hypre copies matrix data from oomph-lib's CRDoubleMatrix
693  /// or DistributedCRDoubleMatrix into its own data structures,
694  /// doubling the memory requirements for the matrix.
695  /// As far as the Hypre solvers are concerned, the oomph-lib matrix
696  /// is no longer required and could be deleted to save memory.
697  /// However, this will not be the expected behaviour and therefore
698  /// needs to be requested explicitly by the user by calling the
699  /// enable_delete_matrix() function.
700  void solve(DoubleMatrixBase* const &matrix_pt,
701  const DoubleVector &rhs,
702  DoubleVector &solution);
703 
704  /// \short Function to resolve a linear system using the existing solver
705  /// data, allowing a solve with a new right hand side vector. This
706  /// function must be used after a call to solve(...) with
707  /// enable_resolve set to true.
708  void resolve(const DoubleVector &rhs,
709  DoubleVector &solution);
710 
711  /// Function deletes all solver data.
712  void clean_up_memory();
713 
714  private:
715 
716  /// \short Hypre copies matrix data from oomph-lib's CRDoubleMatrix
717  /// or DistributedCRDoubleMatrix into its own data structures,
718  /// doubling the memory requirements for the matrix.
719  /// As far as the Hypre solvers are concerned the oomph-lib matrix
720  /// is no longer required and could be deleted to save memory.
721  /// However, this will not be the expected behaviour and therefore
722  /// needs to be requested explicitly by the user by changing this
723  /// flag from false (its default) to true.
725  };
726 
727 
728 
729 ////////////////////////////////////////////////////////////////////////
730 ////////////////////////////////////////////////////////////////////////
731 ////////////////////////////////////////////////////////////////////////
732 
733 //=====================================================================
734 /// An Preconditioner class using the suite of Hypre preconditioners
735 /// to allow
736 ///
737 /// BoomerAMG (Algebraic Multi Grid),
738 /// Euclid (ILU) or
739 /// ParaSails (Approximate inverse)
740 ///
741 /// to be used for Preconditioner::preconditioner_solve(...).
742 /// By default BoomerAMG is used.
743 //====================================================================
745  {
746  public:
747 
748  /// \short Constructor. Provide optional string that is used
749  /// in annotation of performance
750  HyprePreconditioner(const std::string& context_string="")
751  {
752  Context_string=context_string;
753 
754  // Hypre copies matrix data from oomph-lib's CRDoubleMatrix
755  // or DistributedCRDoubleMatrix into its own data structures,
756  // doubling the memory requirements for the matrix.
757  // As far as the Hypre solvers are concerned the oomph-lib matrix
758  // is no longer required and could be deleted to save memory.
759  // However, this will not be the expected behaviour and therefore
760  // needs to be requested explicitly by the user by changing this
761  // flag from false (its default) to true.
762  Delete_matrix = false;
763 
764  // Do we want to output results of timings?
765  Doc_time = true;
766 
767  // General control paramaters for using HYPRE as preconditioner
768  Tolerance = 0.0;
769  Max_iter = 1;
770  Hypre_method = BoomerAMG;
771  Internal_preconditioner = None;
772 
773  // Initialise private double that accumulates the preconditioner
774  // solve time of thi instantiation of this class. Is reported
775  // in destructor if Report_my_cumulative_preconditioner_solve_time
776  // is set to true
777  My_cumulative_preconditioner_solve_time=0.0;
778  Report_my_cumulative_preconditioner_solve_time=false;
779  }
780 
781  /// Destructor.
783  {
784  if (Report_my_cumulative_preconditioner_solve_time)
785  {
786  oomph_info
787  << "~HyprePreconditioner() in context \" "
788  << Context_string << "\": My_cumulative_preconditioner_solve_time = "
789  << My_cumulative_preconditioner_solve_time << std::endl;
790  }
791  }
792 
793  /// Broken copy constructor.
795  {
796  BrokenCopy::broken_copy("HyprePreconditioner");
797  }
798 
799  /// Broken assignment operator.
801  {
802  BrokenCopy::broken_assign("HyprePreconditioner");
803  }
804 
805  /// \short Static double that accumulates the preconditioner
806  /// solve time of all instantiations of this class. Reset
807  /// it manually, e.g. after every Newton solve, using
808  /// reset_cumulative_solve_times().
810 
811  /// \short Static double that accumulates the preconditioner
812  /// solve time of all instantiations of this class, labeled by
813  /// context string. Reset
814  /// it manually, e.g. after every Newton solve, using
815  /// reset_cumulative_solve_times().
816  static std::map<std::string,double> Context_based_cumulative_solve_time;
817 
818 
819  /// \short Static unsigned that accumulates the number of preconditioner
820  /// solves of all instantiations of this class. Reset
821  /// it manually, e.g. after every Newton solve, using
822  /// reset_cumulative_solve_times().
824 
825  /// \short Static unsigned that accumulates the number of preconditioner
826  /// solves of all instantiations of this class, labeled by
827  /// context string. Reset
828  /// it manually, e.g. after every Newton solve, using
829  /// reset_cumulative_solve_times().
830  static std::map<std::string,unsigned>
832 
833  /// \short Static unsigned that stores nrow for the most recent
834  /// instantiations of this class, labeled by
835  /// context string. Reset
836  /// it manually, e.g. after every Newton solve, using
837  /// reset_cumulative_solve_times().
838  static std::map<std::string,unsigned> Context_based_nrow;
839 
840  /// \short Report cumulative solve times of all instantiations of this
841  /// class
842  static void report_cumulative_solve_times();
843 
844  /// \short Reset cumulative solve times
845  static void reset_cumulative_solve_times();
846 
847  /// \short Enable reporting of cumulative solve time in destructor
849  {Report_my_cumulative_preconditioner_solve_time=true;}
850 
851  /// \short Disable reporting of cumulative solve time in destructor
853  {Report_my_cumulative_preconditioner_solve_time=false;}
854 
855  /// Enable documentation of preconditioner timings
856  void enable_doc_time() {Doc_time = true;}
857 
858  /// Disable documentation of preconditioner timings
859  void disable_doc_time() {Doc_time = false;}
860 
861  /// Access function to Hypre_method flag -- specified via enumeration.
862  unsigned& hypre_method() {return Hypre_method;}
863 
864  /// \short Access function to Internal_preconditioner flag -- specified
865  /// via enumeration.
866  unsigned& internal_preconditioner() {return Internal_preconditioner;}
867 
868  /// Function to select BoomerAMG as the preconditioner
869  void use_BoomerAMG() {Hypre_method=BoomerAMG;}
870 
871  /// Function to set the number of times to apply BoomerAMG
872  void set_amg_iterations(const unsigned& amg_iterations)
873  {
874  Max_iter = amg_iterations;
875  }
876 
877  /// Return function for Max_iter
878  unsigned& amg_iterations()
879  {
880  return Max_iter;
881  }
882 
883  /// \short Function to select use of 'simple' AMG smoothers as controlled
884  /// by the flag AMG_simple_smoother
885  void amg_using_simple_smoothing() {AMG_using_simple_smoothing = true;}
886 
887  /// Access function to AMG_simple_smoother flag
888  unsigned& amg_simple_smoother() {return AMG_simple_smoother;}
889 
890  /// \short Function to select use of 'complex' AMG smoothers as controlled
891  /// by the flag AMG_complex_smoother
892  void amg_using_complex_smoothing() {AMG_using_simple_smoothing = false;}
893 
894  /// Access function to AMG_complex_smoother flag
895  unsigned& amg_complex_smoother() {return AMG_complex_smoother;}
896 
897  /// \short Return function for the AMG_using_simple_smoothing_flag
899  {
900  return AMG_using_simple_smoothing;
901  }
902 
903  /// Access function to AMG_print_level
904  unsigned& amg_print_level() {return AMG_print_level;}
905 
906  /// Access function to AMG_smoother_iterations
908 
909  /// Access function to AMG_coarsening flag
910  unsigned& amg_coarsening() {return AMG_coarsening;}
911 
912  /// Access function to AMG_max_levels
913  unsigned& amg_max_levels() {return AMG_max_levels;}
914 
915  /// Access function to AMG_damping parameter
916  double& amg_damping() {return AMG_damping;}
917 
918  /// Access function to AMG_strength
919  double& amg_strength() {return AMG_strength;}
920 
921  /// Access function to AMG_max_row_sum
922  double& amg_max_row_sum() {return AMG_max_row_sum;}
923 
924  /// Access function to AMG_truncation
925  double& amg_truncation() {return AMG_truncation;}
926 
927  /// Function to select ParaSails as the preconditioner
928  void use_ParaSails() {Hypre_method=ParaSails;}
929 
930  /// Access function to ParaSails symmetry flag
931  int& parasails_symmetry() {return ParaSails_symmetry;}
932 
933  /// Access function to ParaSails nlevel parameter
934  int& parasails_nlevel() {return ParaSails_nlevel;}
935 
936  /// Access function to ParaSails thresh parameter
937  double& parasails_thresh() {return ParaSails_thresh;}
938 
939  /// Access function to ParaSails filter parameter
940  double& parasails_filter() {return ParaSails_filter;}
941 
942  /// Function to select use Euclid as the preconditioner
943  void use_Euclid() {Hypre_method=Euclid;}
944 
945  /// Access function to Euclid drop tolerance parameter
946  double& euclid_droptol() {return Euclid_droptol;}
947 
948  /// Access function to Euclid level parameter for ILU(k) factorization
949  int& euclid_level() {return Euclid_level;}
950 
951  /// Enable euclid rowScaling
952  void enable_euclid_rowScale() {Euclid_rowScale=true;}
953 
954  /// Disable euclid row scaling
955  void disable_euclid_rowScale() {Euclid_rowScale=false;}
956 
957  /// \short Enable use of Block Jacobi
958  /// as opposed to PILU
959  void enable_euclid_using_BJ() {Euclid_using_BJ=true;}
960 
961  /// \short Disable use of Block Jacobi,
962  /// so PILU will be used
963  void disable_euclid_using_BJ() {Euclid_using_BJ=false;}
964 
965  /// \short Function to switch on ILU(k) factorization for Euclid
966  /// (default is ILU(k) factorization)
967  void euclid_using_ILUK() {Euclid_using_ILUT = false;}
968 
969  /// \short Function to switch on ILUT factorization for Euclid
970  /// (default is ILU(k) factorization)
971  void euclid_using_ILUT() {Euclid_using_ILUT = true;}
972 
973  /// \short Function to set the level of printing from Euclid
974  /// when the Euclid destructor is called
975  /// 0: no printing (default)
976  /// 1: prints summary of runtime settings and timings
977  /// 2: as 1 plus prints memory usage
978  unsigned& euclid_print_level() {return Euclid_print_level;}
979 
980  /// \short Hypre copies matrix data from oomph-lib's CRDoubleMatrix
981  /// or DistributedCRDoubleMatrix into its own data structures,
982  /// doubling the memory requirements for the matrix.
983  /// As far as the Hypre solvers are concerned the oomph-lib matrix
984  /// is no longer required and could be deleted to save memory.
985  /// However, this will not be the expected behaviour and therefore
986  /// needs to be requested explicitly by the user by calling this function
987  /// which changes the
988  /// flag from false (its default) to true.
989  void enable_delete_matrix() {Delete_matrix=true;}
990 
991  /// \short Hypre copies matrix data from oomph-lib's CRDoubleMatrix
992  /// or DistributedCRDoubleMatrix into its own data structures,
993  /// doubling the memory requirements for the matrix.
994  /// Calling this function ensures that the matrix is not deleted.
995  void disable_delete_matrix() {Delete_matrix=false;}
996 
997  /// \short Function to set up a preconditioner for the linear
998  /// system defined by matrix_pt. This function is required when
999  /// preconditioning and must be called before using the
1000  /// preconditioner_solve(...) function. This interface allows
1001  /// HyprePreconditioner to be used as a Preconditioner object
1002  /// for oomph-lib's own IterativeLinearSolver class.
1003  /// \b Note: matrix_pt must point to an object of type
1004  /// CRDoubleMatrix or DistributedCRDoubleMatrix.
1005  /// \b Note: Hypre copies matrix data from oomph-lib's CRDoubleMatrix
1006  /// and DistributedCRDoubleMatrix into its own data structures,
1007  /// doubling the memory requirements for the matrix.
1008  /// As far as the Hypre solvers are concerned, the oomph-lib matrix
1009  /// is no longer required and could be deleted to save memory.
1010  /// However, this will not be the expected behaviour and therefore
1011  /// needs to be requested explicitly by the user by calling the
1012  /// enable_delete_matrix() function.
1013  void setup();
1014 
1015  /// \short Function applies solver to vector r for preconditioning.
1016  /// This requires a call to setup(...) first.
1017  /// \b Note: Hypre copies matrix data from oomph-lib's CRDoubleMatrix
1018  /// or DistributedCRDoubleMatrix into its own data structures,
1019  /// doubling the memory requirements for the matrix.
1020  /// As far as the Hypre solvers are concerned, the oomph-lib matrix
1021  /// is no longer required and could be deleted to save memory.
1022  /// However, this will not be the expected behaviour and therefore
1023  /// needs to be requested explicitly by the user with the
1024  /// delete_matrix() function.
1025  void preconditioner_solve(const DoubleVector &r,
1026  DoubleVector &z);
1027 
1028  /// Function deletes all solver data.
1029  void clean_up_memory();
1030 
1031  private:
1032 
1033  /// \short Hypre copies matrix data from oomph-lib's CRDoubleMatrix
1034  /// or DistributedCRDoubleMatrix into its own data structures,
1035  /// doubling the memory requirements for the matrix.
1036  /// As far as the Hypre solvers are concerned the oomph-lib matrix
1037  /// is no longer required and could be deleted to save memory.
1038  /// However, this will not be the expected behaviour and therefore
1039  /// needs to be requested explicitly by the user by changing this
1040  /// flag from false (its default) to true.
1042 
1043  // Flag is true to output results of timings
1044  bool Doc_time;
1045 
1046  /// \short Private double that accumulates the preconditioner
1047  /// solve time of thi instantiation of this class. Is reported
1048  /// in destructor if Report_my_cumulative_preconditioner_solve_time
1049  /// is set to true
1051 
1052  /// \short Bool to request report of My_cumulative_preconditioner_solve_time
1053  /// in destructor
1055 
1056  /// String can be used to provide context for annotation
1058 
1059  };
1060 
1061 
1062 ////////////////////////////////////////////////////////////////////////
1063 ////////////////////////////////////////////////////////////////////////
1064 ////////////////////////////////////////////////////////////////////////
1065 
1066 //==================================================================
1067 /// Default settings for various uses of the Hypre solver
1068 //==================================================================
1069  namespace Hypre_default_settings
1070  {
1071 
1072  /// \short Set default parameters for use as preconditioner in
1073  /// for momentum block in Navier-Stokes problem
1075  HyprePreconditioner* hypre_preconditioner_pt);
1076 
1077  /// \short Set default parameters for use as preconditioner in
1078  /// 2D Poisson-type problem.
1080  HyprePreconditioner* hypre_preconditioner_pt);
1081 
1082  /// \short Set default parameters for use as preconditioner in
1083  /// 3D Poisson-type problem.
1085  HyprePreconditioner* hypre_preconditioner_pt);
1086 
1087  }
1088 }
1089 
1090 #endif
bool Output_info
Flag is true to output info and results of timings.
Definition: hypre_solver.h:307
bool & amg_using_simple_smoothing_flag()
Return function for the AMG_using_simple_smoothing_flag.
Definition: hypre_solver.h:898
unsigned Krylov_print_level
Used to set the Hypre printing level for the Krylov subspace solvers.
Definition: hypre_solver.h:431
double & parasails_filter()
Access function to ParaSails filter parameter.
Definition: hypre_solver.h:622
void disable_euclid_using_BJ()
Disable use of Block Jacobi,.
Definition: hypre_solver.h:643
void use_BoomerAMG()
Function to select BoomerAMG as the preconditioner.
Definition: hypre_solver.h:869
unsigned & amg_simple_smoother()
Access function to AMG_simple_smoother flag.
Definition: hypre_solver.h:888
unsigned & amg_iterations()
Return function for Max_iter.
Definition: hypre_solver.h:878
int Euclid_level
Euclid level parameter for ILU(k) factorization.
Definition: hypre_solver.h:420
void amg_using_complex_smoothing()
Function to select use of &#39;complex&#39; AMG smoothers as controlled by AMG_complex_smoother flag...
Definition: hypre_solver.h:583
unsigned Hypre_method
Hypre method flag. Valid values are specified in enumeration.
Definition: hypre_solver.h:316
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
bool Hypre_error_messages
Flag to determine if non-zero values of the Hypre error flag plus Hypre error messages are output to ...
Definition: hypre_solver.h:443
HYPRE_IJMatrix Matrix_ij
The Hypre_IJMatrix version of the matrix used in solve(...), resolve(...) or preconditioner_solve(...).
Definition: hypre_solver.h:472
HypreSolver(const HypreSolver &)
Broken copy constructor.
Definition: hypre_solver.h:542
unsigned & amg_max_levels()
Access function to AMG_max_levels.
Definition: hypre_solver.h:598
void enable_euclid_rowScale()
Enable euclid rowScaling.
Definition: hypre_solver.h:952
HYPRE_Solver Preconditioner
The internal Hypre preconditioner used in conjunction with Solver. [This is a C structure!].
Definition: hypre_solver.h:484
void disable_euclid_rowScale()
Disable euclid row scaling.
Definition: hypre_solver.h:955
void euclid_using_ILUT()
Function to switch on ILUT factorization for Euclid (default is ILU(k) factorization) ...
Definition: hypre_solver.h:971
~HypreSolver()
Empty destructor.
Definition: hypre_solver.h:539
double & amg_truncation()
Access function to AMG_truncation.
Definition: hypre_solver.h:610
bool AMGEuclidSmoother_use_block_jacobi
Definition: hypre_solver.h:280
void enable_euclid_rowScale()
Enable euclid rowScaling.
Definition: hypre_solver.h:632
HypreSolver()
Constructor.
Definition: hypre_solver.h:522
double & amg_damping()
Access function to AMG_damping parameter.
Definition: hypre_solver.h:916
void use_ParaSails()
Function to select ParaSails as the preconditioner.
Definition: hypre_solver.h:928
void enable_euclid_using_BJ()
Enable use of Block Jacobi as opposed to PILU.
Definition: hypre_solver.h:639
int hypre__global_error
bool Report_my_cumulative_preconditioner_solve_time
Bool to request report of My_cumulative_preconditioner_solve_time in destructor.
~HypreInterface()
Destructor.
Definition: hypre_solver.h:236
void disable_hypre_error_messages()
Turn off hypre error messages.
Definition: hypre_solver.h:261
double & euclid_droptol()
Access function to Euclid drop tolerance parameter.
Definition: hypre_solver.h:625
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.
bool AMG_using_simple_smoothing
Flag to determine whether simple smoothers (determined by the AMG_simple_smoother flag) or complex sm...
Definition: hypre_solver.h:340
unsigned AMG_print_level
Used to set the Hypre printing level for AMG 0: no printout 1: print setup information 2: print solve...
Definition: hypre_solver.h:329
std::string Context_string
String can be used to provide context for annotation.
bool Delete_matrix
Hypre copies matrix data from oomph-lib&#39;s CRDoubleMatrix into its own data structures, doubling the memory requirements. As far as the Hypre solvers are concerned the oomph-lib matrix is no longer required and could be deleted to save memory. However, this will not be the expected behaviour and therefore needs to be requested explicitly by the user by changing this flag from false (its default) to true.
Definition: hypre_solver.h:468
The Problem class.
Definition: problem.h:152
double AMGEuclidSmoother_drop_tol
Definition: hypre_solver.h:284
void operator=(const HyprePreconditioner &)
Broken assignment operator.
Definition: hypre_solver.h:800
int ParaSails_nlevel
ParaSails nlevel parameter.
Definition: hypre_solver.h:399
void euclid_using_ILUT()
Function to switch on ILUT factorization for Euclid (default is ILU(k) factorization) ...
Definition: hypre_solver.h:651
double My_cumulative_preconditioner_solve_time
Private double that accumulates the preconditioner solve time of thi instantiation of this class...
double Euclid_droptol
Euclid drop tolerance for ILU(k) and ILUT factorization.
Definition: hypre_solver.h:408
void amg_using_complex_smoothing()
Function to select use of &#39;complex&#39; AMG smoothers as controlled by the flag AMG_complex_smoother.
Definition: hypre_solver.h:892
double AMG_strength
Connection strength threshold parameter for BoomerAMG.
Definition: hypre_solver.h:371
unsigned & amg_print_level()
Access function to AMG_print_level.
Definition: hypre_solver.h:904
void operator=(const HypreSolver &)
Broken assignment operator.
Definition: hypre_solver.h:548
unsigned & amg_coarsening()
Access function to AMG_coarsening flag.
Definition: hypre_solver.h:910
static OomphCommunicator * communicator_pt()
access to the global oomph-lib communicator
OomphInfo oomph_info
void enable_delete_matrix()
Hypre copies matrix data from oomph-lib&#39;s CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
Definition: hypre_solver.h:989
unsigned & amg_complex_smoother()
Access function to AMG_complex_smoother flag.
Definition: hypre_solver.h:586
unsigned & amg_coarsening()
Access function to AMG_coarsening flag.
Definition: hypre_solver.h:595
static bool mpi_has_been_initialised()
return true if MPI has been initialised
e
Definition: cfortran.h:575
The GMRES method.
unsigned Existing_preconditioner
Used to keep track of which preconditioner (if any) is currently stored.
Definition: hypre_solver.h:490
void set_amg_iterations(const unsigned &amg_iterations)
Function to set the number of times to apply BoomerAMG.
Definition: hypre_solver.h:872
bool AMGEuclidSmoother_use_row_scaling
Definition: hypre_solver.h:281
unsigned Existing_solver
Used to keep track of which solver (if any) is currently stored.
Definition: hypre_solver.h:487
unsigned & internal_preconditioner()
Access function to Internal_preconditioner flag – specified via enumeration.
Definition: hypre_solver.h:572
void disable_delete_matrix()
Hypre copies matrix data from oomph-lib&#39;s CRDoubleMatrix.
Definition: hypre_solver.h:678
HypreInterface(const HypreInterface &)
Broken copy constructor.
Definition: hypre_solver.h:246
unsigned & amg_print_level()
Access function to AMG_print_level.
Definition: hypre_solver.h:589
unsigned & amg_max_levels()
Access function to AMG_max_levels.
Definition: hypre_solver.h:913
unsigned AMG_simple_smoother
Simple smoothing methods used in BoomerAMG. Relaxation types include: 0 = Jacobi 1 = Gauss-Seidel...
Definition: hypre_solver.h:353
unsigned Euclid_print_level
Flag to set the level of printing from Euclid when the Euclid destructor is called 0: no printing (de...
Definition: hypre_solver.h:427
int & parasails_nlevel()
Access function to ParaSails nlevel parameter.
Definition: hypre_solver.h:616
double & parasails_filter()
Access function to ParaSails filter parameter.
Definition: hypre_solver.h:940
void setup()
Setup terminate helper.
bool Euclid_rowScale
Flag to switch on Euclid row scaling.
Definition: hypre_solver.h:411
int & parasails_symmetry()
Access function to ParaSails symmetry flag.
Definition: hypre_solver.h:931
unsigned & amg_smoother_iterations()
Access function to AMG_smoother_iterations.
Definition: hypre_solver.h:592
void euclid_using_ILUK()
Function to switch on ILU(k) factorization for Euclid (default is ILU(k) factorization) ...
Definition: hypre_solver.h:967
double AMG_strength
Default for AMG strength (0.25 recommended for 2D problems; larger (0.5-0.75, say) for 3D...
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
void enable_hypre_error_messages()
Turn on the hypre error messages.
Definition: hypre_solver.h:258
void amg_using_simple_smoothing()
Function to select use of &#39;simple&#39; AMG smoothers as controlled by the flag AMG_simple_smoother.
Definition: hypre_solver.h:885
double AMG_truncation
Interpolation truncation factor for BoomerAMG.
Definition: hypre_solver.h:374
static unsigned Cumulative_npreconditioner_solve
Static unsigned that accumulates the number of preconditioner solves of all instantiations of this cl...
Definition: hypre_solver.h:823
double & amg_damping()
Access function to AMG_damping parameter.
Definition: hypre_solver.h:601
unsigned AMGEuclidSmoother_print_level
Definition: hypre_solver.h:285
unsigned Max_iter
Maximum number of iterations used in solver.
Definition: hypre_solver.h:310
unsigned Internal_preconditioner
Preconditioner method flag used with Hypre&#39;s PCG, GMRES and BiCGStab in solve(...) or resolve(...
Definition: hypre_solver.h:322
HyprePreconditioner(const HyprePreconditioner &)
Broken copy constructor.
Definition: hypre_solver.h:794
bool Using_distributed_rhs
Internal flag which tell the solver if the rhs Vector is distributed or not.
Definition: hypre_solver.h:452
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...
Definition: hypre_solver.h:816
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.
Hypre_method_types
Enumerated flag to define which Hypre methods are used CAREFUL: DON&#39;T CHANGE THE ORDER OF THESE! ...
Definition: hypre_solver.h:265
double AMG_damping
Damping factor for BoomerAMG smoothed Jacobi or hybrid SOR.
Definition: hypre_solver.h:368
void set_defaults_for_3D_poisson_problem(HyprePreconditioner *hypre_preconditioner_pt)
Set default parameters for use as preconditioner in 3D Poisson-type problem.
Definition: hypre_solver.cc:77
unsigned & amg_smoother_iterations()
Access function to AMG_smoother_iterations.
Definition: hypre_solver.h:907
void disable_euclid_rowScale()
Disable euclid row scaling.
Definition: hypre_solver.h:635
unsigned & hypre_method()
Access function to Hypre_method flag – specified via enumeration.
Definition: hypre_solver.h:568
unsigned AMG_smoother_iterations
The number of smoother iterations to apply.
Definition: hypre_solver.h:365
void disable_doc_time()
Disable documentation of preconditioner timings.
Definition: hypre_solver.h:859
unsigned AMG_max_levels
Maximum number of levels used in AMG.
Definition: hypre_solver.h:332
void disable_resolve()
Disable resolve function (overloads the LinearSolver disable_resolve function).
Definition: hypre_solver.h:555
unsigned Max_iter
Max. # of Newton iterations.
unsigned AMG_coarsening
AMG coarsening strategy. Coarsening types include: 0 = CLJP (parallel coarsening using independent se...
Definition: hypre_solver.h:388
unsigned & hypre_method()
Access function to Hypre_method flag – specified via enumeration.
Definition: hypre_solver.h:862
unsigned existing_solver()
Function to return value of which solver (if any) is currently stored.
Definition: hypre_solver.h:274
HypreInterface()
Constructor.
Definition: hypre_solver.h:146
~HyprePreconditioner()
Destructor.
Definition: hypre_solver.h:782
double & parasails_thresh()
Access function to ParaSails thresh parameter.
Definition: hypre_solver.h:619
unsigned & krylov_print_level()
Access function to Krylov_print_level.
Definition: hypre_solver.h:661
double & amg_strength()
Access function to AMG_strength.
Definition: hypre_solver.h:604
HYPRE_ParCSRMatrix Matrix_par
The Hypre_ParCSRMatrix version of the matrix used in solve(...), resolve(...) or preconditioner_solve...
Definition: hypre_solver.h:476
double & euclid_droptol()
Access function to Euclid drop tolerance parameter.
Definition: hypre_solver.h:946
HYPRE_Solver Solver
The Hypre solver used in solve(...), resolve(...) or preconditioner_solve(...). [This is a C structur...
Definition: hypre_solver.h:480
bool Euclid_using_ILUT
Flag to determine if ILUT (if true) or ILU(k) is used in Euclid.
Definition: hypre_solver.h:414
int & parasails_symmetry()
Access function to ParaSails symmetry flag.
Definition: hypre_solver.h:613
unsigned AMG_complex_smoother
Complex smoothing methods used in BoomerAMG. Relaxation types are: 6 = Schwarz 7 = Pilut 8 = ParaSail...
Definition: hypre_solver.h:362
double & amg_max_row_sum()
Access function to AMG_max_row_sum.
Definition: hypre_solver.h:607
double ParaSails_thresh
ParaSails thresh parameter.
Definition: hypre_solver.h:402
unsigned AMGEuclidSmoother_level
Definition: hypre_solver.h:283
void operator=(const HypreInterface &)
Broken assignment operator.
Definition: hypre_solver.h:252
int ParaSails_symmetry
ParaSails symmetry flag, used to inform ParaSails of Symmetry of definitenss of problem and type of P...
Definition: hypre_solver.h:396
int & euclid_level()
Access function to Euclid level parameter for ILU(k) factorization.
Definition: hypre_solver.h:949
Preconditioner base class. Gives an interface to call all other preconditioners through and stores th...
void euclid_using_ILUK()
Function to switch on ILU(k) factorization for Euclid (default is ILU(k) factorization) ...
Definition: hypre_solver.h:647
void disable_euclid_using_BJ()
Disable use of Block Jacobi,.
Definition: hypre_solver.h:963
double & amg_truncation()
Access function to AMG_truncation.
Definition: hypre_solver.h:925
The conjugate gradient method.
double & tolerance()
Access function to Tolerance.
Definition: hypre_solver.h:565
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
void enable_report_my_cumulative_preconditioner_solve_time()
Enable reporting of cumulative solve time in destructor.
Definition: hypre_solver.h:848
double & amg_strength()
Access function to AMG_strength.
Definition: hypre_solver.h:919
bool Delete_input_data
Internal flag which is true when hypre_setup or hypre_solve can delete input matrix.
Definition: hypre_solver.h:447
void disable_report_my_cumulative_preconditioner_solve_time()
Disable reporting of cumulative solve time in destructor.
Definition: hypre_solver.h:852
bool Euclid_using_BJ
Flag to determine if Block Jacobi is used instead of PILU.
Definition: hypre_solver.h:417
bool Delete_matrix
Hypre copies matrix data from oomph-lib&#39;s CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
void enable_euclid_using_BJ()
Enable use of Block Jacobi as opposed to PILU.
Definition: hypre_solver.h:959
int & parasails_nlevel()
Access function to ParaSails nlevel parameter.
Definition: hypre_solver.h:934
static double Cumulative_preconditioner_solve_time
Static double that accumulates the preconditioner solve time of all instantiations of this class...
Definition: hypre_solver.h:809
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn&#39;t been defined.
bool Returning_distributed_solution
Internal flag which tell the solver if the solution Vector to be returned is distributed or not...
Definition: hypre_solver.h:456
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.
unsigned & amg_simple_smoother()
Access function to AMG_simple_smoother flag.
Definition: hypre_solver.h:579
unsigned & amg_complex_smoother()
Access function to AMG_complex_smoother flag.
Definition: hypre_solver.h:895
void amg_using_simple_smoothing()
Function to select use of &#39;simple&#39; AMG smoothers as controlled by AMG_simple_smoother flag...
Definition: hypre_solver.h:576
unsigned & internal_preconditioner()
Access function to Internal_preconditioner flag – specified via enumeration.
Definition: hypre_solver.h:866
double AMG_truncation
AMG interpolation truncation factor.
double AMG_max_row_sum
Parameter to identify diagonally dominant parts of the matrix in AMG.
Definition: hypre_solver.h:335
bool Delete_matrix
Hypre copies matrix data from oomph-lib&#39;s CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
Definition: hypre_solver.h:724
A vector in the mathematical sense, initially developed for linear algebra type applications. If MPI then this vector can be distributed - its distribution is described by the LinearAlgebraDistribution object at Distribution_pt. Data is stored in a C-style pointer vector (double*)
Definition: double_vector.h:61
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...
Definition: hypre_solver.cc:90
static std::map< std::string, unsigned > Context_based_nrow
Static unsigned that stores nrow for the most recent instantiations of this class, labeled by context string. Reset it manually, e.g. after every Newton solve, using reset_cumulative_solve_times().
Definition: hypre_solver.h:838
void enable_delete_matrix()
Hypre copies matrix data from oomph-lib&#39;s CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
Definition: hypre_solver.h:672
void use_Euclid()
Function to select use Euclid as the preconditioner.
Definition: hypre_solver.h:943
unsigned AMG_coarsening
Default AMG coarsening strategy. Coarsening types include: 0 = CLJP (parallel coarsening using indepe...
unsigned & euclid_print_level()
Function to set the level of printing from Euclid when the Euclid destructor is called 0: no printing...
Definition: hypre_solver.h:658
LinearAlgebraDistribution * Hypre_distribution_pt
the distribution for this helpers-
Definition: hypre_solver.h:493
Abstract base class for matrices of doubles – adds abstract interfaces for solving, LU decomposition and multiplication by vectors.
Definition: matrices.h:275
double Tolerance
Tolerance used to terminate solver.
Definition: hypre_solver.h:313
double & parasails_thresh()
Access function to ParaSails thresh parameter.
Definition: hypre_solver.h:937
unsigned & euclid_print_level()
Function to set the level of printing from Euclid when the Euclid destructor is called 0: no printing...
Definition: hypre_solver.h:978
A class for compressed row matrices. This is a distributable object.
Definition: matrices.h:872
unsigned & max_iter()
Access function to Max_iter.
Definition: hypre_solver.h:562
double & amg_max_row_sum()
Access function to AMG_max_row_sum.
Definition: hypre_solver.h:922
void set_defaults_for_2D_poisson_problem(HyprePreconditioner *hypre_preconditioner_pt)
Set default parameters for use as preconditioner in 2D Poisson-type problem.
Definition: hypre_solver.cc:50
HyprePreconditioner(const std::string &context_string="")
Constructor. Provide optional string that is used in annotation of performance.
Definition: hypre_solver.h:750
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...
Definition: hypre_solver.h:831
void enable_doc_time()
Enable documentation of preconditioner timings.
Definition: hypre_solver.h:856
void disable_delete_matrix()
Hypre copies matrix data from oomph-lib&#39;s CRDoubleMatrix.
Definition: hypre_solver.h:995
double ParaSails_filter
ParaSails filter parameter.
Definition: hypre_solver.h:405
unsigned existing_preconditioner()
Function return value of which preconditioner (if any) is stored.
Definition: hypre_solver.h:277
int check_HYPRE_error_flag(std::ostringstream &message)
Helper function to check the Hypre error flag, return the message associated with any error...