Reference documentation for deal.II version 9.5.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\}}\)
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | 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
 

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
}
 
using size_type = types::global_dof_index
 

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)
 
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)
 
std::size_t memory_consumption () const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
Subscriptor functionality

Classes derived from Subscriptor provide a facility to subscribe to this object. This is mostly used by the SmartPointer class.

void subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
void unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
unsigned int n_subscriptions () const
 
template<typename StreamType >
void list_subscribers (StreamType &stream) const
 
void list_subscribers () const
 

Static Public Member Functions

static ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)
 
static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)
 

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< intselect
 
VectorType src
 
VectorType dst
 
VectorType tmp
 
std::vector< types::global_dof_indexlocal_indices
 
double sigmar
 
double sigmai
 

Private Types

using map_value_type = decltype(counter_map)::value_type
 
using map_iterator = decltype(counter_map)::iterator
 

Private Member Functions

void internal_reinit (const IndexSet &locally_owned_dofs)
 
void check_no_subscribers () const noexcept
 

Static Private Member Functions

static ::ExceptionBasePArpackExcConvergedEigenvectors (int arg1, int arg2)
 
static ::ExceptionBasePArpackExcInvalidNumberofEigenvalues (int arg1, int arg2)
 
static ::ExceptionBasePArpackExcInvalidEigenvectorSize (int arg1, int arg2)
 
static ::ExceptionBasePArpackExcInvalidEigenvectorSizeNonsymmetric (int arg1, int arg2)
 
static ::ExceptionBasePArpackExcInvalidEigenvalueSize (int arg1, int arg2)
 
static ::ExceptionBasePArpackExcInvalidNumberofArnoldiVectors (int arg1, int arg2)
 
static ::ExceptionBasePArpackExcSmallNumberofArnoldiVectors (int arg1, int arg2)
 
static ::ExceptionBasePArpackExcIdo (int arg1)
 
static ::ExceptionBasePArpackExcMode (int arg1)
 
static ::ExceptionBasePArpackExcInfoPdnaupd (int arg1)
 
static ::ExceptionBasePArpackExcInfoPdneupd (int arg1)
 
static ::ExceptionBasePArpackExcInfoMaxIt (int arg1)
 
static ::ExceptionBasePArpackExcNoShifts (int arg1)
 

Private Attributes

std::atomic< unsigned intcounter
 
std::map< std::string, unsigned intcounter_map
 
std::vector< std::atomic< bool > * > validity_pointers
 
const std::type_info * object_info
 

Static Private Attributes

static std::mutex mutex
 

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);
SolverControl & solver_control
MPI_Comm mpi_communicator
const AdditionalData additional_data

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.

Currently, only three modes of (P)Arpack are implemented. In mode 3 (default), OP is an inverse operation for the matrix A - sigma * B, where sigma is a shift value, set to zero by default. Whereas in mode 2, OP is an inverse of M. Finally, mode 1 corresponds to standard eigenvalue problem without spectral transformation \(Ax=\lambda x\). The mode can be specified via AdditionalData object. Note that for shift-and-invert (mode=3), the sought eigenpairs are those after the spectral transformation is applied.

The OP can be specified by using a 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 =
LinearOperator< Domain, Range, Payload > inverse_operator(const LinearOperator< Range, Domain, Payload > &op, Solver &solver, const Preconditioner &preconditioner)

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.

Definition at line 211 of file parpack_solver.h.

Member Typedef Documentation

◆ size_type

template<typename VectorType >
using PArpackSolver< VectorType >::size_type = types::global_dof_index

Declare the type for container size.

Definition at line 217 of file parpack_solver.h.

◆ map_value_type

using Subscriptor::map_value_type = decltype(counter_map)::value_type
privateinherited

The data type used in counter_map.

Definition at line 230 of file subscriptor.h.

◆ map_iterator

using Subscriptor::map_iterator = decltype(counter_map)::iterator
privateinherited

The iterator type used in counter_map.

Definition at line 235 of file subscriptor.h.

