Ginkgo  Generated from pipelines/2969282958 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 
43 template <typename ValueType = default_precision, typename IndexType = int32>
44 class Pmis : public LinOp, public EnableMultigridLevel<ValueType> {
45  GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
46 
47 public:
48  using value_type = ValueType;
49  using index_type = IndexType;
50 
56  std::shared_ptr<const LinOp> get_system_matrix() const
57  {
58  return system_matrix_;
59  }
60 
61 
63  {
72  strength_threshold, remove_complex<ValueType>{0.25});
73 
74 
85  bool GKO_FACTORY_PARAMETER_SCALAR(skip_sorting, false);
86  };
89 
103  static parameters_type parse(
104  const config::pnode& config, const config::registry& context,
105  const config::type_descriptor& td_for_child =
106  config::make_type_descriptor<ValueType, IndexType>());
107 
108 protected:
109  void apply_impl(const LinOp* b, LinOp* x) const override;
110 
111  void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
112  LinOp* x) const override;
113 
114  explicit Pmis(std::shared_ptr<const Executor> exec);
115 
116  explicit Pmis(const Factory* factory,
117  std::shared_ptr<const LinOp> system_matrix);
118 
119  void generate();
120 
121 private:
122  std::shared_ptr<const LinOp> system_matrix_{};
123 };
124 
125 
126 } // namespace multigrid
127 } // namespace gko
128 
129 
130 #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: matrix.hpp:43
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:56
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_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:1094
gko::multigrid::Pmis::Factory
Definition: pmis.hpp:87
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