Reference documentation for deal.II version 9.2.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\}}\)
slepc_spectral_transformation.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2009 - 2019 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 
17 
18 #ifdef DEAL_II_WITH_SLEPC
19 
22 
23 # include <petscversion.h>
24 
25 # include <cmath>
26 # include <vector>
27 
29 
30 namespace SLEPcWrappers
31 {
33  {
34  const PetscErrorCode ierr = STCreate(mpi_communicator, &st);
35  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
36  }
37 
39  {
40  if (st != nullptr)
41  {
42  const PetscErrorCode ierr = STDestroy(&st);
43  (void)ierr;
44  AssertNothrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
45  }
46  }
47 
48  void
50  {
51  const PetscErrorCode ierr = STSetMatMode(st, mode);
52  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
53  }
54 
55  void
57  {
58  PetscErrorCode ierr = STSetKSP(st, solver.solver_data->ksp);
59  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
60  }
61 
62  /* ------------------- TransformationShift --------------------- */
63 
65  const double shift_parameter)
66  : shift_parameter(shift_parameter)
67  {}
68 
70  const AdditionalData &data)
71  : TransformationBase(mpi_communicator)
72  , additional_data(data)
73  {
74  PetscErrorCode ierr = STSetType(st, const_cast<char *>(STSHIFT));
75  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
76 
77  ierr = STSetShift(st, additional_data.shift_parameter);
78  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
79  }
80 
81  /* ---------------- TransformationShiftInvert ------------------ */
82 
84  const double shift_parameter)
85  : shift_parameter(shift_parameter)
86  {}
87 
89  const MPI_Comm & mpi_communicator,
90  const AdditionalData &data)
91  : TransformationBase(mpi_communicator)
92  , additional_data(data)
93  {
94  PetscErrorCode ierr = STSetType(st, const_cast<char *>(STSINVERT));
95  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
96 
97  ierr = STSetShift(st, additional_data.shift_parameter);
98  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
99  }
100 
101  /* --------------- TransformationSpectrumFolding ----------------- */
102 
104  const double shift_parameter)
105  : shift_parameter(shift_parameter)
106  {}
107 
109  const MPI_Comm & mpi_communicator,
110  const AdditionalData &data)
111  : TransformationBase(mpi_communicator)
112  , additional_data(data)
113  {
114 # if DEAL_II_PETSC_VERSION_LT(3, 5, 0)
115  PetscErrorCode ierr = STSetType(st, const_cast<char *>(STFOLD));
116  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
117 
118  ierr = STSetShift(st, additional_data.shift_parameter);
119  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
120 # else
121  // PETSc/SLEPc version must be < 3.5.0.
122  (void)st;
123  Assert((false),
124  ExcMessage(
125  "Folding transformation has been removed in SLEPc 3.5.0 and newer."
126  " You cannot use this transformation anymore."));
127 # endif
128  }
129 
130  /* ------------------- TransformationCayley --------------------- */
131 
133  const double shift_parameter,
134  const double antishift_parameter)
135  : shift_parameter(shift_parameter)
136  , antishift_parameter(antishift_parameter)
137  {}
138 
140  const AdditionalData &data)
141  : TransformationBase(mpi_communicator)
142  , additional_data(data)
143  {
144  PetscErrorCode ierr = STSetType(st, const_cast<char *>(STCAYLEY));
145  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
146 
147  ierr = STSetShift(st, additional_data.shift_parameter);
148  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
149 
150  ierr = STCayleySetAntishift(st, additional_data.antishift_parameter);
151  AssertThrow(ierr == 0, SolverBase::ExcSLEPcError(ierr));
152  }
153 
154 } // namespace SLEPcWrappers
155 
157 
158 #endif // DEAL_II_WITH_SLEPC
SLEPcWrappers::TransformationShiftInvert::TransformationShiftInvert
TransformationShiftInvert(const MPI_Comm &mpi_communicator, const AdditionalData &data=AdditionalData())
Definition: slepc_spectral_transformation.cc:88
PETScWrappers::SolverBase
Definition: petsc_solver.h:113
SLEPcWrappers::TransformationSpectrumFolding::AdditionalData::AdditionalData
AdditionalData(const double shift_parameter=0)
Definition: slepc_spectral_transformation.cc:103
SLEPcWrappers::TransformationCayley::additional_data
const AdditionalData additional_data
Definition: slepc_spectral_transformation.h:285
SLEPcWrappers::TransformationShift::additional_data
const AdditionalData additional_data
Definition: slepc_spectral_transformation.h:154
SLEPcWrappers::SolverBase::ExcSLEPcError
static ::ExceptionBase & ExcSLEPcError(int arg1)
SLEPcWrappers::TransformationCayley::AdditionalData::antishift_parameter
const double antishift_parameter
Definition: slepc_spectral_transformation.h:271
SLEPcWrappers::TransformationShiftInvert::AdditionalData
Definition: slepc_spectral_transformation.h:170
SLEPcWrappers::TransformationShift::AdditionalData::AdditionalData
AdditionalData(const double shift_parameter=0)
Definition: slepc_spectral_transformation.cc:64
petsc_matrix_base.h
SLEPcWrappers::TransformationSpectrumFolding::additional_data
const AdditionalData additional_data
Definition: slepc_spectral_transformation.h:240
MPI_Comm
SLEPcWrappers::TransformationCayley::AdditionalData::AdditionalData
AdditionalData(const double shift_parameter=0, const double antishift_parameter=0)
Definition: slepc_spectral_transformation.cc:132
SLEPcWrappers::TransformationShift::TransformationShift
TransformationShift(const MPI_Comm &mpi_communicator, const AdditionalData &data=AdditionalData())
Definition: slepc_spectral_transformation.cc:69
SLEPcWrappers::TransformationBase::set_solver
void set_solver(const PETScWrappers::SolverBase &solver)
Definition: slepc_spectral_transformation.cc:56
SLEPcWrappers::TransformationBase::set_matrix_mode
void set_matrix_mode(const STMatMode mode)
Definition: slepc_spectral_transformation.cc:49
SLEPcWrappers::TransformationShiftInvert::additional_data
const AdditionalData additional_data
Definition: slepc_spectral_transformation.h:194
SLEPcWrappers::TransformationBase
Definition: slepc_spectral_transformation.h:74
StandardExceptions::ExcMessage
static ::ExceptionBase & ExcMessage(std::string arg1)
slepc_solver.h
SLEPcWrappers::TransformationBase::~TransformationBase
virtual ~TransformationBase()
Definition: slepc_spectral_transformation.cc:38
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
SLEPcWrappers::TransformationShift::AdditionalData
Definition: slepc_spectral_transformation.h:129
SLEPcWrappers::TransformationCayley::TransformationCayley
TransformationCayley(const MPI_Comm &mpi_communicator, const AdditionalData &data=AdditionalData())
Definition: slepc_spectral_transformation.cc:139
SLEPcWrappers
Definition: slepc_solver.h:137
SLEPcWrappers::TransformationShiftInvert::AdditionalData::AdditionalData
AdditionalData(const double shift_parameter=0)
Definition: slepc_spectral_transformation.cc:83
SLEPcWrappers::TransformationSpectrumFolding::TransformationSpectrumFolding
TransformationSpectrumFolding(const MPI_Comm &mpi_communicator, const AdditionalData &data=AdditionalData())
Definition: slepc_spectral_transformation.cc:108
slepc_spectral_transformation.h
SLEPcWrappers::TransformationSpectrumFolding::AdditionalData::shift_parameter
const double shift_parameter
Definition: slepc_spectral_transformation.h:225
Assert
#define Assert(cond, exc)
Definition: exceptions.h:1419
SLEPcWrappers::TransformationBase::TransformationBase
TransformationBase(const MPI_Comm &mpi_communicator)
Definition: slepc_spectral_transformation.cc:32
SLEPcWrappers::TransformationSpectrumFolding::AdditionalData
Definition: slepc_spectral_transformation.h:215
SLEPcWrappers::TransformationShiftInvert::AdditionalData::shift_parameter
const double shift_parameter
Definition: slepc_spectral_transformation.h:180
AssertNothrow
#define AssertNothrow(cond, exc)
Definition: exceptions.h:1483
PETScWrappers::SolverBase::solver_data
std::unique_ptr< SolverData > solver_data
Definition: petsc_solver.h:252
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
SLEPcWrappers::TransformationCayley::AdditionalData
Definition: slepc_spectral_transformation.h:255
AssertThrow
#define AssertThrow(cond, exc)
Definition: exceptions.h:1531
SLEPcWrappers::TransformationCayley::AdditionalData::shift_parameter
const double shift_parameter
Definition: slepc_spectral_transformation.h:266
SLEPcWrappers::TransformationBase::st
ST st
Definition: slepc_spectral_transformation.h:110
SLEPcWrappers::TransformationShift::AdditionalData::shift_parameter
const double shift_parameter
Definition: slepc_spectral_transformation.h:139