Member Enumeration Documentation

◆ WhichEigenvalues

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 228 of file parpack_solver.h.

Constructor & Destructor Documentation

◆ PArpackSolver()

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

Constructor.

Definition at line 640 of file parpack_solver.h.

Member Function Documentation

◆ control()

template<typename VectorType >
SolverControl & PArpackSolver< VectorType >::control

Access to the object that controls convergence.

Definition at line 1160 of file parpack_solver.h.

◆ reinit() [1/3]

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

Initialize internal variables.

Definition at line 726 of file parpack_solver.h.

◆ reinit() [2/3]

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 754 of file parpack_solver.h.

◆ reinit() [3/3]

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

Initialize internal variables from the input distributed_vector.

Definition at line 740 of file parpack_solver.h.

◆ set_initial_vector()

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

Set initial vector for building Krylov space.

Definition at line 672 of file parpack_solver.h.

◆ set_shift()

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.

Note
only relevant for mode=3 (see the general documentation of this class for a definition of what the different modes are).

Definition at line 662 of file parpack_solver.h.

◆ solve() [1/2]

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.

In mode=3, inverse should correspond to \([A-\sigma B]^{-1}\), whereas in mode=2 it should represent \(B^{-1}\). For mode=1 both B and inverse are ignored.

Definition at line 770 of file parpack_solver.h.

◆ solve() [2/2]

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 
)

Same as above but takes eigenvectors as pointers.

Definition at line 788 of file parpack_solver.h.

◆ memory_consumption()

template<typename VectorType >
std::size_t PArpackSolver< VectorType >::memory_consumption

Return the memory consumption of this class in bytes.

Definition at line 589 of file parpack_solver.h.

◆ internal_reinit()

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 686 of file parpack_solver.h.

◆ subscribe()

void Subscriptor::subscribe ( std::atomic< bool > *const  validity,
const std::string &  identifier = "" 
) const
inherited

Subscribes a user of the object by storing the pointer validity. The subscriber may be identified by text supplied as identifier.

Definition at line 136 of file subscriptor.cc.

◆ unsubscribe()

void Subscriptor::unsubscribe ( std::atomic< bool > *const  validity,
const std::string &  identifier = "" 
) const
inherited

Unsubscribes a user from the object.

Note
The identifier and the validity pointer must be the same as the one supplied to subscribe().

Definition at line 156 of file subscriptor.cc.

◆ n_subscriptions()

unsigned int Subscriptor::n_subscriptions ( ) const
inlineinherited

Return the present number of subscriptions to this object. This allows to use this class for reference counted lifetime determination where the last one to unsubscribe also deletes the object.

Definition at line 300 of file subscriptor.h.

◆ list_subscribers() [1/2]

template<typename StreamType >
void Subscriptor::list_subscribers ( StreamType &  stream) const
inlineinherited

List the subscribers to the input stream.

Definition at line 317 of file subscriptor.h.

◆ list_subscribers() [2/2]

void Subscriptor::list_subscribers ( ) const
inherited

List the subscribers to deallog.

Definition at line 204 of file subscriptor.cc.

◆ serialize()

template<class Archive >
void Subscriptor::serialize ( Archive &  ar,
const unsigned int  version 
)
inlineinherited

Read or write the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.

This function does not actually serialize any of the member variables of this class. The reason is that what this class stores is only who subscribes to this object, but who does so at the time of storing the contents of this object does not necessarily have anything to do with who subscribes to the object when it is restored. Consequently, we do not want to overwrite the subscribers at the time of restoring, and then there is no reason to write the subscribers out in the first place.

Definition at line 309 of file subscriptor.h.

◆ check_no_subscribers()

void Subscriptor::check_no_subscribers ( ) const
privatenoexceptinherited

Check that there are no objects subscribing to this object. If this check passes then it is safe to destroy the current object. It this check fails then this function will either abort or print an error message to deallog (by using the AssertNothrow mechanism), but will not throw an exception.

