oomph::HyprePreconditioner Class Reference

#include <hypre_solver.h>

+ Inheritance diagram for oomph::HyprePreconditioner:

Public Member Functions

 HyprePreconditioner (const std::string &context_string="")
 
 ~HyprePreconditioner ()
 Destructor. More...
 
 HyprePreconditioner (const HyprePreconditioner &)=delete
 Broken copy constructor. More...
 
void operator= (const HyprePreconditioner &)=delete
 Broken assignment operator. More...
 
void enable_report_my_cumulative_preconditioner_solve_time ()
 Enable reporting of cumulative solve time in destructor. More...
 
void disable_report_my_cumulative_preconditioner_solve_time ()
 Disable reporting of cumulative solve time in destructor. More...
 
void enable_doc_time ()
 Enable documentation of preconditioner timings. More...
 
void disable_doc_time ()
 Disable documentation of preconditioner timings. More...
 
unsignedhypre_method ()
 Access function to Hypre_method flag – specified via enumeration. More...
 
unsignedinternal_preconditioner ()
 
void use_BoomerAMG ()
 Function to select BoomerAMG as the preconditioner. More...
 
void set_amg_iterations (const unsigned &amg_iterations)
 Function to set the number of times to apply BoomerAMG. More...
 
unsignedamg_iterations ()
 Return function for Max_iter. More...
 
void amg_using_simple_smoothing ()
 
unsignedamg_simple_smoother ()
 Access function to AMG_simple_smoother flag. More...
 
void amg_using_complex_smoothing ()
 
unsignedamg_complex_smoother ()
 Access function to AMG_complex_smoother flag. More...
 
boolamg_using_simple_smoothing_flag ()
 Return function for the AMG_using_simple_smoothing_flag. More...
 
unsignedamg_print_level ()
 Access function to AMG_print_level. More...
 
unsignedamg_smoother_iterations ()
 Access function to AMG_smoother_iterations. More...
 
unsignedamg_coarsening ()
 Access function to AMG_coarsening flag. More...
 
unsignedamg_max_levels ()
 Access function to AMG_max_levels. More...
 
doubleamg_damping ()
 Access function to AMG_damping parameter. More...
 
doubleamg_strength ()
 Access function to AMG_strength. More...
 
doubleamg_max_row_sum ()
 Access function to AMG_max_row_sum. More...
 
doubleamg_truncation ()
 Access function to AMG_truncation. More...
 
void use_ParaSails ()
 Function to select ParaSails as the preconditioner. More...
 
intparasails_symmetry ()
 Access function to ParaSails symmetry flag. More...
 
intparasails_nlevel ()
 Access function to ParaSails nlevel parameter. More...
 
doubleparasails_thresh ()
 Access function to ParaSails thresh parameter. More...
 
doubleparasails_filter ()
 Access function to ParaSails filter parameter. More...
 
void use_Euclid ()
 Function to select use Euclid as the preconditioner. More...
 
doubleeuclid_droptol ()
 Access function to Euclid drop tolerance parameter. More...
 
inteuclid_level ()
 Access function to Euclid level parameter for ILU(k) factorization. More...
 
void enable_euclid_rowScale ()
 Enable euclid rowScaling. More...
 
void disable_euclid_rowScale ()
 Disable euclid row scaling. More...
 
void enable_euclid_using_BJ ()
 
void disable_euclid_using_BJ ()
 
void euclid_using_ILUK ()
 
void euclid_using_ILUT ()
 
unsignedeuclid_print_level ()
 
void enable_delete_matrix ()
 
void disable_delete_matrix ()
 
void setup ()
 
void preconditioner_solve (const DoubleVector &r, DoubleVector &z)
 Preconditioner_solve uses a hypre solver to precondition vector r. More...
 
void clean_up_memory ()
 Function deletes all solver data. More...
 
- Public Member Functions inherited from oomph::Preconditioner
 Preconditioner ()
 Constructor. More...
 
 Preconditioner (const Preconditioner &)=delete
 Broken copy constructor. More...
 
void operator= (const Preconditioner &)=delete
 Broken assignment operator. More...
 
virtual ~Preconditioner ()
 Destructor (empty) More...
 
virtual void preconditioner_solve_transpose (const DoubleVector &r, DoubleVector &z)
 
void setup (DoubleMatrixBase *matrix_pt)
 
void setup (const Problem *problem_pt, DoubleMatrixBase *matrix_pt)
 
void enable_silent_preconditioner_setup ()
 Set up the block preconditioner quietly! More...
 
void disable_silent_preconditioner_setup ()
 Be verbose in the block preconditioner setup. More...
 
virtual DoubleMatrixBasematrix_pt () const
 Get function for matrix pointer. More...
 
virtual void set_matrix_pt (DoubleMatrixBase *matrix_pt)
 Set the matrix pointer. More...
 
virtual const OomphCommunicatorcomm_pt () const
 Get function for comm pointer. More...
 
virtual void set_comm_pt (const OomphCommunicator *const comm_pt)
 Set the communicator pointer. More...
 
