Multigrid Class Reference

Multigrid Class Reference#

Reference API: gko::solver::Multigrid Class Reference
Reference API

#include <ginkgo/core/solver/multigrid.hpp>

Inheritance diagram for gko::solver::Multigrid:
[legend]

Classes

class  Factory
 
struct  parameters_type
 

Public Member Functions

bool apply_uses_initial_guess () const override
 
std::vector< std::shared_ptr< const gko::multigrid::MultigridLevel > > get_mg_level_list () const
 
std::vector< std::shared_ptr< const LinOp > > get_pre_smoother_list () const
 
std::vector< std::shared_ptr< const LinOp > > get_mid_smoother_list () const
 
std::vector< std::shared_ptr< const LinOp > > get_post_smoother_list () const
 
std::shared_ptr< const LinOpget_coarsest_solver () const
 
multigrid::cycle get_cycle () const
 
void set_cycle (multigrid::cycle cycle)
 
const parameters_typeget_parameters () const
 
- Public Member Functions inherited from gko::EnableLinOp< Multigrid >
const Multigrid * apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 
Multigrid * apply (ptr_param< const LinOp > b, ptr_param< LinOp > x)
 
const Multigrid * apply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x) const
 
Multigrid * apply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x)
 
- Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< AbstractObject, PolymorphicBase >
std::unique_ptr< AbstractObject > create_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractObject > create_default () const
 
std::unique_ptr< AbstractObject > clone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractObject > clone () const
 
AbstractObject * copy_from (const PolymorphicObject *other)
 
template<typename Derived >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractObject > * copy_from (std::unique_ptr< Derived > &&other)
 
template<typename Derived >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractObject > * copy_from (const std::unique_ptr< Derived > &other)
 
AbstractObject * copy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
AbstractObject * move_from (ptr_param< PolymorphicObject > other)
 
AbstractObject * clear ()
 
- Public Member Functions inherited from gko::PolymorphicObject
PolymorphicObjectoperator= (const PolymorphicObject &)
 
std::unique_ptr< PolymorphicObjectcreate_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< PolymorphicObjectcreate_default () const
 
std::unique_ptr< PolymorphicObjectclone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< PolymorphicObjectclone () const
 
PolymorphicObjectcopy_from (const PolymorphicObject *other)
 
template<typename Derived , typename Deleter >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * copy_from (std::unique_ptr< Derived, Deleter > &&other)
 
template<typename Derived , typename Deleter >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * copy_from (const std::unique_ptr< Derived, Deleter > &other)
 
PolymorphicObjectcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
PolymorphicObjectmove_from (ptr_param< PolymorphicObject > other)
 
PolymorphicObjectclear ()
 
std::shared_ptr< const Executorget_executor () const noexcept
 
- Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject >
void add_logger (std::shared_ptr< const Logger > logger) override
 
void remove_logger (const Logger *logger) override
 
void remove_logger (ptr_param< const Logger > logger)
 
const std::vector< std::shared_ptr< const Logger > > & get_loggers () const override
 
void clear_loggers () override
 
- Public Member Functions inherited from gko::log::Loggable
void remove_logger (ptr_param< const Logger > logger)
 
- Public Member Functions inherited from gko::EnablePolymorphicAssignment< ConcreteType, ResultType >
void convert_to (result_type *result) const override
 
void move_to (result_type *result) override
 
- Public Member Functions inherited from gko::ConvertibleTo< ResultType >
void convert_to (ptr_param< result_type > result) const
 
void move_to (ptr_param< result_type > result)
 
- Public Member Functions inherited from gko::solver::EnableSolverBase< Multigrid >
EnableSolverBaseoperator= (const EnableSolverBase &other)
 
EnableSolverBaseoperator= (EnableSolverBase &&other)
 
 EnableSolverBase (std::shared_ptr< const LinOp > system_matrix)
 
 EnableSolverBase (const EnableSolverBase &other)
 
 EnableSolverBase (EnableSolverBase &&other)
 
int get_num_workspace_ops () const override
 
std::vector< std::string > get_workspace_op_names () const override
 
std::vector< int > get_workspace_scalars () const override
 
std::vector< int > get_workspace_vectors () const override
 
- Public Member Functions inherited from gko::solver::SolverBase< MatrixType >
std::shared_ptr< const MatrixType > get_system_matrix () const
 
- Public Member Functions inherited from gko::solver::EnableIterativeBase< Multigrid >
EnableIterativeBaseoperator= (const EnableIterativeBase &other)
 
EnableIterativeBaseoperator= (EnableIterativeBase &&other)
 
 EnableIterativeBase (std::shared_ptr< const stop::CriterionFactory > stop_factory)
 
 EnableIterativeBase (const EnableIterativeBase &other)
 
 EnableIterativeBase (EnableIterativeBase &&other)
 
