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

Base class for all linear solvers. This merely defines standard interfaces for linear solvers, so that different solvers can be used in a clean and transparent manner. Note that LinearSolvers are primarily used to solve the linear systems arising in oomph-lib's Newton iteration. Their primary solve function therefore takes a pointer to the associated problem, construct its Jacobian matrix and residual vector, and return the solution of the linear system formed by the Jacobian and the residual vector. We also provide broken virtual interfaces to a linear-algebra-type solve function in which the matrix and the rhs can be specified, but this are not guaranteed to implemented for all linear solvers (e.g. for frontal solvers). More...

#include <linear_solver.h>

+ Inheritance diagram for oomph::LinearSolver:

Public Member Functions

 LinearSolver ()
 Empty constructor, initialise the member data. More...
 
 LinearSolver (const LinearSolver &dummy)=delete
 Broken copy constructor. More...
 
void operator= (const LinearSolver &)=delete
 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 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). More...
 
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. More...
 
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. 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 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) 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 double jacobian_setup_time () const
 returns the time taken to assemble the Jacobian matrix and residual vector (needs to be overloaded for each solver) More...
 
virtual double linear_solver_solution_time () const
 return the time taken to solve the linear system (needs to be overloaded for each linear solver) 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)=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
 if the communicator_pt is null then the distribution is not setup then false is returned, otherwise return true More...
 
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 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...
 

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 solvers. This merely defines standard interfaces for linear solvers, so that different solvers can be used in a clean and transparent manner. Note that LinearSolvers are primarily used to solve the linear systems arising in oomph-lib's Newton iteration. Their primary solve function therefore takes a pointer to the associated problem, construct its Jacobian matrix and residual vector, and return the solution of the linear system formed by the Jacobian and the residual vector. We also provide broken virtual interfaces to a linear-algebra-type solve function in which the matrix and the rhs can be specified, but this are not guaranteed to implemented for all linear solvers (e.g. for frontal solvers).

Definition at line 67 of file linear_solver.h.

Constructor & Destructor Documentation

◆ LinearSolver() [1/2]

oomph::LinearSolver::LinearSolver ( )
inline

Empty constructor, initialise the member data.

Definition at line 92 of file linear_solver.h.

◆ LinearSolver() [2/2]

oomph::LinearSolver::LinearSolver ( const LinearSolver dummy)
delete

Broken copy constructor.

◆ ~LinearSolver()

virtual oomph::LinearSolver::~LinearSolver ( )
inlinevirtual

Empty virtual destructor.

Definition at line 107 of file linear_solver.h.

Member Function Documentation

◆ clean_up_memory()

virtual void oomph::LinearSolver::clean_up_memory ( )
inlinevirtual

◆ disable_computation_of_gradient()

void oomph::LinearSolver::disable_computation_of_gradient ( )
inline

function to disable the computation of the gradient required for the globally convergent Newton method

Definition at line 293 of file linear_solver.h.

References Compute_gradient.

◆ disable_doc_time()

void oomph::LinearSolver::disable_doc_time ( )
inline

◆ disable_resolve()

virtual void oomph::LinearSolver::disable_resolve ( )
inlinevirtual

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.

Reimplemented in oomph::HelmholtzGMRESMG< MATRIX >, oomph::ComplexGMRES< MATRIX >, oomph::TrilinosAztecOOSolver, oomph::MumpsSolver, oomph::SuperLUSolver, oomph::AugmentedProblemGMRES, oomph::GMRES< MATRIX >, oomph::GS< CRDoubleMatrix >, oomph::GS< MATRIX >, oomph::BiCGStab< MATRIX >, oomph::CG< MATRIX >, oomph::HypreSolver, and oomph::HSL_MA42.

Definition at line 144 of file linear_solver.h.

References Enable_resolve.

Referenced by oomph::Problem::calculate_continuation_derivatives(), oomph::HSL_MA42::disable_resolve(), oomph::CG< MATRIX >::disable_resolve(), oomph::BiCGStab< MATRIX >::disable_resolve(), oomph::GS< MATRIX >::disable_resolve(), oomph::GS< CRDoubleMatrix >::disable_resolve(), oomph::GMRES< MATRIX >::disable_resolve(), oomph::AugmentedProblemGMRES::disable_resolve(), oomph::SuperLUSolver::disable_resolve(), oomph::MumpsSolver::disable_resolve(), oomph::ComplexGMRES< MATRIX >::disable_resolve(), oomph::HelmholtzGMRESMG< MATRIX >::disable_resolve(), oomph::FoldHandler::FoldHandler(), oomph::HopfHandler::HopfHandler(), oomph::Problem::newton_solve_continuation(), oomph::AugmentedBlockFoldLinearSolver::resolve(), oomph::BlockPitchForkLinearSolver::resolve(), oomph::AugmentedBlockPitchForkLinearSolver::resolve(), oomph::AugmentedBlockFoldLinearSolver::solve(), oomph::BlockPitchForkLinearSolver::solve(), oomph::AugmentedBlockPitchForkLinearSolver::solve(), oomph::BlockHopfLinearSolver::solve(), and oomph::BlockHopfLinearSolver::solve_for_two_rhs().

