Reference documentation for deal.II version 9.5.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\}}\)
Loading...
Searching...
No Matches
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
28
29# include <petscpc.h>
30
31# include <functional>
32
34
35
36
37namespace 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
115 get_mpi_communicator() const;
116
117 protected:
121 PC pc;
122
127 void
129
133 void
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
324
329 PreconditionSOR(const MatrixBase & matrix,
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
389 PreconditionSSOR(const MatrixBase & matrix,
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
442
447 PreconditionICC(const MatrixBase & matrix,
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
502
507 PreconditionILU(const MatrixBase & matrix,
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
571
576 double damping;
577 };
578
584
589 PreconditionLU(const MatrixBase & matrix,
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
697
704
710
715
720
725
729 unsigned int n_sweeps_coarse;
730
734 double tol;
735
739 unsigned int max_iter;
740
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
948 PreconditionNone(const MatrixBase & matrix,
950
958 void
959 initialize(const MatrixBase & matrix,
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
1049
1054 PreconditionBDDC(const MatrixBase & matrix,
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:
1097
1101 PreconditionShell(const MatrixBase &matrix);
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
1168} // namespace PETScWrappers
1169
1170
1172
1173
1174#endif // DEAL_II_WITH_PETSC
1175
1176#endif
void Tvmult(VectorBase &dst, const VectorBase &src) const
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_DEPRECATED
Definition config.h:172
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
const MPI_Comm comm