Public Member Functions | List of all members
oomph::MGPreconditioner< DIM > Class Template Reference

An interface to allow scalar MG to be used as a Preconditioner. More...

#include <geometric_multigrid.h>

+ Inheritance diagram for oomph::MGPreconditioner< DIM >:

Public Member Functions

 MGPreconditioner (MGProblem *mg_problem_pt)
 Constructor. More...
 
 ~MGPreconditioner ()
 Destructor (empty) More...
 
 MGPreconditioner (const MGPreconditioner &)=delete
 Broken copy constructor. More...
 
void operator= (const MGPreconditioner &)=delete
 Broken assignment operator. More...
 
void setup ()
 Function to set up a preconditioner for the linear system. More...
 
virtual void preconditioner_solve (const DoubleVector &rhs, DoubleVector &z)
 Function applies MG to the vector r for a full solve. More...
 
void clean_up_memory ()
 Clean up memory. More...
 
- Public Member Functions inherited from oomph::MGSolver< DIM >
void set_pre_smoother_factory_function (PreSmootherFactoryFctPt pre_smoother_fn)
 Access function to set the pre-smoother creation function. More...
 
void set_post_smoother_factory_function (PostSmootherFactoryFctPt post_smoother_fn)
 Access function to set the post-smoother creation function. More...
 
 MGSolver (MGProblem *mg_problem_pt)
 Constructor: Set up default values for number of V-cycles and pre- and post-smoothing steps. More...
 
 ~MGSolver ()
 Delete any dynamically allocated data. More...
 
void set_self_test_vector ()
 Makes a vector which will be used in the self-test. Is currently set to make the entries of the vector represent a plane wave propagating at an angle of 45 degrees. More...
 
void self_test ()
 Makes a vector, restricts it down the levels of the hierarchy and documents it at each level. After this is done the vector is interpolated up the levels of the hierarchy with the output being documented at each level. More...
 
void restriction_self_test ()
 Make a self-test to make sure that the interpolation matrices are doing the same thing to restrict the vectors down through the heirachy. More...
 
void interpolation_self_test ()
 Make a self-test to make sure that the interpolation matrices are doing the same thing to interpolate the vectors up. More...
 
void plot (const unsigned &hierarchy_level, const DoubleVector &input_vector, const std::string &filename)
 Given a level in the hierarchy, an input vector and a filename this function will document the given vector according to the structure of the mesh on the given level. More...
 
void disable_v_cycle_output ()
 Disable all output from mg_solve apart from the number of V-cycles used to solve the problem. More...
 
void disable_output ()
 Suppress anything that can be suppressed, i.e. any timings. Things like mesh adaptation can not however be silenced using this. More...
 
void enable_v_cycle_output ()
 Enable the output of the V-cycle timings and other output. More...
 
void enable_doc_everything ()
 Enable the output from anything that could have been suppressed. More...
 
void enable_output ()
 Enable the output from anything that could have been suppressed. More...
 
void disable_smoother_and_superlu_doc_time ()
 Suppress the output of both smoothers and SuperLU. More...
 
unsigned & npost_smooth ()
 Return the number of post-smoothing iterations (lvalue) More...
 
unsigned & npre_smooth ()
 Return the number of pre-smoothing iterations (lvalue) More...
 
void pre_smooth (const unsigned &level)
 Pre-smoother: Perform 'max_iter' smoothing steps on the linear system Ax=b with current RHS vector, b, starting with current solution vector, x. Return the residual vector r=b-Ax. Uses the default smoother (set in the MGProblem constructor) which can be overloaded for a specific problem. More...
 
void post_smooth (const unsigned &level)
 Post-smoother: Perform max_iter smoothing steps on the linear system Ax=b with current RHS vector, b, starting with current solution vector, x. Uses the default smoother (set in the MGProblem constructor) which can be overloaded for specific problem. More...
 
double residual_norm (const unsigned &level)
 Return norm of residual r=b-Ax and the residual vector itself on the level-th level. More...
 
void direct_solve ()
 Call the direct solver (SuperLU) to solve the problem exactly. More...
 
void interpolation_matrix_set (const unsigned &level, double *value, int *col_index, int *row_st, unsigned &ncol, unsigned &nnz)
 Builds a CRDoubleMatrix that is used to interpolate the residual between levels. The transpose can be used as the full weighting restriction. More...
 
