oomph::Smoother Class Referenceabstract

#include <iterative_linear_solver.h>

+ Inheritance diagram for oomph::Smoother:

Public Member Functions

 Smoother ()
 Empty constructor. More...
 
virtual ~Smoother ()
 Virtual empty destructor. More...
 
virtual void smoother_solve (const DoubleVector &rhs, DoubleVector &result)=0
 
virtual void smoother_setup (DoubleMatrixBase *matrix_pt)=0
 Set up the smoother for the matrix specified by the pointer. More...
 
template<typename MATRIX >
void check_validity_of_solve_helper_inputs (MATRIX *const &matrix_pt, const DoubleVector &rhs, DoubleVector &solution, const double &n_dof)
 
- 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...
 
virtual unsigned iterations () const =0
 Number of iterations taken. 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 (Problem *const &problem_pt, DoubleVector &result)=0
 
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 clean_up_memory ()
 
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)
 

Protected Attributes

bool Use_as_smoother
 
- 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
 

Additional Inherited Members

- Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 
- Static Protected Attributes inherited from oomph::IterativeLinearSolver
static IdentityPreconditioner Default_preconditioner
 

Detailed Description

//////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// Smoother class: The smoother class is designed for to be used in conjunction with multigrid. The action of the smoother should reduce the high frequency errors. These methods are inefficient as stand-alone solvers.

Constructor & Destructor Documentation

◆ Smoother()

oomph::Smoother::Smoother ( )
inline

Empty constructor.

553 : Use_as_smoother(false) {}
bool Use_as_smoother
Definition: iterative_linear_solver.h:585

◆ ~Smoother()

virtual oomph::Smoother::~Smoother ( )
inlinevirtual

Virtual empty destructor.

556 {};

Member Function Documentation

◆ check_validity_of_solve_helper_inputs()

template<typename MATRIX >
void oomph::Smoother::check_validity_of_solve_helper_inputs ( MATRIX *const &  matrix_pt,
const DoubleVector rhs,
DoubleVector solution,
const double n_dof 
)

Self-test to check that all the dimensions of the inputs to solve helper are consistent and everything that needs to be built, is.

/////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// Self-test to be called inside solve_helper to ensure that all inputs are consistent and everything that needs to be built, is.

1033  {
1034  // Check that if the matrix is not distributable then it should not
1035  // be distributed
1036  if (dynamic_cast<DistributableLinearAlgebraObject*>(matrix_pt) != 0)
1037  {
1038  if (dynamic_cast<DistributableLinearAlgebraObject*>(matrix_pt)
1039  ->distributed())
1040  {
1041  std::ostringstream error_message_stream;
1042  error_message_stream << "The matrix must not be distributed.";
1043  throw OomphLibError(error_message_stream.str(),
1046  }
1047  } // if (dynamic_cast<DistributableLinearAlgebraObject*>(matrix_pt)!=0)
1048  // Check that this rhs distribution is setup
1049  if (!rhs.built())
1050  {
1051  std::ostringstream error_message_stream;
1052  error_message_stream << "The rhs vector distribution must be setup.";
1053  throw OomphLibError(error_message_stream.str(),
1056  }
1057  // Check that the rhs has the right number of global rows
1058  if (rhs.nrow() != n_dof)
1059  {
1060  std::ostringstream error_message_stream;
1061  error_message_stream << "RHS does not have the same dimension as "
1062  << "the linear system";
1063  throw OomphLibError(error_message_stream.str(),
1066  }
1067  // Check that the rhs is not distributed
1068  if (rhs.distribution_pt()->distributed())
1069  {
1070  std::ostringstream error_message_stream;
1071  error_message_stream << "The rhs vector must not be distributed.";
1072  throw OomphLibError(error_message_stream.str(),
1075  }
1076  // Check that if the result is setup it matches the distribution
1077  // of the rhs
1078  if (solution.built())
1079  {
1080  if (!(*rhs.distribution_pt() == *solution.distribution_pt()))
1081  {
1082  std::ostringstream error_message_stream;
1083  error_message_stream << "If the result distribution is setup then it "
1084  << "must be the same as the rhs distribution";
1085  throw OomphLibError(error_message_stream.str(),
1088  }
1089  } // if (solution.built())
1090  } // End of check_validity_of_solve_helper_inputs
bool distributed() const
distribution is serial or distributed
Definition: linear_algebra_distribution.h:493
DistributableLinearAlgebraObject()
Default constructor - create a distribution.
Definition: linear_algebra_distribution.h:438
void solution(const Vector< double > &x, Vector< double > &u)
Definition: two_d_biharmonic.cc:113
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::DoubleVector::built(), oomph::LinearAlgebraDistribution::distributed(), oomph::DistributableLinearAlgebraObject::distributed(), oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::DistributableLinearAlgebraObject::nrow(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and BiharmonicTestFunctions1::solution().

◆ smoother_setup()

virtual void oomph::Smoother::smoother_setup ( DoubleMatrixBase matrix_pt)
pure virtual

Set up the smoother for the matrix specified by the pointer.

Implemented in oomph::DampedJacobi< MATRIX >, oomph::GS< CRDoubleMatrix >, and oomph::GS< MATRIX >.

◆ smoother_solve()

virtual void oomph::Smoother::smoother_solve ( const DoubleVector rhs,
DoubleVector result 
)
pure virtual

The smoother_solve function performs fixed number of iterations on the system A*result=rhs. The number of (smoothing) iterations is the same as the max. number of iterations in the underlying IterativeLinearSolver class. Note that the result vector MUST NOT re-initialised to zero (as it would typically be when the Smoother is called as a iterative linear solver).

Implemented in oomph::DampedJacobi< MATRIX >, oomph::GS< CRDoubleMatrix >, and oomph::GS< MATRIX >.

Member Data Documentation

◆ Use_as_smoother

bool oomph::Smoother::Use_as_smoother
protected

When a derived class object is being used as a smoother in the MG solver (or elsewhere) the residual norm does not need to be calculated because we're simply performing a fixed number of (smoothing) iterations. This boolean is used as a flag to indicate that the IterativeLinearSolver (which this class is by inheritance) is supposed to act in this way.

Referenced by oomph::GS< MATRIX >::smoother_solve(), oomph::GS< CRDoubleMatrix >::smoother_solve(), oomph::DampedJacobi< MATRIX >::smoother_solve(), oomph::GS< MATRIX >::solve(), oomph::DampedJacobi< MATRIX >::solve(), oomph::GS< CRDoubleMatrix >::solve(), and oomph::GS< CRDoubleMatrix >::solve_helper().


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