Reference documentation for deal.II version Git 9ccd10d 2017-04-29 21:50:25 -0400
Classes | Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
PArpackSolver< VectorType > Class Template Reference

#include <deal.II/lac/parpack_solver.h>

Inheritance diagram for PArpackSolver< VectorType >:
[legend]

Classes

struct  AdditionalData
 
class  Shift
 

Public Types

enum  WhichEigenvalues {
  algebraically_largest, algebraically_smallest, largest_magnitude, smallest_magnitude,
  largest_real_part, smallest_real_part, largest_imaginary_part, smallest_imaginary_part,
  both_ends
}
 
typedef types::global_dof_index size_type
 

Public Member Functions

SolverControlcontrol () const
 
 PArpackSolver (SolverControl &control, const MPI_Comm &mpi_communicator, const AdditionalData &data=AdditionalData())
 
void reinit (const IndexSet &locally_owned_dofs)
 
void reinit (const IndexSet &locally_owned_dofs, const std::vector< IndexSet > &partitioning)
 
void reinit (const VectorType &distributed_vector)
 
void set_initial_vector (const VectorType &vec)
 
void set_shift (const std::complex< double > sigma)
 
template<typename MatrixType1 , typename MatrixType2 , typename INVERSE >
void solve (const MatrixType1 &A, const MatrixType2 &B, const INVERSE &inverse, std::vector< std::complex< double > > &eigenvalues, std::vector< VectorType > &eigenvectors, const unsigned int n_eigenvalues)
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
 Subscriptor (Subscriptor &&)
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
Subscriptoroperator= (Subscriptor &&)
 
void subscribe (const char *identifier=nullptr) const
 
void unsubscribe (const char *identifier=nullptr) const
 
unsigned int n_subscriptions () const
 
void list_subscribers () const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Protected Attributes

SolverControlsolver_control
 
const AdditionalData additional_data
 
MPI_Comm mpi_communicator
 
MPI_Fint mpi_communicator_fortran
 
int lworkl
 
std::vector< double > workl
 
std::vector< double > workd
 
int nloc
 
int ncv
 
int ldv
 
std::vector< double > v
 
bool initial_vector_provided
 
std::vector< double > resid
 
int ldz
 
std::vector< double > z
 
int lworkev
 
std::vector< double > workev
 
std::vector< int > select
 
VectorType src
 
std::vector< types::global_dof_indexlocal_indices
 
double sigmar
 
double sigmai
 

Private Member Functions

void internal_reinit (const IndexSet &locally_owned_dofs)
 

Static Private Member Functions

static::ExceptionBase & PArpackExcConvergedEigenvectors (int arg1, int arg2)
 
static::ExceptionBase & PArpackExcInvalidNumberofEigenvalues (int arg1, int arg2)
 
static::ExceptionBase & PArpackExcInvalidEigenvectorSize (int arg1, int arg2)
 
static::ExceptionBase & PArpackExcInvalidEigenvectorSizeNonsymmetric (int arg1, int arg2)
 
static::ExceptionBase & PArpackExcInvalidEigenvalueSize (int arg1, int arg2)
 
static::ExceptionBase & PArpackExcInvalidNumberofArnoldiVectors (int arg1, int arg2)
 
static::ExceptionBase & PArpackExcSmallNumberofArnoldiVectors (int arg1, int arg2)
 
static::ExceptionBase & PArpackExcIdo (int arg1)
 
static::ExceptionBase & PArpackExcMode (int arg1)
 
static::ExceptionBase & PArpackExcInfoPdnaupd (int arg1)
 
static::ExceptionBase & PArpackExcInfoPdneupd (int arg1)
 
static::ExceptionBase & PArpackExcInfoMaxIt (int arg1)
 
static::ExceptionBase & PArpackExcNoShifts (int arg1)
 

Additional Inherited Members

- Static Public Member Functions inherited from Subscriptor
static::ExceptionBase & ExcInUse (int arg1, char *arg2, std::string &arg3)
 
static::ExceptionBase & ExcNoSubscriber (char *arg1, char *arg2)
 

Detailed Description

template<typename VectorType>
class PArpackSolver< VectorType >

Interface for using PARPACK. PARPACK is a collection of Fortran77 subroutines designed to solve large scale eigenvalue problems. Here we interface to the routines pdneupd, pdseupd, pdnaupd, pdsaupd of PARPACK. The package is designed to compute a few eigenvalues and corresponding eigenvectors of a general n by n matrix A. It is most appropriate for large sparse matrices A.

In this class we make use of the method applied to the generalized eigenspectrum problem \((A-\lambda B)x=0\), for \(x\neq0\); where \(A\) is a system matrix, \(B\) is a mass matrix, and \(\lambda, x\) are a set of eigenvalues and eigenvectors respectively.

The ArpackSolver can be used in application codes in the following way:

