Reference documentation for deal.II version 9.2.0
\(\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\}}\)
ginkgo_solver.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2018 - 2019 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_ginkgo_solver_h
17 # define dealii_ginkgo_solver_h
18 
19 
20 # include <deal.II/base/config.h>
21 
22 # ifdef DEAL_II_WITH_GINKGO
23 
25 # include <deal.II/lac/exceptions.h>
28 # include <deal.II/lac/vector.h>
29 
30 # include <ginkgo/ginkgo.hpp>
31 
32 # include <memory>
33 
35 
36 namespace GinkgoWrappers
37 {
49  template <typename ValueType, typename IndexType>
50  class SolverBase
51  {
52  public:
105  SolverBase(SolverControl &solver_control, const std::string &exec_type);
106 
110  virtual ~SolverBase() = default;
111 
115  void
117 
123  void
124  apply(Vector<ValueType> &solution, const Vector<ValueType> &rhs);
125 
131  void
133  Vector<ValueType> & solution,
134  const Vector<ValueType> & rhs);
135 
139  SolverControl &
140  control() const;
141 
142 
143  protected:
149 
153  std::shared_ptr<gko::LinOpFactory> solver_gen;
154 
159  std::shared_ptr<gko::stop::ResidualNormReduction<>::Factory>
161 
166  std::shared_ptr<gko::log::Convergence<>> convergence_logger;
167 
172  std::shared_ptr<gko::stop::Combined::Factory> combined_factory;
173 
179  std::shared_ptr<gko::Executor> executor;
180 
181  private:
188  void
190 
198  std::shared_ptr<gko::matrix::Csr<ValueType, IndexType>> system_matrix;
199 
205  const std::string exec_type;
206  };
207 
208 
214  template <typename ValueType = double, typename IndexType = int32_t>
215  class SolverCG : public SolverBase<ValueType, IndexType>
216  {
217  public:
222  {};
223 
236  const std::string & exec_type,
237  const AdditionalData &data = AdditionalData());
238 
253  const std::string & exec_type,
254  const std::shared_ptr<gko::LinOpFactory> &preconditioner,
255  const AdditionalData & data = AdditionalData());
256 
257  protected:
262  };
263 
264 
270  template <typename ValueType = double, typename IndexType = int32_t>
271  class SolverBicgstab : public SolverBase<ValueType, IndexType>
272  {
273  public:
278  {};
279 
292  const std::string & exec_type,
293  const AdditionalData &data = AdditionalData());
294 
309  const std::string & exec_type,
310  const std::shared_ptr<gko::LinOpFactory> &preconditioner,
311  const AdditionalData &data = AdditionalData());
312 
313  protected:
318  };
319 
328  template <typename ValueType = double, typename IndexType = int32_t>
329  class SolverCGS : public SolverBase<ValueType, IndexType>
330  {
331  public:
336  {};
337 
350  const std::string & exec_type,
351  const AdditionalData &data = AdditionalData());
352 
367  const std::string & exec_type,
368  const std::shared_ptr<gko::LinOpFactory> &preconditioner,
369  const AdditionalData &data = AdditionalData());
370 
371  protected:
376  };
377 
395  template <typename ValueType = double, typename IndexType = int32_t>
396  class SolverFCG : public SolverBase<ValueType, IndexType>
397  {
398  public:
403  {};
404 
417  const std::string & exec_type,
418  const AdditionalData &data = AdditionalData());
419 
434  const std::string & exec_type,
435  const std::shared_ptr<gko::LinOpFactory> &preconditioner,
436  const AdditionalData &data = AdditionalData());
437 
438  protected:
443  };
444 
450  template <typename ValueType = double, typename IndexType = int32_t>
451  class SolverGMRES : public SolverBase<ValueType, IndexType>
452  {
453  public:
458  {
463  AdditionalData(const unsigned int restart_parameter = 30);
464 
468  unsigned int restart_parameter;
469  };
470 
483  const std::string & exec_type,
484  const AdditionalData &data = AdditionalData());
485 
500  const std::string & exec_type,
501  const std::shared_ptr<gko::LinOpFactory> &preconditioner,
502  const AdditionalData &data = AdditionalData());
503 
504  protected:
509  };
510 
520  template <typename ValueType = double, typename IndexType = int32_t>
521  class SolverIR : public SolverBase<ValueType, IndexType>
522  {
523  public:
528  {};
529 
542  const std::string & exec_type,
543  const AdditionalData &data = AdditionalData());
544 
559  const std::string & exec_type,
560  const std::shared_ptr<gko::LinOpFactory> &inner_solver,
561  const AdditionalData & data = AdditionalData());
562 
563  protected:
568  };
569 
570 
571 } // namespace GinkgoWrappers
572 
574 
575 # endif // DEAL_II_WITH_GINKGO
576 
577 #endif
578 /*---------------------------- ginkgo_solver.h ---------------------------*/
GinkgoWrappers::SolverBase::SolverBase
SolverBase(SolverControl &solver_control, const std::string &exec_type)
Definition: ginkgo_solver.cc:34
sparse_matrix.h
GinkgoWrappers::SolverBase::residual_criterion
std::shared_ptr< gko::stop::ResidualNormReduction<>::Factory > residual_criterion
Definition: ginkgo_solver.h:160
GinkgoWrappers::SolverCG
Definition: ginkgo_solver.h:215
GinkgoWrappers::SolverBase::control
SolverControl & control() const
Definition: ginkgo_solver.cc:209
GinkgoWrappers::SolverBase::convergence_logger
std::shared_ptr< gko::log::Convergence<> > convergence_logger
Definition: ginkgo_solver.h:166
GinkgoWrappers::SolverBase::system_matrix
std::shared_ptr< gko::matrix::Csr< ValueType, IndexType > > system_matrix
Definition: ginkgo_solver.h:198
GinkgoWrappers::SolverBase::initialize_ginkgo_log
void initialize_ginkgo_log()
Definition: ginkgo_solver.cc:76
GinkgoWrappers::SolverGMRES
Definition: ginkgo_solver.h:451
SparseMatrix
Definition: sparse_matrix.h:497
GinkgoWrappers::SolverGMRES::AdditionalData::AdditionalData
AdditionalData(const unsigned int restart_parameter=30)
Definition: ginkgo_solver.cc:438
GinkgoWrappers::SolverFCG::additional_data
const AdditionalData additional_data
Definition: ginkgo_solver.h:442
exceptions.h
GinkgoWrappers::SolverBase::initialize
void initialize(const SparseMatrix< ValueType > &matrix)
Definition: ginkgo_solver.cc:218
GinkgoWrappers::SolverIR::SolverIR
SolverIR(SolverControl &solver_control, const std::string &exec_type, const AdditionalData &data=AdditionalData())
Definition: ginkgo_solver.cc:482
GinkgoWrappers::SolverIR
Definition: ginkgo_solver.h:521
GinkgoWrappers::SolverBicgstab::SolverBicgstab
SolverBicgstab(SolverControl &solver_control, const std::string &exec_type, const AdditionalData &data=AdditionalData())
Definition: ginkgo_solver.cc:337
GinkgoWrappers::SolverBase::executor
std::shared_ptr< gko::Executor > executor
Definition: ginkgo_solver.h:179
GinkgoWrappers::SolverCG::SolverCG
SolverCG(SolverControl &solver_control, const std::string &exec_type, const AdditionalData &data=AdditionalData())
Definition: ginkgo_solver.cc:304
GinkgoWrappers::SolverCG::AdditionalData
Definition: ginkgo_solver.h:221
GinkgoWrappers::SolverFCG::SolverFCG
SolverFCG(SolverControl &solver_control, const std::string &exec_type, const AdditionalData &data=AdditionalData())
Definition: ginkgo_solver.cc:405
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
GinkgoWrappers::SolverGMRES::SolverGMRES
SolverGMRES(SolverControl &solver_control, const std::string &exec_type, const AdditionalData &data=AdditionalData())
Definition: ginkgo_solver.cc:446
LAPACKSupport::matrix
@ matrix
Contents is actually a matrix.
Definition: lapack_support.h:60
GinkgoWrappers::SolverBase::apply
void apply(Vector< ValueType > &solution, const Vector< ValueType > &rhs)
Definition: ginkgo_solver.cc:88
GinkgoWrappers::SolverIR::AdditionalData
Definition: ginkgo_solver.h:527
GinkgoWrappers::SolverGMRES::additional_data
const AdditionalData additional_data
Definition: ginkgo_solver.h:508
GinkgoWrappers::SolverFCG::AdditionalData
Definition: ginkgo_solver.h:402
GinkgoWrappers::SolverGMRES::AdditionalData
Definition: ginkgo_solver.h:457
GinkgoWrappers::SolverIR::additional_data
const AdditionalData additional_data
Definition: ginkgo_solver.h:567
GinkgoWrappers
Definition: ginkgo_solver.h:36
GinkgoWrappers::SolverBicgstab
Definition: ginkgo_solver.h:271
GinkgoWrappers::SolverCGS::AdditionalData
Definition: ginkgo_solver.h:335
GinkgoWrappers::SolverBase::solver_gen
std::shared_ptr< gko::LinOpFactory > solver_gen
Definition: ginkgo_solver.h:153
GinkgoWrappers::SolverBicgstab::AdditionalData
Definition: ginkgo_solver.h:277
GinkgoWrappers::SolverBase::solve
void solve(const SparseMatrix< ValueType > &matrix, Vector< ValueType > &solution, const Vector< ValueType > &rhs)
Definition: ginkgo_solver.cc:292
vector.h
block_sparse_matrix.h
GinkgoWrappers::SolverGMRES::AdditionalData::restart_parameter
unsigned int restart_parameter
Definition: ginkgo_solver.h:468
GinkgoWrappers::SolverBase
Definition: ginkgo_solver.h:50
GinkgoWrappers::SolverFCG
Definition: ginkgo_solver.h:396
GinkgoWrappers::SolverBase::combined_factory
std::shared_ptr< gko::stop::Combined::Factory > combined_factory
Definition: ginkgo_solver.h:172
config.h
GinkgoWrappers::SolverBase::exec_type
const std::string exec_type
Definition: ginkgo_solver.h:205
GinkgoWrappers::SolverBase::~SolverBase
virtual ~SolverBase()=default
SolverControl
Definition: solver_control.h:67
GinkgoWrappers::SolverBicgstab::additional_data
const AdditionalData additional_data
Definition: ginkgo_solver.h:317
GinkgoWrappers::SolverCGS::SolverCGS
SolverCGS(SolverControl &solver_control, const std::string &exec_type, const AdditionalData &data=AdditionalData())
Definition: ginkgo_solver.cc:372
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
GinkgoWrappers::SolverBase::solver_control
SolverControl & solver_control
Definition: ginkgo_solver.h:148
GinkgoWrappers::SolverCG::additional_data
const AdditionalData additional_data
Definition: ginkgo_solver.h:261
GinkgoWrappers::SolverCGS
Definition: ginkgo_solver.h:329
GinkgoWrappers::SolverCGS::additional_data
const AdditionalData additional_data
Definition: ginkgo_solver.h:375
solver_control.h