double setup_time () const
 Returns the time to setup the preconditioner. More...
 
virtual void turn_into_subsidiary_block_preconditioner (BlockPreconditioner< CRDoubleMatrix > *master_block_prec_pt, const Vector< unsigned > &doftype_in_master_preconditioner_coarse)
 
virtual void turn_into_subsidiary_block_preconditioner (BlockPreconditioner< CRDoubleMatrix > *master_block_prec_pt, const Vector< unsigned > &doftype_in_master_preconditioner_coarse, const Vector< Vector< unsigned >> &doftype_coarsen_map_coarse)
 
- Public Member Functions inherited from oomph::DistributableLinearAlgebraObject
 DistributableLinearAlgebraObject ()
 Default constructor - create a distribution. More...
 
 DistributableLinearAlgebraObject (const DistributableLinearAlgebraObject &matrix)=delete
 Broken copy constructor. More...
 
void operator= (const DistributableLinearAlgebraObject &)=delete
 Broken assignment operator. More...
 
virtual ~DistributableLinearAlgebraObject ()
 Destructor. More...
 
LinearAlgebraDistributiondistribution_pt () const
 access to the LinearAlgebraDistribution More...
 
unsigned nrow () const
 access function to the number of global rows. More...
 
unsigned nrow_local () const
 access function for the num of local rows on this processor. More...
 
unsigned nrow_local (const unsigned &p) const
 access function for the num of local rows on this processor. More...
 
unsigned first_row () const
 access function for the first row on this processor More...
 
unsigned first_row (const unsigned &p) const
 access function for the first row on this processor More...
 
bool distributed () const
 distribution is serial or distributed More...
 
bool distribution_built () const
 
void build_distribution (const LinearAlgebraDistribution *const dist_pt)
 
void build_distribution (const LinearAlgebraDistribution &dist)
 
- Public Member Functions inherited from oomph::HypreInterface
 HypreInterface ()
 Constructor. More...
 
 ~HypreInterface ()
 Destructor. More...
 
 HypreInterface (const HypreInterface &)=delete
 Broken copy constructor. More...
 
void operator= (const HypreInterface &)=delete
 Broken assignment operator. More...
 
void enable_hypre_error_messages ()
 Turn on the hypre error messages. More...
 
void disable_hypre_error_messages ()
 Turn off hypre error messages. More...
 
unsigned existing_solver ()
 Function to return value of which solver (if any) is currently stored. More...
 
unsigned existing_preconditioner ()
 Function return value of which preconditioner (if any) is stored. More...
 

Static Public Member Functions

static void report_cumulative_solve_times ()
 
static void reset_cumulative_solve_times ()
 Reset cumulative solve times. More...
 

Static Public Attributes

static double Cumulative_preconditioner_solve_time = 0.0
 
static std::map< std::string, doubleContext_based_cumulative_solve_time
 
static unsigned Cumulative_npreconditioner_solve = 0
 
static std::map< std::string, unsignedContext_based_cumulative_npreconditioner_solve
 
static std::map< std::string, unsignedContext_based_nrow
 

Private Attributes

bool Delete_matrix
 
bool Doc_time
 
double My_cumulative_preconditioner_solve_time
 
bool Report_my_cumulative_preconditioner_solve_time
 
std::string Context_string
 String can be used to provide context for annotation. More...
 

Additional Inherited Members

- Public Types inherited from oomph::HypreInterface
enum  Hypre_method_types {
  CG , GMRES , BiCGStab , BoomerAMG ,
  Euclid , ParaSails , None
}
 
- Public Attributes inherited from oomph::HypreInterface
bool AMGEuclidSmoother_use_block_jacobi
 
bool AMGEuclidSmoother_use_row_scaling
 
bool AMGEuclidSmoother_use_ilut
 
unsigned AMGEuclidSmoother_level
 
double AMGEuclidSmoother_drop_tol
 
unsigned AMGEuclidSmoother_print_level
 
- Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 
- Protected Member Functions inherited from oomph::HypreInterface
void hypre_clean_up_memory ()
 Function deletes all solver data. More...
 
void hypre_matrix_setup (CRDoubleMatrix *matrix_pt)
 
void hypre_solver_setup ()
 
void hypre_solve (const DoubleVector &rhs, DoubleVector &solution)
 
- Protected Attributes inherited from oomph::Preconditioner
bool Silent_preconditioner_setup
 Boolean to indicate whether or not the build should be done silently. More...
 
std::ostream * Stream_pt
 Pointer to the output stream – defaults to std::cout. More...
 
- Protected Attributes inherited from oomph::HypreInterface
bool Output_info
 Flag is true to output info and results of timings. More...
 
unsigned Max_iter
 Maximum number of iterations used in solver. More...
 
double Tolerance
 Tolerance used to terminate solver. More...
 
unsigned Hypre_method
 Hypre method flag. Valid values are specified in enumeration. More...
 
unsigned Internal_preconditioner
 
unsigned AMG_print_level
 
unsigned AMG_max_levels
 Maximum number of levels used in AMG. More...
 
