libMesh
eigen_solver.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 #include "libmesh/libmesh_config.h"
20 #ifdef LIBMESH_HAVE_SLEPC
21 
22 // C++ includes
23 
24 // Local Includes
25 #include "libmesh/eigen_solver.h"
26 #include "libmesh/slepc_eigen_solver.h"
27 #include "libmesh/solver_configuration.h"
28 
29 namespace libMesh
30 {
31 
32 
33 //------------------------------------------------------------------
34 // EigenSolver members
35 template <typename T>
36 UniquePtr<EigenSolver<T>>
38  const SolverPackage solver_package)
39 {
40  // Build the appropriate solver
41  switch (solver_package)
42  {
43 
44 #ifdef LIBMESH_HAVE_SLEPC
45  case SLEPC_SOLVERS:
47 #endif
48 
49  default:
50  libmesh_error_msg("ERROR: Unrecognized eigen solver package: " << solver_package);
51  }
52 
53  return UniquePtr<EigenSolver<T>>();
54 }
55 
56 
57 template <typename T>
59 {
60  _solver_configuration = &solver_configuration;
61 }
62 
63 template <typename T>
65 {
66  if (pos >= 0)
67  _position_of_spectrum = TARGET_MAGNITUDE;
68  else
69  _position_of_spectrum = TARGET_REAL;
70 
71  _target_val = pos;
72 }
73 
74 template <typename T>
76 {
77  _position_of_spectrum = target;
78  _target_val = pos;
79 }
80 
81 
82 
83 //------------------------------------------------------------------
84 // Explicit instantiations
85 template class EigenSolver<Number>;
86 
87 } // namespace libMesh
88 
89 
90 #endif // LIBMESH_HAVE_SLEPC
Encapsulates the MPI_Comm object.
Definition: parallel.h:657
This class provides an interface to the SLEPc eigenvalue solver library from http://slepc.upv.es/.
SolverPackage
Defines an enum for various linear solver packages.
The libMesh namespace provides an interface to certain functionality in the library.
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
This class stores solver configuration data, e.g.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void set_position_of_spectrum(PositionOfSpectrum pos)
Sets the position of the spectrum.
Definition: eigen_solver.h:146
PositionOfSpectrum
Defines an enum for the position of the spectrum, i.e.
void set_solver_configuration(SolverConfiguration &solver_configuration)
Set the solver configuration object.
Definition: eigen_solver.C:58
static UniquePtr< EigenSolver< T > > build(const Parallel::Communicator &comm_in LIBMESH_CAN_DEFAULT_TO_COMMWORLD, const SolverPackage solver_package=SLEPC_SOLVERS)
Builds an EigenSolver using the linear solver package specified by solver_package.
Definition: eigen_solver.C:37
This class provides an interface to solvers for eigenvalue problems.
Definition: eigen_solver.h:54