void interpolation_matrix_set (const unsigned &level, Vector< double > &value, Vector< int > &col_index, Vector< int > &row_st, unsigned &ncol, unsigned &nrow)
 Builds a CRDoubleMatrix that is used to interpolate the residual between levels. The transpose can be used as the full weighting restriction. More...
 
void set_restriction_matrices_as_interpolation_transposes ()
 Builds a CRDoubleMatrix on each level that is used to restrict the residual between levels. The transpose can be used as the interpolation matrix. More...
 
void restrict_residual (const unsigned &level)
 Restrict residual (computed on level-th MG level) to the next coarser mesh and stick it into the coarse mesh RHS vector. More...
 
void interpolate_and_correct (const unsigned &level)
 Interpolate solution at current level onto next finer mesh and correct the solution x at that level. More...
 
void level_up_local_coord_of_node (const int &son_type, Vector< double > &s)
 Given the son_type of an element and a local node number j in that element with nnode_1d nodes per coordinate direction, return the local coordinate s in its father element. Needed in the setup of the interpolation matrices. More...
 
void setup_interpolation_matrices ()
 Setup the interpolation matrix on each level. More...
 
void setup_interpolation_matrices_unstructured ()
 Setup the interpolation matrix on each level (used for unstructured meshes) More...
 
void setup_transfer_matrices ()
 Setup the transfer matrices on each level. More...
 
void full_setup ()
 Do a full setup (assumes everything will be setup around the MGProblem pointer given in the constructor) More...
 
void solve (Problem *const &problem_pt, DoubleVector &result)
 Virtual function in the base class that needs to be implemented later but for now just leave it empty. More...
 
unsigned iterations () const
 Number of iterations. More...
 
unsigned & max_iter ()
 Number of iterations. More...
 
void level_up_local_coord_of_node (const int &son_type, Vector< double > &s)
 Given the son type of the element and the local coordinate s of a given node in the son element, return the local coordinate s in its father element. 2D case. More...
 
void level_up_local_coord_of_node (const int &son_type, Vector< double > &s)
 Given the son type of the element and the local coordinate s of a given node in the son element, return the local coordinate s in its father element. 3D case. More...
 
- Public Member Functions inherited from oomph::IterativeLinearSolver
 IterativeLinearSolver ()
 Constructor: Set (default) trivial preconditioner and set defaults for tolerance and max. number of iterations. More...
 
 IterativeLinearSolver (const IterativeLinearSolver &)=delete
 Broken copy constructor. More...
 
void operator= (const IterativeLinearSolver &)=delete
 Broken assignment operator. More...
 
virtual ~IterativeLinearSolver ()
 Destructor (empty) More...
 
Preconditioner *& preconditioner_pt ()
 Access function to preconditioner. More...
 
Preconditioner *const & preconditioner_pt () const
 Access function to preconditioner (const version) More...
 
double & tolerance ()
 Access to convergence tolerance. More...
 
unsigned & max_iter ()
 Access to max. number of iterations. More...
 
void enable_doc_convergence_history ()
 Enable documentation of the convergence history. More...
 
void disable_doc_convergence_history ()
 Disable documentation of the convergence history. More...
 
void open_convergence_history_file_stream (const std::string &file_name, const std::string &zone_title="")
 Write convergence history into file with specified filename (automatically switches on doc). Optional second argument is a string that can be used (as a zone title) to identify what case we're running (e.g. what combination of linear solver and preconditioner or parameter values are used). More...
 
void close_convergence_history_file_stream ()
 Close convergence history output stream. More...
 
double jacobian_setup_time () const
 returns the time taken to assemble the jacobian matrix and residual vector More...
 
double linear_solver_solution_time () const
 return the time taken to solve the linear system More...
 
virtual double preconditioner_setup_time () const
 returns the the time taken to setup the preconditioner More...
 
void enable_setup_preconditioner_before_solve ()
 Setup the preconditioner before the solve. More...
 
void disable_setup_preconditioner_before_solve ()
 Don't set up the preconditioner before the solve. More...
 
void enable_error_after_max_iter ()
 Throw an error if we don't converge within max_iter. More...
 
void disable_error_after_max_iter ()
 Don't throw an error if we don't converge within max_iter (default). More...
 
void enable_iterative_solver_as_preconditioner ()
 Enables the iterative solver be used as preconditioner (when calling the solve method it bypass the setup solver method – currently only used by Trilinos solver —) More...
 
