 |
Ginkgo
Generated from pipelines/2969282958 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_SOLVER_MULTIGRID_HPP_
6 #define GKO_PUBLIC_CORE_SOLVER_MULTIGRID_HPP_
14 #include <ginkgo/core/base/abstract_factory.hpp>
15 #include <ginkgo/core/base/array.hpp>
16 #include <ginkgo/core/base/exception_helpers.hpp>
17 #include <ginkgo/core/base/lin_op.hpp>
18 #include <ginkgo/core/base/math.hpp>
19 #include <ginkgo/core/base/precision_dispatch.hpp>
20 #include <ginkgo/core/base/types.hpp>
21 #include <ginkgo/core/config/config.hpp>
22 #include <ginkgo/core/config/registry.hpp>
23 #include <ginkgo/core/config/type_descriptor.hpp>
24 #include <ginkgo/core/log/logger.hpp>
25 #include <ginkgo/core/matrix/dense.hpp>
26 #include <ginkgo/core/matrix/identity.hpp>
27 #include <ginkgo/core/multigrid/multigrid_level.hpp>
28 #include <ginkgo/core/solver/solver_base.hpp>
29 #include <ginkgo/core/stop/combined.hpp>
30 #include <ginkgo/core/stop/criterion.hpp>
166 return this->get_default_initial_guess() ==
175 std::vector<std::shared_ptr<const gko::multigrid::MultigridLevel>>
178 return mg_level_list_;
188 return pre_smoother_list_;
198 return mid_smoother_list_;
208 return post_smoother_list_;
218 return coarsest_solver_;
244 std::vector<std::shared_ptr<const LinOpFactory>>
290 std::vector<std::shared_ptr<const LinOpFactory>>
298 std::vector<std::shared_ptr<const LinOpFactory>>
308 std::vector<std::shared_ptr<const LinOpFactory>>
349 std::vector<std::shared_ptr<const LinOpFactory>>
383 multigrid::cycle::v);
438 std::unique_ptr<LinOpFactory::ReuseData> level;
439 std::unique_ptr<LinOpFactory::ReuseData> pre_smoother;
440 std::unique_ptr<LinOpFactory::ReuseData> mid_smoother;
441 std::unique_ptr<LinOpFactory::ReuseData> post_smoother;
444 bool initialized_ =
false;
446 std::vector<level_data> levels_;
448 std::unique_ptr<LinOpFactory::ReuseData> coarsest_solver_;
468 config::make_type_descriptor<>());
471 void apply_impl(
const LinOp* b,
LinOp* x)
const override;
474 LinOp* x)
const override;
476 void apply_with_initial_guess_impl(
const LinOp* b,
LinOp* x,
479 void apply_with_initial_guess_impl(
const LinOp* alpha,
const LinOp* b,
483 template <
typename VectorType>
484 void apply_dense_impl(
const VectorType* b, VectorType* x,
511 void generate_smoothers(
512 std::shared_ptr<const gko::multigrid::MultigridLevel> mg_level,
514 std::vector<std::shared_ptr<const LinOp>>& pre_smoother_list,
515 std::vector<std::shared_ptr<const LinOp>>& mid_smoother_list,
516 std::vector<std::shared_ptr<const LinOp>>& post_smoother_list,
517 reuse_data_type::level_data* level_reuse);
534 std::unique_ptr<LinOp> generate_coarsest_solver(
535 std::shared_ptr<const gko::multigrid::MultigridLevel> last_mg_level,
536 size_type level, std::shared_ptr<const LinOp> matrix,
537 std::unique_ptr<LinOpFactory::ReuseData>* reuse_data,
540 explicit Multigrid(std::shared_ptr<const Executor> exec);
543 std::shared_ptr<const LinOp> system_matrix);
546 std::shared_ptr<const LinOp> system_matrix,
550 std::shared_ptr<const LinOp> system_matrix,
554 static void check_reuse_consistent(
const Factory* factory,
574 void create_state()
const;
577 std::vector<std::shared_ptr<const gko::multigrid::MultigridLevel>>
579 std::vector<std::shared_ptr<const LinOp>> pre_smoother_list_{};
580 std::vector<std::shared_ptr<const LinOp>> mid_smoother_list_{};
581 std::vector<std::shared_ptr<const LinOp>> post_smoother_list_{};
582 std::shared_ptr<const LinOp> coarsest_solver_{};
596 mutable struct cache_struct {
597 cache_struct() =
default;
599 ~cache_struct() =
default;
601 cache_struct(
const cache_struct&) {}
603 cache_struct(cache_struct&&) noexcept {}
605 cache_struct&
operator=(
const cache_struct&) {
return *
this; }
607 cache_struct&
operator=(cache_struct&&) noexcept {
return *
this; }
611 std::shared_ptr<multigrid::detail::MultigridState> state{};
619 static int num_vectors(
const Solver&);
621 static int num_arrays(
const Solver&);
623 static std::vector<std::string> op_names(
const Solver&);
625 static std::vector<std::string> array_names(
const Solver&);
627 static std::vector<int> scalars(
const Solver&);
629 static std::vector<int> vectors(
const Solver&);
632 constexpr
static int stop = 0;
640 #endif // GKO_PUBLIC_CORE_SOLVER_MULTIGRID_HPP_
Definition: multigrid.hpp:238
EnableApplyWithInitialGuess providing default operation for ApplyWithInitialGuess with correct valida...
Definition: solver_base.hpp:170
std::vector< std::shared_ptr< const LinOpFactory > > coarsest_solver
Coarsest factory list.
Definition: multigrid.hpp:350
pnode describes a tree of properties.
Definition: property_tree.hpp:28
A LinOp deriving from this CRTP class stores a stopping criterion factory and allows applying with a ...
Definition: solver_base.hpp:729
Definition: lin_op.hpp:117
multigrid::cycle cycle
Multigrid cycle type.
Definition: multigrid.hpp:383
std::vector< std::shared_ptr< const LinOp > > get_pre_smoother_list() const
Gets the list of pre-smoother operators.
Definition: multigrid.hpp:186
std::vector< std::shared_ptr< const LinOpFactory > > post_smoother
Post-smooth Factory list.
Definition: multigrid.hpp:299
Records the hierarchy of generate_reuse() and the reuse data of its levels, smoothers and coarsest so...
Definition: multigrid.hpp:432
Definition: solver_base.hpp:1125
std::vector< std::shared_ptr< const gko::multigrid::MultigridLevel > > get_mg_level_list() const
Gets the list of MultigridLevel operators.
Definition: multigrid.hpp:176
std::function< size_type(const size_type, const LinOp *)> level_selector
Custom selector size_type (size_type level, const LinOp* fine_matrix) Selector function returns the e...
Definition: multigrid.hpp:274
std::vector< std::shared_ptr< const LinOpFactory > > pre_smoother
Pre-smooth Factory list.
Definition: multigrid.hpp:291
size_type kcycle_base
kcycle_base is a factor to choose how often enable FCG/GCR step.
Definition: multigrid.hpp:393
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:101
multigrid::cycle get_cycle() const
Get the cycle of multigrid.
Definition: multigrid.hpp:226
Multigrid solves a linear system by combining cheap iterative sweeps (smoothers) on a hierarchy of pr...
Definition: multigrid.hpp:151
double kcycle_rel_tol
kcycle_rel_tol decides whether run the second iteration of FCG/GCR step.
Definition: multigrid.hpp:402
void set_cycle(multigrid::cycle cycle)
Set the cycle of multigrid.
Definition: multigrid.hpp:233
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition: abstract_factory.hpp:469
This class describes the value and index types to be used when building a Ginkgo type from a configur...
Definition: type_descriptor.hpp:39
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
multigrid::mid_smooth_type mid_case
Choose the behavior of mid smoother between two cycles close to each other in the same level.
Definition: multigrid.hpp:325
std::vector< std::shared_ptr< const LinOp > > get_mid_smoother_list() const
Gets the list of mid-smoother operators.
Definition: multigrid.hpp:196
Definition: multigrid.hpp:425
LinOp & operator=(const LinOp &)=default
Copy-assigns a LinOp.
initial_guess_mode default_initial_guess
Default initial guess mode.
Definition: multigrid.hpp:421
size_type max_levels
The maximum number of mg_level (without coarsest solver level) that can be used.
Definition: multigrid.hpp:334
A LinOp deriving from this CRTP class stores a system matrix.
Definition: solver_base.hpp:565
std::shared_ptr< const LinOp > get_coarsest_solver() const
Gets the operator at the coarsest level.
Definition: multigrid.hpp:216
std::vector< std::shared_ptr< const LinOpFactory > > mg_level
MultigridLevel Factory list.
Definition: multigrid.hpp:245
Opaque base for the data a factory records in generate_reuse() to speed up later generations.
Definition: lin_op.hpp:371
std::vector< std::shared_ptr< const LinOp > > get_post_smoother_list() const
Gets the list of post-smoother operators.
Definition: multigrid.hpp:206
size_type min_coarse_rows
The minimal number of coarse rows.
Definition: multigrid.hpp:341
This class stores additional context for creating Ginkgo objects from configuration files.
Definition: registry.hpp:167
size_type smoother_iters
smoother_iters is the number of iteration of default generated smoother.
Definition: multigrid.hpp:414
#define GKO_ENABLE_BUILD_METHOD(_factory_name)
Defines a build method for the factory, simplifying its construction by removing the repetitive typin...
Definition: abstract_factory.hpp:418
initial_guess_mode
Give a initial guess mode about the input of the apply method.
Definition: solver_base.hpp:39
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.
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 s...
Definition: multigrid.hpp:164
Traits class providing information on the type and location of workspace vectors inside a solver.
Definition: solver_base.hpp:247
#define GKO_ENABLE_LIN_OP_FACTORY_WITH_REUSE(_lin_op, _parameters_name, _factory_name, _reuse_data_type)
Like GKO_ENABLE_LIN_OP_FACTORY, but the factory also supports LinOpFactory::generate_reuse(),...
Definition: lin_op.hpp:1167
mid_smooth_type
mid_smooth_type gives the options to handle the middle smoother behavior between the two cycles in th...
Definition: multigrid.hpp:72
std::vector< std::shared_ptr< const LinOpFactory > > mid_smoother
Mid-smooth Factory list.
Definition: multigrid.hpp:309
std::function< size_type(const size_type, const LinOp *)> solver_selector
Custom coarsest_solver selector size_type (size_type level, const LinOp *coarsest_matrix) Selector fu...
Definition: multigrid.hpp:375
cycle
cycle defines which kind of multigrid cycle can be used.
Definition: multigrid.hpp:56
std::complex< double > smoother_relax
smoother_relax is the relaxation factor of default generated smoother.
Definition: multigrid.hpp:408
LinOp(const LinOp &)=default
Copy-constructs a LinOp.
bool post_uses_pre
Whether post-smoothing-related calls use corresponding pre-smoothing-related calls.
Definition: multigrid.hpp:315