libMesh::SlepcEigenSolver< T > Class Template Reference

EigenSolver implementation based on SLEPc. More...

#include <slepc_eigen_solver.h>

Inheritance diagram for libMesh::SlepcEigenSolver< T >:

Public Member Functions

 SlepcEigenSolver (const Parallel::Communicator &comm_in LIBMESH_CAN_DEFAULT_TO_COMMWORLD)
 
 ~SlepcEigenSolver ()
 
virtual void clear () libmesh_override
 
virtual void init () libmesh_override
 
virtual std::pair< unsigned int, unsigned int > solve_standard (SparseMatrix< T > &matrix_A, int nev, int ncv, const double tol, const unsigned int m_its) libmesh_override
 
virtual std::pair< unsigned int, unsigned int > solve_standard (ShellMatrix< T > &shell_matrix, int nev, int ncv, const double tol, const unsigned int m_its) libmesh_override
 
virtual std::pair< unsigned int, unsigned int > solve_generalized (SparseMatrix< T > &matrix_A, SparseMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its) libmesh_override
 
virtual std::pair< unsigned int, unsigned int > solve_generalized (ShellMatrix< T > &matrix_A, SparseMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its) libmesh_override
 
virtual std::pair< unsigned int, unsigned int > solve_generalized (SparseMatrix< T > &matrix_A, ShellMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its) libmesh_override
 
virtual std::pair< unsigned int, unsigned int > solve_generalized (ShellMatrix< T > &matrix_A, ShellMatrix< T > &matrix_B, int nev, int ncv, const double tol, const unsigned int m_its) libmesh_override
 
virtual std::pair< Real, Realget_eigenpair (dof_id_type i, NumericVector< T > &solution_in) libmesh_override
 
virtual std::pair< Real, Realget_eigenvalue (dof_id_type i) libmesh_override
 
Real get_relative_error (unsigned int i)
 
virtual void attach_deflation_space (NumericVector< T > &deflation_vector) libmesh_override
 
virtual void set_initial_space (NumericVector< T > &initial_space_in) libmesh_override
 
EPS eps ()
 
bool initialized () const
 
EigenSolverType eigen_solver_type () const
 
EigenProblemType eigen_problem_type () const
 
PositionOfSpectrum position_of_spectrum () const
 
void set_eigensolver_type (const EigenSolverType est)
 
void set_eigenproblem_type (EigenProblemType ept)
 
void set_position_of_spectrum (PositionOfSpectrum pos)
 
void set_position_of_spectrum (Real pos)
 
void set_position_of_spectrum (Real pos, PositionOfSpectrum target)
 
void set_solver_configuration (SolverConfiguration &solver_configuration)
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static UniquePtr< EigenSolver< T > > build (const Parallel::Communicator &comm_in LIBMESH_CAN_DEFAULT_TO_COMMWORLD, const SolverPackage solver_package=SLEPC_SOLVERS)
 
static std::string get_info ()
 
static void print_info (std::ostream &out=libMesh::out)
 
static unsigned int n_objects ()
 
static void enable_print_counter_info ()
 
static void disable_print_counter_info ()
 

Protected Types

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

Protected Member Functions

void increment_constructor_count (const std::string &name)
 
void increment_destructor_count (const std::string &name)
 

Protected Attributes

EigenSolverType _eigen_solver_type
 
EigenProblemType _eigen_problem_type
 
PositionOfSpectrum _position_of_spectrum
 
bool _is_initialized
 
SolverConfiguration_solver_configuration
 
Real _target_val
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

static Counts _counts
 
static Threads::atomic< unsigned int > _n_objects
 
static Threads::spin_mutex _mutex
 
static bool _enable_print_counter = true
 

Private Member Functions

std::pair< unsigned int, unsigned int > _solve_standard_helper (Mat mat, int nev, int ncv, const double tol, const unsigned int m_its)
 
std::pair< unsigned int, unsigned int > _solve_generalized_helper (Mat mat_A, Mat mat_B, int nev, int ncv, const double tol, const unsigned int m_its)
 
void set_slepc_solver_type ()
 
void set_slepc_problem_type ()
 
void set_slepc_position_of_spectrum ()
 

Static Private Member Functions

static PetscErrorCode _petsc_shell_matrix_mult (Mat mat, Vec arg, Vec dest)
 
static PetscErrorCode _petsc_shell_matrix_get_diagonal (Mat mat, Vec dest)
 

Private Attributes

EPS _eps
 

Detailed Description

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

EigenSolver implementation based on SLEPc.

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

Author
Steffen Peterson
Date
2005

Definition at line 48 of file slepc_eigen_solver.h.

Member Typedef Documentation

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 119 of file reference_counter.h.

Constructor & Destructor Documentation

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

Constructor. Initializes Petsc data structures

Definition at line 279 of file slepc_eigen_solver.h.

References libMesh::EigenSolver< T >::_eigen_problem_type, libMesh::EigenSolver< T >::_eigen_solver_type, libMesh::ARNOLDI, and libMesh::NHEP.

279  :
280  EigenSolver<T>(comm_in)
281 {
282  this->_eigen_solver_type = ARNOLDI;
283  this->_eigen_problem_type = NHEP;
284 }
EigenSolverType _eigen_solver_type
Definition: eigen_solver.h:248
EigenProblemType _eigen_problem_type
Definition: eigen_solver.h:253
template<typename T >
libMesh::SlepcEigenSolver< T >::~SlepcEigenSolver ( )
inline

Destructor.

Definition at line 290 of file slepc_eigen_solver.h.

References libMesh::SlepcEigenSolver< T >::clear().

291 {
292  this->clear ();
293 }
virtual void clear() libmesh_override

Member Function Documentation

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 862 of file slepc_eigen_solver.C.

References libMesh::ParallelObject::comm(), libMesh::ctx, libMesh::ShellMatrix< T >::get_diagonal(), and ierr.

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