const unsigned int num_arnoldi_vectors = 2*size_of_spectrum + 2;
additional_data(num_arnoldi_vectors,
true);
eigensolver.set_shift(sigma);
eigensolver.reinit(locally_owned_dofs);
eigensolver.solve (A,
B,
OP,
lambda,
x,
size_of_spectrum);

for the generalized eigenvalue problem \(Ax=B\lambda x\), where the variable size_of_spectrum tells PARPACK the number of eigenvector/eigenvalue pairs to solve for. Here, lambda is a vector that will contain the eigenvalues computed, x a vector of objects of type V that will contain the eigenvectors computed. OP is an inverse operation for the matrix A - sigma * B, where sigma is a shift value, set to zero by default. Note that (P)Arpack supports other transformations, but currently this class implements only shift-and-invert mode.

The OP can be specified either using auxiliary Shift class together with IterativeInverse or by using LinearOperator

const double shift = 5.0;
const auto op_A = linear_operator<vector_t>(A);
const auto op_B = linear_operator<vector_t>(B);
const auto op_shift = op_A - shift * op_B;
SolverControl solver_control_lin (1000, 1e-10,false,false);
SolverCG<vector_t> cg(solver_control_lin);
const auto op_shift_invert = inverse_operator(op_shift, cg, PreconditionIdentity ());

Through the AdditionalData the user can specify some of the parameters to be set.

The class is intended to be used with MPI and can work on arbitrary vector and matrix distributed classes. Both symmetric and non-symmetric A are supported.

For further information on how the PARPACK routines pdneupd, pdseupd, pdnaupd, pdsaupd work and also how to set the parameters appropriately please take a look into the PARPACK manual.

Author
Denis Davydov, 2015.

Definition at line 144 of file parpack_solver.h.

Member Typedef Documentation

template<typename VectorType>
typedef types::global_dof_index PArpackSolver< VectorType >::size_type

Declare the type for container size.

Definition at line 150 of file parpack_solver.h.

Member Enumeration Documentation

template<typename VectorType>
enum PArpackSolver::WhichEigenvalues

An enum that lists the possible choices for which eigenvalues to compute in the solve() function. Note, that this corresponds to the problem after shift-and-invert (the only currently supported spectral transformation) is applied.

A particular choice is limited based on symmetric or non-symmetric matrix A considered.

Enumerator
algebraically_largest 

The algebraically largest eigenvalues.

algebraically_smallest 

The algebraically smallest eigenvalues.

largest_magnitude 

The eigenvalue with the largest magnitudes.

smallest_magnitude 

The eigenvalue with the smallest magnitudes.

largest_real_part 

The eigenvalues with the largest real parts.

smallest_real_part 

The eigenvalues with the smallest real parts.

largest_imaginary_part 

The eigenvalues with the largest imaginary parts.

smallest_imaginary_part 

The eigenvalues with the smallest imaginary parts.

both_ends 

Compute half of the eigenvalues from the high end of the spectrum and the other half from the low end. If the number of requested eigenvectors is odd, then the extra eigenvector comes from the high end of the spectrum.

Definition at line 161 of file parpack_solver.h.

Constructor & Destructor Documentation

template<typename VectorType >
PArpackSolver< VectorType >::PArpackSolver ( SolverControl control,
const MPI_Comm &  mpi_communicator,
const AdditionalData data = AdditionalData() 
)

Constructor.

Definition at line 556 of file parpack_solver.h.

Member Function Documentation

template<typename VectorType >
SolverControl & PArpackSolver< VectorType >::control ( ) const

Access to the object that controls convergence.

Definition at line 1020 of file parpack_solver.h.

template<typename VectorType >
void PArpackSolver< VectorType >::reinit ( const IndexSet locally_owned_dofs)

Initialize internal variables.

Definition at line 637 of file parpack_solver.h.

template<typename VectorType >
void PArpackSolver< VectorType >::reinit ( const IndexSet locally_owned_dofs,
const std::vector< IndexSet > &  partitioning 
)

Initialize internal variables when working with BlockVectors. locally_owned_dofs is used to set the dimension of the problem, whereas partitioning is used for calling the reinit of the deal.II blockvectors used.

Definition at line 660 of file parpack_solver.h.

template<typename VectorType >
void PArpackSolver< VectorType >::reinit ( const VectorType &  distributed_vector)

Initialize internal variables from the input distributed_vector.

Definition at line 648 of file parpack_solver.h.

template<typename VectorType >
void PArpackSolver< VectorType >::set_initial_vector ( const VectorType &  vec)

Set initial vector for building Krylov space.

Definition at line 584 of file parpack_solver.h.

template<typename VectorType >
void PArpackSolver< VectorType >::set_shift ( const std::complex< double >  sigma)

Set shift sigma for shift-and-invert spectral transformation.

If this function is not called, the shift is assumed to be zero.

Definition at line 576 of file parpack_solver.h.