double AMG_max_row_sum
 Parameter to identify diagonally dominant parts of the matrix in AMG. More...
 
bool AMG_using_simple_smoothing
 
unsigned AMG_simple_smoother
 
unsigned AMG_complex_smoother
 
unsigned AMG_smoother_iterations
 The number of smoother iterations to apply. More...
 
double AMG_damping
 Damping factor for BoomerAMG smoothed Jacobi or hybrid SOR. More...
 
double AMG_strength
 Connection strength threshold parameter for BoomerAMG. More...
 
double AMG_truncation
 Interpolation truncation factor for BoomerAMG. More...
 
unsigned AMG_coarsening
 
int ParaSails_symmetry
 
int ParaSails_nlevel
 ParaSails nlevel parameter. More...
 
double ParaSails_thresh
 ParaSails thresh parameter. More...
 
double ParaSails_filter
 ParaSails filter parameter. More...
 
double Euclid_droptol
 Euclid drop tolerance for ILU(k) and ILUT factorization. More...
 
bool Euclid_rowScale
 Flag to switch on Euclid row scaling. More...
 
bool Euclid_using_ILUT
 Flag to determine if ILUT (if true) or ILU(k) is used in Euclid. More...
 
bool Euclid_using_BJ
 Flag to determine if Block Jacobi is used instead of PILU. More...
 
int Euclid_level
 Euclid level parameter for ILU(k) factorization. More...
 
unsigned Euclid_print_level
 
unsigned Krylov_print_level
 
bool Hypre_error_messages
 
bool Delete_input_data
 

Detailed Description

///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// An Preconditioner class using the suite of Hypre preconditioners to allow

 BoomerAMG (Algebraic Multi Grid),
 Euclid (ILU) or
 ParaSails (Approximate inverse)

to be used for Preconditioner::preconditioner_solve(...). By default BoomerAMG is used.

Constructor & Destructor Documentation

◆ HyprePreconditioner() [1/2]

oomph::HyprePreconditioner::HyprePreconditioner ( const std::string &  context_string = "")
inline

Constructor. Provide optional string that is used in annotation of performance

831  {
832  Context_string = context_string;
833 
834  // Hypre copies matrix data from oomph-lib's CRDoubleMatrix
835  // or DistributedCRDoubleMatrix into its own data structures,
836  // doubling the memory requirements for the matrix.
837  // As far as the Hypre solvers are concerned the oomph-lib matrix
838  // is no longer required and could be deleted to save memory.
839  // However, this will not be the expected behaviour and therefore
840  // needs to be requested explicitly by the user by changing this
841  // flag from false (its default) to true.
842  Delete_matrix = false;
843 
844  // Do we want to output results of timings?
845  Doc_time = true;
846 
847  // General control paramaters for using HYPRE as preconditioner
848  Tolerance = 0.0;
849  Max_iter = 1;
852 
853  // Initialise private double that accumulates the preconditioner
854  // solve time of thi instantiation of this class. Is reported
855  // in destructor if Report_my_cumulative_preconditioner_solve_time
856  // is set to true
859  }
unsigned Internal_preconditioner
Definition: hypre_solver.h:320
@ None
Definition: hypre_solver.h:263
@ BoomerAMG
Definition: hypre_solver.h:260
double Tolerance
Tolerance used to terminate solver.
Definition: hypre_solver.h:311
unsigned Max_iter
Maximum number of iterations used in solver.
Definition: hypre_solver.h:308
unsigned Hypre_method
Hypre method flag. Valid values are specified in enumeration.
Definition: hypre_solver.h:314
std::string Context_string
String can be used to provide context for annotation.
Definition: hypre_solver.h:1234
bool Report_my_cumulative_preconditioner_solve_time
Definition: hypre_solver.h:1231
bool Delete_matrix
Definition: hypre_solver.h:1218
double My_cumulative_preconditioner_solve_time
Definition: hypre_solver.h:1227
bool Doc_time
Definition: hypre_solver.h:1221

References oomph::HypreInterface::BoomerAMG, Context_string, Delete_matrix, Doc_time, oomph::HypreInterface::Hypre_method, oomph::HypreInterface::Internal_preconditioner, oomph::HypreInterface::Max_iter, My_cumulative_preconditioner_solve_time, oomph::HypreInterface::None, Report_my_cumulative_preconditioner_solve_time, and oomph::HypreInterface::Tolerance.

◆ ~HyprePreconditioner()

oomph::HyprePreconditioner::~HyprePreconditioner ( )
inline

Destructor.

863  {
865  {
866  oomph_info << "~HyprePreconditioner() in context \" " << Context_string
867  << "\": My_cumulative_preconditioner_solve_time = "
869  }
870  }
OomphInfo oomph_info
Definition: oomph_definitions.cc:319

References Context_string, My_cumulative_preconditioner_solve_time, oomph::oomph_info, and Report_my_cumulative_preconditioner_solve_time.

◆ HyprePreconditioner() [2/2]

oomph::HyprePreconditioner::HyprePreconditioner ( const HyprePreconditioner )
delete

