Base class for all linear iterative solvers. This merely defines standard interfaces for linear iterative solvers, so that different solvers can be used in a clean and transparent manner. More...
#include <iterative_linear_solver.h>
Public Member Functions | |
IterativeLinearSolver () | |
Constructor: Set (default) trivial preconditioner and set defaults for tolerance and max. number of iterations. | |
IterativeLinearSolver (const IterativeLinearSolver &)=delete | |
Broken copy constructor. | |
void | operator= (const IterativeLinearSolver &)=delete |
Broken assignment operator. | |
virtual | ~IterativeLinearSolver () |
Destructor (empty) | |
Preconditioner *& | preconditioner_pt () |
Access function to preconditioner. | |
Preconditioner *const & | preconditioner_pt () const |
Access function to preconditioner (const version) | |
double & | tolerance () |
Access to convergence tolerance. | |
unsigned & | max_iter () |
Access to max. number of iterations. | |
virtual unsigned | iterations () const =0 |
Number of iterations taken. | |
void | enable_doc_convergence_history () |
Enable documentation of the convergence history. | |
void | disable_doc_convergence_history () |
Disable documentation of the convergence history. | |
void | open_convergence_history_file_stream (const std::string &file_name, const std::string &zone_title="") |
Write convergence history into file with specified filename (automatically switches on doc). Optional second argument is a string that can be used (as a zone title) to identify what case we're running (e.g. what combination of linear solver and preconditioner or parameter values are used). | |
void | close_convergence_history_file_stream () |
Close convergence history output stream. | |
double | jacobian_setup_time () const |
returns the time taken to assemble the jacobian matrix and residual vector | |
double | linear_solver_solution_time () const |
return the time taken to solve the linear system | |
virtual double | preconditioner_setup_time () const |
returns the the time taken to setup the preconditioner | |
void | enable_setup_preconditioner_before_solve () |
Setup the preconditioner before the solve. | |
void | disable_setup_preconditioner_before_solve () |
Don't set up the preconditioner before the solve. | |
void | enable_error_after_max_iter () |
Throw an error if we don't converge within max_iter. | |
void | disable_error_after_max_iter () |
Don't throw an error if we don't converge within max_iter (default). | |
void | enable_iterative_solver_as_preconditioner () |
Enables the iterative solver be used as preconditioner (when calling the solve method it bypass the setup solver method – currently only used by Trilinos solver —) | |
void | disable_iterative_solver_as_preconditioner () |
Disables the iterative solver be used as preconditioner (when calling the solve method it bypass the setup solver method – currently only used by Trilinos solver —) | |
![]() | |
LinearSolver () | |
Empty constructor, initialise the member data. | |
LinearSolver (const LinearSolver &dummy)=delete | |
Broken copy constructor. | |
void | operator= (const LinearSolver &)=delete |
Broken assignment operator. | |
virtual | ~LinearSolver () |
Empty virtual destructor. | |
void | enable_doc_time () |
Enable documentation of solve times. | |
void | disable_doc_time () |
Disable documentation of solve times. | |
bool | is_doc_time_enabled () const |
Is documentation of solve times enabled? | |
bool | is_resolve_enabled () const |
Boolean flag indicating if resolves are enabled. | |
virtual void | enable_resolve () |
Enable resolve (i.e. store matrix and/or LU decomposition, say) Virtual so it can be overloaded to perform additional tasks. | |
virtual void | disable_resolve () |
Disable resolve (i.e. store matrix and/or LU decomposition, say) This function simply resets an internal flag. It's virtual so it can be overloaded to perform additional tasks such as cleaning up memory that is only required for the resolve. | |
virtual void | solve (Problem *const &problem_pt, DoubleVector &result)=0 |
Solver: Takes pointer to problem and returns the results vector which contains the solution of the linear system defined by the problem's fully assembled Jacobian and residual vector. | |
virtual void | solve (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &result) |
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system. | |
virtual void | solve (DoubleMatrixBase *const &matrix_pt, const Vector< double > &rhs, Vector< double > &result) |
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system. | |
virtual void | solve_transpose (Problem *const &problem_pt, DoubleVector &result) |
Solver: Takes pointer to problem and returns the results vector which contains the solution of the linear system defined by the problem's fully assembled Jacobian and residual vector (broken virtual). | |
virtual void | solve_transpose (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &result) |
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system. | |
virtual void | solve_transpose (DoubleMatrixBase *const &matrix_pt, const Vector< double > &rhs, Vector< double > &result) |
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system. | |
virtual void | resolve (const DoubleVector &rhs, DoubleVector &result) |
Resolve the system defined by the last assembled jacobian and the rhs vector. Solution is returned in the vector result. (broken virtual) | |
virtual void | resolve_transpose (const DoubleVector &rhs, DoubleVector &result) |
Solver: Resolve the system defined by the last assembled jacobian and the rhs vector. Solution is returned in the vector result. (broken virtual) | |
virtual void | clean_up_memory () |
Empty virtual function that can be overloaded in specific linear solvers to clean up any memory that may have been allocated (e.g. when preparing for a re-solve). | |
virtual void | enable_computation_of_gradient () |
function to enable the computation of the gradient required for the globally convergent Newton method | |
void | disable_computation_of_gradient () |
function to disable the computation of the gradient required for the globally convergent Newton method | |
void | reset_gradient () |
function to reset the size of the gradient before each Newton solve | |
void | get_gradient (DoubleVector &gradient) |
function to access the gradient, provided it has been computed | |
![]() | |
DistributableLinearAlgebraObject () | |
Default constructor - create a distribution. | |
DistributableLinearAlgebraObject (const DistributableLinearAlgebraObject &matrix)=delete | |
Broken copy constructor. | |
void | operator= (const DistributableLinearAlgebraObject &)=delete |
Broken assignment operator. | |
virtual | ~DistributableLinearAlgebraObject () |
Destructor. | |
LinearAlgebraDistribution * | distribution_pt () const |
access to the LinearAlgebraDistribution | |
unsigned | nrow () const |
access function to the number of global rows. | |
unsigned | nrow_local () const |
access function for the num of local rows on this processor. | |
unsigned | nrow_local (const unsigned &p) const |
access function for the num of local rows on this processor. | |
unsigned | first_row () const |
access function for the first row on this processor | |
unsigned | first_row (const unsigned &p) const |
access function for the first row on this processor | |
bool | distributed () const |
distribution is serial or distributed | |
bool | distribution_built () const |
if the communicator_pt is null then the distribution is not setup then false is returned, otherwise return true | |
void | build_distribution (const LinearAlgebraDistribution *const dist_pt) |
setup the distribution of this distributable linear algebra object | |
void | build_distribution (const LinearAlgebraDistribution &dist) |
setup the distribution of this distributable linear algebra object | |
Protected Attributes | |
bool | Doc_convergence_history |
Flag indicating if the convergence history is to be documented. | |
std::ofstream | Output_file_stream |
Output file stream for convergence history. | |
double | Tolerance |
Convergence tolerance. | |
unsigned | Max_iter |
Maximum number of iterations. | |
Preconditioner * | Preconditioner_pt |
Pointer to the preconditioner. | |
double | Jacobian_setup_time |
Jacobian setup time. | |
double | Solution_time |
linear solver solution time | |
double | Preconditioner_setup_time |
Preconditioner setup time. | |
bool | Setup_preconditioner_before_solve |
indicates whether the preconditioner should be setup before solve. Default = true; | |
bool | Throw_error_after_max_iter |
Should we throw an error instead of just returning when we hit the max iterations? | |
bool | Use_iterative_solver_as_preconditioner |
Use the iterative solver as preconditioner. | |
bool | First_time_solve_when_used_as_preconditioner |
When the iterative solver is used a preconditioner then we call the setup of solver method only once (the first time the solve method is called) | |
![]() | |
bool | Enable_resolve |
Boolean that indicates whether the matrix (or its factors, in the case of direct solver) should be stored so that the resolve function can be used. | |
bool | Doc_time |
Boolean flag that indicates whether the time taken. | |
bool | Compute_gradient |
flag that indicates whether the gradient required for the globally convergent Newton method should be computed or not | |
bool | Gradient_has_been_computed |
flag that indicates whether the gradient was computed or not | |
DoubleVector | Gradient_for_glob_conv_newton_solve |
DoubleVector storing the gradient for the globally convergent Newton method. | |
Static Protected Attributes | |
static IdentityPreconditioner | Default_preconditioner |
Default preconditioner: The base class for preconditioners is a fully functional (if trivial!) preconditioner. | |
Additional Inherited Members | |
![]() | |
void | clear_distribution () |
clear the distribution of this distributable linear algebra object | |
Base class for all linear iterative solvers. This merely defines standard interfaces for linear iterative solvers, so that different solvers can be used in a clean and transparent manner.
Definition at line 53 of file iterative_linear_solver.h.
|
inline |
Constructor: Set (default) trivial preconditioner and set defaults for tolerance and max. number of iterations.
Definition at line 58 of file iterative_linear_solver.h.
References Default_preconditioner, Doc_convergence_history, First_time_solve_when_used_as_preconditioner, Max_iter, Preconditioner_pt, Setup_preconditioner_before_solve, Throw_error_after_max_iter, Tolerance, and Use_iterative_solver_as_preconditioner.
|
delete |
Broken copy constructor.
|
inlinevirtual |
Destructor (empty)
Definition at line 92 of file iterative_linear_solver.h.
|
inline |
Close convergence history output stream.
Definition at line 161 of file iterative_linear_solver.h.
References Output_file_stream.
|
inline |
Disable documentation of the convergence history.
Definition at line 128 of file iterative_linear_solver.h.
References Doc_convergence_history.
|
inline |
Don't throw an error if we don't converge within max_iter (default).
Definition at line 204 of file iterative_linear_solver.h.
References Throw_error_after_max_iter.
|
inline |
Disables the iterative solver be used as preconditioner (when calling the solve method it bypass the setup solver method – currently only used by Trilinos solver —)
Definition at line 220 of file iterative_linear_solver.h.
References Use_iterative_solver_as_preconditioner.
|
inline |
Don't set up the preconditioner before the solve.
Definition at line 192 of file iterative_linear_solver.h.
References Setup_preconditioner_before_solve.
|
inline |
Enable documentation of the convergence history.
Definition at line 122 of file iterative_linear_solver.h.
References Doc_convergence_history.
|
inline |
Throw an error if we don't converge within max_iter.
Definition at line 198 of file iterative_linear_solver.h.
References Throw_error_after_max_iter.
|
inline |
Enables the iterative solver be used as preconditioner (when calling the solve method it bypass the setup solver method – currently only used by Trilinos solver —)
Definition at line 212 of file iterative_linear_solver.h.
References Use_iterative_solver_as_preconditioner.
|
inline |
Setup the preconditioner before the solve.
Definition at line 186 of file iterative_linear_solver.h.
References Setup_preconditioner_before_solve.
Number of iterations taken.
Implemented in oomph::MGSolver< DIM >, oomph::CG< MATRIX >, oomph::BiCGStab< MATRIX >, oomph::GS< MATRIX >, oomph::GS< CRDoubleMatrix >, oomph::DampedJacobi< MATRIX >, oomph::GMRES< MATRIX >, oomph::AugmentedProblemGMRES, oomph::TrilinosAztecOOSolver, oomph::ComplexDampedJacobi< MATRIX >, oomph::ComplexGMRES< MATRIX >, oomph::HelmholtzGMRESMG< MATRIX >, and oomph::GMRESBlockPreconditioner.
|
inlinevirtual |
returns the time taken to assemble the jacobian matrix and residual vector
Reimplemented from oomph::LinearSolver.
Definition at line 168 of file iterative_linear_solver.h.
References Jacobian_setup_time.
|
inlinevirtual |
return the time taken to solve the linear system
Reimplemented from oomph::LinearSolver.
Definition at line 174 of file iterative_linear_solver.h.
References Solution_time.
|
inline |
Access to max. number of iterations.
Definition at line 113 of file iterative_linear_solver.h.
References Max_iter.
|
inline |
Write convergence history into file with specified filename (automatically switches on doc). Optional second argument is a string that can be used (as a zone title) to identify what case we're running (e.g. what combination of linear solver and preconditioner or parameter values are used).
Definition at line 138 of file iterative_linear_solver.h.
References Doc_convergence_history, and Output_file_stream.
|
delete |
Broken assignment operator.
|
inline |
Access function to preconditioner.
Definition at line 95 of file iterative_linear_solver.h.
References Preconditioner_pt.
Referenced by oomph::AugmentedProblemGMRES::apply_schur_complement_preconditioner(), oomph::TrilinosAztecOOSolver::clean_up_memory(), oomph::ProjectionProblem< PROJECTABLE_ELEMENT >::project(), oomph::AugmentedProblemGMRES::solve_helper(), oomph::GMRES< MATRIX >::update(), and oomph::HelmholtzGMRESMG< MATRIX >::update().
|
inline |
Access function to preconditioner (const version)
Definition at line 101 of file iterative_linear_solver.h.
References Preconditioner_pt.
returns the the time taken to setup the preconditioner
Reimplemented in oomph::GS< MATRIX >, and oomph::GS< CRDoubleMatrix >.
Definition at line 180 of file iterative_linear_solver.h.
References Preconditioner_setup_time.
|
inline |
Access to convergence tolerance.
Definition at line 107 of file iterative_linear_solver.h.
References Tolerance.
Referenced by oomph::ComplexDampedJacobi< MATRIX >::calculate_omega(), oomph::ComplexGMRES< MATRIX >::generate_plane_rotation(), and oomph::HelmholtzGMRESMG< MATRIX >::generate_plane_rotation().
|
staticprotected |
Default preconditioner: The base class for preconditioners is a fully functional (if trivial!) preconditioner.
Default preconditioner for iterative solvers: The base class for preconditioners is a fully functional (if trivial!) preconditioner.
Definition at line 236 of file iterative_linear_solver.h.
Referenced by IterativeLinearSolver().
|
protected |
Flag indicating if the convergence history is to be documented.
Definition at line 228 of file iterative_linear_solver.h.
Referenced by disable_doc_convergence_history(), enable_doc_convergence_history(), IterativeLinearSolver(), open_convergence_history_file_stream(), oomph::GMRESBlockPreconditioner::preconditioner_solve(), and oomph::AugmentedProblemGMRES::solve_helper().
|
protected |
When the iterative solver is used a preconditioner then we call the setup of solver method only once (the first time the solve method is called)
Definition at line 270 of file iterative_linear_solver.h.
Referenced by IterativeLinearSolver(), and oomph::TrilinosAztecOOSolver::solve().
|
protected |
Jacobian setup time.
Definition at line 248 of file iterative_linear_solver.h.
Referenced by jacobian_setup_time(), oomph::AugmentedProblemGMRES::solve(), oomph::HelmholtzGMRESMG< MATRIX >::solve(), and oomph::HelmholtzFGMRESMG< MATRIX >::solve().
|
protected |
Maximum number of iterations.
Definition at line 242 of file iterative_linear_solver.h.
Referenced by IterativeLinearSolver(), max_iter(), oomph::TrilinosAztecOOSolver::max_iter(), oomph::GMRESBlockPreconditioner::preconditioner_solve(), oomph::AugmentedProblemGMRES::solve_helper(), oomph::TrilinosAztecOOSolver::solve_using_AztecOO(), and oomph::TrilinosAztecOOSolver::solver_setup().
|
protected |
Output file stream for convergence history.
Definition at line 231 of file iterative_linear_solver.h.
Referenced by close_convergence_history_file_stream(), open_convergence_history_file_stream(), oomph::GMRESBlockPreconditioner::preconditioner_solve(), and oomph::AugmentedProblemGMRES::solve_helper().
|
protected |
Pointer to the preconditioner.
Definition at line 245 of file iterative_linear_solver.h.
Referenced by IterativeLinearSolver(), preconditioner_pt(), preconditioner_pt(), and oomph::TrilinosAztecOOSolver::solver_setup().
|
protected |
Preconditioner setup time.
Definition at line 254 of file iterative_linear_solver.h.
Referenced by preconditioner_setup_time(), and oomph::AugmentedProblemGMRES::solve_helper().
|
protected |
indicates whether the preconditioner should be setup before solve. Default = true;
Definition at line 258 of file iterative_linear_solver.h.
Referenced by disable_setup_preconditioner_before_solve(), enable_setup_preconditioner_before_solve(), IterativeLinearSolver(), oomph::AugmentedProblemGMRES::solve_helper(), and oomph::TrilinosAztecOOSolver::solver_setup().
|
protected |
linear solver solution time
Definition at line 251 of file iterative_linear_solver.h.
Referenced by linear_solver_solution_time(), oomph::GMRESBlockPreconditioner::preconditioner_solve(), and oomph::AugmentedProblemGMRES::solve_helper().
|
protected |
Should we throw an error instead of just returning when we hit the max iterations?
Definition at line 262 of file iterative_linear_solver.h.
Referenced by disable_error_after_max_iter(), enable_error_after_max_iter(), IterativeLinearSolver(), oomph::GMRESBlockPreconditioner::preconditioner_solve(), and oomph::AugmentedProblemGMRES::solve_helper().
|
protected |
Convergence tolerance.
Definition at line 239 of file iterative_linear_solver.h.
Referenced by IterativeLinearSolver(), oomph::MGSolver< DIM >::MGSolver(), oomph::GMRESBlockPreconditioner::preconditioner_solve(), oomph::AugmentedProblemGMRES::solve_helper(), oomph::TrilinosAztecOOSolver::solve_using_AztecOO(), tolerance(), oomph::TrilinosAztecOOSolver::tolerance(), and oomph::TrilinosAztecOOSolver::TrilinosAztecOOSolver().
|
protected |
Use the iterative solver as preconditioner.
Definition at line 265 of file iterative_linear_solver.h.
Referenced by disable_iterative_solver_as_preconditioner(), enable_iterative_solver_as_preconditioner(), IterativeLinearSolver(), and oomph::TrilinosAztecOOSolver::solve().