void set_stop_criterion_factory (std::shared_ptr< const stop::CriterionFactory > new_stop_factory) override
 
- Public Member Functions inherited from gko::solver::IterativeBase
std::shared_ptr< const stop::CriterionFactoryget_stop_criterion_factory () const
 

Static Public Member Functions

static auto build () -> decltype(Factory ::create())
 
static parameters_type parse (const config::pnode &config, const config::registry &context, const config::type_descriptor &td_for_child=config::make_type_descriptor<>())
 

Protected Member Functions

void apply_impl (const LinOp *b, LinOp *x) const override
 
void apply_impl (const LinOp *alpha, const LinOp *b, const LinOp *beta, LinOp *x) const override
 
void apply_with_initial_guess_impl (const LinOp *b, LinOp *x, initial_guess_mode guess) const override
 
void apply_with_initial_guess_impl (const LinOp *alpha, const LinOp *b, const LinOp *beta, LinOp *x, initial_guess_mode guess) const override
 
template<typename VectorType >
void apply_dense_impl (const VectorType *b, VectorType *x, initial_guess_mode guess) const
 
void generate ()
 
 Multigrid (std::shared_ptr< const Executor > exec)
 
 Multigrid (const Factory *factory, std::shared_ptr< const LinOp > system_matrix)
 
void validate ()
 
void verify_legal_length (bool checked, size_type len, size_type ref_len)
 
void create_state () const
 
- Protected Member Functions inherited from gko::EnableLinOp< Multigrid >
Multigrid * self () noexcept
 
const Multigrid * self () const noexcept
 
- Protected Member Functions inherited from gko::EnablePolymorphicObject< ConcreteObject, PolymorphicBase >
std::unique_ptr< PolymorphicObjectcreate_default_impl (std::shared_ptr< const Executor > exec) const override
 
PolymorphicObjectcopy_from_impl (const PolymorphicObject *other) override
 
PolymorphicObjectcopy_from_impl (std::unique_ptr< PolymorphicObject > other) override
 
PolymorphicObjectmove_from_impl (PolymorphicObject *other) override
 
PolymorphicObjectmove_from_impl (std::unique_ptr< PolymorphicObject > other) override
 
PolymorphicObjectclear_impl () override
 
- Protected Member Functions inherited from gko::PolymorphicObject
 PolymorphicObject (std::shared_ptr< const Executor > exec)
 
 PolymorphicObject (const PolymorphicObject &other)
 
- Protected Member Functions inherited from gko::log::EnableLogging< PolymorphicObject >
void log (Params &&... params) const
 
- Protected Member Functions inherited from gko::solver::EnableSolverBase< Multigrid >
void set_system_matrix (std::shared_ptr< const LinOp > new_system_matrix)
 
void setup_workspace () const
 
- Protected Member Functions inherited from gko::solver::SolverBase< MatrixType >
void set_system_matrix_base (std::shared_ptr< const MatrixType > system_matrix)
 
- Protected Member Functions inherited from gko::solver::EnableApplyWithInitialGuess< Multigrid >
 EnableApplyWithInitialGuess (initial_guess_mode guess=initial_guess_mode::provided)
 
void apply_with_initial_guess (const LinOp *b, LinOp *x, initial_guess_mode guess) const override
 
void apply_with_initial_guess (const LinOp *alpha, const LinOp *b, const LinOp *beta, LinOp *x, initial_guess_mode guess) const override
 
Multigridself () noexcept
 
const Multigridself () const noexcept
 
- Protected Member Functions inherited from gko::solver::ApplyWithInitialGuess
void apply_with_initial_guess (ptr_param< const LinOp > b, ptr_param< LinOp > x, initial_guess_mode guess) const
 
void apply_with_initial_guess (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x, initial_guess_mode guess) const
 
initial_guess_mode get_default_initial_guess () const
 
 ApplyWithInitialGuess (initial_guess_mode guess=initial_guess_mode::provided)
 
void set_default_initial_guess (initial_guess_mode guess)
 

Friends

class EnableLinOp< Multigrid >
 
class EnablePolymorphicObject< Multigrid, LinOp >
 
class EnableApplyWithInitialGuess< Multigrid >
 

Additional Inherited Members

- Public Types inherited from gko::EnablePolymorphicAssignment< ConcreteType, ResultType >
using result_type = ResultType
 
- Public Types inherited from gko::ConvertibleTo< ResultType >
using result_type = ResultType
 
- Protected Attributes inherited from gko::log::EnableLogging< PolymorphicObject >
std::vector< std::shared_ptr< const Logger > > loggers_
 

Detailed Description

