deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
ginkgo_solver.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2019 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_ginkgo_solver_h
14#define dealii_ginkgo_solver_h
15
16
17#include <deal.II/base/config.h>
18
19#ifdef DEAL_II_WITH_GINKGO
20
25# include <deal.II/lac/vector.h>
26
27# include <ginkgo/ginkgo.hpp>
28
29# include <memory>
30
31#endif // DEAL_II_WITH_GINKGO
32
34
35#ifdef DEAL_II_WITH_GINKGO
37{
47 template <typename ValueType, typename IndexType>
49 {
50 public:
103 SolverBase(SolverControl &solver_control, const std::string &exec_type);
104
108 virtual ~SolverBase() = default;
109
113 void
114 initialize(const SparseMatrix<ValueType> &matrix);
115
121 void
122 apply(Vector<ValueType> &solution, const Vector<ValueType> &rhs);
123
129 void
130 solve(const SparseMatrix<ValueType> &matrix,
131 Vector<ValueType> &solution,
132 const Vector<ValueType> &rhs);
133
138 control() const;
139
140
141 protected:
147
151 std::shared_ptr<gko::LinOpFactory> solver_gen;
152
157 std::shared_ptr<gko::stop::ResidualNormReduction<>::Factory>
159
164 std::shared_ptr<gko::log::Convergence<>> convergence_logger;
165
170 std::shared_ptr<gko::stop::Combined::Factory> combined_factory;
171
177 std::shared_ptr<gko::Executor> executor;
178
179 private:
186 void
188
196 std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> system_matrix;
197
203 const std::string exec_type;
204 };
205
206
210 template <typename ValueType = double, typename IndexType = int32_t>
211 class SolverCG : public SolverBase<ValueType, IndexType>
212 {
213 public:
218 {};
219
232 const std::string &exec_type,
234
249 const std::string &exec_type,
250 const std::shared_ptr<gko::LinOpFactory> &preconditioner,
252
253 protected:
258 };
259
260
264 template <typename ValueType = double, typename IndexType = int32_t>
265 class SolverBicgstab : public SolverBase<ValueType, IndexType>
266 {
267 public:
272 {};
273
286 const std::string &exec_type,
288
303 const std::string &exec_type,
304 const std::shared_ptr<gko::LinOpFactory> &preconditioner,
306
307 protected:
312 };
313
320 template <typename ValueType = double, typename IndexType = int32_t>
321 class SolverCGS : public SolverBase<ValueType, IndexType>
322 {
323 public:
328 {};
329
342 const std::string &exec_type,
344
359 const std::string &exec_type,
360 const std::shared_ptr<gko::LinOpFactory> &preconditioner,
362
363 protected:
368 };
369
385 template <typename ValueType = double, typename IndexType = int32_t>
386 class SolverFCG : public SolverBase<ValueType, IndexType>
387 {
388 public:
393 {};
394
407 const std::string &exec_type,
409
424 const std::string &exec_type,
425 const std::shared_ptr<gko::LinOpFactory> &preconditioner,
427
428 protected:
433 };
434
438 template <typename ValueType = double, typename IndexType = int32_t>
439 class SolverGMRES : public SolverBase<ValueType, IndexType>
440 {
441 public:
446 {
451 AdditionalData(const unsigned int restart_parameter = 30);
452
456 unsigned int restart_parameter;
457 };
458
471 const std::string &exec_type,
473
488 const std::string &exec_type,
489 const std::shared_ptr<gko::LinOpFactory> &preconditioner,
491
492 protected:
497 };
498
506 template <typename ValueType = double, typename IndexType = int32_t>
507 class SolverIR : public SolverBase<ValueType, IndexType>
508 {
509 public:
514 {};
515
528 const std::string &exec_type,
530
545 const std::string &exec_type,
546 const std::shared_ptr<gko::LinOpFactory> &inner_solver,
548
549 protected:
554 };
555
556
557} // namespace GinkgoWrappers
558
559#endif // DEAL_II_WITH_GINKGO
560
562
563#endif
SolverControl & control() const
const std::string exec_type
SolverControl & solver_control
std::shared_ptr< gko::log::Convergence<> > convergence_logger
void initialize(const SparseMatrix< ValueType > &matrix)
std::shared_ptr< gko::matrix::Csr< ValueType, IndexType > > system_matrix
void apply(Vector< ValueType > &solution, const Vector< ValueType > &rhs)
std::shared_ptr< gko::Executor > executor
std::shared_ptr< gko::LinOpFactory > solver_gen
void solve(const SparseMatrix< ValueType > &matrix, Vector< ValueType > &solution, const Vector< ValueType > &rhs)
virtual ~SolverBase()=default
std::shared_ptr< gko::stop::ResidualNormReduction<>::Factory > residual_criterion
std::shared_ptr< gko::stop::Combined::Factory > combined_factory
const AdditionalData additional_data
const AdditionalData additional_data
const AdditionalData additional_data
const AdditionalData additional_data
const AdditionalData additional_data
const AdditionalData additional_data
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
std::vector< index_type > data
Definition mpi.cc:734