Broken copy constructor.

Member Function Documentation

◆ amg_coarsening()

◆ amg_complex_smoother()

unsigned& oomph::HyprePreconditioner::amg_complex_smoother ( )
inline

Access function to AMG_complex_smoother flag.

997  {
998  return AMG_complex_smoother;
999  }
unsigned AMG_complex_smoother
Definition: hypre_solver.h:360

References oomph::HypreInterface::AMG_complex_smoother.

◆ amg_damping()

◆ amg_iterations()

unsigned& oomph::HyprePreconditioner::amg_iterations ( )
inline

Return function for Max_iter.

971  {
972  return Max_iter;
973  }

References oomph::HypreInterface::Max_iter.

Referenced by set_amg_iterations().

◆ amg_max_levels()

unsigned& oomph::HyprePreconditioner::amg_max_levels ( )
inline

Access function to AMG_max_levels.

1027  {
1028  return AMG_max_levels;
1029  }
unsigned AMG_max_levels
Maximum number of levels used in AMG.
Definition: hypre_solver.h:330

References oomph::HypreInterface::AMG_max_levels.

◆ amg_max_row_sum()

double& oomph::HyprePreconditioner::amg_max_row_sum ( )
inline

Access function to AMG_max_row_sum.

1045  {
1046  return AMG_max_row_sum;
1047  }
double AMG_max_row_sum
Parameter to identify diagonally dominant parts of the matrix in AMG.
Definition: hypre_solver.h:333

References oomph::HypreInterface::AMG_max_row_sum.

◆ amg_print_level()

unsigned& oomph::HyprePreconditioner::amg_print_level ( )
inline

Access function to AMG_print_level.

1009  {
1010  return AMG_print_level;
1011  }
unsigned AMG_print_level
Definition: hypre_solver.h:327

References oomph::HypreInterface::AMG_print_level.

◆ amg_simple_smoother()

◆ amg_smoother_iterations()

◆ amg_strength()

◆ amg_truncation()

double& oomph::HyprePreconditioner::amg_truncation ( )
inline

Access function to AMG_truncation.

1051  {
1052  return AMG_truncation;
1053  }
double AMG_truncation
Interpolation truncation factor for BoomerAMG.
Definition: hypre_solver.h:372

References oomph::HypreInterface::AMG_truncation.

◆ amg_using_complex_smoothing()

void oomph::HyprePreconditioner::amg_using_complex_smoothing ( )
inline

Function to select use of 'complex' AMG smoothers as controlled by the flag AMG_complex_smoother

991  {
993  }
bool AMG_using_simple_smoothing
Definition: hypre_solver.h:338

References oomph::HypreInterface::AMG_using_simple_smoothing.

◆ amg_using_simple_smoothing()

void oomph::HyprePreconditioner::amg_using_simple_smoothing ( )
inline

◆ amg_using_simple_smoothing_flag()

bool& oomph::HyprePreconditioner::amg_using_simple_smoothing_flag ( )
inline

Return function for the AMG_using_simple_smoothing_flag.

1003  {
1005  }

References oomph::HypreInterface::AMG_using_simple_smoothing.

◆ clean_up_memory()

void oomph::HyprePreconditioner::clean_up_memory ( )
virtual

Function deletes all solver data.

clean_up_memory() deletes any existing Hypre solver and Hypre matrix

Reimplemented from oomph::Preconditioner.

1843  {
1845  }
void hypre_clean_up_memory()
Function deletes all solver data.
Definition: hypre_solver.cc:1301

References oomph::HypreInterface::hypre_clean_up_memory().

Referenced by setup().

◆ disable_delete_matrix()

void oomph::HyprePreconditioner::disable_delete_matrix ( )
inline

Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own data structures, doubling the memory requirements for the matrix. Calling this function ensures that the matrix is not deleted.

1172  {
1173  Delete_matrix = false;
1174  }

References Delete_matrix.

◆ disable_doc_time()

◆ disable_euclid_rowScale()

void oomph::HyprePreconditioner::disable_euclid_rowScale ( )
inline

Disable euclid row scaling.

1111  {
1112  Euclid_rowScale = false;
1113  }
bool Euclid_rowScale
Flag to switch on Euclid row scaling.
Definition: hypre_solver.h:409

References oomph::HypreInterface::Euclid_rowScale.

◆ disable_euclid_using_BJ()

void oomph::HyprePreconditioner::disable_euclid_using_BJ ( )
inline

Disable use of Block Jacobi, so PILU will be used

1125  {
1126  Euclid_using_BJ = false;
1127  }
bool Euclid_using_BJ
Flag to determine if Block Jacobi is used instead of PILU.
Definition: hypre_solver.h:415

References oomph::HypreInterface::Euclid_using_BJ.

◆ disable_report_my_cumulative_preconditioner_solve_time()

void oomph::HyprePreconditioner::disable_report_my_cumulative_preconditioner_solve_time ( )
inline

Disable reporting of cumulative solve time in destructor.

928  {
930  }

References Report_my_cumulative_preconditioner_solve_time.

