oomph::FD_LU Class Reference

#include <linear_solver.h>

+ Inheritance diagram for oomph::FD_LU:

Public Member Functions

 FD_LU ()
 Constructor: empty. More...
 
 FD_LU (const FD_LU &dummy)=delete
 Broken copy constructor. More...
 
void operator= (const FD_LU &)=delete
 Broken assignment operator. More...
 
void solve (Problem *const &problem_pt, DoubleVector &result)
 
void solve (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &result)
 
void solve (DoubleMatrixBase *const &matrix_pt, const Vector< double > &rhs, Vector< double > &result)
 
- Public Member Functions inherited from oomph::DenseLU
 DenseLU ()
 Constructor, initialise storage. More...
 
 DenseLU (const DenseLU &dummy)=delete
 Broken copy constructor. More...
 
void operator= (const DenseLU &)=delete
 Broken assignment operator. More...
 
 ~DenseLU ()
 Destructor, clean up the stored LU factors. More...
 
double jacobian_setup_time () const
 
virtual double linear_solver_solution_time () const
 
- Public Member Functions inherited from oomph::LinearSolver
 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 disable_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 (const DoubleVector &rhs, DoubleVector &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...
 
- 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
 
void build_distribution (const LinearAlgebraDistribution *const dist_pt)
 
void build_distribution (const LinearAlgebraDistribution &dist)
 

Additional Inherited Members

- Protected Member Functions inherited from oomph::DenseLU
void factorise (DoubleMatrixBase *const &matrix_pt)
 Perform the LU decomposition of the matrix. More...
 
void backsub (const DoubleVector &rhs, DoubleVector &result)
 Do the backsubstitution step to solve the system LU result = rhs. More...
 
void backsub (const Vector< double > &rhs, Vector< double > &result)
 perform back substitution using Vector<double> More...
 
void clean_up_memory ()
 Clean up the stored LU factors. More...
 
- Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 
- Protected Attributes inherited from oomph::DenseLU
double Jacobian_setup_time
 Jacobian setup time. More...
 
double Solution_time
 Solution time. More...
 
int Sign_of_determinant_of_matrix
 
- Protected Attributes inherited from oomph::LinearSolver
bool Enable_resolve
 
bool Doc_time
 Boolean flag that indicates whether the time taken. More...
 
bool Compute_gradient
 
bool Gradient_has_been_computed
 flag that indicates whether the gradient was computed or not More...
 
DoubleVector Gradient_for_glob_conv_newton_solve
 

Detailed Description

Dense LU decomposition-based solve of linear system assembled via finite differencing of the residuals Vector. Even more inefficient than DenseLU but excellent sanity check!

Constructor & Destructor Documentation

◆ FD_LU() [1/2]

oomph::FD_LU::FD_LU ( )
inline

Constructor: empty.

435 : DenseLU() {}
DenseLU()
Constructor, initialise storage.
Definition: linear_solver.h:340

◆ FD_LU() [2/2]

oomph::FD_LU::FD_LU ( const FD_LU dummy)
delete

Broken copy constructor.

Member Function Documentation

◆ operator=()

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

Broken assignment operator.

◆ solve() [1/3]

void oomph::FD_LU::solve ( 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 from oomph::DenseLU.

453  {
454  DenseLU::solve(matrix_pt, rhs, result);
455  }
void solve(Problem *const &problem_pt, DoubleVector &result)
Definition: linear_solver.cc:51

References oomph::DenseLU::solve().

◆ solve() [2/3]

void oomph::FD_LU::solve ( 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 Call the broken base-class version. If you want this, please implement it

Reimplemented from oomph::DenseLU.

464  {
465  LinearSolver::solve(matrix_pt, rhs, result);
466  }
virtual void solve(Problem *const &problem_pt, DoubleVector &result)=0

References oomph::LinearSolver::solve().

◆ solve() [3/3]

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

Solver: Takes pointer to problem and returns the results Vector which contains the solution of the linear system defined by the problem's residual Vector (Jacobian computed by FD approx.)

Solver: Takes pointer to problem and returns the results Vector which contains the solution of the linear system defined by the problem's residual Vector. (Jacobian assembled by FD).

Reimplemented from oomph::DenseLU.

576  {
577  // Initialise timer
578  clock_t t_start = clock();
579 
580 #ifdef PARANOID
581  // if the result vector is setup then check it is not distributed and has
582  // the same communicator as the rhs vector
583  if (result.built())
584  {
585  if (result.distributed())
586  {
587  std::ostringstream error_message_stream;
588  error_message_stream << "The result vector must not be distributed";
589  throw OomphLibError(error_message_stream.str(),
592  }
593  }
594 #endif
595 
596  // Find # of degrees of freedom
597  unsigned long n_dof = problem_pt->ndof();
598 
599  // Allocate storage for the residuals vector and the jacobian matrix
600  DoubleVector residuals;
601  DenseDoubleMatrix jacobian(n_dof);
602 
603  {
604  // initialise timer
605  clock_t t_start = clock();
606 
607  // Get the full jacobian by finite differencing) VERY INEFFICIENT!
608  problem_pt->get_fd_jacobian(residuals, jacobian);
609 
610  // compute jacobian setup time
611  clock_t t_end = clock();
612  Jacobian_setup_time = double(t_end - t_start) / CLOCKS_PER_SEC;
613 
614  // Report the time
615  if (Doc_time)
616  {
617  oomph_info << std::endl
618  << "CPU for setup of Dense Jacobian: "
621  << std::endl
622  << std::endl;
623  }
624  }
625 
626  // Solve by dense LU decomposition (not efficient)
627  solve(&jacobian, residuals, result);
628 
629  // Set the sign of the determinant of the jacobian
630  problem_pt->sign_of_jacobian() = Sign_of_determinant_of_matrix;
631 
632  // Finalise/doc timings
633  clock_t t_end = clock();
634  double total_time = double(t_end - t_start) / CLOCKS_PER_SEC;
635  if (Doc_time)
636  {
637  oomph_info << "CPU for FD DenseLU LinearSolver: "
639  << std::endl
640  << std::endl;
641  }
642  }
std::vector< double > DoubleVector
loads clump configuration
Definition: ClumpInput.h:26
double Jacobian_setup_time
Jacobian setup time.
Definition: linear_solver.h:408
friend class DenseDoubleMatrix
The DenseDoubleMatrix class is a friend.
Definition: linear_solver.h:336
int Sign_of_determinant_of_matrix
Definition: linear_solver.h:415
void solve(Problem *const &problem_pt, DoubleVector &result)
Definition: linear_solver.cc:575
bool Doc_time
Boolean flag that indicates whether the time taken.
Definition: linear_solver.h:77
std::string convert_secs_to_formatted_string(const double &time_in_sec)
Definition: oomph_utilities.cc:1316
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::DoubleVector::built(), oomph::TimingHelpers::convert_secs_to_formatted_string(), oomph::DistributableLinearAlgebraObject::distributed(), oomph::LinearSolver::Doc_time, oomph::Problem::get_fd_jacobian(), oomph::DenseLU::Jacobian_setup_time, oomph::Problem::ndof(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::oomph_info, oomph::DenseLU::Sign_of_determinant_of_matrix, and oomph::Problem::sign_of_jacobian().


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