Reference documentation for deal.II version GIT d1e6af55b6 2023-02-07 07:50:02+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\}}\)
petsc_precondition.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2021 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_petsc_precondition_h
17 #define dealii_petsc_precondition_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/point.h>
24 
25 #ifdef DEAL_II_WITH_PETSC
26 
27 # include <deal.II/lac/exceptions.h>
28 
29 # include <petscpc.h>
30 
31 # include <functional>
32 
34 
35 
36 
37 namespace PETScWrappers
38 {
39  // forward declarations
40 # ifndef DOXYGEN
41  class MatrixBase;
42  class VectorBase;
43 # endif
44 
61  {
62  public:
66  explicit PreconditionBase(const MPI_Comm &mpi_communicator);
67 
73 
77  virtual ~PreconditionBase();
78 
83  void
84  clear();
85 
89  void
90  vmult(VectorBase &dst, const VectorBase &src) const;
91 
95  void
96  Tvmult(VectorBase &dst, const VectorBase &src) const;
97 
102  void
103  setup();
104 
108  const PC &
109  get_pc() const;
110 
114  const MPI_Comm &
115  get_mpi_communicator() const;
116 
117  protected:
121  PC pc;
122 
127  void
129 
133  void
134  create_pc_with_comm(const MPI_Comm &);
135  };
136 
137 
138 
150  {
151  public:
157  {};
158 
164 
170  const MatrixBase & matrix,
172 
178  const MPI_Comm & communicator,
180 
187  void
188  initialize(const MatrixBase & matrix,
190 
191  protected:
196 
202  void
203  initialize();
204  };
205 
206 
207 
232  {
233  public:
239  {};
240 
246 
252  const MatrixBase & matrix,
254 
260  const MPI_Comm & communicator,
262 
263 
270  void
271  initialize(const MatrixBase & matrix,
273 
274  protected:
279 
285  void
286  initialize();
287  };
288 
289 
290 
300  {
301  public:
307  {
311  AdditionalData(const double omega = 1);
312 
316  double omega;
317  };
318 
323  PreconditionSOR();
324 
331 
338  void
339  initialize(const MatrixBase & matrix,
341 
342  protected:
347  };
348 
349 
350 
360  {
361  public:
367  {
371  AdditionalData(const double omega = 1);
372 
376  double omega;
377  };
378 
384 
391 
398  void
399  initialize(const MatrixBase & matrix,
401 
402  protected:
407  };
408 
418  {
419  public:
425  {
429  AdditionalData(const unsigned int levels = 0);
430 
434  unsigned int levels;
435  };
436 
441  PreconditionICC();
442 
449 
456  void
457  initialize(const MatrixBase & matrix,
459 
460  protected:
465  };
466 
467 
468 
478  {
479  public:
485  {
489  AdditionalData(const unsigned int levels = 0);
490 
494  unsigned int levels;
495  };
496 
501  PreconditionILU();
502 
509 
516  void
517  initialize(const MatrixBase & matrix,
519 
520  protected:
525  };
526 
527 
528 
543  {
544  public:
550  {
555  AdditionalData(const double pivoting = 1.e-6,
556  const double zero_pivot = 1.e-12,
557  const double damping = 0.0);
558 
564  double pivoting;
565 
570  double zero_pivot;
571 
576  double damping;
577  };
578 
583  PreconditionLU();
584 
591 
598  void
599  initialize(const MatrixBase & matrix,
601 
602  protected:
607  };
608 
609 
610 
622  {
623  public:
629  {
633  enum class RelaxationType
634  {
635  Jacobi,
638  SORJacobi,
645  CG,
646  Chebyshev,
647  FCFJacobi,
649  None
650  };
651 
657  const bool symmetric_operator = false,
658  const double strong_threshold = 0.25,
659  const double max_row_sum = 0.9,
660  const unsigned int aggressive_coarsening_num_levels = 0,
661  const bool output_details = false,
666  const unsigned int n_sweeps_coarse = 1,
667  const double tol = 0.0,
668  const unsigned int max_iter = 1,
669  const bool w_cycle = false);
670 
677 
684 
696  double max_row_sum;
697 
704 
710 
715 
720 
725 
729  unsigned int n_sweeps_coarse;
730 
734  double tol;
735 
739  unsigned int max_iter;
740 
745  bool w_cycle;
746  };
747 
753 
759  const MatrixBase & matrix,
761 
767  const MPI_Comm & communicator,
769 
770 
777  void
778  initialize(const MatrixBase & matrix,
780 
781  protected:
786 
792  void
793  initialize();
794  };
795 
796 
797 
818  {
819  public:
825  {
829  AdditionalData(const unsigned int symmetric = 1,
830  const unsigned int n_levels = 1,
831  const double threshold = 0.1,
832  const double filter = 0.05,
833  const bool output_details = false);
834 
846  unsigned int symmetric;
847 
854  unsigned int n_levels;
855 
866  double threshold;
867 
878  double filter;
879 
885  };
886 
887 
888 
894 
900  const MatrixBase & matrix,
902 
909  void
910  initialize(const MatrixBase & matrix,
912 
913  private:
918  };
919 
920 
921 
928  {
929  public:
935  {};
936 
942 
950 
958  void
959  initialize(const MatrixBase & matrix,
961 
962  private:
967  };
968 
986  template <int dim>
988  {
989  public:
995  {
1000  AdditionalData(const bool use_vertices = true,
1001  const bool use_edges = false,
1002  const bool use_faces = false,
1003  const bool symmetric = false,
1004  const std::vector<Point<dim>> coords = {});
1005 
1011 
1018 
1025 
1030 
1035  std::vector<Point<dim>> coords;
1036  };
1037 
1042  PreconditionBDDC();
1043 
1050 
1055  PreconditionBDDC(const MPI_Comm communicator,
1057 
1064  void
1065  initialize(const MatrixBase & matrix,
1067 
1068  protected:
1073 
1079  void
1080  initialize();
1081  };
1082 
1084  {
1085  public:
1090  PreconditionShell() = default;
1091 
1096 
1100  PreconditionShell(const MPI_Comm &communicator);
1101 
1105  std::function<int(VectorBase &dst, const VectorBase &src)> vmult;
1106 
1110  std::function<int(VectorBase &dst, const VectorBase &src)> vmultT;
1111 
1112  protected:
1117  void
1118  initialize(const MPI_Comm &comm);
1119 
1124  void
1125  initialize(const MatrixBase &matrix);
1126 
1127  private:
1131  static int
1132  pcapply(PC pc, Vec src, Vec dst);
1133 
1137  static int
1138  pcapply_transpose(PC pc, Vec src, Vec dst);
1139  };
1140 
1146 } // namespace PETScWrappers
1147 
1148 
1150 
1151 
1152 #endif // DEAL_II_WITH_PETSC
1153 
1154 #endif
void Tvmult(VectorBase &dst, const VectorBase &src) const
const MPI_Comm & get_mpi_communicator() const
void vmult(VectorBase &dst, const VectorBase &src) const
void create_pc_with_comm(const MPI_Comm &)
void create_pc_with_mat(const MatrixBase &)
void initialize(const MatrixBase &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const MatrixBase &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const MatrixBase &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const MatrixBase &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const MatrixBase &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const MatrixBase &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const MatrixBase &matrix, const AdditionalData &additional_data=AdditionalData())
static int pcapply_transpose(PC pc, Vec src, Vec dst)
std::function< int(VectorBase &dst, const VectorBase &src)> vmultT
static int pcapply(PC pc, Vec src, Vec dst)
std::function< int(VectorBase &dst, const VectorBase &src)> vmult
void initialize(const MPI_Comm &comm)
Definition: point.h:111
#define DEAL_II_DEPRECATED
Definition: config.h:162
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:461
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:462
@ matrix
Contents is actually a matrix.
AdditionalData(const bool use_vertices=true, const bool use_edges=false, const bool use_faces=false, const bool symmetric=false, const std::vector< Point< dim >> coords={})
AdditionalData(const bool symmetric_operator=false, const double strong_threshold=0.25, const double max_row_sum=0.9, const unsigned int aggressive_coarsening_num_levels=0, const bool output_details=false, const RelaxationType relaxation_type_up=RelaxationType::SORJacobi, const RelaxationType relaxation_type_down=RelaxationType::SORJacobi, const RelaxationType relaxation_type_coarse=RelaxationType::GaussianElimination, const unsigned int n_sweeps_coarse=1, const double tol=0.0, const unsigned int max_iter=1, const bool w_cycle=false)
AdditionalData(const double pivoting=1.e-6, const double zero_pivot=1.e-12, const double damping=0.0)
AdditionalData(const unsigned int symmetric=1, const unsigned int n_levels=1, const double threshold=0.1, const double filter=0.05, const bool output_details=false)
const MPI_Comm & comm