Ginkgo  Generated from pipelines/2837190956 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
pmis.hpp
1 // SPDX-FileCopyrightText: 2025 - 2026 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_MULTIGRID_PMIS_HPP_
6 #define GKO_PUBLIC_CORE_MULTIGRID_PMIS_HPP_
7 
8 
9 #include <ginkgo/core/base/composition.hpp>
10 #include <ginkgo/core/base/lin_op.hpp>
11 #include <ginkgo/core/base/types.hpp>
12 #include <ginkgo/core/config/config.hpp>
13 #include <ginkgo/core/config/registry.hpp>
14 #include <ginkgo/core/config/type_descriptor.hpp>
15 #include <ginkgo/core/distributed/matrix.hpp>
16 #include <ginkgo/core/multigrid/multigrid_level.hpp>
17 
18 
19 namespace gko {
20 namespace multigrid {
21 
22 
38 template <typename ValueType = default_precision, typename IndexType = int32>
39 class Pmis : public LinOp, public EnableMultigridLevel<ValueType> {
40  GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
41 
42 public:
43  using value_type = ValueType;
44  using index_type = IndexType;
45 
51  std::shared_ptr<const LinOp> get_system_matrix() const
52  {
53  return system_matrix_;
54  }
55 
56 
58  {
67  strength_threshold, remove_complex<ValueType>{0.25});
68 
69 
80  bool GKO_FACTORY_PARAMETER_SCALAR(skip_sorting, false);
81  };
84 
98  static parameters_type parse(
99  const config::pnode& config, const config::registry& context,
100  const config::type_descriptor& td_for_child =
101  config::make_type_descriptor<ValueType, IndexType>());
102 
103 protected:
104  void apply_impl(const LinOp* b, LinOp* x) const override;
105 
106  void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
107  LinOp* x) const override;
108 
109  explicit Pmis(std::shared_ptr<const Executor> exec);
110 
111  explicit Pmis(const Factory* factory,
112  std::shared_ptr<const LinOp> system_matrix);
113 
114  void generate();
115 
116 private:
117  std::shared_ptr<const LinOp> system_matrix_{};
118 };
119 
120 
121 } // namespace multigrid
122 } // namespace gko
123 
124 
125 #endif // GKO_PUBLIC_CORE_MULTIGRID_PMIS_HPP_
gko::multigrid::Pmis
Parallel modified independent set (Pmis) is the classical coarsening method introduced in the paper H...
Definition: pmis.hpp:39
gko::multigrid::Pmis::parse
static parameters_type parse(const config::pnode &config, const config::registry &context, const config::type_descriptor &td_for_child=config::make_type_descriptor< ValueType, IndexType >())
Create the parameters from the property_tree.
gko::config::pnode
pnode describes a tree of properties.
Definition: property_tree.hpp:28
gko::LinOp
Definition: lin_op.hpp:117
gko::multigrid::Pmis::get_system_matrix
std::shared_ptr< const LinOp > get_system_matrix() const
Returns the system operator (matrix) of the linear system.
Definition: pmis.hpp:51
GKO_FACTORY_PARAMETER_SCALAR
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition: abstract_factory.hpp:469
gko::config::type_descriptor
This class describes the value and index types to be used when building a Ginkgo type from a configur...
Definition: type_descriptor.hpp:39
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
gko::multigrid::EnableMultigridLevel
The EnableMultigridLevel gives the default implementation of MultigridLevel with composition and prov...
Definition: multigrid_level.hpp:80
GKO_ENABLE_LIN_OP_FACTORY
#define GKO_ENABLE_LIN_OP_FACTORY(_lin_op, _parameters_name, _factory_name)
This macro will generate a default implementation of a LinOpFactory for the LinOp subclass it is defi...
Definition: lin_op.hpp:899
gko::multigrid::Pmis::Factory
Definition: pmis.hpp:82
gko::config::registry
This class stores additional context for creating Ginkgo objects from configuration files.
Definition: registry.hpp:167
GKO_ENABLE_BUILD_METHOD
#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
GKO_CREATE_FACTORY_PARAMETERS
#define GKO_CREATE_FACTORY_PARAMETERS(_parameters_name, _factory_name)
This Macro will generate a new type containing the parameters for the factory _factory_name.
Definition: abstract_factory.hpp:304
gko::remove_complex
typename detail::remove_complex_s< T >::type remove_complex
Obtain the type which removed the complex of complex/scalar type or the template parameter of class b...
Definition: math.hpp:263