28 #ifndef OOMPH_GENERAL_BLOCK_PRECONDITIONERS
29 #define OOMPH_GENERAL_BLOCK_PRECONDITIONERS
34 #include <oomph-lib-config.h>
52 namespace PreconditionerCreationFunctions
75 template<
typename MATRIX>
192 const bool& allow_multiple_element_type_in_mesh =
false)
198 std::ostringstream err_msg;
199 err_msg <<
"The mesh_pt is null, please point it to a mesh.\n";
201 err_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
206 std::make_pair(
mesh_pt, allow_multiple_element_type_in_mesh));
224 std::ostringstream err_msg;
225 err_msg <<
"There are no meshes set.\n"
226 <<
"Have you remembered to call add_mesh(...)?\n";
228 err_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
233 for (
unsigned mesh_i = 0; mesh_i <
nmesh; mesh_i++)
269 using namespace StringConversion;
270 std::string error_msg =
"Wrong number of precondtioners in";
271 error_msg +=
"Subsidiary_preconditioner_pt, should have ";
272 error_msg +=
to_string(nprec_needed) +
" but we actually have ";
275 error_msg, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
288 (*Subsidiary_preconditioner_creation_function_pt)();
318 template<
typename MATRIX>
327 Use_two_level_parallelisation =
false;
330 Preconditioner_array_pt = 0;
333 Doc_time_during_preconditioner_solve =
false;
345 if (Use_two_level_parallelisation)
347 delete Preconditioner_array_pt;
348 Preconditioner_array_pt = 0;
365 virtual void setup();
370 #ifndef OOMPH_HAS_MPI
371 throw OomphLibError(
"Cannot do any parallelism since we don't have MPI.",
372 OOMPH_CURRENT_FUNCTION,
373 OOMPH_EXCEPTION_LOCATION);
375 Use_two_level_parallelisation =
true;
381 Use_two_level_parallelisation =
false;
387 Doc_time_during_preconditioner_solve =
true;
393 Doc_time_during_preconditioner_solve =
false;
399 if ((Use_two_level_parallelisation) &&
403 "Two level parallelism diagonal block preconditioners cannot have";
405 " any preset preconditioners (due to weird memory management";
406 err_msg +=
" in the PreconditionerArray, you could try fixing it).";
408 err_msg, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
424 const unsigned& nblock)
const
456 template<
typename MATRIX>
466 Upper_triangular =
true;
479 for (
unsigned i = 0, ni = Off_diagonal_matrix_vector_products.nrow();
483 for (
unsigned j = 0, nj = Off_diagonal_matrix_vector_products.ncol();
487 delete Off_diagonal_matrix_vector_products(
i, j);
488 Off_diagonal_matrix_vector_products(
i, j) = 0;
512 Upper_triangular =
true;
518 Upper_triangular =
false;
539 template<
typename MATRIX>
576 template<
typename MATRIX>
588 return nblock -
i - 1;
597 template<
typename MATRIX>
Block "anti-diagonal" preconditioner, i.e. same as block diagonal but along the other diagonal of the...
unsigned get_other_diag_ds(const unsigned &i, const unsigned &nblock) const
This is a helper function to allow us to implement BlockAntiDiagonal using BlockDiagonal precondition...
Block diagonal preconditioner. By default SuperLU is used to solve the subsidiary systems,...
void disable_doc_time_during_preconditioner_solve()
Disable Doc timings in application of block sub-preconditioners.
virtual ~BlockDiagonalPreconditioner()
Destructor - delete the preconditioner matrices.
void fill_in_subsidiary_preconditioners(const unsigned &nprec_needed)
void enable_two_level_parallelisation()
Use two level parallelisation.
bool Doc_time_during_preconditioner_solve
Doc timings in application of block sub-preconditioners?
void operator=(const BlockDiagonalPreconditioner &)=delete
Broken assignment operator.
void enable_doc_time_during_preconditioner_solve()
Enable Doc timings in application of block sub-preconditioners.
void disable_two_level_parallelisation()
Don't use two-level parallelisation.
BlockDiagonalPreconditioner(const BlockDiagonalPreconditioner &)=delete
Broken copy constructor.
BlockDiagonalPreconditioner()
constructor - when the preconditioner is used as a master preconditioner
virtual unsigned get_other_diag_ds(const unsigned &i, const unsigned &nblock) const
This is a helper function to allow us to implement AntiDiagonal preconditioner by only changing this ...
virtual void clean_up_memory()
clean up the memory
PreconditionerArray * Preconditioner_array_pt
pointer for the PreconditionerArray
bool Use_two_level_parallelisation
Use two level parallelism using the PreconditionerArray.
Block Preconditioner base class. The block structure of the overall problem is determined from the Me...
unsigned nmesh() const
Return the number of meshes in Mesh_pt.
const Mesh * mesh_pt(const unsigned &i) const
Access to i-th mesh (of the various meshes that contain block preconditionable elements of the same n...
void clear_block_preconditioner_base()
Clears all BlockPreconditioner data. Called by the destructor and the block_setup(....
void set_nmesh(const unsigned &n)
Specify the number of meshes required by this block preconditioner. Note: elements in different meshe...
virtual void block_setup()
Determine the size of the matrix blocks and setup the lookup schemes relating the global degrees of f...
void set_mesh(const unsigned &i, const Mesh *const mesh_pt, const bool &allow_multiple_element_type_in_mesh=false)
Set the i-th mesh for this block preconditioner. Note: The method set_nmesh(...) must be called befor...
//////////////////////////////////////////////////////////////////////////// ////////////////////////...
virtual ~BlockTriangularPreconditioner()
Destructor - delete the preconditioner matrices.
DenseMatrix< MatrixVectorProduct * > Off_diagonal_matrix_vector_products
Matrix of matrix vector product operators for the off diagonals.
void upper_triangular()
Use as an upper triangular preconditioner.
BlockTriangularPreconditioner()
Constructor. (By default this preconditioner is upper triangular).
void operator=(const BlockTriangularPreconditioner &)=delete
Broken assignment operator.
BlockTriangularPreconditioner(const BlockTriangularPreconditioner &)=delete
Broken copy constructor.
void lower_triangular()
Use as a lower triangular preconditioner.
virtual void clean_up_memory()
clean up the memory
bool Upper_triangular
Boolean indicating upper or lower triangular.
//////////////////////////////////////////////////////////////////////////// ////////////////////////...
A vector in the mathematical sense, initially developed for linear algebra type applications....
void build(const DoubleVector &old_vector)
Just copys the argument DoubleVector.
Preconditioner that doesn't actually do any preconditioning, it just allows access to the Jacobian bl...
DummyBlockPreconditioner(const DummyBlockPreconditioner &)=delete
Broken copy constructor.
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Apply preconditioner to r (just copy r to z).
DummyBlockPreconditioner()
Constructor.
void setup()
Setup the preconditioner.
~DummyBlockPreconditioner()
Destructor.
void operator=(const DummyBlockPreconditioner &)=delete
Broken assignment operator.
//////////////////////////////////////////////////////////////////////////// ////////////////////////...
ExactBlockPreconditioner()
constructor
void operator=(const ExactBlockPreconditioner &)=delete
Broken assignment operator.
ExactBlockPreconditioner(const ExactBlockPreconditioner &)=delete
Broken copy constructor.
virtual ~ExactBlockPreconditioner()
Destructor.
Preconditioner *& preconditioner_pt()
Access for the preconditioner pointer used to solve the system (stored in the vector of pointers in t...
Base class for general purpose block preconditioners. Deals with setting subsidiary preconditioners a...
void operator=(const GeneralPurposeBlockPreconditioner &)=delete
Broken assignment operator.
Vector< unsigned > Dof_to_block_map
the set of dof to block maps for this preconditioner
void set_dof_to_block_map(Vector< unsigned > &dof_to_block_map)
Specify a DOF to block map.
virtual void clean_up_memory()
??ds I think clean_up_memory is supposed to clear out any stuff that doesn't need to be stored betwee...
GeneralPurposeBlockPreconditioner()
constructor
virtual ~GeneralPurposeBlockPreconditioner()
Destructor: clean up memory then delete all subsidiary preconditioners.
Preconditioner *(* SubsidiaryPreconditionerFctPt)()
typedef for a function that allows other preconditioners to be employed to solve the subsidiary linea...
SubsidiaryPreconditionerFctPt Subsidiary_preconditioner_creation_function_pt
Function to create any subsidiary preconditioners not set in Subsidiary_preconditioner_pt.
Vector< Preconditioner * > Subsidiary_preconditioner_pt
List of preconditioners to use for the blocks to be solved.
Vector< std::pair< const Mesh *, bool > > Gp_mesh_pt
Vector of mesh pointers and a boolean indicating if we allow multiple element types in the same mesh.
Preconditioner * subsidiary_preconditioner_pt(const unsigned &i) const
Get the subsidiary precondtioner pointer in block i (is allowed to be null if not yet set).
void reset_subsidiary_preconditioner_function_to_default()
Reset the subsidiary preconditioner function to its default.
void add_mesh(const Mesh *mesh_pt, const bool &allow_multiple_element_type_in_mesh=false)
Adds a mesh to be used by the block preconditioning framework for classifying DOF types....
void gp_preconditioner_set_all_meshes()
Set the mesh in the block preconditioning framework.
GeneralPurposeBlockPreconditioner(const GeneralPurposeBlockPreconditioner &)=delete
Broken copy constructor.
void fill_in_subsidiary_preconditioners(const unsigned &nprec_needed)
Create any subsidiary preconditioners needed. Usually nprec_needed = nblock_types,...
void set_subsidiary_preconditioner_pt(Preconditioner *prec, const unsigned &i)
Set the subsidiary preconditioner to use for block i. The subsidiary preconditioner should have been ...
void gp_preconditioner_block_setup()
Modified block setup for general purpose block preconditioners.
void set_subsidiary_preconditioner_function(SubsidiaryPreconditionerFctPt sub_prec_fn)
access function to set the subsidiary preconditioner function.
unsigned gp_nmesh()
Returns the number of meshes currently set in the GeneralPurposeBlockPreconditioner base class.
An OomphLibError object which should be thrown when an run-time error is encountered....
PreconditionerArray - NOTE - first implementation, a number of assumptions / simplifications were mad...
Preconditioner base class. Gives an interface to call all other preconditioners through and stores th...
virtual void preconditioner_solve(const DoubleVector &r, DoubleVector &z)=0
Apply the preconditioner. Pure virtual generic interface function. This method should apply the preco...
virtual void setup()=0
Setup the preconditioner. Pure virtual generic interface function.
An interface to allow SuperLU to be used as an (exact) Preconditioner.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
Preconditioner * create_super_lu_preconditioner()
Helper function to create a SuperLu preconditioner (for use as the default subsididary preconditioner...
std::string to_string(T object, unsigned float_precision=8)
Conversion function that should work for anything with operator<< defined (at least all basic types).
//////////////////////////////////////////////////////////////////// ////////////////////////////////...