863 {
864  // Get the matrix context.
865  PetscErrorCode ierr=0;
866  void * ctx;
867  ierr = MatShellGetContext(mat,&ctx);
868 
870  PetscObjectGetComm((PetscObject)mat,&comm);
871  CHKERRABORT(comm,ierr);
872 
873  // Get user shell matrix object.
874  const ShellMatrix<T> & shell_matrix = *static_cast<const ShellMatrix<T> *>(ctx);
875 
876  // Make \p NumericVector instances around the vector.
877  PetscVector<T> dest_global(dest, shell_matrix.comm());
878 
879  // Call the user function.
880  shell_matrix.get_diagonal(dest_global);
881 
882  return ierr;
883 }
MPI_Comm communicator
Definition: parallel.h:177
PetscErrorCode Vec Mat Mat void * ctx
PetscErrorCode ierr
const Parallel::Communicator & comm() const
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 837 of file slepc_eigen_solver.C.

References libMesh::ParallelObject::comm(), libMesh::ctx, ierr, and libMesh::ShellMatrix< T >::vector_mult().

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

838 {
839  // Get the matrix context.
840  PetscErrorCode ierr=0;
841  void * ctx;
842  ierr = MatShellGetContext(mat,&ctx);
843 
845  PetscObjectGetComm((PetscObject)mat,&comm);
846  CHKERRABORT(comm,ierr);
847 
848  // Get user shell matrix object.
849  const ShellMatrix<T> & shell_matrix = *static_cast<const ShellMatrix<T> *>(ctx);
850 
851  // Make \p NumericVector instances around the vectors.
852  PetscVector<T> arg_global(arg, shell_matrix.comm());
853  PetscVector<T> dest_global(dest, shell_matrix.comm());
854 
855  // Call the user function.
856  shell_matrix.vector_mult(dest_global,arg_global);
857 
858  return ierr;
859 }
MPI_Comm communicator
Definition: parallel.h:177
PetscErrorCode Vec Mat Mat void * ctx
PetscErrorCode ierr
const Parallel::Communicator & comm() const
template<typename T >
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::_solve_generalized_helper ( Mat  mat_A,
Mat  mat_B,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
private

Helper function that actually performs the generalized eigensolve.

Definition at line 432 of file slepc_eigen_solver.C.

References ierr.

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

438 {
439  LOG_SCOPE("solve_generalized()", "SlepcEigenSolver");
440 
441  PetscErrorCode ierr=0;
442 
443  // converged eigen pairs and number of iterations
444  PetscInt nconv=0;
445  PetscInt its=0;
446 
447 #ifdef DEBUG
448  // The relative error.
449  PetscReal error, re, im;
450 
451  // Pointer to vectors of the real parts, imaginary parts.
452  PetscScalar kr, ki;
453 #endif
454 
455  // Set operators.
456  ierr = EPSSetOperators (_eps, mat_A, mat_B);
457  LIBMESH_CHKERR(ierr);
458 
459  //set the problem type and the position of the spectrum
462 
463  // Set eigenvalues to be computed.
464 #if SLEPC_VERSION_LESS_THAN(3,0,0)
465  ierr = EPSSetDimensions (_eps, nev, ncv);
466 #else
467  ierr = EPSSetDimensions (_eps, nev, ncv, PETSC_DECIDE);
468 #endif
469  LIBMESH_CHKERR(ierr);
470 
471 
472  // Set the tolerance and maximum iterations.
473  ierr = EPSSetTolerances (_eps, tol, m_its);
474  LIBMESH_CHKERR(ierr);
475 
476  // Set runtime options, e.g.,
477  // -eps_type <type>, -eps_nev <nev>, -eps_ncv <ncv>
478  // Similar to PETSc, these options will override those specified
479  // above as long as EPSSetFromOptions() is called _after_ any
480  // other customization routines.
481  ierr = EPSSetFromOptions (_eps);
482  LIBMESH_CHKERR(ierr);
483 
484  // If the SolverConfiguration object is provided, use it to override
485  // solver options.
486  if (this->_solver_configuration)
487  {
489  }
490 
491  // Solve the eigenproblem.
492  ierr = EPSSolve (_eps);
493  LIBMESH_CHKERR(ierr);
494 
495  // Get the number of iterations.
496  ierr = EPSGetIterationNumber (_eps, &its);
497  LIBMESH_CHKERR(ierr);
498 
499  // Get number of converged eigenpairs.
500  ierr = EPSGetConverged(_eps,&nconv);
501  LIBMESH_CHKERR(ierr);
502 
503 
504 #ifdef DEBUG
505  // ierr = PetscPrintf(this->comm().get(),
506  // "\n Number of iterations: %d\n"
507  // " Number of converged eigenpairs: %d\n\n", its, nconv);
508 
509  // Display eigenvalues and relative errors.
510  ierr = PetscPrintf(this->comm().get(),
511  " k ||Ax-kx||/|kx|\n"
512  " ----------------- -----------------\n" );
513  LIBMESH_CHKERR(ierr);
514 
515  for (PetscInt i=0; i<nconv; i++ )
516  {
517  ierr = EPSGetEigenpair(_eps, i, &kr, &ki, PETSC_NULL, PETSC_NULL);
518  LIBMESH_CHKERR(ierr);
519 
520 #if SLEPC_VERSION_LESS_THAN(3,6,0)
521  ierr = EPSComputeRelativeError(_eps, i, &error);
522 #else
523  ierr = EPSComputeError(_eps, i, EPS_ERROR_RELATIVE, &error);
524 #endif
525  LIBMESH_CHKERR(ierr);
526 
527 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
528  re = PetscRealPart(kr);
529  im = PetscImaginaryPart(kr);
530 #else
531  re = kr;
532  im = ki;
533 #endif
534 
535  if (im != .0)
536  {
537  ierr = PetscPrintf(this->comm().get()," %9f%+9f i %12f\n", re, im, error);
538  LIBMESH_CHKERR(ierr);
539  }
540  else
541  {
542  ierr = PetscPrintf(this->comm().get()," %12f %12f\n", re, error);
543  LIBMESH_CHKERR(ierr);
544  }
545  }
546 
547  ierr = PetscPrintf(this->comm().get(),"\n" );
548  LIBMESH_CHKERR(ierr);
549 #endif // DEBUG
550 
551  // return the number of converged eigenpairs
552  // and the number of iterations
553  return std::make_pair(nconv, its);
554 }
SolverConfiguration * _solver_configuration
Definition: eigen_solver.h:269
virtual void configure_solver()=0
PetscErrorCode ierr
const Parallel::Communicator & comm() const
template<typename T >
std::pair< unsigned int, unsigned int > libMesh::SlepcEigenSolver< T >::_solve_standard_helper ( Mat  mat,
int  nev,
int  ncv,
const double  tol,
const unsigned int  m_its 
)
private

Helper function that actually performs the standard eigensolve.

Definition at line 141 of file slepc_eigen_solver.C.

References ierr.

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

146 {
147  LOG_SCOPE("solve_standard()", "SlepcEigenSolver");
148 
149  PetscErrorCode ierr=0;
150 
151  // converged eigen pairs and number of iterations
152  PetscInt nconv=0;
153  PetscInt its=0;
154 
155 #ifdef DEBUG
156  // The relative error.
157  PetscReal error, re, im;
158 
159  // Pointer to vectors of the real parts, imaginary parts.
160  PetscScalar kr, ki;
161 #endif
162 
163  // Set operators.
164  ierr = EPSSetOperators (_eps, mat, PETSC_NULL);
165  LIBMESH_CHKERR(ierr);
166 
167  //set the problem type and the position of the spectrum
170 
171  // Set eigenvalues to be computed.
172 #if SLEPC_VERSION_LESS_THAN(3,0,0)
173  ierr = EPSSetDimensions (_eps, nev, ncv);
174 #else
175  ierr = EPSSetDimensions (_eps, nev, ncv, PETSC_DECIDE);
176 #endif
177  LIBMESH_CHKERR(ierr);
178  // Set the tolerance and maximum iterations.
179  ierr = EPSSetTolerances (_eps, tol, m_its);
180  LIBMESH_CHKERR(ierr);
181 
182  // Set runtime options, e.g.,
183  // -eps_type <type>, -eps_nev <nev>, -eps_ncv <ncv>
184  // Similar to PETSc, these options will override those specified
185  // above as long as EPSSetFromOptions() is called _after_ any
186  // other customization routines.
187  ierr = EPSSetFromOptions (_eps);
188  LIBMESH_CHKERR(ierr);
189 
190  // If the SolverConfiguration object is provided, use it to override
191  // solver options.
192  if (this->_solver_configuration)
193  {
195  }
196 
197  // Solve the eigenproblem.
198  ierr = EPSSolve (_eps);
199  LIBMESH_CHKERR(ierr);
200 
201  // Get the number of iterations.
202  ierr = EPSGetIterationNumber (_eps, &its);
203  LIBMESH_CHKERR(ierr);
204 
205  // Get number of converged eigenpairs.
206  ierr = EPSGetConverged(_eps,&nconv);
207  LIBMESH_CHKERR(ierr);
208 
209 
210 #ifdef DEBUG
211  // ierr = PetscPrintf(this->comm().get(),
212  // "\n Number of iterations: %d\n"
213  // " Number of converged eigenpairs: %d\n\n", its, nconv);
214 
215  // Display eigenvalues and relative errors.
216  ierr = PetscPrintf(this->comm().get(),
217  " k ||Ax-kx||/|kx|\n"
218  " ----------------- -----------------\n" );
219  LIBMESH_CHKERR(ierr);
220 
221  for (PetscInt i=0; i<nconv; i++ )
222  {
223  ierr = EPSGetEigenpair(_eps, i, &kr, &ki, PETSC_NULL, PETSC_NULL);
224  LIBMESH_CHKERR(ierr);
225 
226 #if SLEPC_VERSION_LESS_THAN(3,6,0)
227  ierr = EPSComputeRelativeError(_eps, i, &error);
228 #else
229  ierr = EPSComputeError(_eps, i, EPS_ERROR_RELATIVE, &error);
230 #endif
231  LIBMESH_CHKERR(ierr);
232 
233 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
234  re = PetscRealPart(kr);
235  im = PetscImaginaryPart(kr);
236 #else
237  re = kr;
238  im = ki;
239 #endif
240 
241  if (im != .0)
242  {
243  ierr = PetscPrintf(this->comm().get()," %9f%+9f i %12f\n", re, im, error);
244  LIBMESH_CHKERR(ierr);
245  }
246  else
247  {
248  ierr = PetscPrintf(this->comm().get()," %12f %12f\n", re, error);
249  LIBMESH_CHKERR(ierr);
250  }
251  }
252 
253  ierr = PetscPrintf(this->comm().get(),"\n" );
254  LIBMESH_CHKERR(ierr);
255 #endif // DEBUG
256 
257  // return the number of converged eigenpairs
258  // and the number of iterations
259  return std::make_pair(nconv, its);
260 }
SolverConfiguration * _solver_configuration
Definition: eigen_solver.h:269
virtual void configure_solver()=0
PetscErrorCode ierr
const Parallel::Communicator & comm() const
template<typename T >
void libMesh::SlepcEigenSolver< T >::attach_deflation_space ( NumericVector< T > &  deflation_vector)
virtual

Attach a deflation space defined by a single vector.

Implements libMesh::EigenSolver< T >.

Definition at line 787 of file slepc_eigen_solver.C.

References ierr, libMesh::TriangleWrapper::init(), and libMesh::PetscVector< T >::vec().

788 {
789  this->init();
790 
791  PetscErrorCode ierr = 0;
792 
793  // Make sure the input vector is actually a PetscVector
794  PetscVector<T> * deflation_vector_petsc_vec =
795  dynamic_cast<PetscVector<T> *>(&deflation_vector_in);
796 
797  if (!deflation_vector_petsc_vec)
798  libmesh_error_msg("Error attaching deflation space: input vector must be a PetscVector.");
799 
800  // Get a handle for the underlying Vec.
801  Vec deflation_vector = deflation_vector_petsc_vec->vec();
802 
803 #if SLEPC_VERSION_LESS_THAN(3,1,0)
804  ierr = EPSAttachDeflationSpace(_eps, 1, &deflation_vector, PETSC_FALSE);
805 #else
806  ierr = EPSSetDeflationSpace(_eps, 1, &deflation_vector);
807 #endif
808  LIBMESH_CHKERR(ierr);
809 }
PetscErrorCode ierr
virtual void init() libmesh_override
template<typename T >
UniquePtr< EigenSolver< T > > libMesh::EigenSolver< T >::build ( const Parallel::Communicator &comm_in  LIBMESH_CAN_DEFAULT_TO_COMMWORLD,
const SolverPackage  solver_package = SLEPC_SOLVERS 
)
staticinherited

Builds an EigenSolver using the linear solver package specified by solver_package

Definition at line 37 of file eigen_solver.C.

References libMesh::SLEPC_SOLVERS.

39 {
40  // Build the appropriate solver
41  switch (solver_package)
42  {
43 
44 #ifdef LIBMESH_HAVE_SLEPC
45  case SLEPC_SOLVERS:
46  return UniquePtr<EigenSolver<T> >(new SlepcEigenSolver<T>(comm));
47 #endif
48 
49  default:
50  libmesh_error_msg("ERROR: Unrecognized eigen solver package: " << solver_package);
51  }
52 
53  return UniquePtr<EigenSolver<T> >();
54 }
const Parallel::Communicator & comm() const
template<typename T >
void libMesh::SlepcEigenSolver< T >::clear ( )
virtual

Release all memory and clear data structures.

Reimplemented from libMesh::EigenSolver< T >.

Definition at line 40 of file slepc_eigen_solver.C.

References libMesh::libMeshPrivateData::_is_initialized, ierr, libMesh::initialized(), and libMesh::KRYLOVSCHUR.

Referenced by libMesh::SlepcEigenSolver< T >::~SlepcEigenSolver().

41 {
42  if (this->initialized())
43  {
44  this->_is_initialized = false;
45 
46  PetscErrorCode ierr=0;
47 
48  ierr = LibMeshEPSDestroy(&_eps);
49  LIBMESH_CHKERR(ierr);
50 
51  // SLEPc default eigenproblem solver
53  }
54 }
PetscErrorCode ierr
bool initialized() const
Definition: eigen_solver.h:82
EigenSolverType _eigen_solver_type
Definition: eigen_solver.h:248
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_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::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::EpetraVector< T >::close(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), 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::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), 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::MeshRefinement::eliminate_unrefined_patches(), libMesh::EpetraVector< T >::EpetraVector(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TopologyMap::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::EpetraVector< T >::init(), libMesh::PetscVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), 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::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), 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::DistributedVector< T >::max(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::DistributedVector< T >::min(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), 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::Partitioner::partition(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::SparseMatrix< T >::print(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::DistributedVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), and libMesh::PetscVector< T >::zero_clone().

88  { return _communicator; }
const Parallel::Communicator & _communicator
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited
template<typename T >
EigenProblemType libMesh::EigenSolver< T >::eigen_problem_type ( ) const
inlineinherited
Returns
The type of the eigen problem.

Definition at line 103 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_eigen_problem_type.

103 { return _eigen_problem_type;}
EigenProblemType _eigen_problem_type
Definition: eigen_solver.h:253
template<typename T >
EigenSolverType libMesh::EigenSolver< T >::eigen_solver_type ( ) const
inlineinherited
Returns
The type of eigensolver to use.

Definition at line 98 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_eigen_solver_type.

98 { return _eigen_solver_type; }
EigenSolverType _eigen_solver_type
Definition: eigen_solver.h:248
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Definition at line 101 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

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

102 {
103  _enable_print_counter = true;
104  return;
105 }
template<typename T >
std::pair< Real, Real > libMesh::SlepcEigenSolver< T >::get_eigenpair ( dof_id_type  i,
NumericVector< T > &  solution_in 
)
virtual
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 711 of file slepc_eigen_solver.C.

References libMesh::PetscVector< T >::close(), ierr, and libMesh::PetscVector< T >::vec().

713 {
714  PetscErrorCode ierr=0;
715 
716  PetscReal re, im;
717 
718  // Make sure the NumericVector passed in is really a PetscVector
719  PetscVector<T> * solution = dynamic_cast<PetscVector<T> *>(&solution_in);
720 
721  if (!solution)
722  libmesh_error_msg("Error getting eigenvector: input vector must be a PetscVector.");
723 
724  // real and imaginary part of the ith eigenvalue.
725  PetscScalar kr, ki;
726 
727  solution->close();
728 
729  ierr = EPSGetEigenpair(_eps, i, &kr, &ki, solution->vec(), PETSC_NULL);
730  LIBMESH_CHKERR(ierr);
731 
732 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
733  re = PetscRealPart(kr);
734  im = PetscImaginaryPart(kr);
735 #else
736  re = kr;
737  im = ki;
738 #endif
739 
740  return std::make_pair(re, im);
741 }
PetscErrorCode ierr
template<typename T >
std::pair< Real, Real > libMesh::SlepcEigenSolver< T >::get_eigenvalue ( dof_id_type  i)
virtual

Same as above, but does not copy the eigenvector.

Implements libMesh::EigenSolver< T >.

Definition at line 745 of file slepc_eigen_solver.C.

References ierr.

746 {
747  PetscErrorCode ierr=0;
748 
749  PetscReal re, im;
750 
751  // real and imaginary part of the ith eigenvalue.
752  PetscScalar kr, ki;
753 
754  ierr = EPSGetEigenvalue(_eps, i, &kr, &ki);
755  LIBMESH_CHKERR(ierr);
756 
757 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
758  re = PetscRealPart(kr);
759  im = PetscImaginaryPart(kr);
760 #else
761  re = kr;
762  im = ki;
763 #endif
764 
765  return std::make_pair(re, im);
766 }
PetscErrorCode ierr
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

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

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

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 (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
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 770 of file slepc_eigen_solver.C.

References ierr.

771 {
772  PetscErrorCode ierr=0;
773  PetscReal error;
774 
775 #if SLEPC_VERSION_LESS_THAN(3,6,0)
776  ierr = EPSComputeRelativeError(_eps, i, &error);
777 #else
778  ierr = EPSComputeError(_eps, i, EPS_ERROR_RELATIVE, &error);
779 #endif
780  LIBMESH_CHKERR(ierr);
781 
782  return error;
783 }
PetscErrorCode ierr
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 185 of file reference_counter.h.

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

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

186 {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189 
190  p.first++;
191 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
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 198 of file reference_counter.h.

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

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

199 {
200  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
201  std::pair<unsigned int, unsigned int> & p = _counts[name];
202 
203  p.second++;
204 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
template<typename T >
void libMesh::SlepcEigenSolver< T >::init ( )
virtual

Initialize data structures if not done so already.

Implements libMesh::EigenSolver< T >.

Definition at line 59 of file slepc_eigen_solver.C.

References libMesh::libMeshPrivateData::_is_initialized, ierr, and libMesh::initialized().

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

60 {
61 
62  PetscErrorCode ierr=0;
63 
64  // Initialize the data structures if not done so already.
65  if (!this->initialized())
66  {
67  this->_is_initialized = true;
68 
69  // Create the eigenproblem solver context
70  ierr = EPSCreate (this->comm().get(), &_eps);
71  LIBMESH_CHKERR(ierr);
72 
73  // Set user-specified solver
75  }
76 }
PetscErrorCode ierr
const Parallel::Communicator & comm() const
bool initialized() const
Definition: eigen_solver.h:82
template<typename T >
bool libMesh::EigenSolver< T >::initialized ( ) const
inlineinherited
Returns
true if the data structures are initialized, false otherwise.

Definition at line 82 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_is_initialized.

82 { return _is_initialized; }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), 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::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::get_solution(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), 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::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::read_nodes(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:722
const Parallel::Communicator & _communicator
template<typename T >
PositionOfSpectrum libMesh::EigenSolver< T >::position_of_spectrum ( ) const
inlineinherited
Returns
The position of the spectrum to compute.

Definition at line 108 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_position_of_spectrum.

109  { return _position_of_spectrum;}
PositionOfSpectrum _position_of_spectrum
Definition: eigen_solver.h:258
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

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

Definition at line 88 of file reference_counter.C.

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

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

89 {
91  out_stream << ReferenceCounter::get_info();
92 }
static std::string get_info()
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 99 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::rank().

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshCommunication::broadcast(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DofMap::build_sparsity(), 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::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::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::EnsightIO::EnsightIO(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), 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::MeshBase::get_info(), 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::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::EquationSystems::get_solution(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), 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::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), 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::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MetisPartitioner::partition_range(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NumericVector< T >::print_global(), 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::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::CheckpointIO::read_header(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), 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::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::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_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), 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::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:720
template<typename T >
void libMesh::EigenSolver< T >::set_eigenproblem_type ( EigenProblemType  ept)
inlineinherited

Sets the type of the eigenproblem.

Definition at line 120 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_eigen_problem_type.

121  {_eigen_problem_type = ept;}
EigenProblemType _eigen_problem_type
Definition: eigen_solver.h:253
template<typename T >
void libMesh::EigenSolver< T >::set_eigensolver_type ( const EigenSolverType  est)
inlineinherited

Sets the type of eigensolver to use.

Definition at line 114 of file eigen_solver.h.

References libMesh::EigenSolver< T >::_eigen_solver_type.

115  { _eigen_solver_type = est; }
EigenSolverType _eigen_solver_type
Definition: eigen_solver.h:248
template<typename T >
void libMesh::SlepcEigenSolver< T >::set_initial_space ( NumericVector< T > &  initial_space_in)
virtual

Use initial_space_in as the initial guess.

Implements libMesh::EigenSolver< T >.

Definition at line 812 of file slepc_eigen_solver.C.

References ierr, libMesh::TriangleWrapper::init(), and libMesh::PetscVector< T >::vec().

813 {
814 #if SLEPC_VERSION_LESS_THAN(3,1,0)
815  libmesh_error_msg("SLEPc 3.1 is required to call EigenSolver::set_initial_space()");
816 #else
817  this->init();
818 
819  PetscErrorCode ierr = 0;
820 
821  // Make sure the input vector is actually a PetscVector
822  PetscVector<T> * initial_space_petsc_vec =
823  dynamic_cast<PetscVector<T> *>(&initial_space_in);
824 
825  if (!initial_space_petsc_vec)
826  libmesh_error_msg("Error attaching initial space: input vector must be a PetscVector.");
827 
828  // Get a handle for the underlying Vec.
829  Vec initial_vector = initial_space_petsc_vec->vec();
830 
831  ierr = EPSSetInitialSpace(_eps, 1, &initial_vector);
832  LIBMESH_CHKERR(ierr);
833 #endif
834 }
PetscErrorCode ierr
virtual void init() libmesh_override
template<typename T >
void libMesh::EigenSolver< T >::set_position_of_spectrum ( Real  pos)
inherited

Definition at line 64 of file eigen_solver.C.

References libMesh::TARGET_MAGNITUDE, and libMesh::TARGET_REAL.

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

Definition at line 75 of file eigen_solver.C.

76 {
77  _position_of_spectrum = target;
78  _target_val = pos;
79 }
PositionOfSpectrum _position_of_spectrum
Definition: eigen_solver.h:258
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 629 of file slepc_eigen_solver.C.

References ierr, libMesh::LARGEST_IMAGINARY, libMesh::LARGEST_MAGNITUDE, libMesh::LARGEST_REAL, libMesh::SMALLEST_IMAGINARY, libMesh::SMALLEST_MAGNITUDE, libMesh::SMALLEST_REAL, libMesh::TARGET_IMAGINARY, libMesh::TARGET_MAGNITUDE, and libMesh::TARGET_REAL.

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

630 {
631  PetscErrorCode ierr = 0;
632 
633  switch (this->_position_of_spectrum)
634  {
635  case LARGEST_MAGNITUDE:
636  {
637  ierr = EPSSetWhichEigenpairs (_eps, EPS_LARGEST_MAGNITUDE);
638  LIBMESH_CHKERR(ierr);
639  return;
640  }
641  case SMALLEST_MAGNITUDE:
642  {
643  ierr = EPSSetWhichEigenpairs (_eps, EPS_SMALLEST_MAGNITUDE);
644  LIBMESH_CHKERR(ierr);
645  return;
646  }
647  case LARGEST_REAL:
648  {
649  ierr = EPSSetWhichEigenpairs (_eps, EPS_LARGEST_REAL);
650  LIBMESH_CHKERR(ierr);
651  return;
652  }
653  case SMALLEST_REAL:
654  {
655  ierr = EPSSetWhichEigenpairs (_eps, EPS_SMALLEST_REAL);
656  LIBMESH_CHKERR(ierr);
657  return;
658  }
659  case LARGEST_IMAGINARY:
660  {
661  ierr = EPSSetWhichEigenpairs (_eps, EPS_LARGEST_IMAGINARY);
662  LIBMESH_CHKERR(ierr);
663  return;
664  }
665  case SMALLEST_IMAGINARY:
666  {
667  ierr = EPSSetWhichEigenpairs (_eps, EPS_SMALLEST_IMAGINARY);
668  LIBMESH_CHKERR(ierr);
669  return;
670  }
671 
672  // The EPS_TARGET_XXX enums were added in SLEPc 3.1
673 #if !SLEPC_VERSION_LESS_THAN(3,1,0)
674  case TARGET_MAGNITUDE:
675  {
676  ierr = EPSSetTarget(_eps, this->_target_val);
677  LIBMESH_CHKERR(ierr);
678  ierr = EPSSetWhichEigenpairs (_eps, EPS_TARGET_MAGNITUDE);
679  LIBMESH_CHKERR(ierr);
680  return;
681  }
682  case TARGET_REAL:
683  {
684  ierr = EPSSetTarget(_eps, this->_target_val);
685  LIBMESH_CHKERR(ierr);
686  ierr = EPSSetWhichEigenpairs (_eps, EPS_TARGET_REAL);
687  LIBMESH_CHKERR(ierr);
688  return;
689  }
690  case TARGET_IMAGINARY:
691  {
692  ierr = EPSSetTarget(_eps, this->_target_val);
693  LIBMESH_CHKERR(ierr);
694  ierr = EPSSetWhichEigenpairs (_eps, EPS_TARGET_IMAGINARY);
695  LIBMESH_CHKERR(ierr);
696  return;
697  }
698 #endif
699 
700  default:
701  libmesh_error_msg("ERROR: Unsupported SLEPc position of spectrum: " << this->_position_of_spectrum);
702  }
703 }
PositionOfSpectrum _position_of_spectrum
Definition: eigen_solver.h:258
PetscErrorCode ierr
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 599 of file slepc_eigen_solver.C.

References libMesh::err, libMesh::GHEP, libMesh::GHIEP, libMesh::GNHEP, libMesh::HEP, ierr, and libMesh::NHEP.

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

600 {
601  PetscErrorCode ierr = 0;
602 
603  switch (this->_eigen_problem_type)
604  {
605  case NHEP:
606  ierr = EPSSetProblemType (_eps, EPS_NHEP); LIBMESH_CHKERR(ierr); return;
607  case GNHEP:
608  ierr = EPSSetProblemType (_eps, EPS_GNHEP); LIBMESH_CHKERR(ierr); return;
609  case HEP:
610  ierr = EPSSetProblemType (_eps, EPS_HEP); LIBMESH_CHKERR(ierr); return;
611  case GHEP:
612  ierr = EPSSetProblemType (_eps, EPS_GHEP); LIBMESH_CHKERR(ierr); return;
613 #if !SLEPC_VERSION_LESS_THAN(3,3,0)
614  // EPS_GHIEP added in 3.3.0
615  case GHIEP:
616  ierr = EPSSetProblemType (_eps, EPS_GHIEP); LIBMESH_CHKERR(ierr); return;
617 #endif
618 
619  default:
620  libMesh::err << "ERROR: Unsupported SLEPc Eigen Problem: "
621  << this->_eigen_problem_type << std::endl
622  << "Continuing with SLEPc defaults" << std::endl;
623  }
624 }
OStreamProxy err(std::cerr)
PetscErrorCode ierr
EigenProblemType _eigen_problem_type
Definition: eigen_solver.h:253
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 567 of file slepc_eigen_solver.C.

References libMesh::ARNOLDI, libMesh::Utility::enum_to_string(), libMesh::err, ierr, libMesh::KRYLOVSCHUR, libMesh::LANCZOS, libMesh::LAPACK, libMesh::POWER, and libMesh::SUBSPACE.

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

568 {
569  PetscErrorCode ierr = 0;
570 
571  switch (this->_eigen_solver_type)
572  {
573  case POWER:
574  ierr = EPSSetType (_eps, (char *) EPSPOWER); LIBMESH_CHKERR(ierr); return;
575  case SUBSPACE:
576  ierr = EPSSetType (_eps, (char *) EPSSUBSPACE); LIBMESH_CHKERR(ierr); return;
577  case LAPACK:
578  ierr = EPSSetType (_eps, (char *) EPSLAPACK); LIBMESH_CHKERR(ierr); return;
579  case ARNOLDI:
580  ierr = EPSSetType (_eps, (char *) EPSARNOLDI); LIBMESH_CHKERR(ierr); return;
581  case LANCZOS:
582  ierr = EPSSetType (_eps, (char *) EPSLANCZOS); LIBMESH_CHKERR(ierr); return;
583  case KRYLOVSCHUR:
584  ierr = EPSSetType (_eps, (char *) EPSKRYLOVSCHUR); LIBMESH_CHKERR(ierr); return;
585  // case ARPACK:
586  // ierr = EPSSetType (_eps, (char *) EPSARPACK); LIBMESH_CHKERR(ierr); return;
587 
588  default:
589  libMesh::err << "ERROR: Unsupported SLEPc Eigen Solver: "
590  << Utility::enum_to_string(this->_eigen_solver_type) << std::endl
591  << "Continuing with SLEPc defaults" << std::endl;
592  }
593 }
OStreamProxy err(std::cerr)
std::string enum_to_string(const T e)
PetscErrorCode ierr
EigenSolverType _eigen_solver_type
Definition: eigen_solver.h:248
template<typename T >
void libMesh::EigenSolver< T >::set_solver_configuration ( SolverConfiguration solver_configuration)
inherited

Set the solver configuration object.

Definition at line 58 of file eigen_solver.C.

Referenced by libMesh::EigenSolver< T >::set_position_of_spectrum().

59 {
60  _solver_configuration = &solver_configuration;
61 }
SolverConfiguration * _solver_configuration
Definition: eigen_solver.h:269
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 
)
virtual

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 268 of file slepc_eigen_solver.C.

References libMesh::PetscMatrix< T >::close(), libMesh::TriangleWrapper::init(), and libMesh::PetscMatrix< T >::mat().

274 {
275  this->init ();
276 
277  // Make sure the data passed in are really of Petsc types
278  PetscMatrix<T> * matrix_A = dynamic_cast<PetscMatrix<T> *>(&matrix_A_in);
279  PetscMatrix<T> * matrix_B = dynamic_cast<PetscMatrix<T> *>(&matrix_B_in);
280 
281  if (!matrix_A || !matrix_B)
282  libmesh_error_msg("Error: inputs to solve_generalized() must be of type PetscMatrix.");
283 
284  // Close the matrix and vectors in case this wasn't already done.
285  matrix_A->close ();
286  matrix_B->close ();
287 
288  return _solve_generalized_helper (matrix_A->mat(), matrix_B->mat(), nev, ncv, tol, m_its);
289 }
std::pair< unsigned int, unsigned int > _solve_generalized_helper(Mat mat_A, Mat mat_B, int nev, int ncv, const double tol, const unsigned int m_its)
virtual void init() libmesh_override
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 
)
virtual

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

Implements libMesh::EigenSolver< T >.

Definition at line 293 of file slepc_eigen_solver.C.

References libMesh::PetscMatrix< T >::close(), ierr, libMesh::TriangleWrapper::init(), libMesh::ShellMatrix< T >::m(), libMesh::PetscMatrix< T >::mat(), and libMesh::ShellMatrix< T >::n().

299 {
300  this->init ();
301 
302  PetscErrorCode ierr=0;
303 
304  // Prepare the matrix. Note that the const_cast is only necessary
305  // because PETSc does not accept a const void *. Inside the member
306  // function _petsc_shell_matrix() below, the pointer is casted back
307  // to a const ShellMatrix<T> *.
308  Mat mat_A;
309  ierr = MatCreateShell(this->comm().get(),
310  shell_matrix_A.m(), // Specify the number of local rows
311  shell_matrix_A.n(), // Specify the number of local columns
312  PETSC_DETERMINE,
313  PETSC_DETERMINE,
314  const_cast<void *>(static_cast<const void *>(&shell_matrix_A)),
315  &mat_A);
316  LIBMESH_CHKERR(ierr);
317 
318  PetscMatrix<T> * matrix_B = dynamic_cast<PetscMatrix<T> *>(&matrix_B_in);
319 
320  if (!matrix_B)
321  libmesh_error_msg("Error: inputs to solve_generalized() must be of type PetscMatrix.");
322 
323  // Close the matrix and vectors in case this wasn't already done.
324  matrix_B->close ();
325 
326  ierr = MatShellSetOperation(mat_A,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
327  LIBMESH_CHKERR(ierr);
328  ierr = MatShellSetOperation(mat_A,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
329  LIBMESH_CHKERR(ierr);
330 
331  return _solve_generalized_helper (mat_A, matrix_B->mat(), nev, ncv, tol, m_its);
332 }
std::pair< unsigned int, unsigned int > _solve_generalized_helper(Mat mat_A, Mat mat_B, int nev, int ncv, const double tol, const unsigned int m_its)
static PetscErrorCode _petsc_shell_matrix_get_diagonal(Mat mat, Vec dest)
PetscErrorCode ierr
const Parallel::Communicator & comm() const
static PetscErrorCode _petsc_shell_matrix_mult(Mat mat, Vec arg, Vec dest)
virtual void init() libmesh_override
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 
)
virtual

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 336 of file slepc_eigen_solver.C.

References libMesh::PetscMatrix< T >::close(), ierr, libMesh::TriangleWrapper::init(), libMesh::ShellMatrix< T >::m(), libMesh::PetscMatrix< T >::mat(), and libMesh::ShellMatrix< T >::n().

342 {
343  this->init ();
344 
345  PetscErrorCode ierr=0;
346 
347  PetscMatrix<T> * matrix_A = dynamic_cast<PetscMatrix<T> *>(&matrix_A_in);
348 
349  if (!matrix_A)
350  libmesh_error_msg("Error: inputs to solve_generalized() must be of type PetscMatrix.");
351 
352  // Close the matrix and vectors in case this wasn't already done.
353  matrix_A->close ();
354 
355  // Prepare the matrix. Note that the const_cast is only necessary
356  // because PETSc does not accept a const void *. Inside the member
357  // function _petsc_shell_matrix() below, the pointer is casted back
358  // to a const ShellMatrix<T> *.
359  Mat mat_B;
360  ierr = MatCreateShell(this->comm().get(),
361  shell_matrix_B.m(), // Specify the number of local rows
362  shell_matrix_B.n(), // Specify the number of local columns
363  PETSC_DETERMINE,
364  PETSC_DETERMINE,
365  const_cast<void *>(static_cast<const void *>(&shell_matrix_B)),
366  &mat_B);
367  LIBMESH_CHKERR(ierr);
368 
369 
370  ierr = MatShellSetOperation(mat_B,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
371  LIBMESH_CHKERR(ierr);
372  ierr = MatShellSetOperation(mat_B,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
373  LIBMESH_CHKERR(ierr);
374 
375  return _solve_generalized_helper (matrix_A->mat(), mat_B, nev, ncv, tol, m_its);
376 }
std::pair< unsigned int, unsigned int > _solve_generalized_helper(Mat mat_A, Mat mat_B, int nev, int ncv, const double tol, const unsigned int m_its)
static PetscErrorCode _petsc_shell_matrix_get_diagonal(Mat mat, Vec dest)
PetscErrorCode ierr
const Parallel::Communicator & comm() const
static PetscErrorCode _petsc_shell_matrix_mult(Mat mat, Vec arg, Vec dest)
virtual void init() libmesh_override
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 
)
virtual

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 380 of file slepc_eigen_solver.C.

References ierr, libMesh::TriangleWrapper::init(), libMesh::ShellMatrix< T >::m(), and libMesh::ShellMatrix< T >::n().

386 {
387  this->init ();
388 
389  PetscErrorCode ierr=0;
390 
391  // Prepare the matrices. Note that the const_casts are only
392  // necessary because PETSc does not accept a const void *. Inside
393  // the member function _petsc_shell_matrix() below, the pointer is
394  // casted back to a const ShellMatrix<T> *.
395  Mat mat_A;
396  ierr = MatCreateShell(this->comm().get(),
397  shell_matrix_A.m(), // Specify the number of local rows
398  shell_matrix_A.n(), // Specify the number of local columns
399  PETSC_DETERMINE,
400  PETSC_DETERMINE,
401  const_cast<void *>(static_cast<const void *>(&shell_matrix_A)),
402  &mat_A);
403  LIBMESH_CHKERR(ierr);
404 
405  Mat mat_B;
406  ierr = MatCreateShell(this->comm().get(),
407  shell_matrix_B.m(), // Specify the number of local rows
408  shell_matrix_B.n(), // Specify the number of local columns
409  PETSC_DETERMINE,
410  PETSC_DETERMINE,
411  const_cast<void *>(static_cast<const void *>(&shell_matrix_B)),
412  &mat_B);
413  LIBMESH_CHKERR(ierr);
414 
415  ierr = MatShellSetOperation(mat_A,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
416  LIBMESH_CHKERR(ierr);
417  ierr = MatShellSetOperation(mat_A,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
418  LIBMESH_CHKERR(ierr);
419 
420  ierr = MatShellSetOperation(mat_B,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
421  LIBMESH_CHKERR(ierr);
422  ierr = MatShellSetOperation(mat_B,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
423  LIBMESH_CHKERR(ierr);
424 
425  return _solve_generalized_helper (mat_A, mat_B, nev, ncv, tol, m_its);
426 }
std::pair< unsigned int, unsigned int > _solve_generalized_helper(Mat mat_A, Mat mat_B, int nev, int ncv, const double tol, const unsigned int m_its)
static PetscErrorCode _petsc_shell_matrix_get_diagonal(Mat mat, Vec dest)
PetscErrorCode ierr
const Parallel::Communicator & comm() const
static PetscErrorCode _petsc_shell_matrix_mult(Mat mat, Vec arg, Vec dest)
virtual void init() libmesh_override
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 
)
virtual

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 82 of file slepc_eigen_solver.C.

References libMesh::PetscMatrix< T >::close(), libMesh::TriangleWrapper::init(), and libMesh::PetscMatrix< T >::mat().

87 {
88  LOG_SCOPE("solve_standard()", "SlepcEigenSolver");
89 
90  this->init ();
91 
92  // Make sure the SparseMatrix passed in is really a PetscMatrix
93  PetscMatrix<T> * matrix_A = dynamic_cast<PetscMatrix<T> *>(&matrix_A_in);
94 
95  if (!matrix_A)
96  libmesh_error_msg("Error: input matrix to solve_standard() must be a PetscMatrix.");
97 
98  // Close the matrix and vectors in case this wasn't already done.
99  matrix_A->close ();
100 
101  return _solve_standard_helper(matrix_A->mat(), nev, ncv, tol, m_its);
102 }
std::pair< unsigned int, unsigned int > _solve_standard_helper(Mat mat, int nev, int ncv, const double tol, const unsigned int m_its)
virtual void init() libmesh_override
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 
)
virtual

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

Implements libMesh::EigenSolver< T >.

Definition at line 107 of file slepc_eigen_solver.C.

References ierr, libMesh::TriangleWrapper::init(), libMesh::ShellMatrix< T >::m(), and libMesh::ShellMatrix< T >::n().

112 {
113  this->init ();
114 
115  PetscErrorCode ierr=0;
116 
117  // Prepare the matrix. Note that the const_cast is only necessary
118  // because PETSc does not accept a const void *. Inside the member
119  // function _petsc_shell_matrix() below, the pointer is casted back
120  // to a const ShellMatrix<T> *.
121  Mat mat;
122  ierr = MatCreateShell(this->comm().get(),
123  shell_matrix.m(), // Specify the number of local rows
124  shell_matrix.n(), // Specify the number of local columns
125  PETSC_DETERMINE,
126  PETSC_DETERMINE,
127  const_cast<void *>(static_cast<const void *>(&shell_matrix)),
128  &mat);
129  LIBMESH_CHKERR(ierr);
130 
131  ierr = MatShellSetOperation(mat,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
132  LIBMESH_CHKERR(ierr);
133  ierr = MatShellSetOperation(mat,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
134  LIBMESH_CHKERR(ierr);
135 
136  return _solve_standard_helper(mat, nev, ncv, tol, m_its);
137 }
static PetscErrorCode _petsc_shell_matrix_get_diagonal(Mat mat, Vec dest)
PetscErrorCode ierr
const Parallel::Communicator & comm() const
static PetscErrorCode _petsc_shell_matrix_mult(Mat mat, Vec arg, Vec dest)
std::pair< unsigned int, unsigned int > _solve_standard_helper(Mat mat, int nev, int ncv, const double tol, const unsigned int m_its)
virtual void init() libmesh_override

Member Data Documentation

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
template<typename T >
EigenProblemType libMesh::EigenSolver< T >::_eigen_problem_type
protectedinherited

Enum stating which type of eigen problem we deal with.

Definition at line 253 of file eigen_solver.h.

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

template<typename T >
EigenSolverType libMesh::EigenSolver< T >::_eigen_solver_type
protectedinherited
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 143 of file reference_counter.h.

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

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

Eigenproblem solver context

Definition at line 271 of file slepc_eigen_solver.h.

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

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

Flag indicating if the data structures have been initialized.

Definition at line 263 of file eigen_solver.h.

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

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

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

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 132 of file reference_counter.h.

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

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

Enum stating where to evaluate the spectrum.

Definition at line 258 of file eigen_solver.h.

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

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 269 of file eigen_solver.h.

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

Definition at line 271 of file eigen_solver.h.


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