Reference documentation for deal.II version GIT f6a5d312c9 2023-10-04 08: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 - 2023 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  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
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
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
341 
342  protected:
347  };
348 
349 
350 
360  {
361  public:
367  {
371  explicit AdditionalData(const double omega = 1);
372 
376  double omega;
377  };
378 
384 
391 
398  void
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
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
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
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
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
912 
913  private:
918  };
919 
920 
921 
928  {
929  public:
935  {};
936 
942 
950 
958  void
961 
962  private:
967  };
968 
992  template <int dim>
994  {
995  public:
1001  {
1006  AdditionalData(const bool use_vertices = true,
1007  const bool use_edges = false,
1008  const bool use_faces = false,
1009  const bool symmetric = false,
1010  const std::vector<Point<dim>> coords = {});
1011 
1017 
1024 
1031 
1036 
1041  std::vector<Point<dim>> coords;
1042  };
1043 
1048  PreconditionBDDC();
1049 
1056 
1061  PreconditionBDDC(const MPI_Comm communicator,
1063 
1070  void
1071  initialize(const MatrixBase &matrix,
1073 
1074  protected:
1079 
1085  void
1086  initialize();
1087  };
1088 
1090  {
1091  public:
1096  PreconditionShell() = default;
1097 
1102 
1106  PreconditionShell(const MPI_Comm communicator);
1107 
1116  std::function<void(VectorBase &dst, const VectorBase &src)> vmult;
1117 
1126  std::function<void(VectorBase &dst, const VectorBase &src)> vmultT;
1127 
1128  protected:
1133  void
1134  initialize(const MPI_Comm comm);
1135 
1140  void
1141  initialize(const MatrixBase &matrix);
1142 
1143  private:
1147  static PetscErrorCode
1148  pcapply(PC pc, Vec src, Vec dst);
1149 
1153  static PetscErrorCode
1154  pcapply_transpose(PC pc, Vec src, Vec dst);
1155 
1159  static PetscErrorCode
1160  pcsetup(PC pc);
1161  };
1162 } // namespace PETScWrappers
1163 
1164 
1166 
1167 
1168 #endif // DEAL_II_WITH_PETSC
1169 
1170 #endif
void Tvmult(VectorBase &dst, const VectorBase &src) const
void create_pc_with_comm(const MPI_Comm)
void vmult(VectorBase &dst, const VectorBase &src) const
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())
std::function< void(VectorBase &dst, const VectorBase &src)> vmult
static PetscErrorCode pcapply_transpose(PC pc, Vec src, Vec dst)
static PetscErrorCode pcsetup(PC pc)
void initialize(const MPI_Comm comm)
std::function< void(VectorBase &dst, const VectorBase &src)> vmultT
static PetscErrorCode pcapply(PC pc, Vec src, Vec dst)
Definition: point.h:112
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
@ 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