![]() |
|
The GMRES method. More...
#include <iterative_linear_solver.h>
Public Member Functions | |
AugmentedProblemGMRES (DoubleVector *b_pt, DoubleVector *c_pt, double *x_pt, double *rhs_pt) | |
Constructor. More... | |
virtual | ~AugmentedProblemGMRES () |
Destructor: Clean up storage. More... | |
AugmentedProblemGMRES (const AugmentedProblemGMRES &)=delete | |
Broken copy constructor. More... | |
void | operator= (const AugmentedProblemGMRES &)=delete |
Broken assignment operator. More... | |
void | disable_resolve () |
Overload disable resolve so that it cleans up memory too. More... | |
void | solve (Problem *const &problem_pt, DoubleVector &result) |
void | solve (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &solution) |
void | solve (DoubleMatrixBase *const &matrix_pt, const Vector< double > &rhs, Vector< double > &result) |
void | resolve (const DoubleVector &rhs, DoubleVector &result) |
unsigned | iterations () const |
Number of iterations taken. More... | |
bool | iteration_restart () const |
access function indicating whether restarted GMRES is used More... | |
void | enable_iteration_restart (const unsigned &restart) |
void | disable_iteration_restart () |
Switches off iteration restart. More... | |
void | set_preconditioner_LHS () |
Set left preconditioning (the default) More... | |
void | set_preconditioner_RHS () |
Enable right preconditioning. More... | |
![]() | |
IterativeLinearSolver () | |
IterativeLinearSolver (const IterativeLinearSolver &)=delete | |
Broken copy constructor. More... | |
void | operator= (const IterativeLinearSolver &)=delete |
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... | |
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="") |
void | close_convergence_history_file_stream () |
Close convergence history output stream. More... | |
double | jacobian_setup_time () const |
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 () |
![]() | |
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 () |
virtual void | solve_transpose (Problem *const &problem_pt, DoubleVector &result) |
virtual void | solve_transpose (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &result) |
virtual void | solve_transpose (DoubleMatrixBase *const &matrix_pt, const Vector< double > &rhs, Vector< double > &result) |
virtual void | resolve_transpose (const DoubleVector &rhs, DoubleVector &result) |
virtual void | enable_computation_of_gradient () |
void | disable_computation_of_gradient () |
void | reset_gradient () |
void | get_gradient (DoubleVector &gradient) |
function to access the gradient, provided it has been computed More... | |
![]() | |
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... | |
LinearAlgebraDistribution * | distribution_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) |
Private Member Functions | |
void | clean_up_memory () |
Cleanup data that's stored for resolve (if any has been stored) More... | |
void | augmented_matrix_multiply (CRDoubleMatrix *matrix_pt, const DoubleVector &x, DoubleVector &soln) |
Multiply the vector x by the augmented system matrix. More... | |
void | apply_schur_complement_preconditioner (const DoubleVector &rhs, DoubleVector &soln) |
void | solve_helper (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &solution) |
General interface to solve function. More... | |
void | update (const unsigned &k, const Vector< Vector< double >> &H, const Vector< double > &s, const Vector< DoubleVector > &v, DoubleVector &x) |
void | generate_plane_rotation (double &dx, double &dy, double &cs, double &sn) |
void | apply_plane_rotation (double &dx, double &dy, double &cs, double &sn) |
Private Attributes | |
unsigned | Iterations |
Number of iterations taken. More... | |
unsigned | Restart |
bool | Iteration_restart |
boolean indicating if iteration restarting is used More... | |
CRDoubleMatrix * | Matrix_pt |
Pointer to matrix. More... | |
DoubleVector * | B_pt |
Pointer to the column vector in the bordered system. More... | |
DoubleVector * | C_pt |
Pointer to the row vector in the bordered system. More... | |
double * | X_pt |
Pointer to the last entry of the LHS vector in the bordered system. More... | |
double * | Rhs_pt |
Pointer to the last entry of the RHS vector in the bordered system. More... | |
double | Schur_complement_scalar |
The scalar component of the Schur complement preconditioner. More... | |
bool | Resolving |
bool | Matrix_can_be_deleted |
bool | Preconditioner_LHS |
The GMRES method.
//////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
|
inline |
Constructor.
References Iteration_restart, and Preconditioner_LHS.
|
inlinevirtual |
Destructor: Clean up storage.
References clean_up_memory().
|
delete |
Broken copy constructor.
|
inlineprivate |
Helper function: Apply plane rotation. This is done using the update:
\[ \begin{bmatrix} dx \newline dy \end{bmatrix} \leftarrow \begin{bmatrix} \cos\theta & \sin\theta \newline -\sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} dx \newline dy \end{bmatrix}. \]
Referenced by solve_helper().
|
inlineprivate |
Apply the block-diagonal Schur complement preconditioner to compute the LHS which has size N+1 (the augmented system size)
References oomph::DistributableLinearAlgebraObject::distribution_pt(), i, oomph::LinearAlgebraDistribution::nrow(), oomph::IterativeLinearSolver::preconditioner_pt(), oomph::Preconditioner::preconditioner_solve(), and Schur_complement_scalar.
Referenced by solve_helper(), and update().
|
inlineprivate |
Multiply the vector x by the augmented system matrix.
References C_pt, oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::DoubleVector::dot(), i, oomph::CRDoubleMatrix::multiply(), oomph::CRDoubleMatrix::nrow(), plotDoE::x, and y.
Referenced by solve_helper().
|
inlineprivatevirtual |
Cleanup data that's stored for resolve (if any has been stored)
Reimplemented from oomph::LinearSolver.
References Matrix_can_be_deleted, and Matrix_pt.
Referenced by disable_resolve(), solve(), and ~AugmentedProblemGMRES().
|
inline |
Switches off iteration restart.
References Iteration_restart.
|
inlinevirtual |
Overload disable resolve so that it cleans up memory too.
Reimplemented from oomph::LinearSolver.
References clean_up_memory(), and oomph::LinearSolver::disable_resolve().
|
inline |
switches on iteration restarting and takes as an argument the number of iterations after which the construction of the orthogonalisation basis vectors should be restarted
References Iteration_restart.
|
inlineprivate |
Helper function: Generate a plane rotation. This is done by finding the values of \( \cos(\theta) \) (i.e. cs) and \sin(\theta) (i.e. sn) such that:
\[ \begin{bmatrix} \cos\theta & \sin\theta \newline -\sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} dx \newline dy \end{bmatrix} = \begin{bmatrix} r \newline 0 \end{bmatrix}, \]
where \( r=\sqrt{pow(dx,2)+pow(dy,2)} \). The values of a and b are given by:
\[ \cos\theta&=\dfrac{dx}{\sqrt{pow(dx,2)+pow(dy,2)}}, \]
and
\[ \sin\theta&=\dfrac{dy}{\sqrt{pow(dx,2)+pow(dy,2)}}. \]
Taken from: Saad Y."Iterative methods for sparse linear systems", p.192
References boost::multiprecision::fabs(), and sqrt().
Referenced by solve_helper().
|
inline |
access function indicating whether restarted GMRES is used
References Iteration_restart.
|
inlinevirtual |
|
delete |
Broken assignment operator.
|
virtual |
Re-solve the system defined by the last assembled Jacobian and the rhs vector specified here. Solution is returned in the vector result.
\Short Re-solve the system defined by the last assembled Jacobian and the rhs vector specified here. Solution is returned in the vector result.
Reimplemented from oomph::LinearSolver.
References Matrix_pt, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, Resolving, and solve().
|
inline |
Set left preconditioning (the default)
References Preconditioner_LHS.
|
inline |
Enable right preconditioning.
References Preconditioner_LHS.
|
inlinevirtual |
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system.
Reimplemented from oomph::LinearSolver.
References oomph::DistributableLinearAlgebraObject::build_distribution(), oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::LinearSolver::Enable_resolve, Matrix_can_be_deleted, Matrix_pt, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, Resolving, BiharmonicTestFunctions1::solution(), and solve_helper().
|
inlinevirtual |
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system Call the broken base-class version. If you want this, please implement it
Reimplemented from oomph::LinearSolver.
References oomph::LinearSolver::solve().
|
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.
//////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// 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.
Implements oomph::LinearSolver.
References oomph::DoubleVector::build(), oomph::DistributableLinearAlgebraObject::build_distribution(), oomph::DoubleVector::built(), clean_up_memory(), oomph::Problem::communicator_pt(), oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::LinearSolver::Doc_time, oomph::LinearSolver::Enable_resolve, f(), oomph::Problem::get_jacobian(), oomph::IterativeLinearSolver::Jacobian_setup_time, Matrix_can_be_deleted, Matrix_pt, oomph::Problem::ndof(), oomph::oomph_info, oomph::DoubleVector::redistribute(), Resolving, Schur_complement_scalar, solve_helper(), and oomph::TimingHelpers::timer().
Referenced by resolve().
|
private |
General interface to solve function.
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system. based on the algorithm presented in Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods, Barrett, Berry et al, SIAM, 2006 and the implementation in the IML++ library : http://math.nist.gov/iml++/
References apply_plane_rotation(), apply_schur_complement_preconditioner(), augmented_matrix_multiply(), B_pt, beta, oomph::DoubleVector::build(), oomph::DoubleVector::built(), C_pt, oomph::LinearAlgebraDistribution::communicator_pt(), oomph::LinearAlgebraDistribution::distributed(), oomph::DistributableLinearAlgebraObject::distributed(), oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::IterativeLinearSolver::Doc_convergence_history, oomph::LinearSolver::Doc_time, oomph::DoubleVector::dot(), boost::multiprecision::fabs(), generate_plane_rotation(), H, i, oomph::DoubleVector::initialise(), isnan, Iteration_restart, Iterations, k, oomph::IterativeLinearSolver::Max_iter, oomph::DoubleVector::norm(), oomph::DistributableLinearAlgebraObject::nrow(), oomph::DoubleMatrixBase::nrow(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::oomph_info, oomph::IterativeLinearSolver::Output_file_stream, Preconditioner_LHS, oomph::IterativeLinearSolver::preconditioner_pt(), oomph::IterativeLinearSolver::Preconditioner_setup_time, oomph::Preconditioner::preconditioner_solve(), UniformPSDSelfTest::r, Resolving, s, Schur_complement_scalar, oomph::Preconditioner::setup(), oomph::IterativeLinearSolver::Setup_preconditioner_before_solve, BiharmonicTestFunctions1::solution(), oomph::IterativeLinearSolver::Solution_time, oomph::Global_string_for_annotation::string(), oomph::IterativeLinearSolver::Throw_error_after_max_iter, oomph::TimingHelpers::timer(), oomph::IterativeLinearSolver::Tolerance, update(), v, oomph::DoubleVector::values_pt(), and w.
Referenced by solve().
|
inlineprivate |
Helper function to update the result vector using the result, x=x_0+V_m*y
References apply_schur_complement_preconditioner(), H, i, j, k, Preconditioner_LHS, s, v, oomph::DoubleVector::values_pt(), plotDoE::x, and y.
Referenced by smc.smc::recursiveBayesian(), and solve_helper().
|
private |
Pointer to the column vector in the bordered system.
Referenced by solve_helper().
|
private |
Pointer to the row vector in the bordered system.
Referenced by augmented_matrix_multiply(), and solve_helper().
|
private |
boolean indicating if iteration restarting is used
Referenced by AugmentedProblemGMRES(), disable_iteration_restart(), enable_iteration_restart(), iteration_restart(), and solve_helper().
|
private |
Number of iterations taken.
Referenced by iterations(), and solve_helper().
|
private |
Boolean flag to indicate if the matrix pointed to be Matrix_pt can be deleted.
Referenced by clean_up_memory(), and solve().
|
private |
Pointer to matrix.
Referenced by clean_up_memory(), resolve(), and solve().
|
private |
boolean indicating use of left hand preconditioning (if true) or right hand preconditioning (if false)
Referenced by AugmentedProblemGMRES(), set_preconditioner_LHS(), set_preconditioner_RHS(), solve_helper(), and update().
|
private |
Boolean flag to indicate if the solve is done in re-solve mode, bypassing setup of matrix and preconditioner
Referenced by resolve(), solve(), and solve_helper().
|
private |
The number of iterations before the iteration proceedure is restarted if iteration restart is used
|
private |
Pointer to the last entry of the RHS vector in the bordered system.
|
private |
The scalar component of the Schur complement preconditioner.
Referenced by apply_schur_complement_preconditioner(), solve(), and solve_helper().
|
private |
Pointer to the last entry of the LHS vector in the bordered system.