/usr/include/libmesh/eigen_solver.h is in libmesh-dev 0.7.1-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | // $Id: eigen_solver.h 4278 2011-03-21 15:23:30Z roystgnr $
// The libMesh Finite Element Library.
// Copyright (C) 2002-2008 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// This library is distributd in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef __eigen_solver_h__
#define __eigen_solver_h__
#include "libmesh_config.h"
#ifdef LIBMESH_HAVE_SLEPC
// C++ includes
// Local includes
#include "libmesh_common.h"
#include "enum_solver_package.h"
#include "enum_eigen_solver_type.h"
#include "reference_counted_object.h"
#include "libmesh.h"
namespace libMesh
{
// forward declarations
template <typename T> class AutoPtr;
template <typename T> class SparseMatrix;
template <typename T> class ShellMatrix;
template <typename T> class NumericVector;
/**
* This class provides an interface to solvers for eigenvalue
* problems.
*/
template <typename T>
class EigenSolver : public ReferenceCountedObject<EigenSolver<T> >
{
public:
/**
* Constructor. Initializes Solver data structures
*/
EigenSolver ();
/**
* Destructor.
*/
virtual ~EigenSolver ();
/**
* Builds an \p EigenSolver using the linear solver package specified by
* \p solver_package
*/
static AutoPtr<EigenSolver<T> > build(const SolverPackage solver_package =
SLEPC_SOLVERS);
/**
* @returns true if the data structures are
* initialized, false otherwise.
*/
bool initialized () const { return _is_initialized; }
/**
* Release all memory and clear data structures.
*/
virtual void clear () {}
/**
* Initialize data structures if not done so already.
*/
virtual void init () = 0;
/**
* Returns the type of eigensolver to use.
*/
EigenSolverType eigen_solver_type () const { return _eigen_solver_type; }
/**
* Returns the type of the eigen problem.
*/
EigenProblemType eigen_problem_type () const { return _eigen_problem_type;}
/**
* Returns the position of the spectrum to compute.
*/
PositionOfSpectrum position_of_spectrum () const
{ return _position_of_spectrum;}
/**
* Sets the type of eigensolver to use.
*/
void set_eigensolver_type (const EigenSolverType est)
{ _eigen_solver_type = est; }
/**
* Sets the type of the eigenproblem.
*/
void set_eigenproblem_type ( EigenProblemType ept)
{_eigen_problem_type = ept;}
/**
* Sets the position of the spectrum.
*/
void set_position_of_spectrum (PositionOfSpectrum pos)
{_position_of_spectrum= pos;}
/**
* Solves the standard eigen problem when matrix_A is a
* \p SparseMatrix, and returns the number of converged
* eigenpairs and the number of iterations.
*/
virtual std::pair<unsigned int, unsigned int> solve_standard (SparseMatrix<T> &matrix_A,
int nev,
int ncv,
const double tol,
const unsigned int m_its) = 0;
/**
* Solves the standard eigen problem when matrix_A is a
* \p ShellMatrix, and returns the number of converged
* eigenpairs and the number of iterations.
*/
virtual std::pair<unsigned int, unsigned int> solve_standard (ShellMatrix<T> &matrix_A,
int nev,
int ncv,
const double tol,
const unsigned int m_its) = 0;
/**
* Solves the generalized eigen problem when both matrix_A
* and matrix_B are of type \p SparseMatrix and returns the
* number of converged eigenpairs and the number
* of iterations.
*/
virtual std::pair<unsigned int, unsigned int> solve_generalized (SparseMatrix<T> &matrix_A,
SparseMatrix<T> &matrix_B,
int nev,
int ncv,
const double tol,
const unsigned int m_its) = 0;
/**
* Solves the generalized eigen problem when matrix_A is
* a ShellMatrix and matrix_B is a SparseMatrix.
*/
virtual std::pair<unsigned int, unsigned int> solve_generalized (ShellMatrix<T> &matrix_A,
SparseMatrix<T> &matrix_B,
int nev,
int ncv,
const double tol,
const unsigned int m_its) = 0;
/**
* Solves the generalized eigen problem when matrix_A is
* a SparseMatrix and matrix_B is a ShellMatrix.
*/
virtual std::pair<unsigned int, unsigned int> solve_generalized (SparseMatrix<T> &matrix_A,
ShellMatrix<T> &matrix_B,
int nev,
int ncv,
const double tol,
const unsigned int m_its) = 0;
/**
* Solves the generalized eigen problem when both matrix_A
* and matrix_B are of type ShellMatrix.
*/
virtual std::pair<unsigned int, unsigned int> solve_generalized (ShellMatrix<T> &matrix_A,
ShellMatrix<T> &matrix_B,
int nev,
int ncv,
const double tol,
const unsigned int m_its) = 0;
/**
* Returns the \p ith eigenvalue (real and imaginary part),
* and copies the \ ith eigen vector to the solution vector.
*/
virtual std::pair<Real, Real> get_eigenpair (unsigned int i,
NumericVector<T> &solution) = 0;
/**
* Attach a deflation space defined by a single vector.
*/
virtual void attach_deflation_space(NumericVector<T> &deflation_vector) = 0;
protected:
/**
* Enum stating which type of eigensolver to use.
*/
EigenSolverType _eigen_solver_type;
/**
* Enum stating which type of eigen problem we deal with.
*/
EigenProblemType _eigen_problem_type;
/**
* Enum stating where to evaluate the spectrum.
*/
PositionOfSpectrum _position_of_spectrum;
/**
* Flag indicating if the data structures have been initialized.
*/
bool _is_initialized;
};
/*----------------------- inline functions ----------------------------------*/
template <typename T>
inline
EigenSolver<T>::EigenSolver () :
_eigen_solver_type (ARNOLDI),
_eigen_problem_type (NHEP),
_position_of_spectrum (LARGEST_MAGNITUDE),
_is_initialized (false)
{
}
template <typename T>
inline
EigenSolver<T>::~EigenSolver ()
{
this->clear ();
}
} // namespace libMesh
#endif // LIBMESH_HAVE_SLEPC
#endif // #ifdef __eigen_solver_h__
|