eigen_solver.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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 // Local Includes
23 #include "libmesh/eigen_solver.h"
26 #include "libmesh/auto_ptr.h" // libmesh_make_unique
28 
29 namespace libMesh
30 {
31 
32 
33 //------------------------------------------------------------------
34 // EigenSolver members
35 template <typename T>
37  ParallelObject(comm_in),
38  _eigen_solver_type (ARNOLDI),
39  _eigen_problem_type (NHEP),
40  _position_of_spectrum (LARGEST_MAGNITUDE),
41  _is_initialized (false),
42  _solver_configuration(nullptr),
43  _close_matrix_before_solve(true)
44 {
45 }
46 
47 
48 
49 template <typename T>
51 {
52  this->clear ();
53 }
54 
55 
56 
57 template <typename T>
58 std::unique_ptr<EigenSolver<T>>
60  const SolverPackage solver_package)
61 {
62  // Build the appropriate solver
63  switch (solver_package)
64  {
65 
66 #ifdef LIBMESH_HAVE_SLEPC
67  case SLEPC_SOLVERS:
68  return libmesh_make_unique<SlepcEigenSolver<T>>(comm);
69 #endif
70 
71  default:
72  libmesh_error_msg("ERROR: Unrecognized eigen solver package: " << solver_package);
73  }
74 
75  return std::unique_ptr<EigenSolver<T>>();
76 }
77 
78 
79 template <typename T>
81 {
82  _solver_configuration = &solver_configuration;
83 }
84 
85 template <typename T>
87 {
88  if (pos >= 0)
89  _position_of_spectrum = TARGET_MAGNITUDE;
90  else
91  _position_of_spectrum = TARGET_REAL;
92 
93  _target_val = pos;
94 }
95 
96 template <typename T>
98 {
99  _position_of_spectrum = target;
100  _target_val = pos;
101 }
102 
103 
104 
105 //------------------------------------------------------------------
106 // Explicit instantiations
107 template class EigenSolver<Number>;
108 
109 } // namespace libMesh
110 
111 
112 #endif // LIBMESH_HAVE_SLEPC
EigenSolver(const Parallel::Communicator &comm_in)
Definition: eigen_solver.C:36
An object whose state is distributed along a set of processors.
virtual ~EigenSolver()
Definition: eigen_solver.C:50
static std::unique_ptr< EigenSolver< T > > build(const Parallel::Communicator &comm_in, const SolverPackage solver_package=SLEPC_SOLVERS)
Definition: eigen_solver.C:59
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void set_position_of_spectrum(PositionOfSpectrum pos)
Definition: eigen_solver.h:158
void set_solver_configuration(SolverConfiguration &solver_configuration)
Definition: eigen_solver.C:80
Base class which defines the interface for solving eigenproblems.
Definition: eigen_solver.h:68