Dense LU decomposition-based solve of full assembled linear system. VERY inefficient but useful to illustrate the principle. Only suitable for use with Serial matrices and vectors. This solver will only work with non-distributed matrices and vectors (note: DenseDoubleMatrix is not distributable) More...
#include <linear_solver.h>
Public Member Functions | |
DenseLU () | |
Constructor, initialise storage. | |
DenseLU (const DenseLU &dummy)=delete | |
Broken copy constructor. | |
void | operator= (const DenseLU &)=delete |
Broken assignment operator. | |
~DenseLU () | |
Destructor, clean up the stored LU factors. | |
void | solve (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. | |
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. | |
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. | |
double | jacobian_setup_time () const |
returns the time taken to assemble the jacobian matrix and residual vector | |
virtual double | linear_solver_solution_time () const |
return the time taken to solve the linear system (needs to be overloaded for each linear 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_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 | 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 Member Functions | |
void | factorise (DoubleMatrixBase *const &matrix_pt) |
Perform the LU decomposition of the matrix. | |
void | backsub (const DoubleVector &rhs, DoubleVector &result) |
Do the backsubstitution step to solve the system LU result = rhs. | |
void | backsub (const Vector< double > &rhs, Vector< double > &result) |
perform back substitution using Vector<double> | |
void | clean_up_memory () |
Clean up the stored LU factors. | |
![]() | |
void | clear_distribution () |
clear the distribution of this distributable linear algebra object | |
Protected Attributes | |
double | Jacobian_setup_time |
Jacobian setup time. | |
double | Solution_time |
Solution time. | |
int | Sign_of_determinant_of_matrix |
Sign of the determinant of the matrix (obtained during the LU decomposition) | |
![]() | |
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. | |
Private Attributes | |
long * | Index |
Pointer to storage for the index of permutations in the LU solve. | |
double * | LU_factors |
Pointer to storage for the LU decomposition. | |
Friends | |
class | DenseDoubleMatrix |
The DenseDoubleMatrix class is a friend. | |
Dense LU decomposition-based solve of full assembled linear system. VERY inefficient but useful to illustrate the principle. Only suitable for use with Serial matrices and vectors. This solver will only work with non-distributed matrices and vectors (note: DenseDoubleMatrix is not distributable)
Definition at line 335 of file linear_solver.h.
|
inline |
Constructor, initialise storage.
Definition at line 342 of file linear_solver.h.
References oomph::LinearSolver::Doc_time.
|
inline |
Destructor, clean up the stored LU factors.
Definition at line 360 of file linear_solver.h.
References clean_up_memory().
|
protected |
Do the backsubstitution step to solve the system LU result = rhs.
Do the backsubstitution for the DenseLU solver. WARNING: this class does not perform any PARANOID checks on the vectors - these are all performed in the solve(...) method.
Definition at line 324 of file linear_solver.cc.
References i, Index, and LU_factors.
perform back substitution using Vector<double>
Do the backsubstitution for the DenseLU solver. WARNING: this class does not perform any PARANOID checks on the vectors - these are all performed in the solve(...) method. So, if you call backsub directly, you have been warned...
Definition at line 376 of file linear_solver.cc.
References i, Index, LU_factors, and oomph::FiniteElement::size().
|
protectedvirtual |
Clean up the stored LU factors.
Delete the storage that has been allocated for the LU factors, if the matrix data is not itself being overwritten.
Reimplemented from oomph::LinearSolver.
Definition at line 110 of file linear_solver.cc.
References oomph::DistributableLinearAlgebraObject::clear_distribution(), Index, and LU_factors.
Referenced by factorise(), solve(), solve(), and ~DenseLU().
|
protected |
Perform the LU decomposition of the matrix.
LU decompose the matrix. WARNING: this class does not perform any PARANOID checks on the vectors - these are all performed in the solve(...) method.
Definition at line 135 of file linear_solver.cc.
References clean_up_memory(), i, Index, LU_factors, oomph::DoubleMatrixBase::nrow(), and Sign_of_determinant_of_matrix.
|
inlinevirtual |
returns the time taken to assemble the jacobian matrix and residual vector
Reimplemented from oomph::LinearSolver.
Definition at line 384 of file linear_solver.h.
References Jacobian_setup_time.
return the time taken to solve the linear system (needs to be overloaded for each linear solver)
Reimplemented from oomph::LinearSolver.
Definition at line 391 of file linear_solver.h.
References Solution_time.
|
virtual |
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system.
Reimplemented from oomph::LinearSolver.
Reimplemented in oomph::FD_LU.
Definition at line 423 of file linear_solver.cc.
References backsub(), oomph::DistributableLinearAlgebraObject::build_distribution(), clean_up_memory(), oomph::TimingHelpers::convert_secs_to_formatted_string(), oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::LinearSolver::Doc_time, oomph::LinearSolver::Enable_resolve, factorise(), oomph::DoubleMatrixBase::ncol(), oomph::DoubleMatrixBase::nrow(), oomph::oomph_info, Solution_time, and oomph::TimingHelpers::timer().
|
virtual |
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system.
Reimplemented from oomph::LinearSolver.
Reimplemented in oomph::FD_LU.
Definition at line 545 of file linear_solver.cc.
References backsub(), clean_up_memory(), oomph::TimingHelpers::convert_secs_to_formatted_string(), oomph::LinearSolver::Doc_time, oomph::LinearSolver::Enable_resolve, factorise(), oomph::oomph_info, and Solution_time.
|
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.
Implements oomph::LinearSolver.
Reimplemented in oomph::FD_LU.
Definition at line 55 of file linear_solver.cc.
References oomph::TimingHelpers::convert_secs_to_formatted_string(), oomph::LinearSolver::Doc_time, oomph::Problem::get_jacobian(), Jacobian_setup_time, oomph::Problem::ndof(), oomph::oomph_info, Sign_of_determinant_of_matrix, oomph::Problem::sign_of_jacobian(), solve(), and oomph::TimingHelpers::timer().
Referenced by oomph::FD_LU::solve(), and solve().
|
friend |
The DenseDoubleMatrix class is a friend.
Definition at line 338 of file linear_solver.h.
|
private |
Pointer to storage for the index of permutations in the LU solve.
Definition at line 421 of file linear_solver.h.
Referenced by backsub(), backsub(), clean_up_memory(), and factorise().
|
protected |
Jacobian setup time.
Definition at line 410 of file linear_solver.h.
Referenced by jacobian_setup_time(), solve(), and oomph::FD_LU::solve().
|
private |
Pointer to storage for the LU decomposition.
Definition at line 424 of file linear_solver.h.
Referenced by backsub(), backsub(), clean_up_memory(), and factorise().
|
protected |
Sign of the determinant of the matrix (obtained during the LU decomposition)
Definition at line 417 of file linear_solver.h.
Referenced by factorise(), solve(), and oomph::FD_LU::solve().
|
protected |
Solution time.
Definition at line 413 of file linear_solver.h.
Referenced by linear_solver_solution_time(), solve(), and solve().