libMesh
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
libMesh::SlepcEigenSolver< T > Class Template Reference

This class provides an interface to the SLEPc eigenvalue solver library from http://slepc.upv.es/. More...

#include <slepc_eigen_solver.h>

Inheritance diagram for libMesh::SlepcEigenSolver< T >:
[legend]

Public Member Functions

 SlepcEigenSolver (const Parallel::Communicator &comm_in)
 Constructor. More...
 
 ~SlepcEigenSolver ()
 Destructor. More...
 
virtual void clear () override
 Release all memory and clear data structures. More...
 
virtual void init () override
 Initialize data structures if not done so already. More...
 
virtual std::pair< unsigned int, unsigned intsolve_standard (SparseMatrix< T > &matrix_A, int nev, int ncv, const double tol, const unsigned int m_its) override
 This function calls the SLEPc solver to compute the eigenpairs of the SparseMatrix matrix_A. More...
 
virtual std::pair< unsigned int, unsigned intsolve_standard (ShellMatrix< T > &shell_matrix, int nev, int ncv, const double tol, const unsigned int m_its) override
 Same as above except that matrix_A is a ShellMatrix in this case. More...
 
virtual std::pair< unsigned int, unsigned intsolve_standard (ShellMatrix< T > &shell_matrix, SparseMatrix< T > &precond, int nev, int ncv, const double tol, const unsigned int m_its) override
 Same as above except that matrix_A is a ShellMatrix in this case. More...
 
virtual std::pair< unsigned int, unsigned intsolve_generalized (SparseMatrix< T > &matrix_A, SparseMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its) override
 This function calls the SLEPc solver to compute the eigenpairs for the generalized eigenproblem defined by the matrix_A and matrix_B, which are of type SparseMatrix. More...
 
virtual std::pair< unsigned int, unsigned intsolve_generalized (ShellMatrix< T > &matrix_A, SparseMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its) override
 Solve generalized eigenproblem when matrix_A is of type ShellMatrix, matrix_B is of type SparseMatrix. More...
 
virtual std::pair< unsigned int, unsigned intsolve_generalized (SparseMatrix< T > &matrix_A, ShellMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its) override
 Solve generalized eigenproblem when matrix_A is of type SparseMatrix, matrix_B is of type ShellMatrix. More...
 
virtual std::pair< unsigned int, unsigned intsolve_generalized (ShellMatrix< T > &matrix_A, ShellMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its) override
 Solve generalized eigenproblem when both matrix_A and matrix_B are of type ShellMatrix. More...
 
virtual std::pair< unsigned int, unsigned intsolve_generalized (ShellMatrix< T > &matrix_A, ShellMatrix< T > &matrix_B, SparseMatrix< T > &precond, int nev, int ncv, const double tol, const unsigned int m_its) override
 Solves the generalized eigenproblem involving ShellMatrices matrix_A, matrix_B and the SparseMatrix precond. More...
 
virtual std::pair< Real, Realget_eigenpair (dof_id_type i, NumericVector< T > &solution_in) override
 
virtual std::pair< Real, Realget_eigenvalue (dof_id_type i) override
 Same as above, but does not copy the eigenvector. More...
 
Real get_relative_error (unsigned int i)
 
virtual void attach_deflation_space (NumericVector< T > &deflation_vector) override
 Attach a deflation space defined by a single vector. More...
 
virtual void set_initial_space (NumericVector< T > &initial_space_in) override
 Use initial_space_in as the initial guess. More...
 
EPS eps ()
 
bool initialized () const
 
bool get_close_matrix_before_solve () const
 
void set_close_matrix_before_solve (bool val)
 Set the flag which controls whether libmesh closes the eigenproblem matrices before solving. More...
 
EigenSolverType eigen_solver_type () const
 
EigenProblemType eigen_problem_type () const
 
PositionOfSpectrum position_of_spectrum () const
 
void set_eigensolver_type (const EigenSolverType est)
 Sets the type of eigensolver to use. More...
 
void set_eigenproblem_type (EigenProblemType ept)
 Sets the type of the eigenproblem. More...
 
void set_position_of_spectrum (PositionOfSpectrum pos)
 Sets the position of the spectrum. More...
 
void set_position_of_spectrum (Real pos)
 
void set_position_of_spectrum (Real pos, PositionOfSpectrum target)
 
void set_solver_configuration (SolverConfiguration &solver_configuration)
 Set the solver configuration object. More...
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static std::unique_ptr< EigenSolver< T > > build (const Parallel::Communicator &comm_in, const SolverPackage solver_package=SLEPC_SOLVERS)
 Builds an EigenSolver using the linear solver package specified by solver_package. More...
 
static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void disable_print_counter_info ()
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information. More...
 

Protected Member Functions

void increment_constructor_count (const std::string &name)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 Increments the destruction counter. More...
 

Protected Attributes

EigenSolverType _eigen_solver_type
 Enum stating which type of eigensolver to use. More...
 
EigenProblemType _eigen_problem_type
 Enum stating which type of eigen problem we deal with. More...
 
PositionOfSpectrum _position_of_spectrum
 Enum stating where to evaluate the spectrum. More...
 
bool _is_initialized
 Flag indicating if the data structures have been initialized. More...
 
SolverConfiguration_solver_configuration
 Optionally store a SolverOptions object that can be used to set parameters like solver type, tolerances and iteration limits. More...
 
Real _target_val
 
bool _close_matrix_before_solve
 
const Parallel::Communicator & _communicator
 

Static Protected Attributes

static Counts _counts
 Actually holds the data. More...
 
static Threads::atomic< unsigned int_n_objects
 The number of objects. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called. More...
 

Private Member Functions

std::pair< unsigned int, unsigned int_solve_standard_helper (Mat mat, Mat precond, int nev, int ncv, const double tol, const unsigned int m_its)
 Helper function that actually performs the standard eigensolve. More...
 
std::pair< unsigned int, unsigned int_solve_generalized_helper (Mat mat_A, Mat mat_B, Mat precond, int nev, int ncv, const double tol, const unsigned int m_its)
 Helper function that actually performs the generalized eigensolve. More...
 
void set_slepc_solver_type ()
 Tells Slepc to use the user-specified solver stored in _eigen_solver_type. More...
 
void set_slepc_problem_type ()
 Tells Slepc to deal with the type of problem stored in _eigen_problem_type. More...
 
void set_slepc_position_of_spectrum ()
 Tells Slepc to compute the spectrum at the position stored in _position_of_spectrum. More...
 

Static Private Member Functions

static PetscErrorCode _petsc_shell_matrix_mult (Mat mat, Vec arg, Vec dest)
 Internal function if shell matrix mode is used, this just calls the shell matrix's matrix multiplication function. More...
 
static PetscErrorCode _petsc_shell_matrix_get_diagonal (Mat mat, Vec dest)
 Internal function if shell matrix mode is used, this just calls the shell matrix's get_diagonal function. More...
 

Private Attributes

EPS _eps
 Eigenproblem solver context. More...
 

Detailed Description

template<typename T>
class libMesh::SlepcEigenSolver< T >

This class provides an interface to the SLEPc eigenvalue solver library from http://slepc.upv.es/.

Author
Steffen Peterson
Date
2005

EigenSolver implementation based on SLEPc.

Definition at line 50 of file slepc_eigen_solver.h.

Member Typedef Documentation

◆ Counts

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 117 of file reference_counter.h.

Constructor & Destructor Documentation

◆ SlepcEigenSolver()

template<typename T >
libMesh::SlepcEigenSolver< T >::SlepcEigenSolver ( const Parallel::Communicator &  comm_in)

Constructor.

Initializes Petsc data structures

Definition at line 41 of file slepc_eigen_solver.C.