◆ enable_delete_matrix()

void oomph::HyprePreconditioner::enable_delete_matrix ( )
inline

Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own data structures, doubling the memory requirements for the matrix. 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 calling this function which changes the flag from false (its default) to true.

1163  {
1164  Delete_matrix = true;
1165  }

References Delete_matrix.

◆ enable_doc_time()

void oomph::HyprePreconditioner::enable_doc_time ( )
inline

Enable documentation of preconditioner timings.

934  {
935  Doc_time = true;
936  }

References Doc_time.

◆ enable_euclid_rowScale()

void oomph::HyprePreconditioner::enable_euclid_rowScale ( )
inline

Enable euclid rowScaling.

1105  {
1106  Euclid_rowScale = true;
1107  }

References oomph::HypreInterface::Euclid_rowScale.

◆ enable_euclid_using_BJ()

void oomph::HyprePreconditioner::enable_euclid_using_BJ ( )
inline

Enable use of Block Jacobi as opposed to PILU

1118  {
1119  Euclid_using_BJ = true;
1120  }

References oomph::HypreInterface::Euclid_using_BJ.

◆ enable_report_my_cumulative_preconditioner_solve_time()

void oomph::HyprePreconditioner::enable_report_my_cumulative_preconditioner_solve_time ( )
inline

Enable reporting of cumulative solve time in destructor.

922  {
924  }

References Report_my_cumulative_preconditioner_solve_time.

◆ euclid_droptol()

double& oomph::HyprePreconditioner::euclid_droptol ( )
inline

Access function to Euclid drop tolerance parameter.

1093  {
1094  return Euclid_droptol;
1095  }
double Euclid_droptol
Euclid drop tolerance for ILU(k) and ILUT factorization.
Definition: hypre_solver.h:406

References oomph::HypreInterface::Euclid_droptol.

◆ euclid_level()

int& oomph::HyprePreconditioner::euclid_level ( )
inline

Access function to Euclid level parameter for ILU(k) factorization.

1099  {
1100  return Euclid_level;
1101  }
int Euclid_level
Euclid level parameter for ILU(k) factorization.
Definition: hypre_solver.h:418

References oomph::HypreInterface::Euclid_level.

◆ euclid_print_level()

unsigned& oomph::HyprePreconditioner::euclid_print_level ( )
inline

Function to set the level of printing from Euclid when the Euclid destructor is called 0: no printing (default) 1: prints summary of runtime settings and timings 2: as 1 plus prints memory usage

1149  {
1150  return Euclid_print_level;
1151  }
unsigned Euclid_print_level
Definition: hypre_solver.h:425

References oomph::HypreInterface::Euclid_print_level.

◆ euclid_using_ILUK()

void oomph::HyprePreconditioner::euclid_using_ILUK ( )
inline

Function to switch on ILU(k) factorization for Euclid (default is ILU(k) factorization)

1132  {
1133  Euclid_using_ILUT = false;
1134  }
bool Euclid_using_ILUT
Flag to determine if ILUT (if true) or ILU(k) is used in Euclid.
Definition: hypre_solver.h:412

References oomph::HypreInterface::Euclid_using_ILUT.

◆ euclid_using_ILUT()

void oomph::HyprePreconditioner::euclid_using_ILUT ( )
inline

Function to switch on ILUT factorization for Euclid (default is ILU(k) factorization)

1139  {
1140  Euclid_using_ILUT = true;
1141  }

References oomph::HypreInterface::Euclid_using_ILUT.

◆ hypre_method()

unsigned& oomph::HyprePreconditioner::hypre_method ( )
inline

◆ internal_preconditioner()

unsigned& oomph::HyprePreconditioner::internal_preconditioner ( )
inline

Access function to Internal_preconditioner flag – specified via enumeration.

953  {
955  }

References oomph::HypreInterface::Internal_preconditioner.

◆ operator=()

void oomph::HyprePreconditioner::operator= ( const HyprePreconditioner )
delete

Broken assignment operator.

◆ parasails_filter()

double& oomph::HyprePreconditioner::parasails_filter ( )
inline

Access function to ParaSails filter parameter.

1081  {
1082  return ParaSails_filter;
1083  }
double ParaSails_filter
ParaSails filter parameter.
Definition: hypre_solver.h:403

References oomph::HypreInterface::ParaSails_filter.

◆ parasails_nlevel()

int& oomph::HyprePreconditioner::parasails_nlevel ( )
inline

Access function to ParaSails nlevel parameter.

1069  {
1070  return ParaSails_nlevel;
1071  }
int ParaSails_nlevel
ParaSails nlevel parameter.
Definition: hypre_solver.h:397

References oomph::HypreInterface::ParaSails_nlevel.

◆ parasails_symmetry()

int& oomph::HyprePreconditioner::parasails_symmetry ( )
inline

Access function to ParaSails symmetry flag.

1063  {
1064  return ParaSails_symmetry;
1065  }
int ParaSails_symmetry
Definition: hypre_solver.h:394

References oomph::HypreInterface::ParaSails_symmetry.

