97 oomph_info <<
"Time to generate Jacobian [sec] : " 107 if (!solution.
built())
155 if (matrix_pt->
nrow() != matrix_pt->
ncol())
157 std::ostringstream error_message_stream;
159 <<
"The matrix at matrix_pt must be square.";
161 OOMPH_CURRENT_FUNCTION,
162 OOMPH_EXCEPTION_LOCATION);
165 if (matrix_pt->
nrow() != rhs.
nrow())
167 std::ostringstream error_message_stream;
169 <<
"The matrix and the rhs vector must have the same number of rows.";
171 OOMPH_CURRENT_FUNCTION,
172 OOMPH_EXCEPTION_LOCATION);
178 if (cr_matrix_pt != 0)
181 if (!(temp_comm == *cr_matrix_pt->distribution_pt()->communicator_pt()))
183 std::ostringstream error_message_stream;
185 <<
"The matrix matrix_pt must have the same communicator as the vectors" 186 <<
" rhs and result must have the same communicator";
188 OOMPH_CURRENT_FUNCTION,
189 OOMPH_EXCEPTION_LOCATION);
195 OOMPH_CURRENT_FUNCTION,
196 OOMPH_EXCEPTION_LOCATION);
205 std::ostringstream error_message_stream;
207 <<
"The result vector distribution has been setup; it must have the " 208 <<
"same distribution as the rhs vector.";
210 OOMPH_CURRENT_FUNCTION,
211 OOMPH_EXCEPTION_LOCATION);
259 oomph_info <<
"Time for trilinos solve itself : " 260 << end_t_trilinos-start_t_trilinos
283 oomph_info <<
"Time for complete trilinos solve : " 318 if (trilinos_prec_pt == 0)
330 double t_prec_setup = prec_setup_finish_t - prec_setup_start_t;
331 oomph_info <<
"Time for preconditioner setup [sec]: " 332 << t_prec_setup << std::endl;
337 std::ostringstream error_message;
338 error_message <<
"The oomph-lib preconditioner and the solver must " 339 <<
"have the same distribution";
341 OOMPH_CURRENT_FUNCTION,
342 OOMPH_EXCEPTION_LOCATION);
370 if (trilinos_prec_pt == 0)
389 oomph_info <<
"Time to generate Trilinos matrix : " 390 << double(end_t_matrix-start_t_matrix)
398 if (trilinos_prec_pt == 0)
408 std::ostringstream error_message;
409 error_message <<
"Preconditioner_pt == 0. (Remember default " 410 <<
"preconditioner is IdentityPreconditioner)";
412 OOMPH_CURRENT_FUNCTION,
413 OOMPH_EXCEPTION_LOCATION);
419 if (trilinos_prec_pt != 0)
440 double t_prec_setup = prec_setup_finish_t - prec_setup_start_t;
441 oomph_info <<
"Time for preconditioner setup [sec]: " 442 << t_prec_setup << std::endl;
464 AztecOO_solver_pt->SetAztecOption(AZ_output, AZ_warnings);
468 AztecOO_solver_pt->SetAztecOption(AZ_output, AZ_none);
470 AztecOO_solver_pt->SetAztecOption(AZ_kspace,
Max_iter);
476 AztecOO_solver_pt->SetAztecOption(AZ_solver, AZ_cg);
480 AztecOO_solver_pt->SetAztecOption(AZ_solver, AZ_gmres);
484 AztecOO_solver_pt->SetAztecOption(AZ_solver, AZ_bicgstab);
488 std::ostringstream error_message;
489 error_message <<
"Solver_type set to incorrect value. " 490 <<
"Acceptable values are " 494 OOMPH_CURRENT_FUNCTION,
495 OOMPH_EXCEPTION_LOCATION);
514 std::ostringstream error_message;
515 error_message <<
"The rhs vector and the matrix must have the same number " 517 <<
"The rhs vector has " << rhs.
nrow() <<
" rows.\n" 521 OOMPH_CURRENT_FUNCTION,
522 OOMPH_EXCEPTION_LOCATION);
527 if (solution.
built())
531 std::ostringstream error_message_stream;
533 <<
"The result vector distribution has been setup; it must have the " 534 <<
"same distribution as the rhs vector.";
536 OOMPH_CURRENT_FUNCTION,
537 OOMPH_EXCEPTION_LOCATION);
543 if (!solution.
built())
589 Epetra_Vector* &soln_pt)
595 std::ostringstream error_message;
596 error_message <<
"Solver must be called with solve(...) " 597 <<
"before resolve(...) to set it up.\n";
599 OOMPH_CURRENT_FUNCTION,
600 OOMPH_EXCEPTION_LOCATION);
619 oomph_info <<
"Final Relative Residual Norm: " << norm << std::endl;
bool First_time_solve_when_used_as_preconditioner
virtual void set_matrix_pt(DoubleMatrixBase *matrix_pt)
Set the matrix pointer.
void solve_using_AztecOO(Epetra_Vector *&rhs_pt, Epetra_Vector *&soln_pt)
Helper function performs the actual solve once the AztecOO solver is set up.
Epetra_CrsMatrix * create_distributed_epetra_matrix_for_aztecoo(CRDoubleMatrix *oomph_matrix_pt)
create and Epetra_CrsMatrix from an oomph-lib CRDoubleMatrix. Specialisation for Trilinos AztecOO...
double Jacobian_setup_time
Stores set up time for Jacobian.
double Linear_solver_solution_time
Stores time for the solution (excludes time to set up preconditioner)
void redistribute(const LinearAlgebraDistribution *const &dist_pt)
The contents of the vector are redistributed to match the new distribution. In a non-MPI rebuild this...
bool Delete_matrix
Trilinos copies matrix data from oomph-lib's own CRDoubleMatrix or DistributedCRDoubleMatrix to Trili...
double Tolerance
Convergence tolerance.
void setup()
Broken assignment operator.
Epetra_Operator * Epetra_preconditioner_pt
A pointer to the Epetra_Operator for the preconditioner. This is only used if the preconditioner NOT ...
unsigned Iterations
Stores number of iterations used.
unsigned Max_iter
Maximum number of iterations.
bool Enable_resolve
Boolean that indicates whether the matrix (or its factors, in the case of direct solver) should be st...
void solve(Problem *const &problem_pt, DoubleVector &solution)
Function which uses problem_pt's get_jacobian(...) function to generate a linear system which is then...
Preconditioner * Preconditioner_pt
Pointer to the preconditioner.
OomphCommunicator * communicator_pt() const
const access to the communicator pointer
void resolve(const DoubleVector &rhs, DoubleVector &solution)
Function to resolve a linear system using the existing solver data, allowing a solve with a new right...
Epetra_CrsMatrix * Epetra_matrix_pt
A pointer for the linear system matrix in Epetra_CrsMatrix format.
Base class for Trilinos preconditioners as oomph-lib preconditioner.
An Epetra_Operator class for oomph-lib preconditioners. A helper class for TrilinosOomphLibPreconditi...
Epetra_CrsMatrix * create_distributed_epetra_matrix(const CRDoubleMatrix *oomph_matrix_pt, const LinearAlgebraDistribution *dist_pt)
create an Epetra_CrsMatrix from an oomph-lib CRDoubleMatrix. If oomph_matrix_pt is NOT distributed (i...
The conjugate gradient method.
bool distribution_built() const
void clean_up_memory()
Clean up method - deletes the solver, the matrices and the preconditioner.
unsigned Solver_type
Defines which solver is set up - available types are defined in AztecOO_solver_types.
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
void build(const DoubleVector &old_vector)
Just copys the argument DoubleVector.
bool Doc_time
Boolean flag that indicates whether the time taken.
bool Use_aztecoo_workaround_for_epetra_matrix_setup
Use workaround for creating of epetra matrix that respects aztecoo's ordering requirements.
DoubleMatrixBase * Oomph_matrix_pt
Oomph lib matrix pointer.
void solver_setup(DoubleMatrixBase *const &matrix_pt)
Helper function for setting up the solver. Converts the oomph-lib matrices to Epetra matrices...
double timer()
returns the time in seconds after some point in past
void setup(DoubleMatrixBase *matrix_pt)
Setup the preconditioner: store the matrix pointer and the communicator pointer then call preconditio...
bool Using_problem_based_solve
Helper flag keeping track of whether we called the linear algebra or problem-based solve function...
virtual void get_jacobian(DoubleVector &residuals, DenseDoubleMatrix &jacobian)
Return the fully-assembled Jacobian and residuals for the problem Interface for the case when the Jac...
The conjugate gradient method.
unsigned nrow() const
access function to the number of global rows.
virtual unsigned long nrow() const =0
Return the number of rows of the matrix.
Epetra_Vector * create_distributed_epetra_vector(const DoubleVector &oomph_vec)
create an Epetra_Vector from an oomph-lib DoubleVector. If oomph_vec is NOT distributed (i...
AztecOO * AztecOO_solver_pt
Pointer to the AztecOO solver.
Problem * Problem_pt
A pointer to the underlying problem (NULL if MATRIX based solve) The problem_pt is stored here in a p...
bool Use_iterative_solver_as_preconditioner
Use the iterative solver as preconditioner.
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
setup the distribution of this distributable linear algebra object
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*)
Epetra_Operator *& epetra_operator_pt()
bool Setup_preconditioner_before_solve
indicates whether the preconditioner should be setup before solve. Default = true; ...
Abstract base class for matrices of doubles – adds abstract interfaces for solving, LU decomposition and multiplication by vectors.
void copy_to_oomphlib_vector(const Epetra_Vector *epetra_vec_pt, DoubleVector &oomph_vec)
Helper function to copy the contents of a Trilinos vector to an oomph-lib distributed vector...
A class for compressed row matrices. This is a distributable object.
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
virtual unsigned long ncol() const =0
Return the number of columns of the matrix.
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...