◆ enable_computation_of_gradient()

virtual void oomph::LinearSolver::enable_computation_of_gradient ( )
inlinevirtual

function to enable the computation of the gradient required for the globally convergent Newton method

Reimplemented in oomph::SuperLUSolver, and oomph::GMRES< MATRIX >.

Definition at line 282 of file linear_solver.h.

Referenced by oomph::Problem::newton_solve().

◆ enable_doc_time()

void oomph::LinearSolver::enable_doc_time ( )
inline

Enable documentation of solve times.

Definition at line 110 of file linear_solver.h.

References Doc_time.

Referenced by oomph::NewMumpsPreconditioner::enable_doc_time(), and oomph::ProjectionProblem< PROJECTABLE_ELEMENT >::project().

◆ enable_resolve()

virtual void oomph::LinearSolver::enable_resolve ( )
inlinevirtual

◆ get_gradient()

void oomph::LinearSolver::get_gradient ( DoubleVector gradient)
inline

function to access the gradient, provided it has been computed

Definition at line 306 of file linear_solver.h.

References Gradient_for_glob_conv_newton_solve, and Gradient_has_been_computed.

Referenced by oomph::Problem::newton_solve().

◆ is_doc_time_enabled()

bool oomph::LinearSolver::is_doc_time_enabled ( ) const
inline

Is documentation of solve times enabled?

Definition at line 122 of file linear_solver.h.

References Doc_time.

Referenced by oomph::ProjectionProblem< PROJECTABLE_ELEMENT >::project().

◆ is_resolve_enabled()

bool oomph::LinearSolver::is_resolve_enabled ( ) const
inline

◆ jacobian_setup_time()

virtual double oomph::LinearSolver::jacobian_setup_time ( ) const
inlinevirtual

returns the time taken to assemble the Jacobian matrix and residual vector (needs to be overloaded for each solver)

Reimplemented in oomph::SuperLUSolver, oomph::DenseLU, and oomph::IterativeLinearSolver.

Definition at line 260 of file linear_solver.h.

◆ linear_solver_solution_time()

virtual double oomph::LinearSolver::linear_solver_solution_time ( ) const
inlinevirtual

return the time taken to solve the linear system (needs to be overloaded for each linear solver)

Reimplemented in oomph::SuperLUSolver, oomph::DenseLU, and oomph::IterativeLinearSolver.

Definition at line 271 of file linear_solver.h.

◆ operator=()

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

Broken assignment operator.

◆ reset_gradient()

void oomph::LinearSolver::reset_gradient ( )
inline

function to reset the size of the gradient before each Newton solve

Definition at line 300 of file linear_solver.h.

References oomph::DoubleVector::clear(), and Gradient_for_glob_conv_newton_solve.

Referenced by oomph::Problem::newton_solve().

◆ resolve()

virtual void oomph::LinearSolver::resolve ( const DoubleVector rhs,
DoubleVector result 
)
inlinevirtual

◆ resolve_transpose()

virtual void oomph::LinearSolver::resolve_transpose ( const DoubleVector rhs,
DoubleVector result 
)
inlinevirtual

Solver: Resolve the system defined by the last assembled jacobian and the rhs vector. Solution is returned in the vector result. (broken virtual)

Reimplemented in oomph::SuperLUSolver.

Definition at line 236 of file linear_solver.h.

◆ solve() [1/3]

virtual void oomph::LinearSolver::solve ( DoubleMatrixBase *const &  matrix_pt,
const DoubleVector rhs,
DoubleVector result 
)
inlinevirtual

◆ solve() [2/3]

virtual void oomph::LinearSolver::solve ( DoubleMatrixBase *const &  matrix_pt,
const Vector< double > &  rhs,
Vector< double > &  result 
)
inlinevirtual

◆ solve() [3/3]

virtual void oomph::LinearSolver::solve ( Problem *const &  problem_pt,
DoubleVector result 
)
pure virtual

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.