void disable_iterative_solver_as_preconditioner ()
 Disables the iterative solver be used as preconditioner (when calling the solve method it bypass the setup solver method – currently only used by Trilinos solver —) More...
 
- Public Member Functions inherited from oomph::LinearSolver
 LinearSolver ()
 Empty constructor, initialise the member data. More...
 
 LinearSolver (const LinearSolver &dummy)=delete
 Broken copy constructor. More...
 
void operator= (const LinearSolver &)=delete
 Broken assignment operator. More...
 
virtual ~LinearSolver ()
 Empty virtual destructor. More...
 
void enable_doc_time ()
 Enable documentation of solve times. More...
 
void disable_doc_time ()
 Disable documentation of solve times. More...
 
bool is_doc_time_enabled () const
 Is documentation of solve times enabled? More...
 
bool is_resolve_enabled () const
 Boolean flag indicating if resolves are enabled. More...
 
virtual void enable_resolve ()
 Enable resolve (i.e. store matrix and/or LU decomposition, say) Virtual so it can be overloaded to perform additional tasks. More...
 
virtual void disable_resolve ()
 Disable resolve (i.e. store matrix and/or LU decomposition, say) This function simply resets an internal flag. It's virtual so it can be overloaded to perform additional tasks such as cleaning up memory that is only required for the resolve. More...
 
virtual void solve (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &result)
 Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system. More...
 
virtual void solve (DoubleMatrixBase *const &matrix_pt, const Vector< double > &rhs, Vector< double > &result)
 Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system. More...
 
virtual void solve_transpose (Problem *const &problem_pt, DoubleVector &result)
 Solver: Takes pointer to problem and returns the results vector which contains the solution of the linear system defined by the problem's fully assembled Jacobian and residual vector (broken virtual). More...
 
virtual void solve_transpose (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &result)
 Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system. More...
 
virtual void solve_transpose (DoubleMatrixBase *const &matrix_pt, const Vector< double > &rhs, Vector< double > &result)
 Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the linear system. More...
 
virtual void resolve (const DoubleVector &rhs, DoubleVector &result)
 Resolve the system defined by the last assembled jacobian and the rhs vector. Solution is returned in the vector result. (broken virtual) More...
 
virtual void resolve_transpose (const DoubleVector &rhs, DoubleVector &result)
 Solver: Resolve the system defined by the last assembled jacobian and the rhs vector. Solution is returned in the vector result. (broken virtual) More...
 
virtual void enable_computation_of_gradient ()
 function to enable the computation of the gradient required for the globally convergent Newton method More...
 
void disable_computation_of_gradient ()
 function to disable the computation of the gradient required for the globally convergent Newton method More...
 
void reset_gradient ()
 function to reset the size of the gradient before each Newton solve More...
 
void get_gradient (DoubleVector &gradient)
 function to access the gradient, provided it has been computed More...
 
- Public Member Functions inherited from oomph::DistributableLinearAlgebraObject
 DistributableLinearAlgebraObject ()
 Default constructor - create a distribution. More...
 
 DistributableLinearAlgebraObject (const DistributableLinearAlgebraObject &matrix)=delete
 Broken copy constructor. More...
 
void operator= (const DistributableLinearAlgebraObject &)=delete
 Broken assignment operator. More...
 
virtual ~DistributableLinearAlgebraObject ()
 Destructor. More...
 
LinearAlgebraDistributiondistribution_pt () const
 access to the LinearAlgebraDistribution More...
 
unsigned nrow () const
 access function to the number of global rows. More...
 
unsigned nrow_local () const
 access function for the num of local rows on this processor. More...
 
unsigned nrow_local (const unsigned &p) const
 access function for the num of local rows on this processor. More...
 
unsigned first_row () const
 access function for the first row on this processor More...
 
unsigned first_row (const unsigned &p) const
 access function for the first row on this processor More...
 
bool distributed () const
 distribution is serial or distributed More...
 
bool distribution_built () const
 if the communicator_pt is null then the distribution is not setup then false is returned, otherwise return true More...
 
void build_distribution (const LinearAlgebraDistribution *const dist_pt)
 setup the distribution of this distributable linear algebra object More...
 
void build_distribution (const LinearAlgebraDistribution &dist)
 setup the distribution of this distributable linear algebra object More...
 
