deal.II version GIT relicensing-2206-gaa53ff9447 2024-12-02 09:10:00+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: 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)
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)
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 /* ------------------- TransformationCayley --------------------- */
101
103 const double shift_parameter,
104 const double antishift_parameter)
105 : shift_parameter(shift_parameter)
106 , antishift_parameter(antishift_parameter)
107 {}
108
110 const AdditionalData &data)
111 : TransformationBase(mpi_communicator)
113 {
114 PetscErrorCode ierr = STSetType(st, const_cast<char *>(STCAYLEY));
115 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
116
117 ierr = STSetShift(st, additional_data.shift_parameter);
118 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
119
120 ierr = STCayleySetAntishift(st, additional_data.antishift_parameter);
121 AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
122 }
123
124} // namespace SLEPcWrappers
125
127
128#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())
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
static ::ExceptionBase & ExcSLEPcError(int arg1)
#define AssertNothrow(cond, exc)
#define AssertThrow(cond, exc)
std::vector< index_type > data
Definition mpi.cc:735
AdditionalData(const double shift_parameter=0, const double antishift_parameter=0)