30 #ifndef OOMPH_HYPRE_SOLVER_HEADER 31 #define OOMPH_HYPRE_SOLVER_HEADER 34 #include "_hypre_utilities.h" 36 #include "HYPRE_parcsr_ls.h" 37 #include "HYPRE_krylov.h" 38 #include "HYPRE_IJ_mv.h" 39 #include "HYPRE_parcsr_mv.h" 57 namespace HypreHelpers
92 const LinearAlgebraDistribution* dist_pt,
93 HYPRE_IJVector& hypre_ij_vector,
94 HYPRE_ParVector& hypre_par_vector);
104 HYPRE_IJVector& hypre_ij_vector,
105 HYPRE_ParVector& hypre_par_vector);
110 HYPRE_IJMatrix& hypre_ij_matrix,
111 HYPRE_ParCSRMatrix& hypre_par_matrix,
112 LinearAlgebraDistribution* dist_pt);
117 const bool &use_row_scaling,
118 const bool &use_ilut,
120 const double &drop_tol,
121 const int &print_level,
122 HYPRE_Solver &euclid_object);
149 #ifndef HYPRE_SEQUENTIAL 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";
157 OOMPH_CURRENT_FUNCTION,
158 OOMPH_EXCEPTION_LOCATION);
169 Existing_solver = None;
170 Existing_preconditioner = None;
178 Hypre_method =
GMRES;
179 Internal_preconditioner = None;
183 AMG_using_simple_smoothing=
true;
187 AMG_simple_smoother = 0;
192 AMG_simple_smoother = 1;
194 AMG_complex_smoother = 6;
200 AMG_max_levels = 100;
201 AMG_max_row_sum = 1.0;
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;
211 AMGEuclidSmoother_print_level = 0;
214 Krylov_print_level = 0;
217 ParaSails_symmetry = 2;
218 ParaSails_nlevel = 1;
219 ParaSails_thresh = 0.1;
220 ParaSails_filter = 0.1;
223 Euclid_droptol = 0.0;
224 Euclid_rowScale =
false;
225 Euclid_using_ILUT =
false;
226 Euclid_using_BJ =
false;
228 Euclid_print_level = 0;
232 Hypre_error_messages =
false;
239 hypre_clean_up_memory();
242 delete Hypre_distribution_pt;
290 void hypre_clean_up_memory();
300 void hypre_solver_setup();
532 Delete_matrix =
false;
557 Enable_resolve=
false;
684 void solve(
Problem*
const &problem_pt,
712 void clean_up_memory();
752 Context_string=context_string;
762 Delete_matrix =
false;
770 Hypre_method = BoomerAMG;
771 Internal_preconditioner = None;
777 My_cumulative_preconditioner_solve_time=0.0;
778 Report_my_cumulative_preconditioner_solve_time=
false;
784 if (Report_my_cumulative_preconditioner_solve_time)
787 <<
"~HyprePreconditioner() in context \" " 788 << Context_string <<
"\": My_cumulative_preconditioner_solve_time = " 789 << My_cumulative_preconditioner_solve_time << std::endl;
830 static std::map<std::string,unsigned>
842 static void report_cumulative_solve_times();
845 static void reset_cumulative_solve_times();
849 {Report_my_cumulative_preconditioner_solve_time=
true;}
853 {Report_my_cumulative_preconditioner_solve_time=
false;}
900 return AMG_using_simple_smoothing;
1029 void clean_up_memory();
1069 namespace Hypre_default_settings
bool Output_info
Flag is true to output info and results of timings.
bool & amg_using_simple_smoothing_flag()
Return function for the AMG_using_simple_smoothing_flag.
unsigned Krylov_print_level
Used to set the Hypre printing level for the Krylov subspace solvers.
double & parasails_filter()
Access function to ParaSails filter parameter.
void disable_euclid_using_BJ()
Disable use of Block Jacobi,.
void use_BoomerAMG()
Function to select BoomerAMG as the preconditioner.
unsigned & amg_simple_smoother()
Access function to AMG_simple_smoother flag.
unsigned & amg_iterations()
Return function for Max_iter.
int Euclid_level
Euclid level parameter for ILU(k) factorization.
void amg_using_complex_smoothing()
Function to select use of 'complex' AMG smoothers as controlled by AMG_complex_smoother flag...
unsigned Hypre_method
Hypre method flag. Valid values are specified in enumeration.
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 ...
HYPRE_IJMatrix Matrix_ij
The Hypre_IJMatrix version of the matrix used in solve(...), resolve(...) or preconditioner_solve(...).
HypreSolver(const HypreSolver &)
Broken copy constructor.
unsigned & amg_max_levels()
Access function to AMG_max_levels.
void enable_euclid_rowScale()
Enable euclid rowScaling.
HYPRE_Solver Preconditioner
The internal Hypre preconditioner used in conjunction with Solver. [This is a C structure!].
void disable_euclid_rowScale()
Disable euclid row scaling.
void euclid_using_ILUT()
Function to switch on ILUT factorization for Euclid (default is ILU(k) factorization) ...
~HypreSolver()
Empty destructor.
double & amg_truncation()
Access function to AMG_truncation.
bool AMGEuclidSmoother_use_block_jacobi
void enable_euclid_rowScale()
Enable euclid rowScaling.
HypreSolver()
Constructor.
double & amg_damping()
Access function to AMG_damping parameter.
void use_ParaSails()
Function to select ParaSails as the preconditioner.
void enable_euclid_using_BJ()
Enable use of Block Jacobi as opposed to PILU.
bool Report_my_cumulative_preconditioner_solve_time
Bool to request report of My_cumulative_preconditioner_solve_time in destructor.
~HypreInterface()
Destructor.
void disable_hypre_error_messages()
Turn off hypre error messages.
double & euclid_droptol()
Access function to Euclid drop tolerance parameter.
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...
unsigned AMG_print_level
Used to set the Hypre printing level for AMG 0: no printout 1: print setup information 2: print solve...
std::string Context_string
String can be used to provide context for annotation.
bool Delete_matrix
Hypre copies matrix data from oomph-lib'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.
double AMGEuclidSmoother_drop_tol
void operator=(const HyprePreconditioner &)
Broken assignment operator.
int ParaSails_nlevel
ParaSails nlevel parameter.
void euclid_using_ILUT()
Function to switch on ILUT factorization for Euclid (default is ILU(k) factorization) ...
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.
void amg_using_complex_smoothing()
Function to select use of 'complex' AMG smoothers as controlled by the flag AMG_complex_smoother.
double AMG_strength
Connection strength threshold parameter for BoomerAMG.
unsigned & amg_print_level()
Access function to AMG_print_level.
void operator=(const HypreSolver &)
Broken assignment operator.
unsigned & amg_coarsening()
Access function to AMG_coarsening flag.
static OomphCommunicator * communicator_pt()
access to the global oomph-lib communicator
void enable_delete_matrix()
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
unsigned & amg_complex_smoother()
Access function to AMG_complex_smoother flag.
unsigned & amg_coarsening()
Access function to AMG_coarsening flag.
static bool mpi_has_been_initialised()
return true if MPI has been initialised
unsigned Existing_preconditioner
Used to keep track of which preconditioner (if any) is currently stored.
void set_amg_iterations(const unsigned &amg_iterations)
Function to set the number of times to apply BoomerAMG.
bool AMGEuclidSmoother_use_row_scaling
unsigned Existing_solver
Used to keep track of which solver (if any) is currently stored.
unsigned & internal_preconditioner()
Access function to Internal_preconditioner flag – specified via enumeration.
void disable_delete_matrix()
Hypre copies matrix data from oomph-lib's CRDoubleMatrix.
HypreInterface(const HypreInterface &)
Broken copy constructor.
unsigned & amg_print_level()
Access function to AMG_print_level.
unsigned & amg_max_levels()
Access function to AMG_max_levels.
unsigned AMG_simple_smoother
Simple smoothing methods used in BoomerAMG. Relaxation types include: 0 = Jacobi 1 = Gauss-Seidel...
unsigned Euclid_print_level
Flag to set the level of printing from Euclid when the Euclid destructor is called 0: no printing (de...
int & parasails_nlevel()
Access function to ParaSails nlevel parameter.
double & parasails_filter()
Access function to ParaSails filter parameter.
void setup()
Setup terminate helper.
bool Euclid_rowScale
Flag to switch on Euclid row scaling.
int & parasails_symmetry()
Access function to ParaSails symmetry flag.
unsigned & amg_smoother_iterations()
Access function to AMG_smoother_iterations.
void euclid_using_ILUK()
Function to switch on ILU(k) factorization for Euclid (default is ILU(k) factorization) ...
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.
void amg_using_simple_smoothing()
Function to select use of 'simple' AMG smoothers as controlled by the flag AMG_simple_smoother.
double AMG_truncation
Interpolation truncation factor for BoomerAMG.
static unsigned Cumulative_npreconditioner_solve
Static unsigned that accumulates the number of preconditioner solves of all instantiations of this cl...
double & amg_damping()
Access function to AMG_damping parameter.
unsigned AMGEuclidSmoother_print_level
unsigned Max_iter
Maximum number of iterations used in solver.
unsigned Internal_preconditioner
Preconditioner method flag used with Hypre's PCG, GMRES and BiCGStab in solve(...) or resolve(...
HyprePreconditioner(const HyprePreconditioner &)
Broken copy constructor.
bool Using_distributed_rhs
Internal flag which tell the solver if the rhs Vector is distributed or not.
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 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'T CHANGE THE ORDER OF THESE! ...
double AMG_damping
Damping factor for BoomerAMG smoothed Jacobi or hybrid SOR.
void set_defaults_for_3D_poisson_problem(HyprePreconditioner *hypre_preconditioner_pt)
Set default parameters for use as preconditioner in 3D Poisson-type problem.
unsigned & amg_smoother_iterations()
Access function to AMG_smoother_iterations.
void disable_euclid_rowScale()
Disable euclid row scaling.
unsigned & hypre_method()
Access function to Hypre_method flag – specified via enumeration.
unsigned AMG_smoother_iterations
The number of smoother iterations to apply.
void disable_doc_time()
Disable documentation of preconditioner timings.
unsigned AMG_max_levels
Maximum number of levels used in AMG.
void disable_resolve()
Disable resolve function (overloads the LinearSolver disable_resolve function).
unsigned Max_iter
Max. # of Newton iterations.
unsigned AMG_coarsening
AMG coarsening strategy. Coarsening types include: 0 = CLJP (parallel coarsening using independent se...
unsigned & hypre_method()
Access function to Hypre_method flag – specified via enumeration.
unsigned existing_solver()
Function to return value of which solver (if any) is currently stored.
HypreInterface()
Constructor.
~HyprePreconditioner()
Destructor.
double & parasails_thresh()
Access function to ParaSails thresh parameter.
unsigned & krylov_print_level()
Access function to Krylov_print_level.
double & amg_strength()
Access function to AMG_strength.
HYPRE_ParCSRMatrix Matrix_par
The Hypre_ParCSRMatrix version of the matrix used in solve(...), resolve(...) or preconditioner_solve...
double & euclid_droptol()
Access function to Euclid drop tolerance parameter.
HYPRE_Solver Solver
The Hypre solver used in solve(...), resolve(...) or preconditioner_solve(...). [This is a C structur...
bool Euclid_using_ILUT
Flag to determine if ILUT (if true) or ILU(k) is used in Euclid.
int & parasails_symmetry()
Access function to ParaSails symmetry flag.
unsigned AMG_complex_smoother
Complex smoothing methods used in BoomerAMG. Relaxation types are: 6 = Schwarz 7 = Pilut 8 = ParaSail...
double & amg_max_row_sum()
Access function to AMG_max_row_sum.
double ParaSails_thresh
ParaSails thresh parameter.
unsigned AMGEuclidSmoother_level
bool AMGEuclidSmoother_use_ilut
void operator=(const HypreInterface &)
Broken assignment operator.
int ParaSails_symmetry
ParaSails symmetry flag, used to inform ParaSails of Symmetry of definitenss of problem and type of P...
int & euclid_level()
Access function to Euclid level parameter for ILU(k) factorization.
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) ...
void disable_euclid_using_BJ()
Disable use of Block Jacobi,.
double & amg_truncation()
Access function to AMG_truncation.
The conjugate gradient method.
double & tolerance()
Access function to Tolerance.
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.
double & amg_strength()
Access function to AMG_strength.
bool Delete_input_data
Internal flag which is true when hypre_setup or hypre_solve can delete input matrix.
void disable_report_my_cumulative_preconditioner_solve_time()
Disable reporting of cumulative solve time in destructor.
bool Euclid_using_BJ
Flag to determine if Block Jacobi is used instead of PILU.
bool Delete_matrix
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
void enable_euclid_using_BJ()
Enable use of Block Jacobi as opposed to PILU.
int & parasails_nlevel()
Access function to ParaSails nlevel parameter.
static double Cumulative_preconditioner_solve_time
Static double that accumulates the preconditioner solve time of all instantiations of this class...
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
bool Returning_distributed_solution
Internal flag which tell the solver if the solution Vector to be returned is distributed or not...
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.
unsigned & amg_complex_smoother()
Access function to AMG_complex_smoother flag.
void amg_using_simple_smoothing()
Function to select use of 'simple' AMG smoothers as controlled by AMG_simple_smoother flag...
unsigned & internal_preconditioner()
Access function to Internal_preconditioner flag – specified via enumeration.
double AMG_truncation
AMG interpolation truncation factor.
double AMG_max_row_sum
Parameter to identify diagonally dominant parts of the matrix in AMG.
bool Delete_matrix
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
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*)
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...
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().
void enable_delete_matrix()
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
void use_Euclid()
Function to select use Euclid as the preconditioner.
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...
LinearAlgebraDistribution * Hypre_distribution_pt
the distribution for this helpers-
Abstract base class for matrices of doubles – adds abstract interfaces for solving, LU decomposition and multiplication by vectors.
double Tolerance
Tolerance used to terminate solver.
double & parasails_thresh()
Access function to ParaSails thresh parameter.
unsigned & euclid_print_level()
Function to set the level of printing from Euclid when the Euclid destructor is called 0: no printing...
A class for compressed row matrices. This is a distributable object.
unsigned & max_iter()
Access function to Max_iter.
double & amg_max_row_sum()
Access function to AMG_max_row_sum.
void set_defaults_for_2D_poisson_problem(HyprePreconditioner *hypre_preconditioner_pt)
Set default parameters for use as preconditioner in 2D Poisson-type problem.
HyprePreconditioner(const std::string &context_string="")
Constructor. Provide optional string that is used in annotation of performance.
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 enable_doc_time()
Enable documentation of preconditioner timings.
void disable_delete_matrix()
Hypre copies matrix data from oomph-lib's CRDoubleMatrix.
double ParaSails_filter
ParaSails filter parameter.
unsigned existing_preconditioner()
Function return value of which preconditioner (if any) is stored.
int check_HYPRE_error_flag(std::ostringstream &message)
Helper function to check the Hypre error flag, return the message associated with any error...
unsigned AMG_smoother_iterations
amg smoother iterations