Reference documentation for deal.II version 9.6.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
slepc_spectral_transformation.cc
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2009 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
16
17#ifdef DEAL_II_WITH_SLEPC
18
21
22# include <petscversion.h>
23
24# include <cmath>
25# include <vector>
26
28
29namespace SLEPcWrappers
30{
32 {
33 const PetscErrorCode ierr = STCreate(mpi_communicator, &st);
34 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
35 }
36
38 {
39 if (st != nullptr)
40 {
41 const PetscErrorCode ierr = STDestroy(&st);
42 (void)ierr;
44 }
45 }
46
47 void
49 {
50 const PetscErrorCode ierr = STSetMatMode(st, mode);
51 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
52 }
53
54 void
56 {
57 PetscErrorCode ierr = STSetKSP(st, solver);
58 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
59 }
60
61 /* ------------------- TransformationShift --------------------- */
62
64 const double shift_parameter)
65 : shift_parameter(shift_parameter)
66 {}
67
69 const AdditionalData &data)
70 : TransformationBase(mpi_communicator)
71 , additional_data(data)
72 {
73 PetscErrorCode ierr = STSetType(st, const_cast<char *>(STSHIFT));
74 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
75
76 ierr = STSetShift(st, additional_data.shift_parameter);
77 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
78 }
79
80 /* ---------------- TransformationShiftInvert ------------------ */
81
83 const double shift_parameter)
84 : shift_parameter(shift_parameter)
85 {}
86
88 const MPI_Comm mpi_communicator,
89 const AdditionalData &data)
90 : TransformationBase(mpi_communicator)
91 , additional_data(data)
92 {
93 PetscErrorCode ierr = STSetType(st, const_cast<char *>(STSINVERT));
94 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
95
96 ierr = STSetShift(st, additional_data.shift_parameter);
97 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
98 }
99
100 /* --------------- TransformationSpectrumFolding ----------------- */
101
103 const double shift_parameter)
104 : shift_parameter(shift_parameter)
105 {}
106
108 const MPI_Comm mpi_communicator,
109 const AdditionalData &data)
110 : TransformationBase(mpi_communicator)
111 , additional_data(data)
112 {
113 // This feature is only in PETSc/SLEPc versions 3.4 or older, which we no
114 // longer support.
115 Assert(false,
117 "Folding transformation has been removed in SLEPc 3.5.0 and newer."
118 " You cannot use this transformation anymore."));
119 }
120
121 /* ------------------- TransformationCayley --------------------- */
122
124 const double shift_parameter,
125 const double antishift_parameter)
126 : shift_parameter(shift_parameter)
127 , antishift_parameter(antishift_parameter)
128 {}
129
131 const AdditionalData &data)
132 : TransformationBase(mpi_communicator)
133 , additional_data(data)
134 {
135 PetscErrorCode ierr = STSetType(st, const_cast<char *>(STCAYLEY));
136 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
137
138 ierr = STSetShift(st, additional_data.shift_parameter);
139 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
140
141 ierr = STCayleySetAntishift(st, additional_data.antishift_parameter);
142 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
143 }
144
145} // namespace SLEPcWrappers
146
148
149#endif // DEAL_II_WITH_SLEPC
TransformationBase(const MPI_Comm mpi_communicator)
void set_solver(const PETScWrappers::SolverBase &solver)
TransformationCayley(const MPI_Comm mpi_communicator, const AdditionalData &data=AdditionalData())
TransformationShiftInvert(const MPI_Comm mpi_communicator, const AdditionalData &data=AdditionalData())
TransformationShift(const MPI_Comm mpi_communicator, const AdditionalData &data=AdditionalData())
TransformationSpectrumFolding(const MPI_Comm mpi_communicator, const AdditionalData &data=AdditionalData())
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
static ::ExceptionBase & ExcSLEPcError(int arg1)
#define Assert(cond, exc)
#define AssertNothrow(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
AdditionalData(const double shift_parameter=0, const double antishift_parameter=0)