Ginkgo Generated from branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
gko::solver::Multigrid Class Reference

Multigrid methods have a hierarchy of many levels, whose corase level is a subset of the fine level, of the problem. More...

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

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

Classes

class  Factory
 
struct  parameters_type
 

Public Member Functions

bool apply_uses_initial_guess () const override
 Return true as iterative solvers use the data in x as an initial guess or false if multigrid always set the input as zero.
 
std::vector< std::shared_ptr< const gko::multigrid::MultigridLevel > > get_mg_level_list () const
 Gets the list of MultigridLevel operators.
 
std::vector< std::shared_ptr< const LinOp > > get_pre_smoother_list () const
 Gets the list of pre-smoother operators.
 
std::vector< std::shared_ptr< const LinOp > > get_mid_smoother_list () const
 Gets the list of mid-smoother operators.
 
std::vector< std::shared_ptr< const LinOp > > get_post_smoother_list () const
 Gets the list of post-smoother operators.
 
std::shared_ptr< const LinOpget_coarsest_solver () const
 Gets the operator at the coarsest level.
 
multigrid::cycle get_cycle () const
 Get the cycle of multigrid.
 
void set_cycle (multigrid::cycle cycle)
 Set the cycle of multigrid.
 
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< Multigrid, LinOp >
std::unique_ptr< Multigrid > create_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< Multigrid > create_default () const
 
std::unique_ptr< Multigrid > clone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< Multigrid > clone () const
 
Multigrid * copy_from (const PolymorphicObject *other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, Multigrid > * copy_from (std::unique_ptr< Derived > &&other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, Multigrid > * copy_from (const std::unique_ptr< Derived > &other)
 
Multigrid * copy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
Multigrid * move_from (ptr_param< PolymorphicObject > other)
 
Multigrid * clear ()
 
- Public Member Functions inherited from gko::LinOp
LinOpapply (ptr_param< const LinOp > b, ptr_param< LinOp > x)
 Applies a linear operator to a vector (or a sequence of vectors).
 
const LinOpapply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 
LinOpapply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x)
 Performs the operation x = alpha * op(b) + beta * x.
 
const LinOpapply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x) const
 
const dim< 2 > & get_size () const noexcept
 Returns the size of the operator.
 
LinOpoperator= (const LinOp &)=default
 Copy-assigns a LinOp.
 
LinOpoperator= (LinOp &&other)
 Move-assigns a LinOp.
 
 LinOp (const LinOp &)=default
 Copy-constructs a LinOp.
 
 LinOp (LinOp &&other)
 Move-constructs a LinOp.
 
- Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< LinOp >
std::unique_ptr< LinOpcreate_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< LinOpcreate_default () const
 
std::unique_ptr< LinOpclone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< LinOpclone () const
 
LinOpcopy_from (const PolymorphicObject *other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, LinOp > * copy_from (std::unique_ptr< Derived > &&other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, LinOp > * copy_from (const std::unique_ptr< Derived > &other)
 
LinOpcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
LinOpmove_from (ptr_param< PolymorphicObject > other)
 
LinOpclear ()
 
- Public Member Functions inherited from gko::PolymorphicObject
PolymorphicObjectoperator= (const PolymorphicObject &)
 
std::unique_ptr< PolymorphicObjectcreate_default (std::shared_ptr< const Executor > exec) const
 Creates a new "default" object of the same dynamic type as this object.
 
std::unique_ptr< PolymorphicObjectcreate_default () const
 Creates a new "default" object of the same dynamic type as this object.
 
std::unique_ptr< PolymorphicObjectclone (std::shared_ptr< const Executor > exec) const
 Creates a clone of the object.
 
std::unique_ptr< PolymorphicObjectclone () const
 Creates a clone of the object.
 
PolymorphicObjectcopy_from (const PolymorphicObject *other)
 Copies another object into this object.
 
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)
 Moves another object into this object.
 
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)
 Copies another object into this object.
 
PolymorphicObjectcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 Copies another object into this object.
 
PolymorphicObjectmove_from (ptr_param< PolymorphicObject > other)
 Moves another object into this object.
 
PolymorphicObjectclear ()
 Transforms the object into its default state.
 
std::shared_ptr< const Executorget_executor () const noexcept
 Returns the Executor of the object.
 
- Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject >
void add_logger (std::shared_ptr< const Logger > logger) override
 Adds a new logger to the list of subscribed loggers.
 
void remove_logger (const Logger *logger) override
 Removes a logger from the list of subscribed loggers.
 
void remove_logger (ptr_param< const Logger > logger)
 
const std::vector< std::shared_ptr< const Logger > > & get_loggers () const override
 Returns the vector containing all loggers registered at this object.
 
void clear_loggers () override
 Remove all loggers registered at this object.
 
- Public Member Functions inherited from gko::log::Loggable
void remove_logger (ptr_param< const Logger > logger)
 
- Public Member Functions inherited from gko::EnablePolymorphicAssignment< Multigrid >
void convert_to (result_type *result) const override
 
void move_to (result_type *result) override
 
- Public Member Functions inherited from gko::ConvertibleTo< Multigrid >
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)
 Creates a shallow copy of the provided system matrix, clones it onto this executor if executors don't match.
 
EnableSolverBaseoperator= (EnableSolverBase &&other)
 Moves the provided system matrix, clones it onto this executor if executors don't match.
 
 EnableSolverBase (std::shared_ptr< const LinOp > system_matrix)
 
 EnableSolverBase (const EnableSolverBase &other)
 Creates a shallow copy of the provided system matrix.
 
 EnableSolverBase (EnableSolverBase &&other)
 Moves the provided system matrix.
 
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
 Returns the IDs of all scalars (workspace vectors with system dimension-independent size, usually 1 x num_rhs).
 
std::vector< int > get_workspace_vectors () const override
 Returns the IDs of all vectors (workspace vectors with system dimension-dependent size, usually system_matrix_size x num_rhs).
 
- Public Member Functions inherited from gko::solver::SolverBase< LinOp >
std::shared_ptr< const LinOpget_system_matrix () const
 Returns the system matrix, with its concrete type, used by the solver.
 
- Public Member Functions inherited from gko::solver::EnableIterativeBase< Multigrid >
EnableIterativeBaseoperator= (const EnableIterativeBase &other)
 Creates a shallow copy of the provided stopping criterion, clones it onto this executor if executors don't match.
 
EnableIterativeBaseoperator= (EnableIterativeBase &&other)
 Moves the provided stopping criterion, clones it onto this executor if executors don't match.
 
 EnableIterativeBase (std::shared_ptr< const stop::CriterionFactory > stop_factory)
 
 EnableIterativeBase (const EnableIterativeBase &other)
 Creates a shallow copy of the provided stopping criterion.
 
 EnableIterativeBase (EnableIterativeBase &&other)
 Moves the provided stopping criterion.
 
void set_stop_criterion_factory (std::shared_ptr< const stop::CriterionFactory > new_stop_factory) override
 Sets the stopping criterion of the solver.
 
- Public Member Functions inherited from gko::solver::IterativeBase
std::shared_ptr< const stop::CriterionFactoryget_stop_criterion_factory () const
 Gets the stopping criterion factory of the solver.
 

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<>())
 Create the parameters from the property_tree.
 

Friends

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

Additional Inherited Members

- Public Types inherited from gko::EnablePolymorphicAssignment< Multigrid >
using result_type
 
- Public Types inherited from gko::ConvertibleTo< Multigrid >
using result_type
 

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
inlineoverridevirtual

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

Reimplemented from gko::LinOp.

References gko::solver::provided.

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


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