template<typename VectorType >
template<typename MatrixType1 , typename MatrixType2 , typename INVERSE >
void PArpackSolver< VectorType >::solve ( const MatrixType1 &  A,
const MatrixType2 &  B,
const INVERSE &  inverse,
std::vector< std::complex< double > > &  eigenvalues,
std::vector< VectorType > &  eigenvectors,
const unsigned int  n_eigenvalues 
)

Solve the generalized eigensprectrum problem \(A x=\lambda B x\) by calling the pd(n/s)eupd and pd(n/s)aupd functions of PARPACK.

Definition at line 674 of file parpack_solver.h.

template<typename VectorType >
void PArpackSolver< VectorType >::internal_reinit ( const IndexSet locally_owned_dofs)
private

Initialize internal variables which depend on locally_owned_dofs.

This function is called inside the reinit() functions

Definition at line 597 of file parpack_solver.h.

Member Data Documentation

template<typename VectorType>
SolverControl& PArpackSolver< VectorType >::solver_control
protected

Reference to the object that controls convergence of the iterative solver.

Definition at line 331 of file parpack_solver.h.

template<typename VectorType>
const AdditionalData PArpackSolver< VectorType >::additional_data
protected

Store a copy of the flags for this particular solver.

Definition at line 336 of file parpack_solver.h.

template<typename VectorType>
MPI_Comm PArpackSolver< VectorType >::mpi_communicator
protected

C++ MPI communicator.

Definition at line 343 of file parpack_solver.h.

template<typename VectorType>
MPI_Fint PArpackSolver< VectorType >::mpi_communicator_fortran
protected

Fortran MPI communicator.

Definition at line 348 of file parpack_solver.h.

template<typename VectorType>
int PArpackSolver< VectorType >::lworkl
protected

Length of the work array workl.

Definition at line 355 of file parpack_solver.h.

template<typename VectorType>
std::vector<double> PArpackSolver< VectorType >::workl
protected

Double precision work array of length lworkl

Definition at line 360 of file parpack_solver.h.

template<typename VectorType>
std::vector<double> PArpackSolver< VectorType >::workd
protected

Double precision work array of length 3*N

Definition at line 365 of file parpack_solver.h.

template<typename VectorType>
int PArpackSolver< VectorType >::nloc
protected

Number of local degrees of freedom.

Definition at line 370 of file parpack_solver.h.

template<typename VectorType>
int PArpackSolver< VectorType >::ncv
protected

Number of Arnoldi basis vectors specified in additional_data

Definition at line 375 of file parpack_solver.h.

template<typename VectorType>
int PArpackSolver< VectorType >::ldv
protected

The leading dimension of the array v

Definition at line 381 of file parpack_solver.h.

template<typename VectorType>
std::vector<double> PArpackSolver< VectorType >::v
protected

Double precision vector of size ldv by NCV. Will contains the final set of Arnoldi basis vectors.

Definition at line 387 of file parpack_solver.h.

template<typename VectorType>
bool PArpackSolver< VectorType >::initial_vector_provided
protected

An auxiliary flag which is set to true when initial vector is provided.

Definition at line 392 of file parpack_solver.h.

template<typename VectorType>
std::vector<double> PArpackSolver< VectorType >::resid
protected

The initial residual vector, possibly from a previous run. On output, it contains the final residual vector.

Definition at line 398 of file parpack_solver.h.

template<typename VectorType>
int PArpackSolver< VectorType >::ldz
protected

The leading dimension of the array Z equal to nloc.

Definition at line 403 of file parpack_solver.h.

template<typename VectorType>
std::vector<double> PArpackSolver< VectorType >::z
protected

A vector of minimum size of nloc by NEV+1. Z contains the B-orthonormal Ritz vectors of the eigensystem A*z = lambda*B*z corresponding to the Ritz value approximations.

Definition at line 410 of file parpack_solver.h.

template<typename VectorType>
int PArpackSolver< VectorType >::lworkev
protected

The size of the workev array.

Definition at line 415 of file parpack_solver.h.

template<typename VectorType>
std::vector<double> PArpackSolver< VectorType >::workev
protected

Double precision work array of dimension 3* NCV.

Definition at line 420 of file parpack_solver.h.

template<typename VectorType>
std::vector<int> PArpackSolver< VectorType >::select
protected

A vector of dimension NCV.

Definition at line 425 of file parpack_solver.h.

template<typename VectorType>
VectorType PArpackSolver< VectorType >::src
protected

Temporary vectors used between Arpack and deal.II

Definition at line 430 of file parpack_solver.h.

template<typename VectorType>
std::vector< types::global_dof_index > PArpackSolver< VectorType >::local_indices
protected

Indices of local degrees of freedom.

Definition at line 435 of file parpack_solver.h.

template<typename VectorType>
double PArpackSolver< VectorType >::sigmar
protected

Real part of the shift

Definition at line 440 of file parpack_solver.h.

template<typename VectorType>
double PArpackSolver< VectorType >::sigmai
protected

Imaginary part of the shift

Definition at line 445 of file parpack_solver.h.


The documentation for this class was generated from the following file: