90 oomph_info <<
"Time to generate Jacobian [sec] : "
100 if (!solution.
built())
144 if (matrix_pt->
nrow() != matrix_pt->
ncol())
146 std::ostringstream error_message_stream;
147 error_message_stream <<
"The matrix at matrix_pt must be square.";
149 OOMPH_CURRENT_FUNCTION,
150 OOMPH_EXCEPTION_LOCATION);
153 if (matrix_pt->
nrow() != rhs.
nrow())
155 std::ostringstream error_message_stream;
157 <<
"The matrix and the rhs vector must have the same number of rows.";
159 OOMPH_CURRENT_FUNCTION,
160 OOMPH_EXCEPTION_LOCATION);
166 if (cr_matrix_pt != 0)
171 std::ostringstream error_message_stream;
173 <<
"The matrix matrix_pt must have the same communicator as the "
175 <<
" rhs and result must have the same communicator";
177 OOMPH_CURRENT_FUNCTION,
178 OOMPH_EXCEPTION_LOCATION);
184 OOMPH_CURRENT_FUNCTION,
185 OOMPH_EXCEPTION_LOCATION);
194 std::ostringstream error_message_stream;
196 <<
"The result vector distribution has been setup; it must have the "
197 <<
"same distribution as the rhs vector.";
199 OOMPH_CURRENT_FUNCTION,
200 OOMPH_EXCEPTION_LOCATION);
233 Epetra_Vector* epetra_r_pt =
237 Epetra_Vector* epetra_z_pt =
248 oomph_info <<
"Time for trilinos solve itself : "
249 << end_t_trilinos - start_t_trilinos <<
"s" << std::endl;
271 oomph_info <<
"Time for complete trilinos solve : "
304 if (trilinos_prec_pt == 0)
316 double t_prec_setup = prec_setup_finish_t - prec_setup_start_t;
317 oomph_info <<
"Time for preconditioner setup [sec]: " << t_prec_setup
323 std::ostringstream error_message;
324 error_message <<
"The oomph-lib preconditioner and the solver must "
325 <<
"have the same distribution";
327 OOMPH_CURRENT_FUNCTION,
328 OOMPH_EXCEPTION_LOCATION);
357 if (trilinos_prec_pt == 0)
376 oomph_info <<
"Time to generate Trilinos matrix : "
377 << double(end_t_matrix - start_t_matrix) <<
"s" << std::endl;
384 if (trilinos_prec_pt == 0)
393 std::ostringstream error_message;
394 error_message <<
"Preconditioner_pt == 0. (Remember default "
395 <<
"preconditioner is IdentityPreconditioner)";
397 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
403 if (trilinos_prec_pt != 0)
424 double t_prec_setup = prec_setup_finish_t - prec_setup_start_t;
425 oomph_info <<
"Time for preconditioner setup [sec]: " << t_prec_setup
472 std::ostringstream error_message;
473 error_message <<
"Solver_type set to incorrect value. "
474 <<
"Acceptable values are " <<
CG <<
", " <<
GMRES
475 <<
" and " <<
BiCGStab <<
". Current value is "
478 OOMPH_CURRENT_FUNCTION,
479 OOMPH_EXCEPTION_LOCATION);
498 std::ostringstream error_message;
500 <<
"The rhs vector and the matrix must have the same number "
502 <<
"The rhs vector has " << rhs.
nrow() <<
" rows.\n"
505 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
510 if (solution.
built())
514 std::ostringstream error_message_stream;
516 <<
"The result vector distribution has been setup; it must have the "
517 <<
"same distribution as the rhs vector.";
519 OOMPH_CURRENT_FUNCTION,
520 OOMPH_EXCEPTION_LOCATION);
526 if (!solution.
built())
533 Epetra_Vector* epetra_r_pt =
537 Epetra_Vector* epetra_z_pt =
571 Epetra_Vector*& soln_pt)
577 std::ostringstream error_message;
578 error_message <<
"Solver must be called with solve(...) "
579 <<
"before resolve(...) to set it up.\n";
581 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
599 oomph_info <<
"Final Relative Residual Norm: " << norm << std::endl;
//////////////////////////////////////////////////////////////////////////// ////////////////////////...
//////////////////////////////////////////////////////////////////////////// ////////////////////////...
A class for compressed row matrices. This is a distributable object.
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
unsigned nrow() const
access function to the number of global rows.
bool distribution_built() const
if the communicator_pt is null then the distribution is not setup then false is returned,...
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
setup the distribution of this distributable linear algebra object
Abstract base class for matrices of doubles – adds abstract interfaces for solving,...
virtual unsigned long ncol() const =0
Return the number of columns of the matrix.
virtual unsigned long nrow() const =0
Return the number of rows of the matrix.
A vector in the mathematical sense, initially developed for linear algebra type applications....
void build(const DoubleVector &old_vector)
Just copys the argument DoubleVector.
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 Use_iterative_solver_as_preconditioner
Use the iterative solver as preconditioner.
bool First_time_solve_when_used_as_preconditioner
When the iterative solver is used a preconditioner then we call the setup of solver method only once ...
double Tolerance
Convergence tolerance.
Preconditioner * Preconditioner_pt
Pointer to the preconditioner.
unsigned Max_iter
Maximum number of iterations.
bool Setup_preconditioner_before_solve
indicates whether the preconditioner should be setup before solve. Default = true;
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
OomphCommunicator * communicator_pt() const
const access to the communicator pointer
bool Doc_time
Boolean flag that indicates whether the time taken.
bool Enable_resolve
Boolean that indicates whether the matrix (or its factors, in the case of direct solver) should be st...
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
An OomphLibError object which should be thrown when an run-time error is encountered....
An Epetra_Operator class for oomph-lib preconditioners. A helper class for TrilinosOomphLibPreconditi...
void setup(DoubleMatrixBase *matrix_pt)
Setup the preconditioner: store the matrix pointer and the communicator pointer then call preconditio...
virtual void set_matrix_pt(DoubleMatrixBase *matrix_pt)
Set the matrix pointer.
////////////////////////////////////////////////////////////////// //////////////////////////////////...
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...
bool Using_problem_based_solve
Helper flag keeping track of whether we called the linear algebra or problem-based solve function.
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...
void solver_setup(DoubleMatrixBase *const &matrix_pt)
Helper function for setting up the solver. Converts the oomph-lib matrices to Epetra matrices,...
unsigned Iterations
Stores number of iterations used.
Epetra_CrsMatrix * Epetra_matrix_pt
A pointer for the linear system matrix in Epetra_CrsMatrix format.
void clean_up_memory()
Clean up method - deletes the solver, the matrices and the preconditioner.
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.
bool Delete_matrix
Trilinos copies matrix data from oomph-lib's own CRDoubleMatrix or DistributedCRDoubleMatrix to Trili...
DoubleMatrixBase * Oomph_matrix_pt
Oomph lib matrix pointer.
Epetra_Operator * Epetra_preconditioner_pt
A pointer to the Epetra_Operator for the preconditioner. This is only used if the preconditioner NOT ...
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...
unsigned Solver_type
Defines which solver is set up - available types are defined in AztecOO_solver_types.
double Linear_solver_solution_time
Stores time for the solution (excludes time to set up preconditioner)
Problem * Problem_pt
A pointer to the underlying problem (NULL if MATRIX based solve) The problem_pt is stored here in a p...
AztecOO * AztecOO_solver_pt
Pointer to the AztecOO solver.
bool Use_aztecoo_workaround_for_epetra_matrix_setup
Use workaround for creating of epetra matrix that respects aztecoo's ordering requirements.
double Jacobian_setup_time
Stores set up time for Jacobian.
Base class for Trilinos preconditioners as oomph-lib preconditioner.
Epetra_Operator *& epetra_operator_pt()
Access function to Epetra_preconditioner_pt. For use with TrilinosAztecOOSolver.
void setup()
Broken assignment operator.
double timer()
returns the time in seconds after some point in past
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...
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....
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....
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....
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...