Public Member Functions | Private Member Functions | Private Attributes | List of all members
oomph::DampedJacobi< MATRIX > Class Template Reference

#include <iterative_linear_solver.h>

+ Inheritance diagram for oomph::DampedJacobi< MATRIX >:

Public Member Functions

 DampedJacobi (const double &omega=2.0/3.0)
 Empty constructor. More...
 
 ~DampedJacobi ()
 Empty destructor. More...
 
 DampedJacobi (const DampedJacobi &)
 Broken copy constructor. More...
 
void operator= (const DampedJacobi &)
 Broken assignment operator. More...
 
void clean_up_memory ()
 Cleanup data that's stored for resolve (if any has been stored) More...
 
void smoother_setup (DoubleMatrixBase *matrix_pt)
 Setup: Pass pointer to the matrix and store in cast form. More...
 
void extract_diagonal_entries (DoubleMatrixBase *matrix_pt)
 Function to extract the diagonal entries from the matrix. More...
 
void smoother_solve (const DoubleVector &rhs, DoubleVector &solution)
 The smoother_solve function performs fixed number of iterations on the system A*result=rhs. The number of (smoothing) iterations is the same as the max. number of iterations in the underlying IterativeLinearSolver class. More...
 
void solve (Problem *const &problem_pt, DoubleVector &result)
 Use damped Jacobi iteration as an IterativeLinearSolver: This obtains the Jacobian matrix J and the residual vector r (needed for the Newton method) from the problem's get_jacobian function and returns the result of Jx=r. More...
 
void solve (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &solution)
 Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system. More...
 
void resolve (const DoubleVector &rhs, DoubleVector &result)
 Re-solve the system defined by the last assembled Jacobian and the rhs vector specified here. Solution is returned in the vector result. More...
 
unsigned iterations () const
 Number of iterations taken. More...
 
- Public Member Functions inherited from oomph::Smoother
 Smoother ()
 Empty constructor. More...
 
virtual ~Smoother ()
 Virtual empty destructor. More...
 
template<typename MATRIX >
void check_validity_of_solve_helper_inputs (MATRIX *const &matrix_pt, const DoubleVector &rhs, DoubleVector &solution, const double &n_dof)
 Self-test to check that all the dimensions of the inputs to solve helper are consistent and everything that needs to be built, is. More...
 