Multigrid methods have a hierarchy of many levels, whose corase level is a subset of the fine level, of the problem. The coarse level solves the system on the residual of fine level and fine level will use the coarse solution to correct its own result. Multigrid solves the problem by relatively cheap step in each level and refining the result when prolongating back.

The main step of each level

  • Presmooth (solve on the fine level)
  • Calculate residual
  • Restrict (reduce the problem dimension)
  • Solve residual in next level
  • Prolongate (return to the fine level size)
  • Postsmooth (correct the answer in fine level)

Ginkgo uses the index from 0 for finest level (original problem size) ~ N for the coarsest level (the coarsest solver), and its level counts is N (N multigrid level generation).

Member Function Documentation

◆ apply_uses_initial_guess()

bool gko::solver::Multigrid::apply_uses_initial_guess ( ) const
inlineoverride

Return true as iterative solvers use the data in x as an initial guess or false if multigrid always set the input as zero

Returns
bool it is related to parameters variable zero_guess

References gko::solver::ApplyWithInitialGuess::get_default_initial_guess(), and gko::solver::provided.

◆ apply_with_initial_guess_impl() [1/2]

void gko::solver::Multigrid::apply_with_initial_guess_impl ( const LinOp alpha,
const LinOp b,
const LinOp beta,
LinOp x,
initial_guess_mode  guess 
) const
overrideprotectedvirtual

The class should override this method and must modify the input vectors according to the initial_guess_mode

Implements gko::solver::EnableApplyWithInitialGuess< Multigrid >.

◆ apply_with_initial_guess_impl() [2/2]

void gko::solver::Multigrid::apply_with_initial_guess_impl ( const LinOp b,
LinOp x,
initial_guess_mode  guess 
) const
overrideprotectedvirtual

The class should override this method and must modify the input vectors according to the initial_guess_mode

Implements gko::solver::EnableApplyWithInitialGuess< Multigrid >.

◆ generate()

void gko::solver::Multigrid::generate ( )
protected

Generates the analysis structure from the system matrix and the right hand side needed for the level solver.

◆ get_coarsest_solver()

std::shared_ptr< const LinOp > gko::solver::Multigrid::get_coarsest_solver ( ) const
inline

Gets the operator at the coarsest level.

Returns
the coarsest operator

◆ get_cycle()

multigrid::cycle gko::solver::Multigrid::get_cycle ( ) const
inline

Get the cycle of multigrid

Returns
the multigrid::cycle

References gko::solver::Multigrid::parameters_type::cycle.

◆ get_mg_level_list()

std::vector< std::shared_ptr< const gko::multigrid::MultigridLevel > > gko::solver::Multigrid::get_mg_level_list ( ) const
inline

Gets the list of MultigridLevel operators.

Returns
the list of MultigridLevel operators

◆ get_mid_smoother_list()

std::vector< std::shared_ptr< const LinOp > > gko::solver::Multigrid::get_mid_smoother_list ( ) const
inline

Gets the list of mid-smoother operators.

Returns
the list of mid-smoother operators

◆ get_post_smoother_list()

std::vector< std::shared_ptr< const LinOp > > gko::solver::Multigrid::get_post_smoother_list ( ) const
inline

Gets the list of post-smoother operators.

Returns
the list of post-smoother operators

◆ get_pre_smoother_list()

std::vector< std::shared_ptr< const LinOp > > gko::solver::Multigrid::get_pre_smoother_list ( ) const
inline

Gets the list of pre-smoother operators.

Returns
the list of pre-smoother operators

◆ parse()

static parameters_type gko::solver::Multigrid::parse ( const config::pnode config,
const config::registry context,
const config::type_descriptor td_for_child = config::make_type_descriptor<>() 
)
static

Create the parameters from the property_tree. Because this is directly tied to the specific type, the value/index type settings within config are ignored and type_descriptor is only used for children configs.

Parameters
configthe property tree for setting
contextthe registry
td_for_childthe type descriptor for children configs
Returns
parameters
Note
Multigrid does not support the selector option in file config

◆ set_cycle()

void gko::solver::Multigrid::set_cycle ( multigrid::cycle  cycle)
inline

Set the cycle of multigrid

Parameters
multigrid::cyclethe new cycle

References gko::solver::Multigrid::parameters_type::cycle.

◆ validate()

void gko::solver::Multigrid::validate ( )
protected

validate checks the given parameters are valid or not.

◆ verify_legal_length()

void gko::solver::Multigrid::verify_legal_length ( bool  checked,
size_type  len,
size_type  ref_len 
)
protected

verify_legal_length is to check whether the given len is legal for ref_len if checked is activated. Throw GKO_NOT_SUPPORTED if the length is illegal.

Parameters
checkedwhether check the length
lenthe length of input
ref_lenthe length of reference

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