Reference documentation for deal.II version 9.5.1
\(\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
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
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
324
331
338 void
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
401
402 protected:
407 };
408
418 {
419 public:
425 {
429 AdditionalData(const unsigned int levels = 0);
430
434 unsigned int levels;
435 };
436
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
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
571
576 double damping;
577 };
578
584
591
598 void
601
602 protected:
607 };
608
609
610
622 {
623 public:
629 {
633 enum class RelaxationType
634 {
635 Jacobi,
636 sequentialGaussSeidel,
637 seqboundaryGaussSeidel,
638 SORJacobi,
639 backwardSORJacobi,
640 symmetricSORJacobi,
641 l1scaledSORJacobi,
642 GaussianElimination,
643 l1GaussSeidel,
644 backwardl1GaussSeidel,
645 CG,
646 Chebyshev,
647 FCFJacobi,
648 l1scaledJacobi,
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
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
1049
1056
1061 PreconditionBDDC(const MPI_Comm communicator,
1063
1070 void
1073
1074 protected:
1079
1085 void
1086 initialize();
1087 };
1088
1090 {
1091 public:
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
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 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_DEPRECATED
Definition: config.h:172
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:473
@ 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