ginkgo/core/preconditioner/sor.hpp Source File

ginkgo/core/preconditioner/sor.hpp Source File#

Reference API: ginkgo/core/preconditioner/sor.hpp Source File
Reference API
sor.hpp
1// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_PRECONDITIONER_SOR_HPP_
6#define GKO_PUBLIC_CORE_PRECONDITIONER_SOR_HPP_
7
8
9#include <vector>
10
11#include <ginkgo/core/base/abstract_factory.hpp>
12#include <ginkgo/core/base/composition.hpp>
13#include <ginkgo/core/base/lin_op.hpp>
14#include <ginkgo/core/base/polymorphic_object.hpp>
15#include <ginkgo/core/config/config.hpp>
16
17
18namespace gko {
19namespace preconditioner {
20
21
50template <typename ValueType = default_precision, typename IndexType = int32>
51class Sor
52 : public EnablePolymorphicObject<Sor<ValueType, IndexType>, LinOpFactory>,
53 public EnablePolymorphicAssignment<Sor<ValueType, IndexType>> {
55
56public:
57 struct parameters_type;
59
60 using value_type = ValueType;
61 using index_type = IndexType;
63
65 : public enable_parameters_type<parameters_type, Sor> {
66 // skip sorting of input matrix
67 bool GKO_FACTORY_PARAMETER_SCALAR(skip_sorting, false);
68
69 // determines if SOR or SSOR should be used
70 bool GKO_FACTORY_PARAMETER_SCALAR(symmetric, false);
71
72 // has to be between 0.0 and 2.0
74 relaxation_factor, remove_complex<value_type>(1.2));
75
76 // factory for the lower triangular factor solver, defaults to LowerTrs
77 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
78 l_solver);
79
80 // factory for the upper triangular factor solver, unused if symmetric
81 // is false, defaults to UpperTrs
82 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
83 u_solver);
84 };
85
91 const parameters_type& get_parameters() { return parameters_; }
92
96 const parameters_type& get_parameters() const { return parameters_; }
97
105 std::unique_ptr<composition_type> generate(
106 std::shared_ptr<const LinOp> system_matrix) const;
107
109 static parameters_type build() { return {}; }
110
111 static parameters_type parse(
112 const config::pnode& config, const config::registry& context,
113 const config::type_descriptor& td_for_child =
114 config::make_type_descriptor<ValueType, IndexType>());
115
116protected:
117 explicit Sor(std::shared_ptr<const Executor> exec,
118 const parameters_type& params = {})
119 : EnablePolymorphicObject<Sor, LinOpFactory>(exec), parameters_(params)
120 {
121 GKO_ASSERT(parameters_.relaxation_factor > 0.0 &&
122 parameters_.relaxation_factor < 2.0);
123 }
124
125 std::unique_ptr<LinOp> generate_impl(
126 std::shared_ptr<const LinOp> system_matrix) const override;
127
128private:
129 parameters_type parameters_;
130};
131} // namespace preconditioner
132} // namespace gko
133
134
135#endif // GKO_PUBLIC_CORE_PRECONDITIONER_SOR_HPP_
Definition composition.hpp:41
Definition polymorphic_object.hpp:743
Definition polymorphic_object.hpp:668
Definition lin_op.hpp:385
Definition property_tree.hpp:28
Definition registry.hpp:167
Definition type_descriptor.hpp:39
Definition abstract_factory.hpp:211
Definition sor.hpp:53
const parameters_type & get_parameters()
Definition sor.hpp:91
static parameters_type build()
Definition sor.hpp:109
const parameters_type & get_parameters() const
Definition sor.hpp:96
std::unique_ptr< composition_type > generate(std::shared_ptr< const LinOp > system_matrix) const
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Definition abstract_factory.hpp:445
The Ginkgo namespace.
Definition abstract_factory.hpp:20
typename detail::remove_complex_s< T >::type remove_complex
Definition math.hpp:260