Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
oomph::IterativeLinearSolver Class Referenceabstract

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>

+ Inheritance diagram for oomph::IterativeLinearSolver:

Public Member Functions

 IterativeLinearSolver ()
 Constructor: Set (default) trivial preconditioner and set defaults for tolerance and max. number of iterations. More...
 
 IterativeLinearSolver (const IterativeLinearSolver &)
 Broken copy constructor. More...
 
void operator= (const IterativeLinearSolver &)
 Broken assignment operator. More...
 
virtual ~IterativeLinearSolver ()
 Destructor (empty) More...
 
Preconditioner *& preconditioner_pt ()
 Access function to preconditioner. More...
 
Preconditioner *const & preconditioner_pt () const
 Access function to preconditioner (const version) More...
 
double & tolerance ()
 Access to convergence tolerance. More...
 
unsigned & max_iter ()
 Access to max. number of iterations. More...
 
virtual unsigned iterations () const =0
 Number of iterations taken. More...
 
void enable_doc_convergence_history ()
 Enable documentation of the convergence history. More...
 
void disable_doc_convergence_history ()
 Disable documentation of the convergence history. More...
 
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). More...
 
void close_convergence_history_file_stream ()
 Close convergence history output stream. More...
 
double jacobian_setup_time () const
 returns the time taken to assemble the jacobian matrix and residual vector More...
 
double linear_solver_solution_time () const
 return the time taken to solve the linear system More...
 
virtual double preconditioner_setup_time () const
 returns the the time taken to setup the preconditioner More...
 
void enable_setup_preconditioner_before_solve ()
 Setup the preconditioner before the solve. More...
 
void disable_setup_preconditioner_before_solve ()
 Don't set up the preconditioner before the solve. More...
 
void enable_error_after_max_iter ()
 Throw an error if we don't converge within max_iter. More...
 
void disable_error_after_max_iter ()
 Don't throw an error if we don't converge within max_iter (default). More...
 
void enable_iterative_solver_as_preconditioner ()
 
void disable_iterative_solver_as_preconditioner ()
 
- Public Member Functions inherited from oomph::LinearSolver
 LinearSolver ()
 Empty constructor, initialise the member data. More...
 
 LinearSolver (const LinearSolver &dummy)
 Broken copy constructor. More...
 
void operator= (const LinearSolver &)
 Broken assignment operator. More...
 
virtual ~LinearSolver ()
 Empty virtual destructor. More...
 
void enable_doc_time ()
 Enable documentation of solve times. More...
 
void disable_doc_time ()
 Disable documentation of solve times. More...
 
bool is_doc_time_enabled () const
 Is documentation of solve times enabled? More...
 
bool is_resolve_enabled () const
 Boolean flag indicating if resolves are enabled. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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) More...
 
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). More...
 
virtual void enable_computation_of_gradient ()
 function to enable the computation of the gradient required for the globally convergent Newton method More...
 
void disable_computation_of_gradient ()
 function to disable the computation of the gradient required for the globally convergent Newton method More...
 
void reset_gradient ()
 function to reset the size of the gradient before each Newton solve More...
 
void get_gradient (DoubleVector &gradient)
 function to access the gradient, provided it has been computed More...
 
- Public Member Functions inherited from oomph::DistributableLinearAlgebraObject
 DistributableLinearAlgebraObject ()
 Default constructor - create a distribution. More...
 
 DistributableLinearAlgebraObject (const DistributableLinearAlgebraObject &matrix)
 Broken copy constructor. More...
 
void operator= (const DistributableLinearAlgebraObject &)
 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)
 setup the distribution of this distributable linear algebra object More...
 
void build_distribution (const LinearAlgebraDistribution &dist)
 setup the distribution of this distributable linear algebra object More...
 

Protected Attributes

bool Doc_convergence_history
 Flag indicating if the convergence history is to be documented. More...
 
std::ofstream Output_file_stream
 Output file stream for convergence history. More...
 
double Tolerance
 Convergence tolerance. More...
 
unsigned Max_iter
 Maximum number of iterations. More...
 
PreconditionerPreconditioner_pt
 Pointer to the preconditioner. More...
 
double Jacobian_setup_time
 Jacobian setup time. More...
 
double Solution_time
 linear solver solution time More...
 
double Preconditioner_setup_time
 Preconditioner setup time. More...
 