- Public Member Functions inherited from oomph::Preconditioner
 Preconditioner ()
 Constructor. More...
 
 Preconditioner (const Preconditioner &)=delete
 Broken copy constructor. More...
 
void operator= (const Preconditioner &)=delete
 Broken assignment operator. More...
 
virtual ~Preconditioner ()
 Destructor (empty) More...
 
virtual void preconditioner_solve_transpose (const DoubleVector &r, DoubleVector &z)
 Apply the preconditioner. Pure virtual generic interface function. This method should apply the preconditioner operator to the vector r and return the vector z. (broken virtual) More...
 
void setup (DoubleMatrixBase *matrix_pt)
 Setup the preconditioner: store the matrix pointer and the communicator pointer then call preconditioner specific setup() function. More...
 
void setup (const Problem *problem_pt, DoubleMatrixBase *matrix_pt)
 Compatability layer for old preconditioners where problem pointers were needed. The problem pointer is only used to get a communicator pointer. More...
 
void enable_silent_preconditioner_setup ()
 Set up the block preconditioner quietly! More...
 
void disable_silent_preconditioner_setup ()
 Be verbose in the block preconditioner setup. More...
 
virtual DoubleMatrixBasematrix_pt () const
 Get function for matrix pointer. More...
 
virtual void set_matrix_pt (DoubleMatrixBase *matrix_pt)
 Set the matrix pointer. More...
 
virtual const OomphCommunicatorcomm_pt () const
 Get function for comm pointer. More...
 
virtual void set_comm_pt (const OomphCommunicator *const comm_pt)
 Set the communicator pointer. More...
 
double setup_time () const
 Returns the time to setup the preconditioner. More...
 
virtual void turn_into_subsidiary_block_preconditioner (BlockPreconditioner< CRDoubleMatrix > *master_block_prec_pt, const Vector< unsigned > &doftype_in_master_preconditioner_coarse)
 Virtual interface function for making a preconditioner a subsidiary of a block preconditioner. By default nothing is needed, but if this preconditioner is also a block preconditioner then things need to happen. There's an assumption here that the block preconditioner will be in CR form but since that assumption is hard coded all over BlockPreconditioner we're safe. More...
 
virtual void turn_into_subsidiary_block_preconditioner (BlockPreconditioner< CRDoubleMatrix > *master_block_prec_pt, const Vector< unsigned > &doftype_in_master_preconditioner_coarse, const Vector< Vector< unsigned >> &doftype_coarsen_map_coarse)
 Virtual interface function for making a preconditioner a subsidiary of a block preconditioner. By default nothing is needed, but if this preconditioner is also a block preconditioner then things need to happen. Version for coarsening dof-types. More...
 

Additional Inherited Members

- Public Types inherited from oomph::MGSolver< DIM >
typedef Smoother *(* PreSmootherFactoryFctPt) ()
 typedef for a function that returns a pointer to an object of the class Smoother to be used as the pre-smoother More...
 
typedef Smoother *(* PostSmootherFactoryFctPt) ()
 typedef for a function that returns a pointer to an object of the class Smoother to be used as the post-smoother More...
 
- Protected Member Functions inherited from oomph::MGSolver< DIM >
void mg_solve (DoubleVector &result)
 Do the actual solve – this is called through the pure virtual solve function in the LinearSolver base class. The function is stored as protected to allow the MGPreconditioner derived class to use the solver. More...
 
void modify_restriction_matrices ()
 Normalise the rows of the restriction matrices to avoid amplifications when projecting to the coarser level. More...
 
- Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 clear the distribution of this distributable linear algebra object More...
 
