31 #ifndef OOMPH_GENERAL_PRECONDITION_HEADER 32 #define OOMPH_GENERAL_PRECONDITION_HEADER 37 #include <oomph-lib-config.h> 94 template<
typename MATRIX>
103 Positive_matrix =
false;
106 Inv_lumped_diag_pt = 0;
144 if (Inv_lumped_diag_pt == 0)
147 "The preconditioner has not been setup.",
148 OOMPH_CURRENT_FUNCTION,
149 OOMPH_EXCEPTION_LOCATION);
152 return Positive_matrix;
162 if (Inv_lumped_diag_pt == 0)
165 "The inverse lumped vector has not been created. Created in setup(...)",
166 OOMPH_CURRENT_FUNCTION,
167 OOMPH_EXCEPTION_LOCATION);
170 return Inv_lumped_diag_pt;
175 unsigned&
nrow() {
return Nrow; }
180 delete[] Inv_lumped_diag_pt;
242 return Index < a.
index();
253 unsigned index()
const {
return Index; }
256 double value()
const {
return Value; }
275 template <
typename MATRIX>
398 template <
class SOLVER,
class PRECONDITIONER>
407 Solver_pt =
new SOLVER;
410 Preconditioner_pt =
new PRECONDITIONER;
415 if (dynamic_cast<IterativeLinearSolver* >(Solver_pt) == 0)
418 "The template argument SOLVER must be of type IterativeLinearSolver",
419 OOMPH_CURRENT_FUNCTION,
420 OOMPH_EXCEPTION_LOCATION);
422 if (dynamic_cast<Preconditioner*>(Preconditioner_pt) == 0)
425 "The template argument PRECONDITIONER must be of type Preconditioner",
426 OOMPH_CURRENT_FUNCTION,
427 OOMPH_EXCEPTION_LOCATION);
432 Solver_pt->disable_setup_preconditioner_before_solve();
435 Solver_pt->preconditioner_pt() = Preconditioner_pt;
442 delete Preconditioner_pt;
448 Preconditioner_pt->clean_up_memory();
449 Solver_pt->clean_up_memory();
475 Preconditioner_pt->Preconditioner::setup(
matrix_pt());
478 unsigned max_iter = Solver_pt->max_iter();
479 Solver_pt->max_iter() = 1;
482 Solver_pt->enable_resolve();
484 Solver_pt->max_iter() = max_iter;
491 Solver_pt->resolve(r,z);
498 unsigned&
max_iter() {
return Solver_pt->max_iter();}
virtual DoubleMatrixBase * matrix_pt() const
Get function for matrix pointer.
MatrixBasedLumpedPreconditioner(const MatrixBasedDiagPreconditioner &)
Broken copy constructor.
Vector< unsigned > L_column_start
Column start for lower triangular matrix.
ILUZeroPreconditioner(const ILUZeroPreconditioner &)
Broken copy constructor.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
bool operator<(const CompressedMatrixCoefficient &a) const
Less Than Operator (for the STL sort function)
Vector< unsigned > U_row_start
Row start for upper triangular matrix.
unsigned & index()
access function for the coefficient's (row or column) index
Vector< CompressedMatrixCoefficient > L_row_entry
column entry for the lower triangular matrix (each element of the vector contains the column index an...
unsigned Index
the row or column index of the compressed-matrix coefficient
Vector< CompressedMatrixCoefficient > L_row_entry
Row entry for the lower triangular matrix (each element of the vector contains the row index and coef...
unsigned index() const
Access function for the coefficient's (row or column_ index (const version)
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Apply preconditioner to z, i.e. z=D^-1.
MatrixBasedLumpedPreconditioner()
Constructor.
double & tolerance()
Access to convergence tolerance of the inner iteration solver.
~InnerIterationPreconditioner()
Vector< CompressedMatrixCoefficient > U_row_entry
column entry for the upper triangular matrix (each element of the vector contains the column index an...
void setup()
Setup the preconditioner (store diagonal) from the fully assembled matrix.
CompressedMatrixCoefficient(const CompressedMatrixCoefficient &a)
Copy Constructor. Not Broken. Required for STL sort function.
CompressedMatrixCoefficient(const unsigned &index, const double &value)
Constructor (takes the index and value as arguments)
Vector< unsigned > U_column_start
Column start for upper triangular matrix.
double & value()
access function for the coefficient value
bool positive_matrix() const
Access function to the Positive_matrix which indicates whether lumped matrix was positive.
~MatrixBasedLumpedPreconditioner()
Destructor.
~ILUZeroPreconditioner()
Destructor (empty)
Vector< double > Inv_diag
Vector of inverse diagonal entries.
Vector< CompressedMatrixCoefficient > U_row_entry
Row entry for the upper triangular matrix (each element of the vector contains the row index and coef...
void operator=(const ILUZeroPreconditioner &)
Broken assignment operator.
Vector< unsigned > L_row_start
Row start for lower triangular matrix.
ILUZeroPreconditioner(const ILUZeroPreconditioner &)
Broken copy constructor.
Matrix-based diagonal preconditioner.
ILUZeroPreconditioner()
Constructor (empty)
double Value
the value of the compressed-matrix coefficient
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
Matrix-based lumped preconditioner.
Base class for any linear algebra object that is distributable. Just contains storage for the LinearA...
void setup()
Preconditioner setup method. Setup the preconditioner for the inner iteration solver.
unsigned & nrow()
Access function to number of rows for this preconditioner.
InnerIterationPreconditioner()
Constructor.
CompressedMatrixCoefficient()
Constructor (no arguments)
A preconditioner for performing inner iteration preconditioner solves. The template argument SOLVER s...
void operator=(const CompressedMatrixCoefficient &a)
Assignment Operator. Not Broken. Required for STL sort function.
SOLVER * Solver_pt
pointer to the underlying solver
double * Inv_lumped_diag_pt
Vector of inverse diagonal entries.
PRECONDITIONER * Preconditioner_pt
pointer to the underlying preconditioner
A class for compressed column matrices that store doubles.
Preconditioner base class. Gives an interface to call all other preconditioners through and stores th...
unsigned & max_iter()
Access to max. number of iterations of the inner iteration solver.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
unsigned nrow() const
access function to the number of global rows.
void operator=(const ILUZeroPreconditioner &)
Broken assignment operator.
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Preconditioner solve method. Performs the specified number of Krylov iterations preconditioned with t...
~MatrixBasedDiagPreconditioner()
Destructor (empty)
~ILUZeroPreconditioner()
Destructor (empty)
void operator=(const MatrixBasedLumpedPreconditioner &)
Broken assignment operator.
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
setup the distribution of this distributable linear algebra object
virtual const OomphCommunicator * comm_pt() const
Get function for comm pointer.
virtual void setup()=0
Setup the preconditioner. Pure virtual generic interface function.
ILUZeroPreconditioner()
Constructor (empty)
MatrixBasedDiagPreconditioner(const MatrixBasedDiagPreconditioner &)
Broken copy constructor.
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*)
Class for a compressed-matrix coefficent (for either CC or CR matrices). Contains the (row or column)...
virtual void clean_up_memory()
Clean up memory (empty). Generic interface function.
~CompressedMatrixCoefficient()
Destructor (does nothing)
A class for compressed row matrices. This is a distributable object.
double value() const
access function for the coefficient's value (const version)
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
void operator=(const MatrixBasedDiagPreconditioner &)
Broken assignment operator.
void clean_up_memory()
Clean up memory (empty). Generic interface function.
MatrixBasedDiagPreconditioner()
Constructor (empty)
PRECONDITIONER * preconditioner_pt()
void clean_up_memory()
clean up memory - just delete the inverse lumped vector
double * inverse_lumped_vector_pt()
Access function to the inverse of the lumped vector assembled in the preconditioner setup routine...