27 #ifndef OOMPH_SPACETIME_NAVIER_STOKES_BLOCK_PRECONDITIONERS_HEADER
28 #define OOMPH_SPACETIME_NAVIER_STOKES_BLOCK_PRECONDITIONERS_HEADER
32 #include <oomph-lib-config.h>
39 #include "../../SpaceTimeBlockPreconditioner/spacetime_block_preconditioner.cc"
55 class SpaceTimeNavierStokesSubsidiaryPreconditioner
56 :
public BlockPreconditioner<CRDoubleMatrix>
176 std::ostringstream warning_message_stream;
179 warning_message_stream
180 <<
"The memory statistics have not been calculated "
181 <<
"so I'm returning\nthe value zero." << std::endl;
185 OOMPH_CURRENT_FUNCTION,
186 OOMPH_EXCEPTION_LOCATION);
196 std::ostringstream warning_message_stream;
199 warning_message_stream
200 <<
"The preconditioner hasn't even been set up yet "
201 <<
"so I'm returning\nthe value zero." << std::endl;
205 OOMPH_CURRENT_FUNCTION,
206 OOMPH_EXCEPTION_LOCATION);
251 class GMRESBlockPreconditioner
252 :
public IterativeLinearSolver,
253 public virtual BlockPreconditioner<CRDoubleMatrix>
322 OOMPH_CURRENT_FUNCTION,
323 OOMPH_EXCEPTION_LOCATION);
377 std::ostringstream warning_message_stream;
380 warning_message_stream
381 <<
"The memory statistics have not been calculated "
382 <<
"so I'm returning\nthe value zero." << std::endl;
386 OOMPH_CURRENT_FUNCTION,
387 OOMPH_EXCEPTION_LOCATION);
397 std::ostringstream warning_message_stream;
400 warning_message_stream
401 <<
"The preconditioner hasn't even been set up yet "
402 <<
"so I'm returning\nthe value zero." << std::endl;
406 OOMPH_CURRENT_FUNCTION,
407 OOMPH_EXCEPTION_LOCATION);
438 for (
int i =
int(k);
i >= 0;
i--)
444 for (
int j =
i - 1; j >= 0; j--)
447 y[j] -= H[
i][j] * y[
i];
452 unsigned n_x = x.
nrow();
464 for (
unsigned j = 0; j <= k; j++)
467 const double* vj_pt = v[j].values_pt();
470 for (
unsigned i = 0;
i < n_x;
i++)
472 temp_pt[
i] += vj_pt[
i] * y[j];
499 temp_with_size_of_full_rhs, block_z_with_size_of_full_z);
540 else if (fabs(dy) > fabs(dx))
543 double temp = dx / dy;
546 sn = 1.0 / sqrt(1.0 + temp * temp);
556 double temp = dy / dx;
559 cs = 1.0 / sqrt(1.0 + temp * temp);
572 double temp = cs * dx + sn * dy;
575 dy = -sn * dx + cs * dy;
Block Preconditioner base class. The block structure of the overall problem is determined from the Me...
void return_block_vector(const unsigned &n, const DoubleVector &b, DoubleVector &v) const
Takes the n-th block ordered vector, b, and copies its entries to the appropriate entries in the natu...
void get_block_vector(const unsigned &n, const DoubleVector &v, DoubleVector &b) const
Takes the naturally ordered vector, v and returns the n-th block vector, b. Here n is the block numbe...
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.
A vector in the mathematical sense, initially developed for linear algebra type applications....
double * values_pt()
access function to the underlying values
The block preconditioner form of GMRES. This version extracts the blocks from the global systems and ...
void operator=(const GMRESBlockPreconditioner &)=delete
Broken assignment operator.
double Memory_usage_in_bytes
Storage for the memory usage of the solver if the flag above is set to true (in bytes)
void apply_plane_rotation(double &dx, double &dy, double &cs, double &sn)
Helper function: Apply plane rotation. This is done using the update:
unsigned iterations() const
Handle to the number of iterations taken.
GMRESBlockPreconditioner(const GMRESBlockPreconditioner &)=delete
Broken copy constructor.
void disable_doc_memory_statistics()
Don't document the memory usage!
virtual void clean_up_memory()
Clean up the memory (empty for now...)
void enable_doc_memory_statistics()
Document the memory usage.
SpaceTimeNavierStokesSubsidiaryPreconditioner * Navier_stokes_subsidiary_preconditioner_pt
Pointer to the preconditioner for the block matrix.
bool Compute_memory_statistics
Flag to indicate whether or not to record the memory statistics this preconditioner.
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Apply preconditioner to r.
bool Preconditioner_has_been_setup
Control flag is true if the preconditioner has been setup (used so we can wipe the data when the prec...
unsigned Iterations
Number of iterations taken.
SpaceTimeNavierStokesSubsidiaryPreconditioner * navier_stokes_subsidiary_preconditioner_pt() const
Handle to the Navier-Stokes subsidiary block preconditioner DRAIG: Make sure the desired const-ness i...
void set_preconditioner_RHS()
Enable right preconditioning.
GMRESBlockPreconditioner()
Constructor (empty)
bool Preconditioner_LHS
boolean indicating use of left hand preconditioning (if true) or right hand preconditioning (if false...
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...
double get_memory_usage_in_bytes()
Get the memory statistics.
CRDoubleMatrix * Matrix_pt
Pointer to matrix.
void set_preconditioner_LHS()
Set left preconditioning (the default)
void setup()
Setup the preconditioner.
void update(const unsigned &k, const Vector< Vector< double >> &H, const Vector< double > &s, const Vector< DoubleVector > &v, const DoubleVector &block_x_with_size_of_full_x, DoubleVector &x)
Helper function to update the result vector using the result, x=x_0+V_m*y.
void generate_plane_rotation(double &dx, double &dy, double &cs, double &sn)
Helper function: Generate a plane rotation. This is done by finding the values of (i....
virtual ~GMRESBlockPreconditioner()
Destructor.
Matrix vector product helper class - primarily a wrapper to Trilinos's Epetra matrix vector product m...
An OomphLibError object which should be thrown when an run-time error is encountered....
An OomphLibWarning object which should be created as a temporary object to issue a warning....
Preconditioner base class. Gives an interface to call all other preconditioners through and stores th...
virtual void setup()=0
Setup the preconditioner. Pure virtual generic interface function.
////////////////////////////////////////////////////////////////// //////////////////////////////////...
General purpose block triangular preconditioner. By default this is Upper triangular....
virtual ~SpaceTimeNavierStokesSubsidiaryPreconditioner()
Destructor - delete the preconditioner matrices.
Preconditioner * P_preconditioner_pt
Pointer to the 'preconditioner' for the pressure matrix.
double Memory_usage_in_bytes
Storage for the memory usage of the solver if the flag above is set to true (in bytes)
void setup()
Setup the preconditioner.
bool Preconditioner_has_been_setup
Control flag is true if the preconditioner has been setup (used so we can wipe the data when the prec...
bool Compute_memory_statistics
Flag to indicate whether or not to record the memory statistics this preconditioner.
MatrixVectorProduct * G_mat_vec_pt
MatrixVectorProduct operator for G.
void operator=(const SpaceTimeNavierStokesSubsidiaryPreconditioner &)=delete
Broken assignment operator.
SpaceTimeNavierStokesSubsidiaryPreconditioner()
Constructor. (By default this preconditioner is upper triangular).
MatrixVectorProduct * F_mat_vec_pt
MatrixVectorProduct operator for F.
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Apply preconditioner to r.
void disable_doc_memory_usage()
Don't document the memory usage!
bool Using_default_f_preconditioner
Flag indicating whether the default F preconditioner is used.
virtual void clean_up_memory()
Clean up the memory.
void enable_doc_memory_usage()
Document the memory usage.
bool Using_default_p_preconditioner
Flag indicating whether the default P preconditioner is used.
double get_memory_usage_in_bytes()
Get the memory statistics.
Preconditioner * F_preconditioner_pt
Pointer to the 'preconditioner' for the F matrix.
SpaceTimeNavierStokesSubsidiaryPreconditioner(const SpaceTimeNavierStokesSubsidiaryPreconditioner &)=delete
Broken copy constructor.
A slight extension to the standard template vector class so that we can include "graceful" array rang...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...