◆ parasails_thresh()

double& oomph::HyprePreconditioner::parasails_thresh ( )
inline

Access function to ParaSails thresh parameter.

1075  {
1076  return ParaSails_thresh;
1077  }
double ParaSails_thresh
ParaSails thresh parameter.
Definition: hypre_solver.h:400

References oomph::HypreInterface::ParaSails_thresh.

◆ preconditioner_solve()

void oomph::HyprePreconditioner::preconditioner_solve ( const DoubleVector r,
DoubleVector z 
)
virtual

Preconditioner_solve uses a hypre solver to precondition vector r.

Function applies solver to vector r for preconditioning. This requires a call to setup(...) first. Note: Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own data structures, doubling the memory requirements for the matrix. 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 with the delete_matrix() function.

Implements oomph::Preconditioner.

1777  {
1778  // Store time
1779  double t_start = TimingHelpers::timer();
1780 
1781 #ifdef PARANOID
1782  // check solver data exists
1783  if (existing_solver() == None)
1784  {
1785  std::ostringstream error_message;
1786  error_message << "preconditioner_solve(...) requires that data has "
1787  << "been set up using the function setup(...)" << std::endl;
1788  throw OomphLibError(
1789  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1790  }
1791  // check that rhs has the same distribution as the matrix (now stored
1792  // in Distribution_pt)
1793  if (*this->distribution_pt() != *r.distribution_pt())
1794  {
1795  std::ostringstream error_message;
1796  error_message << "The distribution of the rhs vector and the matrix "
1797  << " must be the same" << std::endl;
1798  throw OomphLibError(
1799  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1800  }
1801 
1802  // if the solution is setup make sure it has the same distribution as
1803  // the matrix as well
1804  if (z.built())
1805  {
1806  if (*this->distribution_pt() != *z.distribution_pt())
1807  {
1808  std::ostringstream error_message;
1809  error_message << "The distribution of the solution vector is setup "
1810  << "there it must be the same as the matrix."
1811  << std::endl;
1812  throw OomphLibError(error_message.str(),
1815  }
1816  }
1817 #endif
1818 
1819  // Switch off any timings for the solve
1820  Output_info = false;
1821 
1822  // perform hypre_solve
1823  hypre_solve(r, z);
1824 
1825  // Add to cumulative solve time
1826  double t_end = TimingHelpers::timer();
1827  Cumulative_preconditioner_solve_time += (t_end - t_start);
1829  My_cumulative_preconditioner_solve_time += (t_end - t_start);
1830  if (Context_string != "")
1831  {
1834  }
1835  }
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
Definition: linear_algebra_distribution.h:457
bool Output_info
Flag is true to output info and results of timings.
Definition: hypre_solver.h:305
void hypre_solve(const DoubleVector &rhs, DoubleVector &solution)
Definition: hypre_solver.cc:1086
unsigned existing_solver()
Function to return value of which solver (if any) is currently stored.
Definition: hypre_solver.h:267
static std::map< std::string, unsigned > Context_based_cumulative_npreconditioner_solve
Definition: hypre_solver.h:904
static double Cumulative_preconditioner_solve_time
Definition: hypre_solver.h:882
static std::map< std::string, double > Context_based_cumulative_solve_time
Definition: hypre_solver.h:889
static unsigned Cumulative_npreconditioner_solve
Definition: hypre_solver.h:896
r
Definition: UniformPSDSelfTest.py:20
double timer()
returns the time in seconds after some point in past
Definition: oomph_utilities.cc:1295
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::DoubleVector::built(), Context_based_cumulative_npreconditioner_solve, Context_based_cumulative_solve_time, Context_string, Cumulative_npreconditioner_solve, Cumulative_preconditioner_solve_time, oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::HypreInterface::existing_solver(), oomph::HypreInterface::hypre_solve(), My_cumulative_preconditioner_solve_time, oomph::HypreInterface::None, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::HypreInterface::Output_info, UniformPSDSelfTest::r, and oomph::TimingHelpers::timer().

◆ report_cumulative_solve_times()

void oomph::HyprePreconditioner::report_cumulative_solve_times ( )
static

Report cumulative solve times of all instantiations of this class

1649  {
1650  oomph_info << "\n\n=====================================================\n";
1651  oomph_info << "Cumulative HyprePreconditioner solve time "
1653  << " for " << Cumulative_npreconditioner_solve << " solves";
1655  {
1656  oomph_info << " ( "
1659  << " per solve )";
1660  }
1661  oomph_info << std::endl << std::endl;
1662  if (Context_based_cumulative_solve_time.size() > 0)
1663  {
1664  oomph_info << "Breakdown by context: " << std::endl;
1665  for (std::map<std::string, double>::iterator it =
1668  it++)
1669  {
1670  oomph_info
1671  << (*it).first << " " << (*it).second << " for "
1673  << " solves";
1674  if (Context_based_cumulative_npreconditioner_solve[(*it).first] != 0)
1675  {
1676  oomph_info
1677  << " ( "
1678  << (*it).second /
1679  double(
1681  << " per solve; "
1682  << (*it).second /
1683  double(
1685  .first]) /
1686  double(Context_based_nrow[(*it).first])
1687  << " per solve per dof )";
1688  }
1689  oomph_info << std::endl;
1690  }
1691  }
1692  oomph_info << "\n=====================================================\n";
1693  oomph_info << std::endl;
1694  }
static std::map< std::string, unsigned > Context_based_nrow
Definition: hypre_solver.h:911

References Context_based_cumulative_npreconditioner_solve, Context_based_cumulative_solve_time, Context_based_nrow, Cumulative_npreconditioner_solve, Cumulative_preconditioner_solve_time, and oomph::oomph_info.

◆ reset_cumulative_solve_times()

void oomph::HyprePreconditioner::reset_cumulative_solve_times ( )
static

◆ set_amg_iterations()

◆ setup()

void oomph::HyprePreconditioner::setup ( )
virtual

Function to set up a preconditioner for the linear system defined by matrix_pt. This function is required when preconditioning and must be called before using the preconditioner_solve(...) function. This interface allows HyprePreconditioner to be used as a Preconditioner object for oomph-lib's own IterativeLinearSolver class. Note: matrix_pt must point to an object of type CRDoubleMatrix or DistributedCRDoubleMatrix. Note: Hypre copies matrix data from oomph-lib's CRDoubleMatrix and DistributedCRDoubleMatrix into its own data structures, doubling the memory requirements for the matrix. 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 calling the enable_delete_matrix() function.

An interface to allow HypreSolver to be used as a Preconditioner for the oomph-lib IterativeLinearSolver class. Matrix has to be of type CRDoubleMatrix or DistributedCRDoubleMatrix.

Implements oomph::Preconditioner.

1715  {
1716  // Set Output_info flag for HypreInterface
1718 
1719 #ifdef PARANOID
1720  // check the matrix is square
1721  if (matrix_pt()->nrow() != matrix_pt()->ncol())
1722  {
1723  std::ostringstream error_message;
1724  error_message << "HyprePreconditioner require a square matrix. "
1725  << "Matrix is " << matrix_pt()->nrow() << " by "
1726  << matrix_pt()->ncol() << std::endl;
1727  throw OomphLibError(
1728  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1729  }
1730 #endif
1731 
1732  // clean up any previous solver data
1733  clean_up_memory();
1734 
1735  // set flag to decide if oomphlib matrix can be deleted
1736  // (Recall that Delete_matrix defaults to false).
1738 
1739  // Try casting to a CRDoubleMatrix
1740  CRDoubleMatrix* cr_matrix_pt = dynamic_cast<CRDoubleMatrix*>(matrix_pt());
1741 
1742  // If cast successful set things up for a serial solve
1743  if (cr_matrix_pt)
1744  {
1745  this->build_distribution(cr_matrix_pt->distribution_pt());
1746  hypre_matrix_setup(cr_matrix_pt);
1747  }
1748  else
1749  {
1750 #ifdef PARANOID
1751  std::ostringstream error_message;
1752  error_message << "HyprePreconditioner only work with "
1753  << "CRDoubleMatrix matrices" << std::endl;
1754  throw OomphLibError(
1755  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1756 #endif
1757  }
1758 
1759  if (Context_string != "")
1760  {
1761  oomph_info << "Setup of HyprePreconditioner in context \" "
1762  << Context_string << "\": nrow, nrow_local, nnz "
1763  << cr_matrix_pt->nrow() << " " << cr_matrix_pt->nrow_local()
1764  << " " << cr_matrix_pt->nnz() << std::endl;
1765  }
1766  Context_based_nrow[Context_string] = cr_matrix_pt->nrow();
1767 
1768  // call hypre_solver_setup
1770  }
unsigned nrow() const
access function to the number of global rows.
Definition: linear_algebra_distribution.h:463
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
Definition: linear_algebra_distribution.h:507
virtual unsigned long ncol() const =0
Return the number of columns of the matrix.
virtual unsigned long nrow() const =0
Return the number of rows of the matrix.
bool Delete_input_data
Definition: hypre_solver.h:445
void hypre_matrix_setup(CRDoubleMatrix *matrix_pt)
Definition: hypre_solver.cc:513
void hypre_solver_setup()
Definition: hypre_solver.cc:558
void clean_up_memory()
Function deletes all solver data.
Definition: hypre_solver.cc:1842
virtual DoubleMatrixBase * matrix_pt() const
Get function for matrix pointer.
Definition: preconditioner.h:150

References oomph::DistributableLinearAlgebraObject::build_distribution(), clean_up_memory(), Context_based_nrow, Context_string, oomph::HypreInterface::Delete_input_data, Delete_matrix, oomph::DistributableLinearAlgebraObject::distribution_pt(), Doc_time, oomph::HypreInterface::hypre_matrix_setup(), oomph::HypreInterface::hypre_solver_setup(), oomph::Preconditioner::matrix_pt(), oomph::DoubleMatrixBase::ncol(), oomph::CRDoubleMatrix::nnz(), oomph::DistributableLinearAlgebraObject::nrow(), oomph::CRDoubleMatrix::nrow(), oomph::DoubleMatrixBase::nrow(), oomph::DistributableLinearAlgebraObject::nrow_local(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::oomph_info, and oomph::HypreInterface::Output_info.

◆ use_BoomerAMG()

void oomph::HyprePreconditioner::use_BoomerAMG ( )
inline

Function to select BoomerAMG as the preconditioner.

959  {
961  }

References oomph::HypreInterface::BoomerAMG, and oomph::HypreInterface::Hypre_method.

Referenced by main().

◆ use_Euclid()

void oomph::HyprePreconditioner::use_Euclid ( )
inline

Function to select use Euclid as the preconditioner.

1087  {
1088  Hypre_method = Euclid;
1089  }
@ Euclid
Definition: hypre_solver.h:261

References oomph::HypreInterface::Euclid, and oomph::HypreInterface::Hypre_method.

◆ use_ParaSails()

void oomph::HyprePreconditioner::use_ParaSails ( )
inline

Function to select ParaSails as the preconditioner.

1057  {
1059  }
@ ParaSails
Definition: hypre_solver.h:262

References oomph::HypreInterface::Hypre_method, and oomph::HypreInterface::ParaSails.

Member Data Documentation

◆ Context_based_cumulative_npreconditioner_solve

std::map< std::string, unsigned > oomph::HyprePreconditioner::Context_based_cumulative_npreconditioner_solve
static

Static unsigned that accumulates the number of preconditioner solves of all instantiations of this class, labeled by context string. Reset it manually, e.g. after every Newton solve, using reset_cumulative_solve_times().

Referenced by preconditioner_solve(), report_cumulative_solve_times(), and reset_cumulative_solve_times().

◆ Context_based_cumulative_solve_time

std::map< std::string, double > oomph::HyprePreconditioner::Context_based_cumulative_solve_time
static

Static double that accumulates the preconditioner solve time of all instantiations of this class, labeled by context string. Reset it manually, e.g. after every Newton solve, using reset_cumulative_solve_times().

map of static doubles that accumulates the preconditioner solve time of all instantiations of this class, labeled by context string. Reset it manually, e.g. after every Newton solve, using reset_cumulative_solve_times().

Referenced by preconditioner_solve(), report_cumulative_solve_times(), and reset_cumulative_solve_times().

◆ Context_based_nrow

std::map< std::string, unsigned > oomph::HyprePreconditioner::Context_based_nrow
static

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().

Referenced by report_cumulative_solve_times(), reset_cumulative_solve_times(), and setup().

◆ Context_string

std::string oomph::HyprePreconditioner::Context_string
private

String can be used to provide context for annotation.

Referenced by HyprePreconditioner(), preconditioner_solve(), setup(), and ~HyprePreconditioner().

◆ Cumulative_npreconditioner_solve

unsigned oomph::HyprePreconditioner::Cumulative_npreconditioner_solve = 0
static

Static unsigned that accumulates the number of preconditioner solves of all instantiations of this class. Reset it manually, e.g. after every Newton solve, using reset_cumulative_solve_times().

Referenced by preconditioner_solve(), report_cumulative_solve_times(), and reset_cumulative_solve_times().

◆ Cumulative_preconditioner_solve_time

double oomph::HyprePreconditioner::Cumulative_preconditioner_solve_time = 0.0
static

Static double that accumulates the preconditioner solve time of all instantiations of this class. Reset it manually, e.g. after every Newton solve, using reset_cumulative_solve_times().

//////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// Static double that accumulates the preconditioner solve time of all instantiations of this class. Reset it manually, e.g. after every Newton solve, using reset_cumulative_solve_times().

Referenced by preconditioner_solve(), report_cumulative_solve_times(), and reset_cumulative_solve_times().

◆ Delete_matrix

bool oomph::HyprePreconditioner::Delete_matrix
private

Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own data structures, doubling the memory requirements for the matrix. 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.

Referenced by disable_delete_matrix(), enable_delete_matrix(), HyprePreconditioner(), and setup().

◆ Doc_time

bool oomph::HyprePreconditioner::Doc_time
private

◆ My_cumulative_preconditioner_solve_time

double oomph::HyprePreconditioner::My_cumulative_preconditioner_solve_time
private

Private double that accumulates the preconditioner solve time of thi instantiation of this class. Is reported in destructor if Report_my_cumulative_preconditioner_solve_time is set to true

Referenced by HyprePreconditioner(), preconditioner_solve(), and ~HyprePreconditioner().

◆ Report_my_cumulative_preconditioner_solve_time

bool oomph::HyprePreconditioner::Report_my_cumulative_preconditioner_solve_time
private

Bool to request report of My_cumulative_preconditioner_solve_time in destructor

Referenced by disable_report_my_cumulative_preconditioner_solve_time(), enable_report_my_cumulative_preconditioner_solve_time(), HyprePreconditioner(), and ~HyprePreconditioner().


The documentation for this class was generated from the following files: