 |
Ginkgo
Generated from pipelines/3136675824 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_SOLVER_IR_HPP_
6 #define GKO_PUBLIC_CORE_SOLVER_IR_HPP_
11 #include <ginkgo/core/base/exception_helpers.hpp>
12 #include <ginkgo/core/base/lin_op.hpp>
13 #include <ginkgo/core/base/types.hpp>
14 #include <ginkgo/core/config/config.hpp>
15 #include <ginkgo/core/config/registry.hpp>
16 #include <ginkgo/core/matrix/dense.hpp>
17 #include <ginkgo/core/matrix/identity.hpp>
18 #include <ginkgo/core/matrix/multivector.hpp>
19 #include <ginkgo/core/solver/solver_base.hpp>
20 #include <ginkgo/core/stop/combined.hpp>
21 #include <ginkgo/core/stop/criterion.hpp>
22 #include <ginkgo/core/stop/iteration.hpp>
92 template <
typename ValueType = default_precision>
99 GKO_ASSERT_SUPPORTED_VALUE_TYPE;
102 using value_type = ValueType;
105 std::unique_ptr<LinOp>
transpose()
const override;
116 return this->get_default_initial_guess() ==
125 std::shared_ptr<const LinOp>
get_solver()
const {
return solver_; }
132 void set_solver(std::shared_ptr<const LinOp> new_solver);
171 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
225 config::make_type_descriptor<ValueType>());
253 void set_relaxation_factor(
256 explicit Ir(std::shared_ptr<const Executor> exec) :
LinOp(std::move(exec))
260 std::shared_ptr<const LinOp> system_matrix)
266 parameters_{factory->get_parameters()}
270 "inner_initial_guess must be initial_guess_mode::zero or "
271 "initial_guess_mode::rhs");
275 }
else if (parameters_.
solver) {
277 parameters_.
solver->generate(this->get_system_matrix()));
283 relaxation_factor_ = gko::initialize<matrix::MultiVector<ValueType>>(
288 std::shared_ptr<const LinOp> solver_{};
289 std::shared_ptr<const matrix::MultiVector<ValueType>> relaxation_factor_{};
293 template <
typename ValueType = default_precision>
294 using Richardson = Ir<ValueType>;
297 template <
typename ValueType>
301 static int num_vectors(
const Solver&);
303 static int num_arrays(
const Solver&);
305 static std::vector<std::string> op_names(
const Solver&);
307 static std::vector<std::string> array_names(
const Solver&);
309 static std::vector<int> scalars(
const Solver&);
311 static std::vector<int> vectors(
const Solver&);
314 constexpr
static int residual = 0;
316 constexpr
static int inner_solution = 1;
318 constexpr
static int one = 2;
320 constexpr
static int minus_one = 3;
323 constexpr
static int stop = 0;
337 template <
typename ValueType>
339 size_type iteration = 1, ValueType relaxation_factor = 0.9)
341 auto exec = factory->get_executor();
343 .with_solver(factory)
344 .with_relaxation_factor(relaxation_factor)
345 .with_criteria(gko::stop::Iteration::build().with_max_iters(iteration))
361 template <
typename ValueType>
363 size_type iteration = 1, ValueType relaxation_factor = 0.9)
365 auto exec = solver->get_executor();
367 .with_generated_solver(solver)
368 .with_relaxation_factor(relaxation_factor)
369 .with_criteria(gko::stop::Iteration::build().with_max_iters(iteration))
378 #endif // GKO_PUBLIC_CORE_SOLVER_IR_HPP_
EnableApplyWithInitialGuess providing default operation for ApplyWithInitialGuess with correct valida...
Definition: solver_base.hpp:174
Ir & operator=(const Ir &)
Copy-assigns an IR solver.
pnode describes a tree of properties.
Definition: property_tree.hpp:28
A LinOp deriving from this CRTP class stores a stopping criterion factory and allows applying with a ...
Definition: solver_base.hpp:728
Definition: lin_op.hpp:163
static parameters_type parse(const config::pnode &config, const config::registry &context, const config::type_descriptor &td_for_child=config::make_type_descriptor< ValueType >())
Create the parameters from the property_tree.
Definition: solver_base.hpp:1123
Iterative refinement (IR) is an iterative method that uses another coarse method to approximate the e...
Definition: ir.hpp:93
std::shared_ptr< const LinOp > generated_solver
Already generated solver.
Definition: ir.hpp:179
Linear operators which support transposition should implement the Transposable interface.
Definition: lin_op.hpp:596
Ir(const Ir &)
Copy-constructs an IR solver.
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:102
std::unique_ptr< LinOp > transpose() const override
Returns a LinOp representing the transpose of the Transposable object.
std::shared_ptr< const LinOp > get_solver() const
Returns the solver operator used as the inner solver.
Definition: ir.hpp:125
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition: abstract_factory.hpp:469
This class describes the value and index types to be used when building a Ginkgo type from a configur...
Definition: type_descriptor.hpp:39
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
initial_guess_mode inner_initial_guess
Initial guess of the inner solver for each correction A * d = residual, if the inner solver uses an i...
Definition: ir.hpp:204
std::unique_ptr< LinOp > conj_transpose() const override
Returns a LinOp representing the conjugate transpose of the Transposable object.
#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:1192
std::shared_ptr< const CriterionFactory > combine(FactoryContainer &&factories)
Combines multiple criterion factories into a single combined criterion factory.
Definition: combined.hpp:105
auto build_smoother(std::shared_ptr< const LinOpFactory > factory, size_type iteration=1, ValueType relaxation_factor=0.9)
build_smoother gives a shortcut to build a smoother by IR(Richardson) with limited stop criterion(ite...
Definition: ir.hpp:338
static std::unique_ptr< Identity > create(std::shared_ptr< const Executor > exec, dim< 2 > size)
Creates an Identity matrix of the specified size.
void set_solver(std::shared_ptr< const LinOp > new_solver)
Sets the solver operator used as the inner solver.
MultiVector is a multivector format which explicitly stores all values of the vector.
Definition: dense_cache.hpp:28
A LinOp deriving from this CRTP class stores a system matrix.
Definition: solver_base.hpp:564
initial_guess_mode default_initial_guess
Default initial guess mode.
Definition: ir.hpp:192
This class stores additional context for creating Ginkgo objects from configuration files.
Definition: registry.hpp:167
bool apply_uses_initial_guess() const override
Return true as iterative solvers use the data in x as an initial guess.
Definition: ir.hpp:114
#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
initial_guess_mode
Give a initial guess mode about the input of the apply method.
Definition: solver_base.hpp:39
ValueType relaxation_factor
Relaxation factor for Richardson iteration.
Definition: ir.hpp:185
std::shared_ptr< const LinOpFactory > solver
Inner solver factory.
Definition: ir.hpp:172
Abstract interface class for (multi-)vector types.
Definition: multivector.hpp:81
std::shared_ptr< const Executor > get_executor() const noexcept
Returns the Executor of the object.
Definition: polymorphic_object.hpp:69
Traits class providing information on the type and location of workspace vectors inside a solver.
Definition: solver_base.hpp:258
const dim< 2 > & get_size() const noexcept
Returns the size of the operator.
Definition: lin_op.hpp:259
constexpr T one()
Returns the multiplicative identity for T.
Definition: math.hpp:653