ginkgo/core/distributed/preconditioner/schwarz.hpp Source File

ginkgo/core/distributed/preconditioner/schwarz.hpp Source File#

Reference API: ginkgo/core/distributed/preconditioner/schwarz.hpp Source File
Reference API
schwarz.hpp
1// SPDX-FileCopyrightText: 2017 - 2025 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/config/config.hpp>
18#include <ginkgo/core/config/registry.hpp>
19#include <ginkgo/core/config/type_descriptor.hpp>
20#include <ginkgo/core/distributed/matrix.hpp>
21#include <ginkgo/core/distributed/vector.hpp>
22#include <ginkgo/core/distributed/vector_cache.hpp>
23
24
25namespace gko {
26namespace experimental {
27namespace distributed {
33namespace preconditioner {
34
35
52template <typename ValueType = default_precision,
53 typename LocalIndexType = int32, typename GlobalIndexType = int64>
55 : public EnableLinOp<Schwarz<ValueType, LocalIndexType, GlobalIndexType>> {
56 friend class EnableLinOp<Schwarz>;
58
59public:
62 using value_type = ValueType;
63 using index_type = GlobalIndexType;
64 using local_index_type = LocalIndexType;
65 using global_index_type = GlobalIndexType;
66
75 bool apply_uses_initial_guess() const override;
76
78 {
82 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
83 local_solver);
84
88 std::shared_ptr<const LinOp> GKO_FACTORY_PARAMETER_SCALAR(
89 generated_local_solver, nullptr);
90
99 bool GKO_FACTORY_PARAMETER_SCALAR(l1_smoother, false);
100 };
103
119 const config::pnode& config, const config::registry& context,
120 const config::type_descriptor& td_for_child =
121 config::make_type_descriptor<ValueType, LocalIndexType,
122 GlobalIndexType>());
123
124protected:
130 explicit Schwarz(std::shared_ptr<const Executor> exec)
131 : EnableLinOp<Schwarz>(std::move(exec))
132 {}
133
141 explicit Schwarz(const Factory* factory,
142 std::shared_ptr<const LinOp> system_matrix)
143 : EnableLinOp<Schwarz>(factory->get_executor(),
144 gko::transpose(system_matrix->get_size())),
145 parameters_{factory->get_parameters()}
146 {
147 this->generate(system_matrix);
148 }
149
153 void generate(std::shared_ptr<const LinOp> system_matrix);
154
155 void apply_impl(const LinOp* b, LinOp* x) const override;
156
157 template <typename VectorType>
158 void apply_dense_impl(const VectorType* b, VectorType* x) const;
159
160 void apply_impl(const LinOp* alpha, const LinOp* b, const LinOp* beta,
161 LinOp* x) const override;
162
163private:
169 void set_solver(std::shared_ptr<const LinOp> new_solver);
170
171 std::shared_ptr<const LinOp> local_solver_;
172
173 detail::VectorCache<ValueType> cache_;
174};
175
176
177} // namespace preconditioner
178} // namespace distributed
179} // namespace experimental
180} // namespace gko
181
182
183#endif // GINKGO_BUILD_MPI
184#endif // GKO_PUBLIC_CORE_DISTRIBUTED_PRECONDITIONER_SCHWARZ_HPP_
Definition lin_op.hpp:878
void move_to(result_type *result) override
Definition polymorphic_object.hpp:751
void convert_to(result_type *result) const override
Definition polymorphic_object.hpp:749
Definition polymorphic_object.hpp:668
Definition lin_op.hpp:117
std::shared_ptr< const Executor > get_executor() const noexcept
Definition polymorphic_object.hpp:243
Definition property_tree.hpp:28
Definition registry.hpp:167
Definition type_descriptor.hpp:39
void generate(std::shared_ptr< const LinOp > system_matrix)
Schwarz(std::shared_ptr< const Executor > exec)
Definition schwarz.hpp:130
static parameters_type parse(const config::pnode &config, const config::registry &context, const config::type_descriptor &td_for_child=config::make_type_descriptor< ValueType, LocalIndexType, GlobalIndexType >())
Schwarz(const Factory *factory, std::shared_ptr< const LinOp > system_matrix)
Definition schwarz.hpp:141
#define GKO_CREATE_FACTORY_PARAMETERS(_parameters_name, _factory_name)
Definition abstract_factory.hpp:280
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Definition abstract_factory.hpp:445
#define GKO_ENABLE_BUILD_METHOD(_factory_name)
Definition abstract_factory.hpp:394
#define GKO_ENABLE_LIN_OP_FACTORY(_lin_op, _parameters_name, _factory_name)
Definition lin_op.hpp:1016
The Ginkgo namespace.
Definition abstract_factory.hpp:20
double default_precision
Definition types.hpp:171
std::int32_t int32
Definition types.hpp:106
std::int64_t int64
Definition types.hpp:112
batch_dim< 2, DimensionType > transpose(const batch_dim< 2, DimensionType > &input)
Definition batch_dim.hpp:119
STL namespace.