41  :
42  EigenSolver<T>(comm_in)
43 {
45  this->_eigen_problem_type = NHEP;
46 }

◆ ~SlepcEigenSolver()

template<typename T >
libMesh::SlepcEigenSolver< T >::~SlepcEigenSolver ( )

Destructor.

Definition at line 51 of file slepc_eigen_solver.C.

52 {
53  this->clear ();
54 }

Member Function Documentation

◆ _petsc_shell_matrix_get_diagonal()

template<typename T >
PetscErrorCode libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal ( Mat  mat,
Vec  dest 
)
staticprivate

Internal function if shell matrix mode is used, this just calls the shell matrix's get_diagonal function.

Required in order to use Jacobi preconditioning.

Definition at line 958 of file slepc_eigen_solver.C.

959 {
960  // Get the matrix context.
961  PetscErrorCode ierr=0;
962  void * ctx;
963  ierr = MatShellGetContext(mat,&ctx);
964 
965  Parallel::communicator comm;
966  PetscObjectGetComm((PetscObject)mat,&comm);
967  CHKERRABORT(comm,ierr);
968 
969  // Get user shell matrix object.
970  const ShellMatrix<T> & shell_matrix = *static_cast<const ShellMatrix<T> *>(ctx);
971 
972  // Make \p NumericVector instances around the vector.
973  PetscVector<T> dest_global(dest, shell_matrix.comm());
974 
975  // Call the user function.
976  shell_matrix.get_diagonal(dest_global);
977 
978  return ierr;
979 }

◆ _petsc_shell_matrix_mult()

template<typename T >
PetscErrorCode libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult ( Mat  mat,
Vec  arg,
Vec  dest 
)
staticprivate

Internal function if shell matrix mode is used, this just calls the shell matrix's matrix multiplication function.

See PetscLinearSolver for a similar implementation.

Definition at line 933 of file slepc_eigen_solver.C.

934 {
935  // Get the matrix context.
936  PetscErrorCode ierr=0;
937  void * ctx;
938  ierr = MatShellGetContext(mat,&ctx);
939 
940  Parallel::communicator comm;
941  PetscObjectGetComm((PetscObject)mat,&comm);
942  CHKERRABORT(comm,ierr);
943 
944  // Get user shell matrix object.
945  const ShellMatrix<T> & shell_matrix = *static_cast<const ShellMatrix<T> *>(ctx);
946 
947  // Make \p NumericVector instances around the vectors.
948  PetscVector<T> arg_global(arg, shell_matrix.comm());
949  PetscVector<T> dest_global(dest, shell_matrix.comm());
950 
951  // Call the user function.
952  shell_matrix.vector_mult(dest_global,arg_global);
953 
954  return ierr;
955 }

◆ _solve_generalized_helper()