- Public Member Functions inherited from oomph::IterativeLinearSolver
 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...
 
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 (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 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...
 

Private Member Functions

void solve_helper (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &solution)
 This is where the actual work is done – different implementations for different matrix types. More...
 

Private Attributes

MATRIX * Matrix_pt
 Pointer to the matrix. More...
 
Vector< double > Matrix_diagonal
 Vector containing the diagonal entries of A. More...
 
bool Resolving
 Boolean flag to indicate if the solve is done in re-solve mode, bypassing setup of matrix and preconditioner. More...
 
bool Matrix_can_be_deleted
 Boolean flag to indicate if the matrix pointed to be Matrix_pt can be deleted. More...
 
unsigned Iterations
 Number of iterations taken. More...
 
double Omega
 Damping factor. More...
 

Additional Inherited Members

- Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 clear the distribution of this distributable linear algebra object More...
 
- Protected Attributes inherited from oomph::Smoother
bool Use_as_smoother
 When a derived class object is being used as a smoother in the MG solver (or elsewhere) the residual norm does not need to be calculated because we're simply performing a fixed number of (smoothing) iterations. This boolean is used as a flag to indicate that the IterativeLinearSolver (which this class is by inheritance) is supposed to act in this way. More...
 
- Protected Attributes inherited from oomph::IterativeLinearSolver
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 inherited from oomph::IterativeLinearSolver
static IdentityPreconditioner Default_preconditioner
 Default preconditioner: The base class for preconditioners is a fully functional (if trivial!) preconditioner. More...
 

Detailed Description

template<typename MATRIX>
class oomph::DampedJacobi< MATRIX >

Damped Jacobi "solver" templated by matrix type. The "solver" exists in many different incarnations: It's an IterativeLinearSolver, and a Smoother, all of which use the same basic iteration.

Definition at line 1012 of file iterative_linear_solver.h.

Constructor & Destructor Documentation

template<typename MATRIX >
oomph::DampedJacobi< MATRIX >::DampedJacobi ( const double &  omega = 2.0/3.0)
inline

Empty constructor.

Definition at line 1018 of file iterative_linear_solver.h.

References oomph::DampedJacobi< MATRIX >::Omega.

template<typename MATRIX >
oomph::DampedJacobi< MATRIX >::~DampedJacobi ( )
inline

Empty destructor.

Definition at line 1025 of file iterative_linear_solver.h.

References oomph::DampedJacobi< MATRIX >::clean_up_memory().

template<typename MATRIX >
oomph::DampedJacobi< MATRIX >::DampedJacobi ( const DampedJacobi< MATRIX > &  )
inline

Broken copy constructor.

Definition at line 1032 of file iterative_linear_solver.h.

References oomph::BrokenCopy::broken_copy().

Member Function Documentation

template<typename MATRIX >
void oomph::DampedJacobi< MATRIX >::clean_up_memory ( )
inlinevirtual

Cleanup data that's stored for resolve (if any has been stored)

Reimplemented from oomph::LinearSolver.

Definition at line 1044 of file iterative_linear_solver.h.

References oomph::DampedJacobi< MATRIX >::Matrix_can_be_deleted, and oomph::DampedJacobi< MATRIX >::Matrix_pt.

Referenced by oomph::DampedJacobi< MATRIX >::~DampedJacobi().

template<typename MATRIX >
void oomph::DampedJacobi< MATRIX >::extract_diagonal_entries ( DoubleMatrixBase matrix_pt)
inline
template<typename MATRIX >
unsigned oomph::DampedJacobi< MATRIX >::iterations ( ) const
inlinevirtual

Number of iterations taken.

Implements oomph::IterativeLinearSolver.

Definition at line 1201 of file iterative_linear_solver.h.

References oomph::DampedJacobi< MATRIX >::Iterations.

template<typename MATRIX >
void oomph::DampedJacobi< MATRIX >::operator= ( const DampedJacobi< MATRIX > &  )
inline

Broken assignment operator.

Definition at line 1038 of file iterative_linear_solver.h.

References oomph::BrokenCopy::broken_assign().

template<typename MATRIX >
void oomph::DampedJacobi< MATRIX >::resolve ( const DoubleVector rhs,
DoubleVector result 
)
inlinevirtual

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.

Definition at line 1179 of file iterative_linear_solver.h.

References oomph::DampedJacobi< MATRIX >::Matrix_pt, oomph::DampedJacobi< MATRIX >::Resolving, and oomph::DampedJacobi< MATRIX >::solve().

template<typename MATRIX >
void oomph::DampedJacobi< MATRIX >::smoother_setup ( DoubleMatrixBase matrix_pt)
inlinevirtual
template<typename MATRIX >
void oomph::DampedJacobi< MATRIX >::smoother_solve ( const DoubleVector rhs,
DoubleVector solution 
)
inlinevirtual

The smoother_solve function performs fixed number of iterations on the system A*result=rhs. The number of (smoothing) iterations is the same as the max. number of iterations in the underlying IterativeLinearSolver class.

Implements oomph::Smoother.

Definition at line 1132 of file iterative_linear_solver.h.

References oomph::DampedJacobi< MATRIX >::Matrix_pt, oomph::DampedJacobi< MATRIX >::solve_helper(), and oomph::Smoother::Use_as_smoother.

template<typename MATRIX >
void oomph::DampedJacobi< MATRIX >::solve ( Problem *const &  problem_pt,
DoubleVector result 
)
virtual

Use damped Jacobi iteration as an IterativeLinearSolver: This obtains the Jacobian matrix J and the residual vector r (needed for the Newton method) from the problem's get_jacobian function and returns the result of Jx=r.

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.

Definition at line 1886 of file iterative_linear_solver.cc.

References oomph::Problem::communicator_pt(), oomph::Problem::get_jacobian(), oomph::Problem::ndof(), oomph::oomph_info, and oomph::TimingHelpers::timer().

Referenced by oomph::DampedJacobi< MATRIX >::resolve().

template<typename MATRIX >
void oomph::DampedJacobi< MATRIX >::solve ( DoubleMatrixBase *const &  matrix_pt,
const DoubleVector rhs,
DoubleVector solution 
)
inlinevirtual
template<typename MATRIX >
void oomph::DampedJacobi< MATRIX >::solve_helper ( DoubleMatrixBase *const &  matrix_pt,
const DoubleVector rhs,
DoubleVector solution 
)
private

This is where the actual work is done – different implementations for different matrix types.

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

Definition at line 1951 of file iterative_linear_solver.cc.

References oomph::DoubleVector::build(), i, oomph::BlackBoxFDNewtonSolver::Max_iter, oomph::DoubleMatrixBase::multiply(), oomph::DoubleVector::norm(), oomph::DistributableLinearAlgebraObject::nrow(), oomph::oomph_info, oomph::DoubleMatrixBase::residual(), oomph::Global_string_for_annotation::string(), and oomph::TimingHelpers::timer().

Referenced by oomph::DampedJacobi< MATRIX >::smoother_solve(), and oomph::DampedJacobi< MATRIX >::solve().

Member Data Documentation

template<typename MATRIX >
unsigned oomph::DampedJacobi< MATRIX >::Iterations
private

Number of iterations taken.

Definition at line 1230 of file iterative_linear_solver.h.

Referenced by oomph::DampedJacobi< MATRIX >::iterations().

template<typename MATRIX >
bool oomph::DampedJacobi< MATRIX >::Matrix_can_be_deleted
private

Boolean flag to indicate if the matrix pointed to be Matrix_pt can be deleted.

Definition at line 1227 of file iterative_linear_solver.h.

Referenced by oomph::DampedJacobi< MATRIX >::clean_up_memory(), oomph::DampedJacobi< MATRIX >::smoother_setup(), and oomph::DampedJacobi< MATRIX >::solve().

template<typename MATRIX >
Vector<double> oomph::DampedJacobi< MATRIX >::Matrix_diagonal
private

Vector containing the diagonal entries of A.

Definition at line 1219 of file iterative_linear_solver.h.

Referenced by oomph::DampedJacobi< MATRIX >::extract_diagonal_entries().

template<typename MATRIX >
MATRIX* oomph::DampedJacobi< MATRIX >::Matrix_pt
private
template<typename MATRIX >
double oomph::DampedJacobi< MATRIX >::Omega
private

Damping factor.

Definition at line 1233 of file iterative_linear_solver.h.

Referenced by oomph::DampedJacobi< MATRIX >::DampedJacobi().

template<typename MATRIX >
bool oomph::DampedJacobi< MATRIX >::Resolving
private

Boolean flag to indicate if the solve is done in re-solve mode, bypassing setup of matrix and preconditioner.

Definition at line 1223 of file iterative_linear_solver.h.

Referenced by oomph::DampedJacobi< MATRIX >::resolve(), and oomph::DampedJacobi< MATRIX >::solve().


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