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)
 
 ~MGSolver ()
 Delete any dynamically allocated data. More...
 
void set_self_test_vector ()
 
void self_test ()
 
void restriction_self_test ()
 
void interpolation_self_test ()
 
void plot (const unsigned &hierarchy_level, const DoubleVector &input_vector, const std::string &filename)
 
void disable_v_cycle_output ()
 
void disable_output ()
 
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...
 
unsignednpost_smooth ()
 Return the number of post-smoothing iterations (lvalue) More...
 
unsignednpre_smooth ()
 Return the number of pre-smoothing iterations (lvalue) More...
 
void pre_smooth (const unsigned &level)
 
void post_smooth (const unsigned &level)
 
double residual_norm (const unsigned &level)
 
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)
 
void interpolation_matrix_set (const unsigned &level, Vector< double > &value, Vector< int > &col_index, Vector< int > &row_st, unsigned &ncol, unsigned &nrow)
 
void set_restriction_matrices_as_interpolation_transposes ()
 
void restrict_residual (const unsigned &level)
 
void interpolate_and_correct (const unsigned &level)
 
void level_up_local_coord_of_node (const int &son_type, Vector< double > &s)
 
void setup_interpolation_matrices ()
 Setup the interpolation matrix on each level. More...
 
void setup_interpolation_matrices_unstructured ()
 Setup the interpolation matrices. More...
 
void setup_transfer_matrices ()
 Setup the transfer matrices on each level. More...
 
void full_setup ()
 Runs a full setup of the MG solver. More...
 
void solve (Problem *const &problem_pt, DoubleVector &result)
 
unsigned iterations () const
 Number of iterations. More...
 
unsignedmax_iter ()
 Number of iterations. More...
 
void level_up_local_coord_of_node (const int &son_type, Vector< double > &s)
 
void level_up_local_coord_of_node (const int &son_type, Vector< double > &s)
 
- Public Member Functions inherited from oomph::IterativeLinearSolver
 IterativeLinearSolver ()
 
 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...
 
doubletolerance ()
 Access to convergence tolerance. More...
 
unsignedmax_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="")
 
void close_convergence_history_file_stream ()
 Close convergence history output stream. More...
 
double jacobian_setup_time () const
 
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 ()
 
void disable_iterative_solver_as_preconditioner ()
 
- 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 ()
 
virtual void disable_resolve ()
 
virtual void solve (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &result)
 
virtual void solve (DoubleMatrixBase *const &matrix_pt, const Vector< double > &rhs, Vector< double > &result)
 
virtual void solve_transpose (Problem *const &problem_pt, DoubleVector &result)
 
virtual void solve_transpose (DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &result)
 
virtual void solve_transpose (DoubleMatrixBase *const &matrix_pt, const Vector< double > &rhs, Vector< double > &result)
 
virtual void resolve (const DoubleVector &rhs, DoubleVector &result)
 
virtual void resolve_transpose (const DoubleVector &rhs, DoubleVector &result)
 
virtual void enable_computation_of_gradient ()
 
void disable_computation_of_gradient ()
 
void reset_gradient ()
 
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
 
void build_distribution (const LinearAlgebraDistribution *const dist_pt)
 
void build_distribution (const LinearAlgebraDistribution &dist)
 
- 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)
 
void setup (DoubleMatrixBase *matrix_pt)
 
void setup (const Problem *problem_pt, DoubleMatrixBase *matrix_pt)
 
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 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)
 

Additional Inherited Members

- Public Types inherited from oomph::MGSolver< DIM >
typedef Smoother *(* PreSmootherFactoryFctPt) ()
 
typedef Smoother *(* PostSmootherFactoryFctPt) ()
 
- Protected Member Functions inherited from oomph::MGSolver< DIM >
void mg_solve (DoubleVector &result)
 Linear solver. More...
 
void modify_restriction_matrices ()
 Modify the restriction matrices. More...
 
- Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 
- Protected Attributes inherited from oomph::MGSolver< DIM >
unsigned Nvcycle
 
MGProblemMg_problem_pt
 
Vector< DoubleVectorRhs_mg_vectors_storage
 
bool Suppress_v_cycle_output
 
bool Suppress_all_output
 
std::ostream * Stream_pt
 
- Protected Attributes inherited from oomph::IterativeLinearSolver
bool Doc_convergence_history
 
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
 
bool Throw_error_after_max_iter
 
bool Use_iterative_solver_as_preconditioner
 Use the iterative solver as preconditioner. More...
 
bool First_time_solve_when_used_as_preconditioner
 
- Protected Attributes inherited from oomph::LinearSolver
bool Enable_resolve
 