template<typename T >
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::_solve_generalized_helper ( Mat  mat_A,
Mat  mat_B,
Mat  precond,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
private

Helper function that actually performs the generalized eigensolve.

Definition at line 520 of file slepc_eigen_solver.C.

527 {
528  LOG_SCOPE("solve_generalized()", "SlepcEigenSolver");
529 
530  PetscErrorCode ierr=0;
531 
532  // converged eigen pairs and number of iterations
533  PetscInt nconv=0;
534  PetscInt its=0;
535  ST st;
536 
537 #ifdef DEBUG
538  // The relative error.
539  PetscReal error, re, im;
540 
541  // Pointer to vectors of the real parts, imaginary parts.
542  PetscScalar kr, ki;
543 #endif
544 
545  // Set operators.
546  ierr = EPSSetOperators (_eps, mat_A, mat_B);
547  LIBMESH_CHKERR(ierr);
548 
549  //set the problem type and the position of the spectrum
552 
553  // Set eigenvalues to be computed.
554 #if SLEPC_VERSION_LESS_THAN(3,0,0)
555  ierr = EPSSetDimensions (_eps, nev, ncv);
556 #else
557  ierr = EPSSetDimensions (_eps, nev, ncv, PETSC_DECIDE);
558 #endif
559  LIBMESH_CHKERR(ierr);
560 
561 
562  // Set the tolerance and maximum iterations.
563  ierr = EPSSetTolerances (_eps, tol, m_its);
564  LIBMESH_CHKERR(ierr);
565 
566  // Set runtime options, e.g.,
567  // -eps_type <type>, -eps_nev <nev>, -eps_ncv <ncv>
568  // Similar to PETSc, these options will override those specified
569  // above as long as EPSSetFromOptions() is called _after_ any
570  // other customization routines.
571  ierr = EPSSetFromOptions (_eps);
572  LIBMESH_CHKERR(ierr);
573 
574  // Set a preconditioning matrix to ST
575  if (precond) {
576  ierr = EPSGetST(_eps,&st);LIBMESH_CHKERR(ierr);
577  ierr = STPrecondSetMatForPC(st,precond);LIBMESH_CHKERR(ierr);
578  }
579 
580  // If the SolverConfiguration object is provided, use it to override
581  // solver options.
582  if (this->_solver_configuration)
583  {
585  }
586 
587  // Solve the eigenproblem.
588  ierr = EPSSolve (_eps);
589  LIBMESH_CHKERR(ierr);
590 
591  // Get the number of iterations.
592  ierr = EPSGetIterationNumber (_eps, &its);
593  LIBMESH_CHKERR(ierr);
594 
595  // Get number of converged eigenpairs.
596  ierr = EPSGetConverged(_eps,&nconv);
597  LIBMESH_CHKERR(ierr);
598 
599 
600 #ifdef DEBUG
601  // ierr = PetscPrintf(this->comm().get(),
602  // "\n Number of iterations: %d\n"
603  // " Number of converged eigenpairs: %d\n\n", its, nconv);
604 
605  // Display eigenvalues and relative errors.
606  ierr = PetscPrintf(this->comm().get(),
607  " k ||Ax-kx||/|kx|\n"
608  " ----------------- -----------------\n" );
609  LIBMESH_CHKERR(ierr);
610 
611  for (PetscInt i=0; i<nconv; i++ )
612  {
613  ierr = EPSGetEigenpair(_eps, i, &kr, &ki, PETSC_NULL, PETSC_NULL);
614  LIBMESH_CHKERR(ierr);
615 
616 #if SLEPC_VERSION_LESS_THAN(3,6,0)
617  ierr = EPSComputeRelativeError(_eps, i, &error);
618 #else
619  ierr = EPSComputeError(_eps, i, EPS_ERROR_RELATIVE, &error);
620 #endif
621  LIBMESH_CHKERR(ierr);
622 
623 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
624  re = PetscRealPart(kr);
625  im = PetscImaginaryPart(kr);
626 #else
627  re = kr;
628  im = ki;
629 #endif
630 
631  if (im != .0)
632  {
633  ierr = PetscPrintf(this->comm().get()," %9f%+9f i %12f\n", re, im, error);
634  LIBMESH_CHKERR(ierr);
635  }
636  else
637  {
638  ierr = PetscPrintf(this->comm().get()," %12f %12f\n", re, error);
639  LIBMESH_CHKERR(ierr);
640  }
641  }
642 
643  ierr = PetscPrintf(this->comm().get(),"\n" );
644  LIBMESH_CHKERR(ierr);
645 #endif // DEBUG
646 
647  // return the number of converged eigenpairs
648  // and the number of iterations
649  return std::make_pair(nconv, its);
650 }

◆ _solve_standard_helper()

template<typename T >
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::_solve_standard_helper ( Mat  mat,
Mat  precond,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
private

Helper function that actually performs the standard eigensolve.

Definition at line 186 of file slepc_eigen_solver.C.

192 {
193  LOG_SCOPE("solve_standard()", "SlepcEigenSolver");
194 
195  PetscErrorCode ierr=0;
196 
197  // converged eigen pairs and number of iterations
198  PetscInt nconv=0;
199  PetscInt its=0;
200  ST st=nullptr;
201 
202 #ifdef DEBUG
203  // The relative error.
204  PetscReal error, re, im;
205 
206  // Pointer to vectors of the real parts, imaginary parts.
207  PetscScalar kr, ki;
208 #endif
209 
210  // Set operators.
211  ierr = EPSSetOperators (_eps, mat, PETSC_NULL);
212  LIBMESH_CHKERR(ierr);
213 
214  //set the problem type and the position of the spectrum
217 
218  // Set eigenvalues to be computed.
219 #if SLEPC_VERSION_LESS_THAN(3,0,0)
220  ierr = EPSSetDimensions (_eps, nev, ncv);
221 #else
222  ierr = EPSSetDimensions (_eps, nev, ncv, PETSC_DECIDE);
223 #endif
224  LIBMESH_CHKERR(ierr);
225  // Set the tolerance and maximum iterations.
226  ierr = EPSSetTolerances (_eps, tol, m_its);
227  LIBMESH_CHKERR(ierr);
228 
229  // Set runtime options, e.g.,
230  // -eps_type <type>, -eps_nev <nev>, -eps_ncv <ncv>
231  // Similar to PETSc, these options will override those specified
232  // above as long as EPSSetFromOptions() is called _after_ any
233  // other customization routines.
234  ierr = EPSSetFromOptions (_eps);
235  LIBMESH_CHKERR(ierr);
236 
237  // Set a preconditioning matrix to ST
238  if (precond) {
239  ierr = EPSGetST(_eps,&st);LIBMESH_CHKERR(ierr);
240  ierr = STPrecondSetMatForPC(st,precond);LIBMESH_CHKERR(ierr);
241  }
242 
243  // If the SolverConfiguration object is provided, use it to override
244  // solver options.
245  if (this->_solver_configuration)
246  {
248  }
249 
250  // Solve the eigenproblem.
251  ierr = EPSSolve (_eps);
252  LIBMESH_CHKERR(ierr);
253 
254  // Get the number of iterations.
255  ierr = EPSGetIterationNumber (_eps, &its);
256  LIBMESH_CHKERR(ierr);
257 
258  // Get number of converged eigenpairs.
259  ierr = EPSGetConverged(_eps,&nconv);
260  LIBMESH_CHKERR(ierr);
261 
262 
263 #ifdef DEBUG
264  // ierr = PetscPrintf(this->comm().get(),
265  // "\n Number of iterations: %d\n"
266  // " Number of converged eigenpairs: %d\n\n", its, nconv);
267 
268  // Display eigenvalues and relative errors.
269  ierr = PetscPrintf(this->comm().get(),
270  " k ||Ax-kx||/|kx|\n"
271  " ----------------- -----------------\n" );
272  LIBMESH_CHKERR(ierr);
273 
274  for (PetscInt i=0; i<nconv; i++ )
275  {
276  ierr = EPSGetEigenpair(_eps, i, &kr, &ki, PETSC_NULL, PETSC_NULL);
277  LIBMESH_CHKERR(ierr);
278 
279 #if SLEPC_VERSION_LESS_THAN(3,6,0)
280  ierr = EPSComputeRelativeError(_eps, i, &error);
281 #else
282  ierr = EPSComputeError(_eps, i, EPS_ERROR_RELATIVE, &error);
283 #endif
284  LIBMESH_CHKERR(ierr);
285 
286 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
287  re = PetscRealPart(kr);
288  im = PetscImaginaryPart(kr);
289 #else
290  re = kr;
291  im = ki;
292 #endif
293 
294  if (im != .0)
295  {
296  ierr = PetscPrintf(this->comm().get()," %9f%+9f i %12f\n", re, im, error);
297  LIBMESH_CHKERR(ierr);
298  }
299  else
300  {
301  ierr = PetscPrintf(this->comm().get()," %12f %12f\n", re, error);
302  LIBMESH_CHKERR(ierr);
303  }
304  }
305 
306  ierr = PetscPrintf(this->comm().get(),"\n" );
307  LIBMESH_CHKERR(ierr);
308 #endif // DEBUG
309 
310  // return the number of converged eigenpairs
311  // and the number of iterations
312  return std::make_pair(nconv, its);
313 }

◆ attach_deflation_space()

template<typename T>
void libMesh::SlepcEigenSolver< T >::attach_deflation_space ( NumericVector< T > &  deflation_vector)
overridevirtual

Attach a deflation space defined by a single vector.

Implements libMesh::EigenSolver< T >.

Definition at line 883 of file slepc_eigen_solver.C.

884 {
885  this->init();
886 
887  PetscErrorCode ierr = 0;
888 
889  // Make sure the input vector is actually a PetscVector
890  PetscVector<T> * deflation_vector_petsc_vec =
891  dynamic_cast<PetscVector<T> *>(&deflation_vector_in);
892 
893  if (!deflation_vector_petsc_vec)
894  libmesh_error_msg("Error attaching deflation space: input vector must be a PetscVector.");
895 
896  // Get a handle for the underlying Vec.
897  Vec deflation_vector = deflation_vector_petsc_vec->vec();
898 
899 #if SLEPC_VERSION_LESS_THAN(3,1,0)
900  ierr = EPSAttachDeflationSpace(_eps, 1, &deflation_vector, PETSC_FALSE);
901 #else
902  ierr = EPSSetDeflationSpace(_eps, 1, &deflation_vector);
903 #endif
904  LIBMESH_CHKERR(ierr);
905 }

◆ build()

template<typename T >
std::unique_ptr< EigenSolver< T > > libMesh::EigenSolver< T >::build ( const Parallel::Communicator &  comm_in,
const SolverPackage  solver_package = SLEPC_SOLVERS 
)
staticinherited

Builds an EigenSolver using the linear solver package specified by solver_package.

Definition at line 59 of file eigen_solver.C.

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 }

◆ clear()

template<typename T >
void libMesh::SlepcEigenSolver< T >::clear ( )
overridevirtual

Release all memory and clear data structures.

Reimplemented from libMesh::EigenSolver< T >.

Definition at line 59 of file slepc_eigen_solver.C.

60 {
61  if (this->initialized())
62  {
63  this->_is_initialized = false;
64 
65  PetscErrorCode ierr=0;
66 
67  ierr = LibMeshEPSDestroy(&_eps);
68  LIBMESH_CHKERR(ierr);
69 
70  // SLEPc default eigenproblem solver
72  }
73 }

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 94 of file parallel_object.h.

95  { return _communicator; }

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::ImplicitSystem::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::DynaIO::add_spline_constraints(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::EigenSystem::init_matrices(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), integrate_function(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::DofMap::n_constrained_dofs(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), SystemsTest::testBlockRestrictedVarNDofs(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), SystemsTest::testProjectCubeWithMeshFunction(), CheckpointIOTest::testSplitter(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

107 {
108  _enable_print_counter = false;
109  return;
110 }

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::LibMeshInit::LibMeshInit().

◆ eigen_problem_type()

template<typename T>
EigenProblemType libMesh::EigenSolver< T >::eigen_problem_type ( ) const
inlineinherited
Returns
The type of the eigen problem.

Definition at line 134 of file eigen_solver.h.

134 { return _eigen_problem_type;}

◆ eigen_solver_type()

template<typename T>
EigenSolverType libMesh::EigenSolver< T >::eigen_solver_type ( ) const
inlineinherited
Returns
The type of eigensolver to use.

Definition at line 129 of file eigen_solver.h.

129 { return _eigen_solver_type; }

◆ enable_print_counter_info()

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

Definition at line 100 of file reference_counter.C.

101 {
102  _enable_print_counter = true;
103  return;
104 }

References libMesh::ReferenceCounter::_enable_print_counter.

◆ eps()

template<typename T>
EPS libMesh::SlepcEigenSolver< T >::eps ( )
inline
Returns
The raw SLEPc EPS pointer.

Definition at line 235 of file slepc_eigen_solver.h.

235 { this->init(); return _eps; }

◆ get_close_matrix_before_solve()

template<typename T>
bool libMesh::EigenSolver< T >::get_close_matrix_before_solve ( ) const
inlineinherited
Returns
The value of the flag which controls whether libmesh closes the eigenproblem matrices before solving. true by default.

Definition at line 100 of file eigen_solver.h.

101  {
102  libmesh_experimental();
104  }

◆ get_eigenpair()

template<typename T>
std::pair< Real, Real > libMesh::SlepcEigenSolver< T >::get_eigenpair ( dof_id_type  i,
NumericVector< T > &  solution_in 
)
overridevirtual
Returns
The real and imaginary part of the ith eigenvalue and copies the respective eigenvector to the solution vector.
Note
The eigenpair may be complex even for real-valued matrices.

Implements libMesh::EigenSolver< T >.

Definition at line 807 of file slepc_eigen_solver.C.

809 {
810  PetscErrorCode ierr=0;
811 
812  PetscReal re, im;
813 
814  // Make sure the NumericVector passed in is really a PetscVector
815  PetscVector<T> * solution = dynamic_cast<PetscVector<T> *>(&solution_in);
816 
817  if (!solution)
818  libmesh_error_msg("Error getting eigenvector: input vector must be a PetscVector.");
819 
820  // real and imaginary part of the ith eigenvalue.
821  PetscScalar kr, ki;
822 
823  solution->close();
824 
825  ierr = EPSGetEigenpair(_eps, i, &kr, &ki, solution->vec(), PETSC_NULL);
826  LIBMESH_CHKERR(ierr);
827 
828 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
829  re = PetscRealPart(kr);
830  im = PetscImaginaryPart(kr);
831 #else
832  re = kr;
833  im = ki;
834 #endif
835 
836  return std::make_pair(re, im);
837 }

◆ get_eigenvalue()

template<typename T >
std::pair< Real, Real > libMesh::SlepcEigenSolver< T >::get_eigenvalue ( dof_id_type  i)
overridevirtual

Same as above, but does not copy the eigenvector.

Implements libMesh::EigenSolver< T >.

Definition at line 841 of file slepc_eigen_solver.C.

842 {
843  PetscErrorCode ierr=0;
844 
845  PetscReal re, im;
846 
847  // real and imaginary part of the ith eigenvalue.
848  PetscScalar kr, ki;
849 
850  ierr = EPSGetEigenvalue(_eps, i, &kr, &ki);
851  LIBMESH_CHKERR(ierr);
852 
853 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
854  re = PetscRealPart(kr);
855  im = PetscImaginaryPart(kr);
856 #else
857  re = kr;
858  im = ki;
859 #endif
860 
861  return std::make_pair(re, im);
862 }

◆ get_info()

std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (const auto & pr : _counts)
59  {
60  const std::string name(pr.first);
61  const unsigned int creations = pr.second.first;
62  const unsigned int destructions = pr.second.second;
63 
64  oss << "| " << name << " reference count information:\n"
65  << "| Creations: " << creations << '\n'
66  << "| Destructions: " << destructions << '\n';
67  }
68 
69  oss << " ---------------------------------------------------------------------------- \n";
70 
71  return oss.str();
72 
73 #else
74 
75  return "";
76 
77 #endif
78 }

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

◆ get_relative_error()

template<typename T >
Real libMesh::SlepcEigenSolver< T >::get_relative_error ( unsigned int  i)
Returns
The relative error \( ||A x - \lambda x|| / |\lambda x| \) of the ith eigenpair (or the equivalent for a general eigenvalue problem).

Definition at line 866 of file slepc_eigen_solver.C.

867 {
868  PetscErrorCode ierr=0;
869  PetscReal error;
870 
871 #if SLEPC_VERSION_LESS_THAN(3,6,0)
872  ierr = EPSComputeRelativeError(_eps, i, &error);
873 #else
874  ierr = EPSComputeError(_eps, i, EPS_ERROR_RELATIVE, &error);
875 #endif
876  LIBMESH_CHKERR(ierr);
877 
878  return error;
879 }

◆ increment_constructor_count()

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectedinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 181 of file reference_counter.h.

182 {
183  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184  std::pair<unsigned int, unsigned int> & p = _counts[name];
185 
186  p.first++;
187 }

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

◆ increment_destructor_count()

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectedinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 194 of file reference_counter.h.

195 {
196  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
197  std::pair<unsigned int, unsigned int> & p = _counts[name];
198 
199  p.second++;
200 }

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

◆ init()

template<typename T >
void libMesh::SlepcEigenSolver< T >::init ( )
overridevirtual

Initialize data structures if not done so already.

Implements libMesh::EigenSolver< T >.

Definition at line 78 of file slepc_eigen_solver.C.

79 {
80 
81  PetscErrorCode ierr=0;
82 
83  // Initialize the data structures if not done so already.
84  if (!this->initialized())
85  {
86  this->_is_initialized = true;
87 
88  // Create the eigenproblem solver context
89  ierr = EPSCreate (this->comm().get(), &_eps);
90  LIBMESH_CHKERR(ierr);
91 
92  // Set user-specified solver
94  }
95 }

Referenced by libMesh::SlepcEigenSolver< libMesh::Number >::eps().

◆ initialized()

template<typename T>
bool libMesh::EigenSolver< T >::initialized ( ) const
inlineinherited
Returns
true if the data structures are initialized, false otherwise.

Definition at line 93 of file eigen_solver.h.

93 { return _is_initialized; }

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 83 of file reference_counter.h.

84  { return _n_objects; }

References libMesh::ReferenceCounter::_n_objects.

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 100 of file parallel_object.h.

101  { return cast_int<processor_id_type>(_communicator.size()); }

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::partition(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::VTKIO::write_nodal_data(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

◆ position_of_spectrum()

template<typename T>
PositionOfSpectrum libMesh::EigenSolver< T >::position_of_spectrum ( ) const
inlineinherited
Returns
The position of the spectrum to compute.

Definition at line 139 of file eigen_solver.h.

140  { return _position_of_spectrum;}

◆ print_info()

void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 87 of file reference_counter.C.

88 {
90  out_stream << ReferenceCounter::get_info();
91 }

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 106 of file parallel_object.h.

107  { return cast_int<processor_id_type>(_communicator.rank()); }

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_out_interpolation_points_elem(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::LaplaceMeshSmoother::smooth(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEvaluation::write_out_vectors(), write_output_solvedata(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

◆ set_close_matrix_before_solve()

template<typename T>
void libMesh::EigenSolver< T >::set_close_matrix_before_solve ( bool  val)
inlineinherited

Set the flag which controls whether libmesh closes the eigenproblem matrices before solving.

Definition at line 110 of file eigen_solver.h.

111  {
112  libmesh_experimental();
114  }

◆ set_eigenproblem_type()

template<typename T>
void libMesh::EigenSolver< T >::set_eigenproblem_type ( EigenProblemType  ept)
inlineinherited

Sets the type of the eigenproblem.

Definition at line 151 of file eigen_solver.h.

152  {_eigen_problem_type = ept;}

◆ set_eigensolver_type()

template<typename T>
void libMesh::EigenSolver< T >::set_eigensolver_type ( const EigenSolverType  est)
inlineinherited

Sets the type of eigensolver to use.

Definition at line 145 of file eigen_solver.h.

146  { _eigen_solver_type = est; }

◆ set_initial_space()

template<typename T>
void libMesh::SlepcEigenSolver< T >::set_initial_space ( NumericVector< T > &  initial_space_in)
overridevirtual

Use initial_space_in as the initial guess.

Implements libMesh::EigenSolver< T >.

Definition at line 908 of file slepc_eigen_solver.C.

909 {
910 #if SLEPC_VERSION_LESS_THAN(3,1,0)
911  libmesh_error_msg("SLEPc 3.1 is required to call EigenSolver::set_initial_space()");
912 #else
913  this->init();
914 
915  PetscErrorCode ierr = 0;
916 
917  // Make sure the input vector is actually a PetscVector
918  PetscVector<T> * initial_space_petsc_vec =
919  dynamic_cast<PetscVector<T> *>(&initial_space_in);
920 
921  if (!initial_space_petsc_vec)
922  libmesh_error_msg("Error attaching initial space: input vector must be a PetscVector.");
923 
924  // Get a handle for the underlying Vec.
925  Vec initial_vector = initial_space_petsc_vec->vec();
926 
927  ierr = EPSSetInitialSpace(_eps, 1, &initial_vector);
928  LIBMESH_CHKERR(ierr);
929 #endif
930 }

◆ set_position_of_spectrum() [1/3]

template<typename T>
void libMesh::EigenSolver< T >::set_position_of_spectrum ( PositionOfSpectrum  pos)
inlineinherited

Sets the position of the spectrum.

Definition at line 157 of file eigen_solver.h.

158  {_position_of_spectrum= pos;}

◆ set_position_of_spectrum() [2/3]

template<typename T >
void libMesh::EigenSolver< T >::set_position_of_spectrum ( Real  pos)
inherited

Definition at line 86 of file eigen_solver.C.

87 {
88  if (pos >= 0)
90  else
92 
93  _target_val = pos;
94 }

◆ set_position_of_spectrum() [3/3]

template<typename T >
void libMesh::EigenSolver< T >::set_position_of_spectrum ( Real  pos,
PositionOfSpectrum  target 
)
inherited

Definition at line 97 of file eigen_solver.C.

98 {
99  _position_of_spectrum = target;
100  _target_val = pos;
101 }

◆ set_slepc_position_of_spectrum()

template<typename T >
void libMesh::SlepcEigenSolver< T >::set_slepc_position_of_spectrum ( )
private

Tells Slepc to compute the spectrum at the position stored in _position_of_spectrum.

Definition at line 725 of file slepc_eigen_solver.C.

726 {
727  PetscErrorCode ierr = 0;
728 
729  switch (this->_position_of_spectrum)
730  {
731  case LARGEST_MAGNITUDE:
732  {
733  ierr = EPSSetWhichEigenpairs (_eps, EPS_LARGEST_MAGNITUDE);
734  LIBMESH_CHKERR(ierr);
735  return;
736  }
737  case SMALLEST_MAGNITUDE:
738  {
739  ierr = EPSSetWhichEigenpairs (_eps, EPS_SMALLEST_MAGNITUDE);
740  LIBMESH_CHKERR(ierr);
741  return;
742  }
743  case LARGEST_REAL:
744  {
745  ierr = EPSSetWhichEigenpairs (_eps, EPS_LARGEST_REAL);
746  LIBMESH_CHKERR(ierr);
747  return;
748  }
749  case SMALLEST_REAL:
750  {
751  ierr = EPSSetWhichEigenpairs (_eps, EPS_SMALLEST_REAL);
752  LIBMESH_CHKERR(ierr);
753  return;
754  }
755  case LARGEST_IMAGINARY:
756  {
757  ierr = EPSSetWhichEigenpairs (_eps, EPS_LARGEST_IMAGINARY);
758  LIBMESH_CHKERR(ierr);
759  return;
760  }
761  case SMALLEST_IMAGINARY:
762  {
763  ierr = EPSSetWhichEigenpairs (_eps, EPS_SMALLEST_IMAGINARY);
764  LIBMESH_CHKERR(ierr);
765  return;
766  }
767 
768  // The EPS_TARGET_XXX enums were added in SLEPc 3.1
769 #if !SLEPC_VERSION_LESS_THAN(3,1,0)
770  case TARGET_MAGNITUDE:
771  {
772  ierr = EPSSetTarget(_eps, this->_target_val);
773  LIBMESH_CHKERR(ierr);
774  ierr = EPSSetWhichEigenpairs (_eps, EPS_TARGET_MAGNITUDE);
775  LIBMESH_CHKERR(ierr);
776  return;
777  }
778  case TARGET_REAL:
779  {
780  ierr = EPSSetTarget(_eps, this->_target_val);
781  LIBMESH_CHKERR(ierr);
782  ierr = EPSSetWhichEigenpairs (_eps, EPS_TARGET_REAL);
783  LIBMESH_CHKERR(ierr);
784  return;
785  }
786  case TARGET_IMAGINARY:
787  {
788  ierr = EPSSetTarget(_eps, this->_target_val);
789  LIBMESH_CHKERR(ierr);
790  ierr = EPSSetWhichEigenpairs (_eps, EPS_TARGET_IMAGINARY);
791  LIBMESH_CHKERR(ierr);
792  return;
793  }
794 #endif
795 
796  default:
797  libmesh_error_msg("ERROR: Unsupported SLEPc position of spectrum: " << this->_position_of_spectrum);
798  }
799 }

◆ set_slepc_problem_type()

template<typename T >
void libMesh::SlepcEigenSolver< T >::set_slepc_problem_type ( )
private

Tells Slepc to deal with the type of problem stored in _eigen_problem_type.

Definition at line 695 of file slepc_eigen_solver.C.

696 {
697  PetscErrorCode ierr = 0;
698 
699  switch (this->_eigen_problem_type)
700  {
701  case NHEP:
702  ierr = EPSSetProblemType (_eps, EPS_NHEP); LIBMESH_CHKERR(ierr); return;
703  case GNHEP:
704  ierr = EPSSetProblemType (_eps, EPS_GNHEP); LIBMESH_CHKERR(ierr); return;
705  case HEP:
706  ierr = EPSSetProblemType (_eps, EPS_HEP); LIBMESH_CHKERR(ierr); return;
707  case GHEP:
708  ierr = EPSSetProblemType (_eps, EPS_GHEP); LIBMESH_CHKERR(ierr); return;
709 #if !SLEPC_VERSION_LESS_THAN(3,3,0)
710  // EPS_GHIEP added in 3.3.0
711  case GHIEP:
712  ierr = EPSSetProblemType (_eps, EPS_GHIEP); LIBMESH_CHKERR(ierr); return;
713 #endif
714 
715  default:
716  libMesh::err << "ERROR: Unsupported SLEPc Eigen Problem: "
717  << this->_eigen_problem_type << std::endl
718  << "Continuing with SLEPc defaults" << std::endl;
719  }
720 }

◆ set_slepc_solver_type()

template<typename T >
void libMesh::SlepcEigenSolver< T >::set_slepc_solver_type ( )
private

Tells Slepc to use the user-specified solver stored in _eigen_solver_type.

Definition at line 663 of file slepc_eigen_solver.C.

664 {
665  PetscErrorCode ierr = 0;
666 
667  switch (this->_eigen_solver_type)
668  {
669  case POWER:
670  ierr = EPSSetType (_eps, EPSPOWER); LIBMESH_CHKERR(ierr); return;
671  case SUBSPACE:
672  ierr = EPSSetType (_eps, EPSSUBSPACE); LIBMESH_CHKERR(ierr); return;
673  case LAPACK:
674  ierr = EPSSetType (_eps, EPSLAPACK); LIBMESH_CHKERR(ierr); return;
675  case ARNOLDI:
676  ierr = EPSSetType (_eps, EPSARNOLDI); LIBMESH_CHKERR(ierr); return;
677  case LANCZOS:
678  ierr = EPSSetType (_eps, EPSLANCZOS); LIBMESH_CHKERR(ierr); return;
679  case KRYLOVSCHUR:
680  ierr = EPSSetType (_eps, EPSKRYLOVSCHUR); LIBMESH_CHKERR(ierr); return;
681  // case ARPACK:
682  // ierr = EPSSetType (_eps, (char *) EPSARPACK); LIBMESH_CHKERR(ierr); return;
683 
684  default:
685  libMesh::err << "ERROR: Unsupported SLEPc Eigen Solver: "
686  << Utility::enum_to_string(this->_eigen_solver_type) << std::endl
687  << "Continuing with SLEPc defaults" << std::endl;
688  }
689 }

◆ set_solver_configuration()

template<typename T >
void libMesh::EigenSolver< T >::set_solver_configuration ( SolverConfiguration solver_configuration)
inherited

Set the solver configuration object.

Definition at line 80 of file eigen_solver.C.

81 {
82  _solver_configuration = &solver_configuration;
83 }

Referenced by main().

◆ solve_generalized() [1/5]

template<typename T>
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::solve_generalized ( ShellMatrix< T > &  matrix_A,
ShellMatrix< T > &  matrix_B,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
overridevirtual

Solve generalized eigenproblem when both matrix_A and matrix_B are of type ShellMatrix.

When using this function, one should use the command line options: -st_ksp_type gmres -st_pc_type none or -st_ksp_type gmres -st_pc_type jacobi or similar.

Implements libMesh::EigenSolver< T >.

Definition at line 444 of file slepc_eigen_solver.C.

450 {
451  this->clear();
452 
453  this->init ();
454 
455  PetscErrorCode ierr=0;
456 
457  // Prepare the matrices. Note that the const_casts are only
458  // necessary because PETSc does not accept a const void *. Inside
459  // the member function _petsc_shell_matrix() below, the pointer is
460  // casted back to a const ShellMatrix<T> *.
461  Mat mat_A;
462  ierr = MatCreateShell(this->comm().get(),
463  shell_matrix_A.m(), // Specify the number of local rows
464  shell_matrix_A.n(), // Specify the number of local columns
465  PETSC_DETERMINE,
466  PETSC_DETERMINE,
467  const_cast<void *>(static_cast<const void *>(&shell_matrix_A)),
468  &mat_A);
469  LIBMESH_CHKERR(ierr);
470 
471  Mat mat_B;
472  ierr = MatCreateShell(this->comm().get(),
473  shell_matrix_B.m(), // Specify the number of local rows
474  shell_matrix_B.n(), // Specify the number of local columns
475  PETSC_DETERMINE,
476  PETSC_DETERMINE,
477  const_cast<void *>(static_cast<const void *>(&shell_matrix_B)),
478  &mat_B);
479  LIBMESH_CHKERR(ierr);
480 
481  ierr = MatShellSetOperation(mat_A,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
482  LIBMESH_CHKERR(ierr);
483  ierr = MatShellSetOperation(mat_A,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
484  LIBMESH_CHKERR(ierr);
485 
486  ierr = MatShellSetOperation(mat_B,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
487  LIBMESH_CHKERR(ierr);
488  ierr = MatShellSetOperation(mat_B,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
489  LIBMESH_CHKERR(ierr);
490 
491  return _solve_generalized_helper (mat_A, mat_B, nullptr, nev, ncv, tol, m_its);
492 }

◆ solve_generalized() [2/5]

template<typename T>
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::solve_generalized ( ShellMatrix< T > &  matrix_A,
ShellMatrix< T > &  matrix_B,
SparseMatrix< T > &  precond,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
overridevirtual

Solves the generalized eigenproblem involving ShellMatrices matrix_A, matrix_B and the SparseMatrix precond.

Returns
The number of converged eigenpairs and the number of iterations.

Implements libMesh::EigenSolver< T >.

Definition at line 496 of file slepc_eigen_solver.C.

503 {
504  this->clear();
505 
506  this->init ();
507 
508  // Make sure the SparseMatrix passed in is really a PetscMatrix
509  PetscMatrix<T> * precond = static_cast<PetscMatrix<T> *>(&precond_in);
510 
511  PetscShellMatrix<T> * matrix_A = static_cast<PetscShellMatrix<T> *> (&shell_matrix_A);
512 
513  PetscShellMatrix<T> * matrix_B = static_cast<PetscShellMatrix<T> *> (&shell_matrix_B);
514 
515  return _solve_generalized_helper (matrix_A->mat(), matrix_B->mat(), precond->mat(), nev, ncv, tol, m_its);
516 }

◆ solve_generalized() [3/5]

template<typename T>
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::solve_generalized ( ShellMatrix< T > &  matrix_A,
SparseMatrix< T > &  matrix_B,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
overridevirtual

Solve generalized eigenproblem when matrix_A is of type ShellMatrix, matrix_B is of type SparseMatrix.

Implements libMesh::EigenSolver< T >.

Definition at line 351 of file slepc_eigen_solver.C.

357 {
358  this->clear();
359 
360  this->init ();
361 
362  PetscErrorCode ierr=0;
363 
364  // Prepare the matrix. Note that the const_cast is only necessary
365  // because PETSc does not accept a const void *. Inside the member
366  // function _petsc_shell_matrix() below, the pointer is casted back
367  // to a const ShellMatrix<T> *.
368  Mat mat_A;
369  ierr = MatCreateShell(this->comm().get(),
370  shell_matrix_A.m(), // Specify the number of local rows
371  shell_matrix_A.n(), // Specify the number of local columns
372  PETSC_DETERMINE,
373  PETSC_DETERMINE,
374  const_cast<void *>(static_cast<const void *>(&shell_matrix_A)),
375  &mat_A);
376  LIBMESH_CHKERR(ierr);
377 
378  PetscMatrix<T> * matrix_B = dynamic_cast<PetscMatrix<T> *>(&matrix_B_in);
379 
380  if (!matrix_B)
381  libmesh_error_msg("Error: inputs to solve_generalized() must be of type PetscMatrix.");
382 
383  // Close the matrix and vectors in case this wasn't already done.
384  if (this->_close_matrix_before_solve)
385  matrix_B->close ();
386 
387  ierr = MatShellSetOperation(mat_A,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
388  LIBMESH_CHKERR(ierr);
389  ierr = MatShellSetOperation(mat_A,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
390  LIBMESH_CHKERR(ierr);
391 
392  return _solve_generalized_helper (mat_A, matrix_B->mat(), nullptr, nev, ncv, tol, m_its);
393 }

◆ solve_generalized() [4/5]

template<typename T>
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::solve_generalized ( SparseMatrix< T > &  matrix_A,
ShellMatrix< T > &  matrix_B,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
overridevirtual

Solve generalized eigenproblem when matrix_A is of type SparseMatrix, matrix_B is of type ShellMatrix.

When using this function, one should use the command line options: -st_ksp_type gmres -st_pc_type none or -st_ksp_type gmres -st_pc_type jacobi or similar.

Implements libMesh::EigenSolver< T >.

Definition at line 397 of file slepc_eigen_solver.C.

403 {
404  this->clear();
405 
406  this->init ();
407 
408  PetscErrorCode ierr=0;
409 
410  PetscMatrix<T> * matrix_A = dynamic_cast<PetscMatrix<T> *>(&matrix_A_in);
411 
412  if (!matrix_A)
413  libmesh_error_msg("Error: inputs to solve_generalized() must be of type PetscMatrix.");
414 
415  // Close the matrix and vectors in case this wasn't already done.
416  if (this->_close_matrix_before_solve)
417  matrix_A->close ();
418 
419  // Prepare the matrix. Note that the const_cast is only necessary
420  // because PETSc does not accept a const void *. Inside the member
421  // function _petsc_shell_matrix() below, the pointer is casted back
422  // to a const ShellMatrix<T> *.
423  Mat mat_B;
424  ierr = MatCreateShell(this->comm().get(),
425  shell_matrix_B.m(), // Specify the number of local rows
426  shell_matrix_B.n(), // Specify the number of local columns
427  PETSC_DETERMINE,
428  PETSC_DETERMINE,
429  const_cast<void *>(static_cast<const void *>(&shell_matrix_B)),
430  &mat_B);
431  LIBMESH_CHKERR(ierr);
432 
433 
434  ierr = MatShellSetOperation(mat_B,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
435  LIBMESH_CHKERR(ierr);
436  ierr = MatShellSetOperation(mat_B,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
437  LIBMESH_CHKERR(ierr);
438 
439  return _solve_generalized_helper (matrix_A->mat(), mat_B, nullptr, nev, ncv, tol, m_its);
440 }

◆ solve_generalized() [5/5]

template<typename T>
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::solve_generalized ( SparseMatrix< T > &  matrix_A,
SparseMatrix< T > &  matrix_B,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
overridevirtual

This function calls the SLEPc solver to compute the eigenpairs for the generalized eigenproblem defined by the matrix_A and matrix_B, which are of type SparseMatrix.

The argument nev is the number of eigenpairs to be computed and ncv is the number of basis vectors to be used in the solution procedure. Return values are the number of converged eigen values and the number of the iterations carried out by the eigen solver.

Implements libMesh::EigenSolver< T >.

Definition at line 321 of file slepc_eigen_solver.C.

327 {
328  this->clear ();
329 
330  this->init ();
331 
332  // Make sure the data passed in are really of Petsc types
333  PetscMatrix<T> * matrix_A = dynamic_cast<PetscMatrix<T> *>(&matrix_A_in);
334  PetscMatrix<T> * matrix_B = dynamic_cast<PetscMatrix<T> *>(&matrix_B_in);
335 
336  if (!matrix_A || !matrix_B)
337  libmesh_error_msg("Error: inputs to solve_generalized() must be of type PetscMatrix.");
338 
339  // Close the matrix and vectors in case this wasn't already done.
340  if (this->_close_matrix_before_solve)
341  {
342  matrix_A->close ();
343  matrix_B->close ();
344  }
345 
346  return _solve_generalized_helper (matrix_A->mat(), matrix_B->mat(), nullptr, nev, ncv, tol, m_its);
347 }

◆ solve_standard() [1/3]

template<typename T>
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::solve_standard ( ShellMatrix< T > &  shell_matrix,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
overridevirtual

Same as above except that matrix_A is a ShellMatrix in this case.

Implements libMesh::EigenSolver< T >.

Definition at line 129 of file slepc_eigen_solver.C.

134 {
135  this->clear ();
136 
137  this->init ();
138 
139  PetscErrorCode ierr=0;
140 
141  // Prepare the matrix. Note that the const_cast is only necessary
142  // because PETSc does not accept a const void *. Inside the member
143  // function _petsc_shell_matrix() below, the pointer is casted back
144  // to a const ShellMatrix<T> *.
145  Mat mat;
146  ierr = MatCreateShell(this->comm().get(),
147  shell_matrix.m(), // Specify the number of local rows
148  shell_matrix.n(), // Specify the number of local columns
149  PETSC_DETERMINE,
150  PETSC_DETERMINE,
151  const_cast<void *>(static_cast<const void *>(&shell_matrix)),
152  &mat);
153  LIBMESH_CHKERR(ierr);
154 
155  ierr = MatShellSetOperation(mat,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
156  LIBMESH_CHKERR(ierr);
157  ierr = MatShellSetOperation(mat,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
158  LIBMESH_CHKERR(ierr);
159 
160  return _solve_standard_helper(mat, nullptr, nev, ncv, tol, m_its);
161 }

◆ solve_standard() [2/3]

template<typename T>
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::solve_standard ( ShellMatrix< T > &  shell_matrix,
SparseMatrix< T > &  precond,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
overridevirtual

Same as above except that matrix_A is a ShellMatrix in this case.

Implements libMesh::EigenSolver< T >.

Definition at line 165 of file slepc_eigen_solver.C.

171 {
172  this->clear ();
173 
174  this->init ();
175 
176  // Make sure the SparseMatrix passed in is really a PetscMatrix
177  PetscMatrix<T> * precond = dynamic_cast<PetscMatrix<T> *>(&precond_in);
178 
179  PetscShellMatrix<T> * matrix = static_cast<PetscShellMatrix<T> *> (&shell_matrix);
180 
181  return _solve_standard_helper(matrix->mat(), precond->mat(), nev, ncv, tol, m_its);
182 }

◆ solve_standard() [3/3]

template<typename T>
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::solve_standard ( SparseMatrix< T > &  matrix_A,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
overridevirtual

This function calls the SLEPc solver to compute the eigenpairs of the SparseMatrix matrix_A.

nev is the number of eigenpairs to be computed and ncv is the number of basis vectors to be used in the solution procedure. Return values are the number of converged eigen values and the number of the iterations carried out by the eigen solver.

Implements libMesh::EigenSolver< T >.

Definition at line 101 of file slepc_eigen_solver.C.

106 {
107  LOG_SCOPE("solve_standard()", "SlepcEigenSolver");
108 
109  this->clear ();
110 
111  this->init ();
112 
113  // Make sure the SparseMatrix passed in is really a PetscMatrix
114  PetscMatrix<T> * matrix_A = dynamic_cast<PetscMatrix<T> *>(&matrix_A_in);
115 
116  if (!matrix_A)
117  libmesh_error_msg("Error: input matrix to solve_standard() must be a PetscMatrix.");
118 
119  // Close the matrix and vectors in case this wasn't already done.
120  if (this->_close_matrix_before_solve)
121  matrix_A->close ();
122 
123  return _solve_standard_helper(matrix_A->mat(), nullptr, nev, ncv, tol, m_its);
124 }

Member Data Documentation

◆ _close_matrix_before_solve

template<typename T>
bool libMesh::EigenSolver< T >::_close_matrix_before_solve
protectedinherited

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _counts

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

◆ _eigen_problem_type

template<typename T>
EigenProblemType libMesh::EigenSolver< T >::_eigen_problem_type
protectedinherited

Enum stating which type of eigen problem we deal with.

Definition at line 313 of file eigen_solver.h.

Referenced by libMesh::EigenSolver< libMesh::Number >::eigen_problem_type(), and libMesh::EigenSolver< libMesh::Number >::set_eigenproblem_type().

◆ _eigen_solver_type

template<typename T>
EigenSolverType libMesh::EigenSolver< T >::_eigen_solver_type
protectedinherited

Enum stating which type of eigensolver to use.

Definition at line 308 of file eigen_solver.h.

Referenced by libMesh::EigenSolver< libMesh::Number >::eigen_solver_type(), and libMesh::EigenSolver< libMesh::Number >::set_eigensolver_type().

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 141 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _eps

template<typename T>
EPS libMesh::SlepcEigenSolver< T >::_eps
private

Eigenproblem solver context.

Definition at line 295 of file slepc_eigen_solver.h.

Referenced by libMesh::SlepcEigenSolver< libMesh::Number >::eps().

◆ _is_initialized

template<typename T>
bool libMesh::EigenSolver< T >::_is_initialized
protectedinherited

Flag indicating if the data structures have been initialized.

Definition at line 323 of file eigen_solver.h.

Referenced by libMesh::EigenSolver< libMesh::Number >::initialized().

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 135 of file reference_counter.h.

◆ _n_objects

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 130 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _position_of_spectrum

template<typename T>
PositionOfSpectrum libMesh::EigenSolver< T >::_position_of_spectrum
protectedinherited

Enum stating where to evaluate the spectrum.

Definition at line 318 of file eigen_solver.h.

Referenced by libMesh::EigenSolver< libMesh::Number >::position_of_spectrum(), and libMesh::EigenSolver< libMesh::Number >::set_position_of_spectrum().

◆ _solver_configuration

template<typename T>
SolverConfiguration* libMesh::EigenSolver< T >::_solver_configuration
protectedinherited

Optionally store a SolverOptions object that can be used to set parameters like solver type, tolerances and iteration limits.

Definition at line 329 of file eigen_solver.h.

◆ _target_val

template<typename T>
Real libMesh::EigenSolver< T >::_target_val
protectedinherited

Definition at line 331 of file eigen_solver.h.


The documentation for this class was generated from the following files:
libMesh::EigenSolver::initialized
bool initialized() const
Definition: eigen_solver.h:93
libMesh::SlepcEigenSolver::_solve_generalized_helper
std::pair< unsigned int, unsigned int > _solve_generalized_helper(Mat mat_A, Mat mat_B, Mat precond, int nev, int ncv, const double tol, const unsigned int m_its)
Helper function that actually performs the generalized eigensolve.
Definition: slepc_eigen_solver.C:520
libMesh::TARGET_IMAGINARY
Definition: enum_eigen_solver_type.h:83
libMesh::GHIEP
Definition: enum_eigen_solver_type.h:59
libMesh::HEP
Definition: enum_eigen_solver_type.h:56
libMesh::LAPACK
Definition: enum_eigen_solver_type.h:35
libMesh::POWER
Definition: enum_eigen_solver_type.h:34
libMesh::TARGET_REAL
Definition: enum_eigen_solver_type.h:80
libMesh::SMALLEST_REAL
Definition: enum_eigen_solver_type.h:79
libMesh::LARGEST_REAL
Definition: enum_eigen_solver_type.h:78
libMesh::ReferenceCounter::_counts
static Counts _counts
Actually holds the data.
Definition: reference_counter.h:122
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition: parallel_object.h:94
libMesh::EigenSolver::_solver_configuration
SolverConfiguration * _solver_configuration
Optionally store a SolverOptions object that can be used to set parameters like solver type,...
Definition: eigen_solver.h:329
libMesh::ReferenceCounter::_n_objects
static Threads::atomic< unsigned int > _n_objects
The number of objects.
Definition: reference_counter.h:130
libMesh::SMALLEST_IMAGINARY
Definition: enum_eigen_solver_type.h:82
libMesh::SlepcEigenSolver::set_slepc_solver_type
void set_slepc_solver_type()
Tells Slepc to use the user-specified solver stored in _eigen_solver_type.
Definition: slepc_eigen_solver.C:663
libMesh::ierr
ierr
Definition: petsc_dm_wrapper.C:72
libMesh::ReferenceCounter::get_info
static std::string get_info()
Gets a string containing the reference information.
Definition: reference_counter.C:47
libMesh::SlepcEigenSolver::_solve_standard_helper
std::pair< unsigned int, unsigned int > _solve_standard_helper(Mat mat, Mat precond, int nev, int ncv, const double tol, const unsigned int m_its)
Helper function that actually performs the standard eigensolve.
Definition: slepc_eigen_solver.C:186
libMesh::EigenSolver::_position_of_spectrum
PositionOfSpectrum _position_of_spectrum
Enum stating where to evaluate the spectrum.
Definition: eigen_solver.h:318
libMesh::EigenSolver::_is_initialized
bool _is_initialized
Flag indicating if the data structures have been initialized.
Definition: eigen_solver.h:323
libMesh::Threads::spin_mtx
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
libMesh::ParallelObject::_communicator
const Parallel::Communicator & _communicator
Definition: parallel_object.h:112
libMesh::LARGEST_IMAGINARY
Definition: enum_eigen_solver_type.h:81
libMesh::Utility::enum_to_string
std::string enum_to_string(const T e)
libMesh::KRYLOVSCHUR
Definition: enum_eigen_solver_type.h:39
libMesh::EigenSolver::_eigen_problem_type
EigenProblemType _eigen_problem_type
Enum stating which type of eigen problem we deal with.
Definition: eigen_solver.h:313
libMesh::EigenSolver::_eigen_solver_type
EigenSolverType _eigen_solver_type
Enum stating which type of eigensolver to use.
Definition: eigen_solver.h:308
libMesh::ARNOLDI
Definition: enum_eigen_solver_type.h:37
libMesh::SMALLEST_MAGNITUDE
Definition: enum_eigen_solver_type.h:76
libMesh::LARGEST_MAGNITUDE
Definition: enum_eigen_solver_type.h:75
libMesh::ReferenceElem::get
const Elem & get(const ElemType type_in)
Definition: reference_elem.C:237
libMesh::NHEP
Definition: enum_eigen_solver_type.h:55
libMesh::SUBSPACE
Definition: enum_eigen_solver_type.h:36
libMesh::SlepcEigenSolver::_petsc_shell_matrix_mult
static PetscErrorCode _petsc_shell_matrix_mult(Mat mat, Vec arg, Vec dest)
Internal function if shell matrix mode is used, this just calls the shell matrix's matrix multiplicat...
Definition: slepc_eigen_solver.C:933
libMesh::GHEP
Definition: enum_eigen_solver_type.h:58
libMesh::ctx
void * ctx
Definition: petsc_dm_wrapper.C:71
libMesh::SlepcEigenSolver::_petsc_shell_matrix_get_diagonal
static PetscErrorCode _petsc_shell_matrix_get_diagonal(Mat mat, Vec dest)
Internal function if shell matrix mode is used, this just calls the shell matrix's get_diagonal funct...
Definition: slepc_eigen_solver.C:958
libMesh::SLEPC_SOLVERS
Definition: enum_solver_package.h:39
libMesh::SlepcEigenSolver::set_slepc_position_of_spectrum
void set_slepc_position_of_spectrum()
Tells Slepc to compute the spectrum at the position stored in _position_of_spectrum.
Definition: slepc_eigen_solver.C:725
libMesh::EigenSolver::_target_val
Real _target_val
Definition: eigen_solver.h:331
libMesh::TARGET_MAGNITUDE
Definition: enum_eigen_solver_type.h:77
libMesh::EigenSolver::_close_matrix_before_solve
bool _close_matrix_before_solve
Definition: eigen_solver.h:333
libMesh::err
OStreamProxy err
libMesh::GNHEP
Definition: enum_eigen_solver_type.h:57
libMesh::ReferenceCounter::_enable_print_counter
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called.
Definition: reference_counter.h:141
libMesh::SlepcEigenSolver::clear
virtual void clear() override
Release all memory and clear data structures.
Definition: slepc_eigen_solver.C:59
libMesh::SlepcEigenSolver::set_slepc_problem_type
void set_slepc_problem_type()
Tells Slepc to deal with the type of problem stored in _eigen_problem_type.
Definition: slepc_eigen_solver.C:695
libMesh::Quality::name
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
libMesh::SolverConfiguration::configure_solver
virtual void configure_solver()=0
Apply solver options to a particular solver.
libMesh::SlepcEigenSolver::init
virtual void init() override
Initialize data structures if not done so already.
Definition: slepc_eigen_solver.C:78
libMesh::SlepcEigenSolver::_eps
EPS _eps
Eigenproblem solver context.
Definition: slepc_eigen_solver.h:295
libMesh::LANCZOS
Definition: enum_eigen_solver_type.h:38