34 #ifndef OOMPH_LINEAR_SOLVER_HEADER 35 #define OOMPH_LINEAR_SOLVER_HEADER 40 #include <oomph-lib-config.h> 101 Compute_gradient(false), Gradient_has_been_computed(false) {}
152 "DoubleVector based solve function not implemented for this solver",
153 OOMPH_CURRENT_FUNCTION,
154 OOMPH_EXCEPTION_LOCATION);
164 "Vector<double> based solve function not implemented for this solver",
165 OOMPH_CURRENT_FUNCTION,
166 OOMPH_EXCEPTION_LOCATION);
175 "Resolve function not implemented for this linear solver",
176 OOMPH_CURRENT_FUNCTION,
177 OOMPH_EXCEPTION_LOCATION);
190 "jacobian_setup_time has not been implemented for this linear solver",
191 OOMPH_CURRENT_FUNCTION,
192 OOMPH_EXCEPTION_LOCATION);
201 "linear_solver_solution_time() not implemented for this linear solver",
202 OOMPH_CURRENT_FUNCTION,
203 OOMPH_EXCEPTION_LOCATION);
212 "enable_computation_of_gradient() not implemented for " 213 "this linear solver",
214 OOMPH_CURRENT_FUNCTION,
215 OOMPH_EXCEPTION_LOCATION);
222 Compute_gradient=
false;
229 Gradient_for_glob_conv_newton_solve.
clear();
236 if(Gradient_has_been_computed)
245 "The gradient has not been computed for this linear solver!",
246 OOMPH_CURRENT_FUNCTION,
247 OOMPH_EXCEPTION_LOCATION);
271 Sign_of_determinant_of_matrix(0),
272 Index(0), LU_factors(0)
312 return Jacobian_setup_time;
319 return Solution_time;
433 enum Type { Default, Serial, Distributed };
437 : Serial_f_factors(0)
441 Suppress_solve=
false;
443 Solver_type = Default;
447 Dist_use_global_solver=
false;
448 Dist_delete_matrix_data=
false;
449 Dist_allow_row_and_col_permutations=
true;
450 Dist_solver_data_pt=0;
451 Dist_global_solve_data_allocated =
false;
452 Dist_distributed_solve_data_allocated =
false;
459 Serial_compressed_row_flag=
true;
460 Serial_sign_of_determinant_of_matrix=0;
538 return Jacobian_setup_time;
545 return Solution_time;
574 {Serial_compressed_row_flag=
true;}
578 {Serial_compressed_row_flag=
false;}
592 {Dist_delete_matrix_data=
true;}
598 {Dist_delete_matrix_data=
false;}
604 {Dist_allow_row_and_col_permutations=
true;}
609 {Dist_allow_row_and_col_permutations=
false;}
617 if (!Dist_use_global_solver)
620 Dist_use_global_solver=
true;
630 if (Dist_use_global_solver)
633 Dist_use_global_solver=
false;
void enable_delete_matrix_data_in_superlu_dist()
Set Delete_matrix_data flag. SuperLU_dist needs its own copy of the input matrix, therefore a copy mu...
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 li...
Class of matrices containing doubles, and stored as a DenseMatrix<double>, but with solving functiona...
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 ...
void use_global_solve_in_superlu_dist()
Calling this method will ensure that when the problem based solve interface is used, a global (serial) jacobian will be assembled. Note: calling this function will delete any distributed solve data.
void solve(Problem *const &problem_pt, DoubleVector &result)
Solver: Takes pointer to problem and returns the results Vector which contains the solution of the li...
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
void * Dist_solver_data_pt
Storage for the LU factors and other data required by SuperLU.
void clear()
wipes the DoubleVector
int Sign_of_determinant_of_matrix
Sign of the determinant of the matrix (obtained during the LU decomposition)
bool Using_dist
boolean flag indicating whether superlu dist is being used
void set_solver_type(const Type &t)
Specify the solve type. Either default, serial or distributed. See enum SuperLU_solver_type for more ...
bool Dist_global_solve_data_allocated
Flag is true if solve data has been generated for a global matrix.
bool is_doc_time_enabled() const
Is documentation of solve times enabled?
int Serial_info
Info flag for the SuperLU solver.
virtual double linear_solver_solution_time() const
return the time taken to solve the linear system (needs to be overloaded for each linear solver) ...
bool Dist_delete_matrix_data
Delete_matrix_data flag. SuperLU_dist needs its own copy of the input matrix, therefore a copy must b...
virtual double jacobian_setup_time() const
returns the time taken to assemble the Jacobian matrix and residual vector (needs to be overloaded fo...
~SuperLUSolver()
Destructor, clean up the stored matrices.
DenseLU()
Constructor, initialise storage.
bool Enable_resolve
Boolean that indicates whether the matrix (or its factors, in the case of direct solver) should be st...
int * Dist_start_pt
Pointers for storage of matrix column or row starts.
int Serial_sign_of_determinant_of_matrix
Sign of the determinant of the matrix.
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...
bool Gradient_has_been_computed
flag that indicates whether the gradient was computed or not
bool Dist_distributed_solve_data_allocated
Flag is true if solve data has been generated for distributed matrix.
virtual double linear_solver_solution_time() const
return the time taken to solve the linear system (needs to be overloaded for each linear solver) ...
. SuperLU Project Solver class. This is a combined wrapper for both SuperLU and SuperLU Dist...
double jacobian_setup_time() const
returns the time taken to assemble the jacobian matrix and residual vector
void enable_doc_stats()
Enable documentation of solver statistics.
double * LU_factors
Pointer to storage for the LU decomposition.
int * Dist_index_pt
Pointer for storage of matrix rows or column indices required by SuperLU_DIST.
void operator=(const LinearSolver &)
Broken assignment operator.
bool Doc_stats
Set to true to output statistics (false by default).
void disable_delete_matrix_data_in_superlu_dist()
Unset Delete_matrix_data flag. SuperLU_dist needs its own copy of the input matrix, therefore a copy must be made if any matrix used with this solver is to be preserved. If the input matrix can be.
void get_gradient(DoubleVector &gradient)
function to access the gradient, provided it has been computed
void reset_gradient()
function to reset the size of the gradient before each Newton solve
Dense LU decomposition-based solve of full assembled linear system. VERY inefficient but useful to il...
int Dist_nprow
Number of rows for the process grid.
Base class for any linear algebra object that is distributable. Just contains storage for the LinearA...
void use_distributed_solve_in_superlu_dist()
Calling this method will ensure that when the problem based solve interface is used, a distributed jacobian will be assembled. Note: calling this function will delete any global solve data.
bool Doc_time
Boolean flag that indicates whether the time taken.
FD_LU()
Constructor: empty.
DoubleVector Gradient_for_glob_conv_newton_solve
DoubleVector storing the gradient for the globally convergent Newton method.
bool is_resolve_enabled() const
Boolean flag indicating if resolves are enabled.
void disable_resolve()
Overload disable resolve so that it cleans up memory too.
void disable_row_and_col_permutations_in_superlu_dist()
Set flag so that SuperLU_DIST is not allowed to permute matrix rows and columns during factorisation...
Dense LU decomposition-based solve of linear system assembled via finite differencing of the residual...
double Jacobian_setup_time
Jacobian setup time.
void enable_row_and_col_permutations_in_superlu_dist()
Set flag so that SuperLU_DIST is allowed to permute matrix rows and columns during factorisation...
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 ...
bool Dist_allow_row_and_col_permutations
If true then SuperLU_DIST is allowed to permute matrix rows and columns during factorisation. This is the default for SuperLU_DIST, and can lead to significantly faster solves, but has been known to fail, hence the default value is 0.
int Dist_info
Info flag for the SuperLU solver.
void enable_computation_of_gradient()
function to enable the computation of the gradient
void disable_doc_time()
Disable documentation of solve times.
Type Solver_type
the solver type. see SuperLU_solver_type for details.
LinearSolver(const LinearSolver &dummy)
Broken copy constructor.
LinearSolver()
Empty constructor, initialise the member data.
virtual void enable_resolve()
Enable resolve (i.e. store matrix and/or LU decomposition, say) Virtual so it can be overloaded to pe...
double Solution_time
Solution time.
double * Dist_value_pt
Pointer for storage of the matrix values required by SuperLU_DIST.
int Dist_npcol
Number of columns for the process grid.
void disable_doc_stats()
Disable documentation of solver statistics.
void operator=(const FD_LU &)
Broken assignment operator.
virtual void disable_resolve()
Disable resolve (i.e. store matrix and/or LU decomposition, say) This function simply resets an inter...
virtual void clean_up_memory()
Empty virtual function that can be overloaded in specific linear solvers to clean up any memory that ...
virtual void enable_computation_of_gradient()
function to enable the computation of the gradient required for the globally convergent Newton method...
virtual double linear_solver_solution_time() const
return the time taken to solve the linear system (needs to be overloaded for each linear solver) ...
virtual ~LinearSolver()
Empty virtual destructor.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
DenseLU(const DenseLU &dummy)
Broken copy constructor.
unsigned long Serial_n_dof
The number of unknowns in the linear system.
bool Suppress_solve
Suppress solve?
Type
enum type to specify the solver behaviour. Default - will employ superlu dist if more than 1 processo...
FD_LU(const FD_LU &dummy)
Broken copy constructor.
bool Doc_stats
Boolean to indicate whether to output basic info during setup_multi_domain_interaction() routines...
void operator=(const DenseLU &)
Broken assignment operator.
void operator=(const SuperLUSolver &)
Broken assignment operator.
double Jacobian_setup_time
Jacobian setup time.
static bool Suppress_incorrect_rhs_distribution_warning_in_resolve
Static flag that determines whether the warning about incorrect distribution of RHSs will be printed ...
void * Serial_f_factors
Storage for the LU factors as required by SuperLU.
A vector in the mathematical sense, initially developed for linear algebra type applications. If MPI then this vector can be distributed - its distribution is described by the LinearAlgebraDistribution object at Distribution_pt. Data is stored in a C-style pointer vector (double*)
SuperLUSolver(const SuperLUSolver &dummy)
Broken copy constructor.
bool Compute_gradient
flag that indicates whether the gradient required for the globally convergent Newton method should be...
void use_compressed_row_for_superlu_serial()
Use the compressed row format in superlu serial.
void enable_doc_time()
Enable documentation of solve times.
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 ...
double Solution_time
Solution time.
bool Dist_use_global_solver
Flag that determines whether the MPIProblem based solve function uses the global or distributed versi...
Abstract base class for matrices of doubles – adds abstract interfaces for solving, LU decomposition and multiplication by vectors.
~DenseLU()
Destructor, clean up the stored LU factors.
void use_compressed_column_for_superlu_serial()
Use the compressed column format in superlu serial.
void disable_computation_of_gradient()
function to disable the computation of the gradient required for the globally convergent Newton metho...
bool Serial_compressed_row_flag
Use compressed row version?
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 ...
double jacobian_setup_time() const
returns the time taken to assemble the jacobian matrix and residual vector
long * Index
Pointer to storage for the index of permutations in the LU solve.
SuperLUSolver()
Constructor. Set the defaults.