Ginkgo  Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
schwarz.hpp
1 // SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_DISTRIBUTED_PRECONDITIONER_SCHWARZ_HPP_
6 #define GKO_PUBLIC_CORE_DISTRIBUTED_PRECONDITIONER_SCHWARZ_HPP_
7 
8 
9 #include <ginkgo/config.hpp>
10 
11 
12 #if GINKGO_BUILD_MPI
13 
14 
15 #include <ginkgo/core/base/abstract_factory.hpp>
16 #include <ginkgo/core/base/lin_op.hpp>
17 #include <ginkgo/core/distributed/matrix.hpp>
18 #include <ginkgo/core/distributed/vector.hpp>
19 
20 
21 namespace gko {
22 namespace experimental {
23 namespace distributed {
29 namespace preconditioner {
30 
31 
49 template <typename ValueType = default_precision,
50  typename LocalIndexType = int32, typename GlobalIndexType = int64>
51 class Schwarz
52  : public EnableLinOp<Schwarz<ValueType, LocalIndexType, GlobalIndexType>> {
53  friend class EnableLinOp<Schwarz>;
54  friend class EnablePolymorphicObject<Schwarz, LinOp>;
55 
56 public:
59  using value_type = ValueType;
60  using index_type = GlobalIndexType;
61  using local_index_type = LocalIndexType;
62  using global_index_type = GlobalIndexType;
63 
65  {
69  std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
70  local_solver);
71 
75  std::shared_ptr<const LinOp> GKO_FACTORY_PARAMETER_SCALAR(
76  generated_local_solver, nullptr);
77  };
80 
81 protected:
87  explicit Schwarz(std::shared_ptr<const Executor> exec)
88  : EnableLinOp<Schwarz>(std::move(exec))
89  {}
90 
98  explicit Schwarz(const Factory* factory,
99  std::shared_ptr<const LinOp> system_matrix)
100  : EnableLinOp<Schwarz>(factory->get_executor(),
101  gko::transpose(system_matrix->get_size())),
102  parameters_{factory->get_parameters()}
103  {
104  this->generate(system_matrix);
105  }
106 
110  void generate(std::shared_ptr<const LinOp> system_matrix);
111 
112  void apply_impl(const LinOp* b, LinOp* x) const override;
113 
114  template <typename VectorType>
115  void apply_dense_impl(const VectorType* b, VectorType* x) const;
116 
117  void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
118  LinOp* x) const override;
119 
120 private:
126  void set_solver(std::shared_ptr<const LinOp> new_solver);
127 
128  std::shared_ptr<const LinOp> local_solver_;
129 };
130 
131 
132 } // namespace preconditioner
133 } // namespace distributed
134 } // namespace experimental
135 } // namespace gko
136 
137 
138 #endif // GINKGO_BUILD_MPI
139 #endif // GKO_PUBLIC_CORE_DISTRIBUTED_PRECONDITIONER_SCHWARZ_HPP_
gko::LinOp
Definition: lin_op.hpp:118
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:445
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::experimental::distributed::preconditioner::Schwarz::Factory
Definition: schwarz.hpp:78
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:1018
gko::transpose
batch_dim< 2, DimensionType > transpose(const batch_dim< 2, DimensionType > &input)
Returns a batch_dim object with its dimensions swapped for batched operators.
Definition: batch_dim.hpp:120
gko::int64
std::int64_t int64
64-bit signed integral type.
Definition: types.hpp:131
gko::default_precision
double default_precision
Precision used if no precision is explicitly specified.
Definition: types.hpp:193
gko::int32
std::int32_t int32
32-bit signed integral type.
Definition: types.hpp:125
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:394
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:280
gko::PolymorphicObject::get_executor
std::shared_ptr< const Executor > get_executor() const noexcept
Returns the Executor of the object.
Definition: polymorphic_object.hpp:235
gko::LinOp::get_size
const dim< 2 > & get_size() const noexcept
Returns the size of the operator.
Definition: lin_op.hpp:211
gko::EnableLinOp
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition: lin_op.hpp:878
gko::experimental::distributed::preconditioner::Schwarz
A Schwarz preconditioner is a simple domain decomposition preconditioner that generalizes the Block J...
Definition: schwarz.hpp:51
gko::EnablePolymorphicObject
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition: polymorphic_object.hpp:662