bool Doc_time
 Boolean flag that indicates whether the time taken. More...
 
bool Compute_gradient
 
bool Gradient_has_been_computed
 flag that indicates whether the gradient was computed or not More...
 
DoubleVector Gradient_for_glob_conv_newton_solve
 
- 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
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ MGPreconditioner() [1/2]

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

Constructor.

738  : MGSolver<DIM>(mg_problem_pt)
739  {
740  // Set the number of V-cycles to be 1 (as expected as a preconditioner)
741  this->Nvcycle = 2;
742  } // End of MGPreconditioner (constructor)
unsigned Nvcycle
Definition: geometric_multigrid.h:622

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

◆ ~MGPreconditioner()

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

Destructor (empty)

745 {};

◆ 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 >.

818 {}

◆ 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

Function applies MG to the vector r for a full solve.

Implements oomph::Preconditioner.

782  {
783 #ifdef PARANOID
784  if (this->Mg_problem_pt->ndof() != rhs.nrow())
785  {
786  throw OomphLibError("Matrix and RHS vector sizes incompatible.",
789  }
790 #endif
791 
792  // Set the right-hand side vector on the finest level to r
793  this->Rhs_mg_vectors_storage[0] = rhs;
794 
795  // Run the MG method and assign the solution to z
796  this->mg_solve(z);
797 
798  // Only output if the V-cycle output isn't suppressed
799  if (!(this->Suppress_v_cycle_output))
800  {
801  // Notify user that the hierarchy of levels is complete
802  oomph_info
803  << "\n==========Multigrid Preconditioner Solve Complete========="
804  << "\n"
805  << std::endl;
806  }
807 
808  // Only enable and assign the stream pointer again if we originally
809  // suppressed everything otherwise it won't be set yet
810  if (this->Suppress_all_output)
811  {
812  // Now enable the stream pointer again
813  oomph_info.stream_pt() = this->Stream_pt;
814  }
815  } // End of preconditioner_solve
bool Suppress_all_output
Definition: geometric_multigrid.h:642
Vector< DoubleVector > Rhs_mg_vectors_storage
Definition: geometric_multigrid.h:631
std::ostream * Stream_pt
Definition: geometric_multigrid.h:648
void mg_solve(DoubleVector &result)
Linear solver.
Definition: geometric_multigrid.h:2525
bool Suppress_v_cycle_output
Definition: geometric_multigrid.h:637
MGProblem * Mg_problem_pt
Definition: geometric_multigrid.h:626
std::ostream *& stream_pt()
Access function for the stream pointer.
Definition: oomph_definitions.h:464
unsigned long ndof() const
Return the number of dofs.
Definition: problem.h:1674
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::MGSolver< DIM >::Mg_problem_pt, oomph::MGSolver< DIM >::mg_solve(), oomph::Problem::ndof(), oomph::DistributableLinearAlgebraObject::nrow(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::oomph_info, oomph::MGSolver< DIM >::Rhs_mg_vectors_storage, oomph::MGSolver< DIM >::Stream_pt, oomph::OomphInfo::stream_pt(), oomph::MGSolver< DIM >::Suppress_all_output, and oomph::MGSolver< DIM >::Suppress_v_cycle_output.

◆ setup()

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

Function to set up a preconditioner for the linear system.

Implements oomph::Preconditioner.

755  {
756 #ifdef OOMPH_HAS_MPI
757  // Make sure that this is running in serial. Can't guarantee it'll
758  // work when the problem is distributed over several processors
759  if (MPI_Helpers::communicator_pt()->nproc() > 1)
760  {
761  // Throw a warning
762  OomphLibWarning("Can't guarantee the MG solver will work in parallel!",
765  }
766 #endif
767 
768  // Call the helper function that actually does all the work
769  this->full_setup();
770 
771  // Only enable and assign the stream pointer again if we originally
772  // suppressed everything otherwise it won't be set yet
773  if (this->Suppress_all_output)
774  {
775  // Now enable the stream pointer again
776  oomph_info.stream_pt() = this->Stream_pt;
777  }
778  } // End of setup
void full_setup()
Runs a full setup of the MG solver.
Definition: geometric_multigrid.h:826
static OomphCommunicator * communicator_pt()
access to the global oomph-lib communicator
Definition: oomph_utilities.cc:1046

References oomph::MPI_Helpers::communicator_pt(), oomph::MGSolver< DIM >::full_setup(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::oomph_info, oomph::MGSolver< DIM >::Stream_pt, oomph::OomphInfo::stream_pt(), and oomph::MGSolver< DIM >::Suppress_all_output.


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