Note
Since this function is just a consistency check it does nothing in release mode.
If this function is called when there is an uncaught exception then, rather than aborting, this function prints an error message to the standard error stream and returns.

Definition at line 53 of file subscriptor.cc.

Member Data Documentation

◆ solver_control

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

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

Definition at line 381 of file parpack_solver.h.

◆ additional_data

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

Store a copy of the flags for this particular solver.

Definition at line 386 of file parpack_solver.h.

◆ mpi_communicator

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

C++ MPI communicator.

Definition at line 393 of file parpack_solver.h.

◆ mpi_communicator_fortran

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

Fortran MPI communicator.

Definition at line 398 of file parpack_solver.h.

◆ lworkl

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

Length of the work array workl.

Definition at line 405 of file parpack_solver.h.

◆ workl

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

Double precision work array of length lworkl

Definition at line 410 of file parpack_solver.h.

◆ workd

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

Double precision work array of length 3*N

Definition at line 415 of file parpack_solver.h.

◆ nloc

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

Number of local degrees of freedom.

Definition at line 420 of file parpack_solver.h.

◆ ncv

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

Number of Arnoldi basis vectors specified in additional_data

Definition at line 425 of file parpack_solver.h.

◆ ldv

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

The leading dimension of the array v

Definition at line 431 of file parpack_solver.h.

◆ v

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 437 of file parpack_solver.h.

◆ initial_vector_provided

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 442 of file parpack_solver.h.

◆ resid

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 448 of file parpack_solver.h.

◆ ldz

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

The leading dimension of the array Z equal to nloc.

Definition at line 453 of file parpack_solver.h.

◆ z

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 460 of file parpack_solver.h.

◆ lworkev

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

The size of the workev array.

Definition at line 465 of file parpack_solver.h.

◆ workev

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

Double precision work array of dimension 3* NCV.

Definition at line 470 of file parpack_solver.h.

◆ select

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

A vector of dimension NCV.

Definition at line 475 of file parpack_solver.h.

◆ src

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

Temporary vectors used between Arpack and deal.II

Definition at line 480 of file parpack_solver.h.

◆ dst

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

Definition at line 480 of file parpack_solver.h.

◆ tmp

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

Definition at line 480 of file parpack_solver.h.

◆ local_indices

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

Indices of local degrees of freedom.

Definition at line 485 of file parpack_solver.h.

◆ sigmar

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

Real part of the shift

Definition at line 490 of file parpack_solver.h.

◆ sigmai

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

Imaginary part of the shift

Definition at line 495 of file parpack_solver.h.

◆ counter

std::atomic<unsigned int> Subscriptor::counter
mutableprivateinherited

Store the number of objects which subscribed to this object. Initially, this number is zero, and upon destruction it shall be zero again (i.e. all objects which subscribed should have unsubscribed again).

The creator (and owner) of an object is counted in the map below if HE manages to supply identification.

We use the mutable keyword in order to allow subscription to constant objects also.

This counter may be read from and written to concurrently in multithreaded code: hence we use the std::atomic class template.

Definition at line 219 of file subscriptor.h.

◆ counter_map

std::map<std::string, unsigned int> Subscriptor::counter_map
mutableprivateinherited

In this map, we count subscriptions for each different identification string supplied to subscribe().

Definition at line 225 of file subscriptor.h.

◆ validity_pointers

std::vector<std::atomic<bool> *> Subscriptor::validity_pointers
mutableprivateinherited

In this vector, we store pointers to the validity bool in the SmartPointer objects that subscribe to this class.

Definition at line 241 of file subscriptor.h.

◆ object_info

const std::type_info* Subscriptor::object_info
mutableprivateinherited

Pointer to the typeinfo object of this object, from which we can later deduce the class name. Since this information on the derived class is neither available in the destructor, nor in the constructor, we obtain it in between and store it here.

Definition at line 249 of file subscriptor.h.

◆ mutex

std::mutex Subscriptor::mutex
staticprivateinherited

A mutex used to ensure data consistency when printing out the list of subscribers.

Definition at line 271 of file subscriptor.h.


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