deal.II version GIT relicensing-6842-g793a97d2aa 2026-10-02 14:00:01+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\}}\)
Loading...
Searching...
No Matches
slepc_spectral_transformation.cc
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2009 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
14
15#ifdef DEAL_II_WITH_SLEPC
18
19# include <petscversion.h>
20
21# include <cmath>
22# include <vector>
23#endif
24
26
27#ifdef DEAL_II_WITH_SLEPC
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);
43 }
44 }
45
46 void
48 {
49 const PetscErrorCode ierr = STSetMatMode(st, mode);
50 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
51 }
52
53 void
55 {
56 PetscErrorCode ierr = STSetKSP(st, solver);
57 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
58 }
59
60 /* ------------------- TransformationShift --------------------- */
61
63 const double shift_parameter)
64 : shift_parameter(shift_parameter)
65 {}
66
68 const AdditionalData &data)
69 : TransformationBase(mpi_communicator)
71 {
72 PetscErrorCode ierr = STSetType(st, const_cast<char *>(STSHIFT));
73 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
74
75 ierr = STSetShift(st, additional_data.shift_parameter);
76 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
77 }
78
79 /* ---------------- TransformationShiftInvert ------------------ */
80
82 const double shift_parameter)
83 : shift_parameter(shift_parameter)
84 {}
85
87 const MPI_Comm mpi_communicator,
88 const AdditionalData &data)
89 : TransformationBase(mpi_communicator)
91 {
92 PetscErrorCode ierr = STSetType(st, const_cast<char *>(STSINVERT));
93 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
94
95 ierr = STSetShift(st, additional_data.shift_parameter);
96 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
97 }
98
99 /* ------------------- TransformationCayley --------------------- */
100
102 const double shift_parameter,
103 const double antishift_parameter)
104 : shift_parameter(shift_parameter)
105 , antishift_parameter(antishift_parameter)
106 {}
107
109 const AdditionalData &data)
110 : TransformationBase(mpi_communicator)
112 {
113 PetscErrorCode ierr = STSetType(st, const_cast<char *>(STCAYLEY));
114 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
115
116 ierr = STSetShift(st, additional_data.shift_parameter);
117 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
118
119 ierr = STCayleySetAntishift(st, additional_data.antishift_parameter);
120 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
121 }
122
123} // namespace SLEPcWrappers
124
125#endif // DEAL_II_WITH_SLEPC
126
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())
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
static ::ExceptionBase & ExcSLEPcError(int arg1)
#define AssertNothrow(cond, exc)
#define AssertThrow(cond, exc)
std::vector< index_type > data
Definition mpi.cc:734
AdditionalData(const double shift_parameter=0, const double antishift_parameter=0)