bool Setup_preconditioner_before_solve
 indicates whether the preconditioner should be setup before solve. Default = true; More...
 
bool Throw_error_after_max_iter
 Should we throw an error instead of just returning when we hit the max iterations? More...
 
bool Use_iterative_solver_as_preconditioner
 Use the iterative solver as preconditioner. More...
 
bool First_time_solve_when_used_as_preconditioner
 
- Protected Attributes inherited from oomph::LinearSolver
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. More...
 
bool Doc_time
 Boolean flag that indicates whether the time taken. More...
 
bool Compute_gradient
 flag that indicates whether the gradient required for the globally convergent Newton method should be computed or not More...
 
bool Gradient_has_been_computed
 flag that indicates whether the gradient was computed or not More...
 
DoubleVector Gradient_for_glob_conv_newton_solve
 DoubleVector storing the gradient for the globally convergent Newton method. More...
 

Static Protected Attributes

static IdentityPreconditioner Default_preconditioner
 Default preconditioner: The base class for preconditioners is a fully functional (if trivial!) preconditioner. More...
 

Additional Inherited Members

- Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 clear the distribution of this distributable linear algebra object More...
 

Detailed Description

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 60 of file iterative_linear_solver.h.

Constructor & Destructor Documentation

oomph::IterativeLinearSolver::IterativeLinearSolver ( )
inline

Constructor: Set (default) trivial preconditioner and set defaults for tolerance and max. number of iterations.

Definition at line 67 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.

oomph::IterativeLinearSolver::IterativeLinearSolver ( const IterativeLinearSolver )
inline

Broken copy constructor.

Definition at line 95 of file iterative_linear_solver.h.

References oomph::BrokenCopy::broken_copy().

virtual oomph::IterativeLinearSolver::~IterativeLinearSolver ( )
inlinevirtual

Destructor (empty)

Definition at line 107 of file iterative_linear_solver.h.

Member Function Documentation

void oomph::IterativeLinearSolver::close_convergence_history_file_stream ( )
inline

Close convergence history output stream.

Definition at line 159 of file iterative_linear_solver.h.

References Output_file_stream.

void oomph::IterativeLinearSolver::disable_doc_convergence_history ( )
inline

Disable documentation of the convergence history.

Definition at line 128 of file iterative_linear_solver.h.

References Doc_convergence_history.

void oomph::IterativeLinearSolver::disable_error_after_max_iter ( )
inline

Don't throw an error if we don't converge within max_iter (default).

Definition at line 196 of file iterative_linear_solver.h.

References Throw_error_after_max_iter.

void oomph::IterativeLinearSolver::disable_iterative_solver_as_preconditioner ( )
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 208 of file iterative_linear_solver.h.

References Use_iterative_solver_as_preconditioner.

void oomph::IterativeLinearSolver::disable_setup_preconditioner_before_solve ( )
inline

Don't set up the preconditioner before the solve.

Definition at line 188 of file iterative_linear_solver.h.

References Setup_preconditioner_before_solve.

void oomph::IterativeLinearSolver::enable_doc_convergence_history ( )
inline

Enable documentation of the convergence history.

Definition at line 125 of file iterative_linear_solver.h.

References Doc_convergence_history.

void oomph::IterativeLinearSolver::enable_error_after_max_iter ( )
inline

Throw an error if we don't converge within max_iter.

Definition at line 192 of file iterative_linear_solver.h.

References Throw_error_after_max_iter.

void oomph::IterativeLinearSolver::enable_iterative_solver_as_preconditioner ( )
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 202 of file iterative_linear_solver.h.

References Use_iterative_solver_as_preconditioner.

void oomph::IterativeLinearSolver::enable_setup_preconditioner_before_solve ( )
inline

Setup the preconditioner before the solve.

Definition at line 184 of file iterative_linear_solver.h.

References Setup_preconditioner_before_solve.

virtual unsigned oomph::IterativeLinearSolver::iterations ( ) const
pure virtual
double oomph::IterativeLinearSolver::jacobian_setup_time ( ) const
inlinevirtual

returns the time taken to assemble the jacobian matrix and residual vector

Reimplemented from oomph::LinearSolver.

Definition at line 166 of file iterative_linear_solver.h.

References Jacobian_setup_time.

