41 namespace Hypre_default_settings
112 namespace HypreHelpers
164 char* error_message =
new char[128];
166 message <<
"WARNING: " << std::endl
167 <<
"HYPRE error message: " << error_message << std::endl;
168 delete[] error_message;
196 unsigned nrow_local =
dist_pt->nrow_local();
201 oomph_vec.distribution_pt()->communicator_pt()->mpi_comm(),
212 int*
indices =
new int[nrow_local];
213 double* values =
new double[nrow_local];
221 for (
unsigned i = 0;
i < nrow_local;
i++)
287 std::ostringstream error_message;
288 error_message <<
"The matrix has not been built";
296 std::ostringstream error_message;
297 error_message <<
"create_HYPRE_Matrix require a square matrix. "
313 <<
"Oomph-lib has been compiled with MPI support and "
314 <<
"you are using HYPRE.\n"
315 <<
"For this combination of flags, MPI must be initialised.\n"
316 <<
"Call MPI_Helpers::init() in the "
317 <<
"main() function of your driver code\n";
344 bool distributed =
true;
345 if (
oomph_matrix->distribution_pt()->communicator_pt()->nproc() == 1)
387 throw OomphLibError(
"Error in HYPRE_IJMatrixSetObjectType()",
457 const char*
args[22];
558 <<
"Warning: HYPRE based solvers may fail if 2*number of processors "
559 <<
"is greater than the number of unknowns!" << std::endl;
731 "HypreSolver::hypre_setup()",
910 oomph_info <<
" with BoomerAMG preconditioner, ";
922 oomph_info <<
" with Euclid ILU preconditioner, ";
934 oomph_info <<
" with ParaSails approximate inverse preconditioner, ";
985 oomph_info <<
" with BoomerAMG preconditioner, ";
997 oomph_info <<
" with Euclid ILU preconditioner, ";
1009 oomph_info <<
" with ParaSails approximate inverse preconditioner, ";
1056 oomph_info <<
" with BoomerAMG preconditioner, ";
1068 oomph_info <<
" with Euclid ILU preconditioner, ";
1080 oomph_info <<
" with ParaSails approximate inverse preconditioner, ";
1107 std::ostringstream error_message;
1108 error_message <<
"Solver has been set to an invalid value. "
1109 <<
"current value=" <<
Solver;
1129 "HypreSolver::hypre_solver_setup()",
1181 "HypreSolver::hypre_solve()",
1222 comm_pt->mpi_comm());
1283 "HypreSolver::hypre_solve()",
1293 int*
indices =
new int[nrow_local];
1294 for (
unsigned i = 0;
i < nrow_local;
i++)
1322 "HypreSolver::hypre_solve()",
1351 oomph_info <<
"Number of iterations : " << iterations
1354 oomph_info <<
"Final Relative Residual Norm : " << norm << std::endl;
1422 "HypreSolver::clean_up_memory()",
1468 oomph_info <<
"Time to generate Jacobian and residual [s] : ";
1505 if (matrix_pt->
nrow() != matrix_pt->
ncol())
1507 std::ostringstream error_message;
1508 error_message <<
"HypreSolver require a square matrix. "
1509 <<
"Matrix is " << matrix_pt->
nrow() <<
" by "
1510 << matrix_pt->
ncol() << std::endl;
1540 std::ostringstream error_message;
1541 error_message <<
"The distribution of the rhs vector and the matrix "
1542 <<
" must be the same" << std::endl;
1553 std::ostringstream error_message;
1554 error_message <<
"The distribution of the solution vector is setup "
1555 <<
"there it must be the same as the matrix."
1569 std::ostringstream error_message;
1570 error_message <<
"HypreSolver only work with "
1571 <<
"CRDoubleMatrix matrices" << std::endl;
1601 std::ostringstream error_message;
1602 error_message <<
"resolve(...) requires that solver data has been "
1603 <<
"set up by a previous call to solve(...) after "
1604 <<
"a call to enable_resolve()" << std::endl;
1612 std::ostringstream error_message;
1613 error_message <<
"The distribution of the rhs vector and the matrix "
1614 <<
" must be the same" << std::endl;
1624 std::ostringstream error_message;
1625 error_message <<
"The distribution of the solution vector is setup "
1626 <<
"there it must be the same as the matrix."
1677 std::map<std::string, double>
1695 std::map<std::string, unsigned>
1713 oomph_info <<
"\n\n=====================================================\n";
1714 oomph_info <<
"Cumulative HyprePreconditioner solve time "
1727 oomph_info <<
"Breakdown by context: " << std::endl;
1728 for (std::map<std::string, double>::iterator
it =
1734 << (*it).first <<
" " << (*it).second <<
" for "
1750 <<
" per solve per dof )";
1755 oomph_info <<
"\n=====================================================\n";
1786 std::ostringstream error_message;
1787 error_message <<
"HyprePreconditioner require a square matrix. "
1788 <<
"Matrix is " <<
matrix_pt()->nrow() <<
" by "
1814 std::ostringstream error_message;
1815 error_message <<
"HyprePreconditioner only work with "
1816 <<
"CRDoubleMatrix matrices" << std::endl;
1824 oomph_info <<
"Setup of HyprePreconditioner in context \" "
1848 std::ostringstream error_message;
1849 error_message <<
"preconditioner_solve(...) requires that data has "
1850 <<
"been set up using the function setup(...)" << std::endl;
1858 std::ostringstream error_message;
1859 error_message <<
"The distribution of the rhs vector and the matrix "
1860 <<
" must be the same" << std::endl;
1871 std::ostringstream error_message;
1872 error_message <<
"The distribution of the solution vector is setup "
1873 <<
"there it must be the same as the matrix."
The conjugate gradient method.
The conjugate gradient method.
A class for compressed row matrices. This is a distributable object.
unsigned long nrow() const
Return the number of rows of the matrix.
unsigned nrow() const
access function to the number of global rows.
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
setup the distribution of this distributable linear algebra object
Abstract base class for matrices of doubles – adds abstract interfaces for solving,...
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.
A vector in the mathematical sense, initially developed for linear algebra type applications....
double size() const
Calculate the size of the element (length, area, volume,...) in Eulerian computational coordinates....
bool Output_info
Flag is true to output info and results of timings.
bool Delete_input_data
Internal flag which is true when hypre_setup or hypre_solve can delete input matrix.
unsigned AMG_coarsening
AMG coarsening strategy. Coarsening types include: 0 = CLJP (parallel coarsening using independent se...
int Euclid_level
Euclid level parameter for ILU(k) factorization.
double AMGEuclidSmoother_drop_tol
bool Euclid_using_BJ
Flag to determine if Block Jacobi is used instead of PILU.
bool Euclid_rowScale
Flag to switch on Euclid row scaling.
double AMG_strength
Connection strength threshold parameter for BoomerAMG.
LinearAlgebraDistribution * Hypre_distribution_pt
the distribution for this helpers-
int ParaSails_nlevel
ParaSails nlevel parameter.
double ParaSails_filter
ParaSails filter parameter.
bool AMGEuclidSmoother_use_row_scaling
unsigned AMGEuclidSmoother_level
HYPRE_Solver Solver
The Hypre solver used in solve(...), resolve(...) or preconditioner_solve(...). [This is a C structur...
int ParaSails_symmetry
ParaSails symmetry flag, used to inform ParaSails of Symmetry of definitenss of problem and type of P...
HYPRE_ParCSRMatrix Matrix_par
The Hypre_ParCSRMatrix version of the matrix used in solve(...), resolve(...) or preconditioner_solve...
bool AMGEuclidSmoother_use_ilut
unsigned Internal_preconditioner
Preconditioner method flag used with Hypre's PCG, GMRES and BiCGStab in solve(...) or resolve(....
void hypre_solve(const DoubleVector &rhs, DoubleVector &solution)
Helper function performs a solve if any solver exists.
unsigned AMGEuclidSmoother_print_level
bool AMGEuclidSmoother_use_block_jacobi
unsigned AMG_complex_smoother
Complex smoothing methods used in BoomerAMG. To use these methods set AMG_using_simple_smoothing to f...
double ParaSails_thresh
ParaSails thresh parameter.
double AMG_truncation
Interpolation truncation factor for BoomerAMG.
unsigned Krylov_print_level
Used to set the Hypre printing level for the Krylov subspace solvers.
unsigned AMG_smoother_iterations
The number of smoother iterations to apply.
unsigned existing_solver()
Function to return value of which solver (if any) is currently stored.
void hypre_clean_up_memory()
Function deletes all solver data.
bool Hypre_error_messages
Flag to determine if non-zero values of the Hypre error flag plus Hypre error messages are output to ...
double Tolerance
Tolerance used to terminate solver.
bool AMG_using_simple_smoothing
Flag to determine whether simple smoothers (determined by the AMG_simple_smoother flag) or complex sm...
unsigned Existing_solver
Used to keep track of which solver (if any) is currently stored.
unsigned Max_iter
Maximum number of iterations used in solver.
double AMG_damping
Damping factor for BoomerAMG smoothed Jacobi or hybrid SOR.
unsigned AMG_simple_smoother
Simple smoothing methods used in BoomerAMG. To use these methods set AMG_using_simple_smoothing to tr...
unsigned AMG_print_level
Used to set the Hypre printing level for AMG 0: no printout 1: print setup information 2: print solve...
HYPRE_IJMatrix Matrix_ij
The Hypre_IJMatrix version of the matrix used in solve(...), resolve(...) or preconditioner_solve(....
unsigned Euclid_print_level
Flag to set the level of printing from Euclid when the Euclid destructor is called 0: no printing (de...
unsigned AMG_max_levels
Maximum number of levels used in AMG.
unsigned Hypre_method
Hypre method flag. Valid values are specified in enumeration.
void hypre_matrix_setup(CRDoubleMatrix *matrix_pt)
Function which sets values of First_global_row, Last_global_row and other partitioning data and creat...
double AMG_max_row_sum
Parameter to identify diagonally dominant parts of the matrix in AMG.
double Euclid_droptol
Euclid drop tolerance for ILU(k) and ILUT factorization.
unsigned Existing_preconditioner
Used to keep track of which preconditioner (if any) is currently stored.
bool Euclid_using_ILUT
Flag to determine if ILUT (if true) or ILU(k) is used in Euclid.
void hypre_solver_setup()
Sets up the data required for to use as an oomph-lib LinearSolver or Preconditioner....
An Preconditioner class using the suite of Hypre preconditioners to allow.
static void reset_cumulative_solve_times()
Reset cumulative solve times.
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...
std::string Context_string
String can be used to provide context for annotation.
void clean_up_memory()
Function deletes all solver data.
static double Cumulative_preconditioner_solve_time
Static double that accumulates the preconditioner solve time of all instantiations of this class....
void setup()
Function to set up a preconditioner for the linear system defined by matrix_pt. This function is requ...
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,...
bool Delete_matrix
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
static std::map< std::string, unsigned > Context_based_nrow
Static unsigned that stores nrow for the most recent instantiations of this class,...
double My_cumulative_preconditioner_solve_time
Private double that accumulates the preconditioner solve time of thi instantiation of this class....
static void report_cumulative_solve_times()
Report cumulative solve times of all instantiations of this class.
static unsigned Cumulative_npreconditioner_solve
Static unsigned that accumulates the number of preconditioner solves of all instantiations of this cl...
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Function applies solver to vector r for preconditioning. This requires a call to setup(....
void solve(Problem *const &problem_pt, DoubleVector &solution)
Function which uses problem_pt's get_jacobian(...) function to generate a linear system which is then...
void clean_up_memory()
Function deletes all solver data.
bool Delete_matrix
Hypre copies matrix data from oomph-lib's CRDoubleMatrix or DistributedCRDoubleMatrix into its own da...
void resolve(const DoubleVector &rhs, DoubleVector &solution)
Function to resolve a linear system using the existing solver data, allowing a solve with a new right...
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
unsigned first_row() const
access function for the first row on this processor. If not distributed then this is just zero.
OomphCommunicator * communicator_pt() const
const access to the communicator pointer
unsigned nrow_local() const
access function for the num of local rows on this processor. If no MPI then Nrow is returned.
bool Doc_time
Boolean flag that indicates whether the time taken.
bool Enable_resolve
Boolean that indicates whether the matrix (or its factors, in the case of direct solver) should be st...
static bool mpi_has_been_initialised()
return true if MPI has been initialised
static OomphCommunicator * communicator_pt()
access to global communicator. This is the oomph-lib equivalent of MPI_COMM_WORLD
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
An OomphLibError object which should be thrown when an run-time error is encountered....
An OomphLibWarning object which should be created as a temporary object to issue a warning....
Preconditioner base class. Gives an interface to call all other preconditioners through and stores th...
virtual DoubleMatrixBase * matrix_pt() const
Get function for matrix pointer.
////////////////////////////////////////////////////////////////// //////////////////////////////////...
virtual void get_jacobian(DoubleVector &residuals, DenseDoubleMatrix &jacobian)
Return the fully-assembled Jacobian and residuals for the problem Interface for the case when the Jac...
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
hypre_Error hypre__global_error
void create_HYPRE_Matrix(CRDoubleMatrix *oomph_matrix, HYPRE_IJMatrix &hypre_ij_matrix, HYPRE_ParCSRMatrix &hypre_par_matrix, LinearAlgebraDistribution *dist_pt)
Helper function to create a serial HYPRE_IJMatrix and HYPRE_ParCSRMatrix from a CRDoubleMatrix NOTE: ...
void create_HYPRE_Vector(const DoubleVector &oomph_vec, const LinearAlgebraDistribution *dist_pt, HYPRE_IJVector &hypre_ij_vector, HYPRE_ParVector &hypre_par_vector)
Helper function to create a HYPRE_IJVector and HYPRE_ParVector.
int check_HYPRE_error_flag(std::ostringstream &message)
Helper function to check the Hypre error flag, return the message associated with any error,...
unsigned Number_of_active_hypre_solvers
Number of active Hypre solvers (smart pointer like behaviuor to make sure that the initialise/finaliz...
unsigned AMG_coarsening
Default AMG coarsening strategy. Coarsening types include: 0 = CLJP (parallel coarsening using indepe...
double AMG_truncation
AMG interpolation truncation factor.
double AMG_strength
Default for AMG strength (0.25 recommended for 2D problems; larger (0.5-0.75, say) for 3D.
void euclid_settings_helper(const bool &use_block_jacobi, const bool &use_row_scaling, const bool &use_ilut, const int &level, const double &drop_tol, const int &print_level, HYPRE_Solver &euclid_object)
Helper function to set Euclid options using a command line like array.
void set_defaults_for_navier_stokes_momentum_block(HyprePreconditioner *hypre_preconditioner_pt)
Set default parameters for use as preconditioner in for momentum block in Navier-Stokes problem.
void set_defaults_for_3D_poisson_problem(HyprePreconditioner *hypre_preconditioner_pt)
Set default parameters for use as preconditioner in 3D Poisson-type problem.
void set_defaults_for_2D_poisson_problem(HyprePreconditioner *hypre_preconditioner_pt)
Set default parameters for use as preconditioner in 2D Poisson-type problem.
double timer()
returns the time in seconds after some point in past
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
std::string lower(const std::string &text)
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...