Implemented in oomph::TrilinosAztecOOSolver, oomph::HypreSolver, oomph::GMRESBlockPreconditioner, oomph::GMRESBlockPreconditioner, oomph::HelmholtzFGMRESMG< MATRIX >, oomph::HelmholtzGMRESMG< MATRIX >, oomph::ComplexGMRES< MATRIX >, oomph::ComplexDampedJacobi< MATRIX >, oomph::MumpsSolver, oomph::SuperLUSolver, oomph::FD_LU, oomph::DenseLU, oomph::AugmentedProblemGMRES, oomph::GMRES< MATRIX >, oomph::DampedJacobi< MATRIX >, oomph::GS< CRDoubleMatrix >, oomph::GS< MATRIX >, oomph::BiCGStab< MATRIX >, oomph::CG< MATRIX >, oomph::MGSolver< DIM >, oomph::HSL_MA42, oomph::BlockHopfLinearSolver, oomph::AugmentedBlockPitchForkLinearSolver, oomph::BlockPitchForkLinearSolver, and oomph::AugmentedBlockFoldLinearSolver.

Referenced by oomph::ProblemBasedShiftInvertOperator::apply(), oomph::AdjointProblemBasedShiftInvertOperator::apply(), oomph::Problem::calculate_continuation_derivatives(), oomph::FoldHandler::FoldHandler(), oomph::Problem::get_inverse_mass_matrix_times_residuals(), oomph::HopfHandler::HopfHandler(), oomph::Problem::newton_solve(), oomph::Problem::newton_solve_continuation(), oomph::SolidICProblem::set_newmark_initial_condition_consistently(), oomph::HSL_MA42::solve(), oomph::BiCGStab< MATRIX >::solve(), oomph::GS< MATRIX >::solve(), oomph::GS< CRDoubleMatrix >::solve(), oomph::GMRES< MATRIX >::solve(), oomph::AugmentedProblemGMRES::solve(), oomph::FD_LU::solve(), oomph::ComplexGMRES< MATRIX >::solve(), oomph::HelmholtzGMRESMG< MATRIX >::solve(), oomph::DoubleMatrixBase::solve(), oomph::AugmentedBlockFoldLinearSolver::solve(), oomph::BlockPitchForkLinearSolver::solve(), oomph::AugmentedBlockPitchForkLinearSolver::solve(), oomph::BlockHopfLinearSolver::solve(), and oomph::BlockHopfLinearSolver::solve_for_two_rhs().

◆ solve_transpose() [1/3]

virtual void oomph::LinearSolver::solve_transpose ( DoubleMatrixBase *const &  matrix_pt,
const DoubleVector rhs,
DoubleVector result 
)
inlinevirtual

Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system.

Reimplemented in oomph::SuperLUSolver.

Definition at line 200 of file linear_solver.h.

◆ solve_transpose() [2/3]

virtual void oomph::LinearSolver::solve_transpose ( DoubleMatrixBase *const &  matrix_pt,
const Vector< double > &  rhs,
Vector< double > &  result 
)
inlinevirtual

Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system.

Definition at line 212 of file linear_solver.h.

◆ solve_transpose() [3/3]

virtual void oomph::LinearSolver::solve_transpose ( Problem *const &  problem_pt,
DoubleVector result 
)
inlinevirtual

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

Reimplemented in oomph::SuperLUSolver.

Definition at line 181 of file linear_solver.h.

Member Data Documentation

◆ Compute_gradient

bool oomph::LinearSolver::Compute_gradient
protected

flag that indicates whether the gradient required for the globally convergent Newton method should be computed or not

Definition at line 81 of file linear_solver.h.

Referenced by disable_computation_of_gradient(), oomph::GMRES< MATRIX >::enable_computation_of_gradient(), oomph::SuperLUSolver::enable_computation_of_gradient(), oomph::SuperLUSolver::solve(), and oomph::SuperLUSolver::solve_transpose().

◆ Doc_time

bool oomph::LinearSolver::Doc_time
protected

◆ Enable_resolve

bool oomph::LinearSolver::Enable_resolve
protected

◆ Gradient_for_glob_conv_newton_solve

DoubleVector oomph::LinearSolver::Gradient_for_glob_conv_newton_solve
protected

DoubleVector storing the gradient for the globally convergent Newton method.

Definition at line 88 of file linear_solver.h.

Referenced by get_gradient(), reset_gradient(), oomph::SuperLUSolver::solve(), and oomph::SuperLUSolver::solve_transpose().

◆ Gradient_has_been_computed

bool oomph::LinearSolver::Gradient_has_been_computed
protected

flag that indicates whether the gradient was computed or not

Definition at line 84 of file linear_solver.h.

Referenced by get_gradient(), oomph::SuperLUSolver::solve(), and oomph::SuperLUSolver::solve_transpose().


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