double oomph::IterativeLinearSolver::linear_solver_solution_time ( ) const
inlinevirtual

return the time taken to solve the linear system

Reimplemented from oomph::LinearSolver.

Definition at line 172 of file iterative_linear_solver.h.

References Solution_time.

unsigned& oomph::IterativeLinearSolver::max_iter ( )
inline

Access to max. number of iterations.

Definition at line 119 of file iterative_linear_solver.h.

References Max_iter.

void oomph::IterativeLinearSolver::open_convergence_history_file_stream ( const std::string &  file_name,
const std::string &  zone_title = "" 
)
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 135 of file iterative_linear_solver.h.

References Doc_convergence_history, and Output_file_stream.

void oomph::IterativeLinearSolver::operator= ( const IterativeLinearSolver )
inline

Broken assignment operator.

Definition at line 101 of file iterative_linear_solver.h.

References oomph::BrokenCopy::broken_assign().

Preconditioner*& oomph::IterativeLinearSolver::preconditioner_pt ( )
inline
Preconditioner* const& oomph::IterativeLinearSolver::preconditioner_pt ( ) const
inline

Access function to preconditioner (const version)

Definition at line 113 of file iterative_linear_solver.h.

References Preconditioner_pt.

virtual double oomph::IterativeLinearSolver::preconditioner_setup_time ( ) const
inlinevirtual

returns the the time taken to setup the preconditioner

Reimplemented in oomph::GS< CRDoubleMatrix >, and oomph::GS< MATRIX >.

Definition at line 178 of file iterative_linear_solver.h.

References Preconditioner_setup_time.

double& oomph::IterativeLinearSolver::tolerance ( )
inline

Member Data Documentation

IdentityPreconditioner oomph::IterativeLinearSolver::Default_preconditioner
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 223 of file iterative_linear_solver.h.

Referenced by IterativeLinearSolver().

bool oomph::IterativeLinearSolver::Doc_convergence_history
protected
bool oomph::IterativeLinearSolver::First_time_solve_when_used_as_preconditioner
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 257 of file iterative_linear_solver.h.

Referenced by IterativeLinearSolver(), and oomph::TrilinosAztecOOSolver::solve().

double oomph::IterativeLinearSolver::Jacobian_setup_time
protected
unsigned oomph::IterativeLinearSolver::Max_iter
protected
std::ofstream oomph::IterativeLinearSolver::Output_file_stream
protected

Output file stream for convergence history.

Definition at line 218 of file iterative_linear_solver.h.

Referenced by close_convergence_history_file_stream(), open_convergence_history_file_stream(), and oomph::GS< CRDoubleMatrix >::solve_helper().

Preconditioner* oomph::IterativeLinearSolver::Preconditioner_pt
protected

Pointer to the preconditioner.

Definition at line 232 of file iterative_linear_solver.h.

Referenced by IterativeLinearSolver(), preconditioner_pt(), and oomph::TrilinosAztecOOSolver::solver_setup().

double oomph::IterativeLinearSolver::Preconditioner_setup_time
protected

Preconditioner setup time.

Definition at line 241 of file iterative_linear_solver.h.

Referenced by preconditioner_setup_time().

bool oomph::IterativeLinearSolver::Setup_preconditioner_before_solve
protected

indicates whether the preconditioner should be setup before solve. Default = true;

Definition at line 245 of file iterative_linear_solver.h.

Referenced by disable_setup_preconditioner_before_solve(), enable_setup_preconditioner_before_solve(), IterativeLinearSolver(), and oomph::TrilinosAztecOOSolver::solver_setup().

double oomph::IterativeLinearSolver::Solution_time
protected

linear solver solution time

Definition at line 238 of file iterative_linear_solver.h.

Referenced by linear_solver_solution_time(), and oomph::GS< CRDoubleMatrix >::solve_helper().

bool oomph::IterativeLinearSolver::Throw_error_after_max_iter
protected

Should we throw an error instead of just returning when we hit the max iterations?

Definition at line 249 of file iterative_linear_solver.h.

Referenced by disable_error_after_max_iter(), enable_error_after_max_iter(), IterativeLinearSolver(), and oomph::GS< CRDoubleMatrix >::solve_helper().

double oomph::IterativeLinearSolver::Tolerance
protected
bool oomph::IterativeLinearSolver::Use_iterative_solver_as_preconditioner
protected

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