- Protected Attributes inherited from oomph::MGSolver< DIM >
unsigned Nvcycle
 Maximum number of V-cycles (this is set as a protected variable so. More...
 
MGProblemMg_problem_pt
 Pointer to the MG problem (deep copy). This is protected to provide access to the MG preconditioner. More...
 
Vector< DoubleVectorRhs_mg_vectors_storage
 Vector to store the RHS vectors (Rhs_mg). This is protected to allow the multigrid preconditioner to assign the RHS vector during preconditioner_solve() More...
 
bool Suppress_v_cycle_output
 Indicates whether or not the V-cycle output should be suppressed. Needs to be protected member data for the multigrid preconditioner to know whether or not to output information with each preconditioning step. More...
 
bool Suppress_all_output
 If this is set to true then all output from the solver is suppressed. This is protected member data so that the multigrid preconditioner knows whether or not to restore the stream pointer. More...
 
std::ostream * Stream_pt
 Pointer to the output stream – defaults to std::cout. This is protected member data to allow the preconditioner to restore normal output if everything was chosen to be suppressed by the user. More...
 
- Protected Attributes inherited from oomph::IterativeLinearSolver
bool Doc_convergence_history
 Flag indicating if the convergence history is to be documented. More...
 
std::ofstream Output_file_stream
 Output file stream for convergence history. More...
 
double Tolerance
 Convergence tolerance. More...
 
unsigned Max_iter
 Maximum number of iterations. More...
 
PreconditionerPreconditioner_pt
 Pointer to the preconditioner. More...
 
double Jacobian_setup_time
 Jacobian setup time. More...
 
double Solution_time
 linear solver solution time More...
 
double Preconditioner_setup_time
 Preconditioner setup time. More...
 
bool Setup_preconditioner_before_solve
 indicates whether the preconditioner should be setup before solve. Default = true; More...
 
bool Throw_error_after_max_iter
 Should we throw an error instead of just returning when we hit the max iterations? More...
 
bool Use_iterative_solver_as_preconditioner
 Use the iterative solver as preconditioner. More...
 
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 (the first time the solve method is called) More...
 
- Protected Attributes inherited from oomph::LinearSolver
bool Enable_resolve
 Boolean that indicates whether the matrix (or its factors, in the case of direct solver) should be stored so that the resolve function can be used. More...
 
bool Doc_time
 Boolean flag that indicates whether the time taken. More...
 
bool Compute_gradient
 flag that indicates whether the gradient required for the globally convergent Newton method should be computed or not More...
 
bool Gradient_has_been_computed
 flag that indicates whether the gradient was computed or not More...
 
DoubleVector Gradient_for_glob_conv_newton_solve
 DoubleVector storing the gradient for the globally convergent Newton method. More...
 
- Protected Attributes inherited from oomph::Preconditioner
bool Silent_preconditioner_setup
 Boolean to indicate whether or not the build should be done silently. More...
 
std::ostream * Stream_pt
 Pointer to the output stream – defaults to std::cout. More...
 
- Static Protected Attributes inherited from oomph::IterativeLinearSolver
static IdentityPreconditioner Default_preconditioner
 Default preconditioner: The base class for preconditioners is a fully functional (if trivial!) preconditioner. More...
 

Detailed Description

template<unsigned DIM>
class oomph::MGPreconditioner< DIM >

An interface to allow scalar MG to be used as a Preconditioner.

Definition at line 734 of file geometric_multigrid.h.

Constructor & Destructor Documentation

◆ MGPreconditioner() [1/2]

template<unsigned DIM>
oomph::MGPreconditioner< DIM >::MGPreconditioner ( MGProblem mg_problem_pt)
inline

Constructor.

Definition at line 738 of file geometric_multigrid.h.

References oomph::MGSolver< DIM >::Nvcycle.

◆ ~MGPreconditioner()

template<unsigned DIM>
oomph::MGPreconditioner< DIM >::~MGPreconditioner ( )
inline

Destructor (empty)

Definition at line 745 of file geometric_multigrid.h.

◆ MGPreconditioner() [2/2]

template<unsigned DIM>
oomph::MGPreconditioner< DIM >::MGPreconditioner ( const MGPreconditioner< DIM > &  )
delete

Broken copy constructor.

Member Function Documentation

◆ clean_up_memory()

template<unsigned DIM>
void oomph::MGPreconditioner< DIM >::clean_up_memory ( )
inlinevirtual

Clean up memory.

Reimplemented from oomph::MGSolver< DIM >.

Definition at line 818 of file geometric_multigrid.h.

◆ operator=()

template<unsigned DIM>
void oomph::MGPreconditioner< DIM >::operator= ( const MGPreconditioner< DIM > &  )
delete

Broken assignment operator.

◆ preconditioner_solve()

template<unsigned DIM>
virtual void oomph::MGPreconditioner< DIM >::preconditioner_solve ( const DoubleVector rhs,
DoubleVector z 
)
inlinevirtual

◆ setup()

template<unsigned DIM>
void oomph::MGPreconditioner< DIM >::setup ( )
inlinevirtual

The documentation for this class was generated from the following file: