libMesh::SlepcEigenSolver< T > Class Template Reference

#include <slepc_eigen_solver.h>

Inheritance diagram for libMesh::SlepcEigenSolver< T >:

Public Member Functions

 SlepcEigenSolver (const Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD)
 
 ~SlepcEigenSolver ()
 
void clear ()
 
void init ()
 
std::pair< unsigned int,
unsigned int > 
solve_standard (SparseMatrix< T > &matrix_A, int nev, int ncv, const double tol, const unsigned int m_its)
 
std::pair< unsigned int,
unsigned int > 
solve_standard (ShellMatrix< T > &shell_matrix, int nev, int ncv, const double tol, const unsigned int m_its)
 
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)
 
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)
 
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)
 
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)
 
std::pair< Real, Realget_eigenpair (unsigned int i, NumericVector< T > &solution_in)
 
std::pair< Real, Realget_eigenvalue (unsigned int i)
 
Real get_relative_error (unsigned int i)
 
void attach_deflation_space (NumericVector< T > &deflation_vector)
 
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)
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static AutoPtr< EigenSolver< T > > build (const Parallel::Communicator &comm 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
 
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 >

This class provides an interface to the SLEPc eigenvalue solver library www.grycap.upv.es/slepc/.

Definition at line 51 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 113 of file reference_counter.h.

Constructor & Destructor Documentation

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

Constructor. Initializes Petsc data structures

Definition at line 263 of file slepc_eigen_solver.h.

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

263  :
264  EigenSolver<T>(comm)
265 {
266  this->_eigen_solver_type = ARNOLDI;
267  this->_eigen_problem_type = NHEP;
268 }
template<typename T >
libMesh::SlepcEigenSolver< T >::~SlepcEigenSolver ( )
inline

Destructor.

Definition at line 274 of file slepc_eigen_solver.h.

275 {
276  this->clear ();
277 }

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

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

775 {
776  /* Get the matrix context. */
778  void* ctx;
779  ierr = MatShellGetContext(mat,&ctx);
780 
782  PetscObjectGetComm((PetscObject)mat,&comm);
783  CHKERRABORT(comm,ierr);
784 
785  /* Get user shell matrix object. */
786  const ShellMatrix<T>& shell_matrix = *static_cast<const ShellMatrix<T>*>(ctx);
787 
788  /* Make \p NumericVector instances around the vector. */
789  PetscVector<T> dest_global(dest, shell_matrix.comm());
790 
791  /* Call the user function. */
792  shell_matrix.get_diagonal(dest_global);
793 
794  return ierr;
795 }
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 749 of file slepc_eigen_solver.C.

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

750 {
751  /* Get the matrix context. */
753  void* ctx;
754  ierr = MatShellGetContext(mat,&ctx);
755 
757  PetscObjectGetComm((PetscObject)mat,&comm);
758  CHKERRABORT(comm,ierr);
759 
760  /* Get user shell matrix object. */
761  const ShellMatrix<T>& shell_matrix = *static_cast<const ShellMatrix<T>*>(ctx);
762 
763  /* Make \p NumericVector instances around the vectors. */
764  PetscVector<T> arg_global(arg, shell_matrix.comm());
765  PetscVector<T> dest_global(dest, shell_matrix.comm());
766 
767  /* Call the user function. */
768  shell_matrix.vector_mult(dest_global,arg_global);
769 
770  return ierr;
771 }
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 444 of file slepc_eigen_solver.C.

References libMesh::comm, libMesh::ierr, libMesh::START_LOG(), and libMesh::STOP_LOG().

450 {
451  START_LOG("solve_generalized()", "SlepcEigenSolver");
452 
454 
455  // converged eigen pairs and number of iterations
456  PetscInt nconv=0;
457  PetscInt its=0;
458 
459 #ifdef DEBUG
460  // The relative error.
461  PetscReal error, re, im;
462 
463  // Pointer to vectors of the real parts, imaginary parts.
464  PetscScalar kr, ki;
465 #endif
466 
467  // Set operators.
468  ierr = EPSSetOperators (_eps, mat_A, mat_B);
469  LIBMESH_CHKERRABORT(ierr);
470 
471  //set the problem type and the position of the spectrum
474 
475  // Set eigenvalues to be computed.
476 #if SLEPC_VERSION_LESS_THAN(3,0,0)
477  ierr = EPSSetDimensions (_eps, nev, ncv);
478 #else
479  ierr = EPSSetDimensions (_eps, nev, ncv, PETSC_DECIDE);
480 #endif
481  LIBMESH_CHKERRABORT(ierr);
482 
483 
484  // Set the tolerance and maximum iterations.
485  ierr = EPSSetTolerances (_eps, tol, m_its);
486  LIBMESH_CHKERRABORT(ierr);
487 
488  // Set runtime options, e.g.,
489  // -eps_type <type>, -eps_nev <nev>, -eps_ncv <ncv>
490  // Similar to PETSc, these options will override those specified
491  // above as long as EPSSetFromOptions() is called _after_ any
492  // other customization routines.
493  ierr = EPSSetFromOptions (_eps);
494  LIBMESH_CHKERRABORT(ierr);
495 
496  // Solve the eigenproblem.
497  ierr = EPSSolve (_eps);
498  LIBMESH_CHKERRABORT(ierr);
499 
500  // Get the number of iterations.
501  ierr = EPSGetIterationNumber (_eps, &its);
502  LIBMESH_CHKERRABORT(ierr);
503 
504  // Get number of converged eigenpairs.
505  ierr = EPSGetConverged(_eps,&nconv);
506  LIBMESH_CHKERRABORT(ierr);
507 
508 
509 #ifdef DEBUG
510  // ierr = PetscPrintf(this->comm().get(),
511  // "\n Number of iterations: %d\n"
512  // " Number of converged eigenpairs: %d\n\n", its, nconv);
513 
514  // Display eigenvalues and relative errors.
515  ierr = PetscPrintf(this->comm().get(),
516  " k ||Ax-kx||/|kx|\n"
517  " ----------------- -----------------\n" );
518  LIBMESH_CHKERRABORT(ierr);
519 
520  for(PetscInt i=0; i<nconv; i++ )
521  {
522  ierr = EPSGetEigenpair(_eps, i, &kr, &ki, PETSC_NULL, PETSC_NULL);
523  LIBMESH_CHKERRABORT(ierr);
524 
525  ierr = EPSComputeRelativeError(_eps, i, &error);
526  LIBMESH_CHKERRABORT(ierr);
527 
528 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
529  re = PetscRealPart(kr);
530  im = PetscImaginaryPart(kr);
531 #else
532  re = kr;
533  im = ki;
534 #endif
535 
536  if (im != .0)
537  {
538  ierr = PetscPrintf(this->comm().get()," %9f%+9f i %12f\n", re, im, error);
539  LIBMESH_CHKERRABORT(ierr);
540  }
541  else
542  {
543  ierr = PetscPrintf(this->comm().get()," %12f %12f\n", re, error);
544  LIBMESH_CHKERRABORT(ierr);
545  }
546  }
547 
548  ierr = PetscPrintf(this->comm().get(),"\n" );
549  LIBMESH_CHKERRABORT(ierr);
550 #endif // DEBUG
551 
552  STOP_LOG("solve_generalized()", "SlepcEigenSolver");
553 
554  // return the number of converged eigenpairs
555  // and the number of iterations
556  return std::make_pair(nconv, its);
557 
558 }
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 166 of file slepc_eigen_solver.C.

References libMesh::comm, libMesh::ierr, libMesh::START_LOG(), and libMesh::STOP_LOG().

171 {
172  START_LOG("solve_standard()", "SlepcEigenSolver");
173 
175 
176  // converged eigen pairs and number of iterations
177  PetscInt nconv=0;
178  PetscInt its=0;
179 
180 #ifdef DEBUG
181  // The relative error.
182  PetscReal error, re, im;
183 
184  // Pointer to vectors of the real parts, imaginary parts.
185  PetscScalar kr, ki;
186 #endif
187 
188  // Set operators.
189  ierr = EPSSetOperators (_eps, mat, PETSC_NULL);
190  LIBMESH_CHKERRABORT(ierr);
191 
192  //set the problem type and the position of the spectrum
195 
196  // Set eigenvalues to be computed.
197 #if SLEPC_VERSION_LESS_THAN(3,0,0)
198  ierr = EPSSetDimensions (_eps, nev, ncv);
199 #else
200  ierr = EPSSetDimensions (_eps, nev, ncv, PETSC_DECIDE);
201 #endif
202  LIBMESH_CHKERRABORT(ierr);
203  // Set the tolerance and maximum iterations.
204  ierr = EPSSetTolerances (_eps, tol, m_its);
205  LIBMESH_CHKERRABORT(ierr);
206 
207  // Set runtime options, e.g.,
208  // -eps_type <type>, -eps_nev <nev>, -eps_ncv <ncv>
209  // Similar to PETSc, these options will override those specified
210  // above as long as EPSSetFromOptions() is called _after_ any
211  // other customization routines.
212  ierr = EPSSetFromOptions (_eps);
213  LIBMESH_CHKERRABORT(ierr);
214 
215  // Solve the eigenproblem.
216  ierr = EPSSolve (_eps);
217  LIBMESH_CHKERRABORT(ierr);
218 
219  // Get the number of iterations.
220  ierr = EPSGetIterationNumber (_eps, &its);
221  LIBMESH_CHKERRABORT(ierr);
222 
223  // Get number of converged eigenpairs.
224  ierr = EPSGetConverged(_eps,&nconv);
225  LIBMESH_CHKERRABORT(ierr);
226 
227 
228 #ifdef DEBUG
229  // ierr = PetscPrintf(this->comm().get(),
230  // "\n Number of iterations: %d\n"
231  // " Number of converged eigenpairs: %d\n\n", its, nconv);
232 
233  // Display eigenvalues and relative errors.
234  ierr = PetscPrintf(this->comm().get(),
235  " k ||Ax-kx||/|kx|\n"
236  " ----------------- -----------------\n" );
237  LIBMESH_CHKERRABORT(ierr);
238 
239  for(PetscInt i=0; i<nconv; i++ )
240  {
241  ierr = EPSGetEigenpair(_eps, i, &kr, &ki, PETSC_NULL, PETSC_NULL);
242  LIBMESH_CHKERRABORT(ierr);
243 
244  ierr = EPSComputeRelativeError(_eps, i, &error);
245  LIBMESH_CHKERRABORT(ierr);
246 
247 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
248  re = PetscRealPart(kr);
249  im = PetscImaginaryPart(kr);
250 #else
251  re = kr;
252  im = ki;
253 #endif
254 
255  if (im != .0)
256  {
257  ierr = PetscPrintf(this->comm().get()," %9f%+9f i %12f\n", re, im, error);
258  LIBMESH_CHKERRABORT(ierr);
259  }
260  else
261  {
262  ierr = PetscPrintf(this->comm().get()," %12f %12f\n", re, error);
263  LIBMESH_CHKERRABORT(ierr);
264  }
265  }
266 
267  ierr = PetscPrintf(this->comm().get(),"\n" );
268  LIBMESH_CHKERRABORT(ierr);
269 #endif // DEBUG
270 
271 
272  STOP_LOG("solve_standard()", "SlepcEigenSolver");
273 
274  // return the number of converged eigenpairs
275  // and the number of iterations
276  return std::make_pair(nconv, its);
277 
278 }
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 733 of file slepc_eigen_solver.C.

References libMesh::ierr, and libMesh::TriangleWrapper::init().

734 {
735  this->init();
736 
737  PetscErrorCode ierr = 0;
738  Vec deflation_vector = (libmesh_cast_ptr<PetscVector<T>*>(&deflation_vector_in))->vec();
739  Vec* deflation_space = &deflation_vector;
740 #if SLEPC_VERSION_LESS_THAN(3,1,0)
741  ierr = EPSAttachDeflationSpace(_eps, 1, deflation_space, PETSC_FALSE);
742 #else
743  ierr = EPSSetDeflationSpace(_eps, 1, deflation_space);
744 #endif
745  LIBMESH_CHKERRABORT(ierr);
746 }
template<typename T>
AutoPtr< EigenSolver< T > > libMesh::EigenSolver< T >::build ( const Parallel::Communicator &comm  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::err, and libMeshEnums::SLEPC_SOLVERS.

39 {
40  // Build the appropriate solver
41  switch (solver_package)
42  {
43 
44 
45 
46 #ifdef LIBMESH_HAVE_SLEPC
47  case SLEPC_SOLVERS:
48  {
49  AutoPtr<EigenSolver<T> > ap(new SlepcEigenSolver<T>(comm));
50  return ap;
51  }
52 #endif
53 
54 
55  default:
56  libMesh::err << "ERROR: Unrecognized eigen solver package: "
57  << solver_package
58  << std::endl;
59  libmesh_error();
60  }
61 
62  AutoPtr<EigenSolver<T> > ap(NULL);
63  return ap;
64 }
template<typename T >
void libMesh::SlepcEigenSolver< T >::clear ( )
virtual

Release all memory and clear data structures.

Reimplemented from libMesh::EigenSolver< T >.

Definition at line 52 of file slepc_eigen_solver.C.

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

53 {
54  if (this->initialized())
55  {
56  this->_is_initialized = false;
57 
59 
60  ierr = LibMeshEPSDestroy(&_eps);
61  LIBMESH_CHKERRABORT(ierr);
62 
63  // SLEPc default eigenproblem solver
64 #if SLEPC_VERSION_LESS_THAN(2,3,2)
66 #else
67  // Krylov-Schur showed up as of Slepc 2.3.2
69 #endif
70  }
71 }
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
a reference to the Parallel::Communicator object used by this mesh.

Definition at line 86 of file parallel_object.h.

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_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_residual(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::MetisPartitioner::_do_partition(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::ParallelMesh::add_elem(), libMesh::ImplicitSystem::add_matrix(), libMesh::ParallelMesh::add_node(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::bounding_box(), libMesh::System::calculate_norm(), libMesh::MeshRefinement::coarsen_elements(), 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::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMLibMeshSetSystem(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::for(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::ParallelMesh::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::ParallelMesh::parallel_max_elem_id(), libMesh::ParallelMesh::parallel_max_node_id(), libMesh::ParallelMesh::parallel_n_elem(), libMesh::ParallelMesh::parallel_n_nodes(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), 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::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::LegacyXdrIO::write_mesh(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), and libMesh::DivaIO::write_stream().

87  { return _communicator; }
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

107 {
108  _enable_print_counter = false;
109  return;
110 }
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.

103 { return _eigen_problem_type;}
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.

98 { return _eigen_solver_type; }
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.

References libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = true;
103  return;
104 }
template<typename T >
std::pair< Real, Real > libMesh::SlepcEigenSolver< T >::get_eigenpair ( unsigned int  i,
NumericVector< T > &  solution_in 
)
virtual

This function returns the real and imaginary part of the ith eigenvalue and copies the respective eigenvector to the solution vector. Note that also in case of purely real matrix entries the eigenpair may be complex values.

Implements libMesh::EigenSolver< T >.

Definition at line 664 of file slepc_eigen_solver.C.

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

666 {
668 
669  PetscReal re, im;
670 
671  // Make sure the NumericVector passed in is really a PetscVector
672  PetscVector<T>* solution = libmesh_cast_ptr<PetscVector<T>*>(&solution_in);
673 
674  // real and imaginary part of the ith eigenvalue.
675  PetscScalar kr, ki;
676 
677  solution->close();
678 
679  ierr = EPSGetEigenpair(_eps, i, &kr, &ki, solution->vec(), PETSC_NULL);
680  LIBMESH_CHKERRABORT(ierr);
681 
682 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
683  re = PetscRealPart(kr);
684  im = PetscImaginaryPart(kr);
685 #else
686  re = kr;
687  im = ki;
688 #endif
689 
690  return std::make_pair(re, im);
691 }
template<typename T >
std::pair< Real, Real > libMesh::SlepcEigenSolver< T >::get_eigenvalue ( unsigned int  i)
virtual

Same as above, but does not copy the eigenvector.

Implements libMesh::EigenSolver< T >.

Definition at line 695 of file slepc_eigen_solver.C.

References libMesh::ierr.

696 {
698 
699  PetscReal re, im;
700 
701  // real and imaginary part of the ith eigenvalue.
702  PetscScalar kr, ki;
703 
704  ierr = EPSGetEigenvalue(_eps, i, &kr, &ki);
705  LIBMESH_CHKERRABORT(ierr);
706 
707 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
708  re = PetscRealPart(kr);
709  im = PetscImaginaryPart(kr);
710 #else
711  re = kr;
712  im = ki;
713 #endif
714 
715  return std::make_pair(re, im);
716 }
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 }
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 720 of file slepc_eigen_solver.C.

References libMesh::ierr.

721 {
723  PetscReal error;
724 
725  ierr = EPSComputeRelativeError(_eps, i, &error);
726  LIBMESH_CHKERRABORT(ierr);
727 
728  return error;
729 }
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 163 of file reference_counter.h.

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

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

164 {
165  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
166  std::pair<unsigned int, unsigned int>& p = _counts[name];
167 
168  p.first++;
169 }
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 176 of file reference_counter.h.

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

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

177 {
178  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
179  std::pair<unsigned int, unsigned int>& p = _counts[name];
180 
181  p.second++;
182 }
template<typename T >
void libMesh::SlepcEigenSolver< T >::init ( )
virtual

Initialize data structures if not done so already.

Implements libMesh::EigenSolver< T >.

Definition at line 76 of file slepc_eigen_solver.C.

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

77 {
78 
80 
81  // Initialize the data structures if not done so already.
82  if (!this->initialized())
83  {
84  this->_is_initialized = true;
85 
86  // Create the eigenproblem solver context
87  ierr = EPSCreate (this->comm().get(), &_eps);
88  LIBMESH_CHKERRABORT(ierr);
89 
90  // Set user-specified solver
92  }
93 }
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.

82 { return _is_initialized; }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

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

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

80  { return _n_objects; }
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
the number of processors in the group.

Definition at line 92 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::ParallelMesh::add_elem(), libMesh::ParallelMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::ParallelMesh::assign_unique_ids(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::ParallelMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), 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::MeshTools::processor_bounding_box(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::UnstructuredMesh::read(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::Partitioner::repartition(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::BoundaryInfo::sync(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::CheckpointIO::write(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

93  { return libmesh_cast_int<processor_id_type>(_communicator.size()); }
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.

109  { return _position_of_spectrum;}
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().

89 {
91 }
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
the rank of this processor in the group.

Definition at line 98 of file parallel_object.h.

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

Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::EquationSystems::_read_impl(), libMesh::SerialMesh::active_local_elements_begin(), libMesh::ParallelMesh::active_local_elements_begin(), libMesh::SerialMesh::active_local_elements_end(), libMesh::ParallelMesh::active_local_elements_end(), libMesh::SerialMesh::active_local_subdomain_elements_begin(), libMesh::ParallelMesh::active_local_subdomain_elements_begin(), libMesh::SerialMesh::active_local_subdomain_elements_end(), libMesh::ParallelMesh::active_local_subdomain_elements_end(), libMesh::SerialMesh::active_not_local_elements_begin(), libMesh::ParallelMesh::active_not_local_elements_begin(), libMesh::SerialMesh::active_not_local_elements_end(), libMesh::ParallelMesh::active_not_local_elements_end(), libMesh::ParallelMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::ParallelMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::ParmetisPartitioner::assign_partitioning(), 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::DofMap::build_sparsity(), libMesh::ParallelMesh::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::ExodusII_IO_Helper::create(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), 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::MeshBase::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::Nemesis_IO_Helper::get_ss_param_global(), libMesh::MeshFunction::gradient(), libMesh::MeshFunction::hessian(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::SerialMesh::local_elements_begin(), libMesh::ParallelMesh::local_elements_begin(), libMesh::SerialMesh::local_elements_end(), libMesh::ParallelMesh::local_elements_end(), libMesh::SerialMesh::local_level_elements_begin(), libMesh::ParallelMesh::local_level_elements_begin(), libMesh::SerialMesh::local_level_elements_end(), libMesh::ParallelMesh::local_level_elements_end(), libMesh::SerialMesh::local_nodes_begin(), libMesh::ParallelMesh::local_nodes_begin(), libMesh::SerialMesh::local_nodes_end(), libMesh::ParallelMesh::local_nodes_end(), libMesh::SerialMesh::local_not_level_elements_begin(), libMesh::ParallelMesh::local_not_level_elements_begin(), libMesh::SerialMesh::local_not_level_elements_end(), libMesh::ParallelMesh::local_not_level_elements_end(), libMesh::MeshRefinement::make_coarsening_compatible(), 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::SerialMesh::not_local_elements_begin(), libMesh::ParallelMesh::not_local_elements_begin(), libMesh::SerialMesh::not_local_elements_end(), libMesh::ParallelMesh::not_local_elements_end(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshFunction::operator()(), libMesh::ParallelMesh::ParallelMesh(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::System::project_vector(), 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::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::UnstructuredMesh::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), 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::MeshData::read_xdr(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::BoundaryInfo::sync(), libMesh::MeshTools::total_weight(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::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_Helper::write_elements_discontinuous(), 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::ExodusII_IO_Helper::write_nodal_coordinates_discontinuous(), 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::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs(), 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_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

99  { return libmesh_cast_int<processor_id_type>(_communicator.rank()); }
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.

121  {_eigen_problem_type = ept;}
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.

115  { _eigen_solver_type = est; }
template<typename T>
void libMesh::EigenSolver< T >::set_position_of_spectrum ( PositionOfSpectrum  pos)
inlineinherited

Sets the position of the spectrum.

Definition at line 126 of file eigen_solver.h.

127  {_position_of_spectrum= pos;}
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 631 of file slepc_eigen_solver.C.

References libMesh::err, libMesh::ierr, libMeshEnums::LARGEST_IMAGINARY, libMeshEnums::LARGEST_MAGNITUDE, libMeshEnums::LARGEST_REAL, libMeshEnums::SMALLEST_IMAGINARY, libMeshEnums::SMALLEST_MAGNITUDE, and libMeshEnums::SMALLEST_REAL.

632 {
633  PetscErrorCode ierr = 0;
634 
635  switch (this->_position_of_spectrum)
636  {
637  case LARGEST_MAGNITUDE:
638  ierr = EPSSetWhichEigenpairs (_eps, EPS_LARGEST_MAGNITUDE); LIBMESH_CHKERRABORT(ierr); return;
639  case SMALLEST_MAGNITUDE:
640  ierr = EPSSetWhichEigenpairs (_eps, EPS_SMALLEST_MAGNITUDE); LIBMESH_CHKERRABORT(ierr); return;
641  case LARGEST_REAL:
642  ierr = EPSSetWhichEigenpairs (_eps, EPS_LARGEST_REAL); LIBMESH_CHKERRABORT(ierr); return;
643  case SMALLEST_REAL:
644  ierr = EPSSetWhichEigenpairs (_eps, EPS_SMALLEST_REAL); LIBMESH_CHKERRABORT(ierr); return;
645  case LARGEST_IMAGINARY:
646  ierr = EPSSetWhichEigenpairs (_eps, EPS_LARGEST_IMAGINARY); LIBMESH_CHKERRABORT(ierr); return;
647  case SMALLEST_IMAGINARY:
648  ierr = EPSSetWhichEigenpairs (_eps, EPS_SMALLEST_IMAGINARY); LIBMESH_CHKERRABORT(ierr); return;
649 
650 
651  default:
652  libMesh::err << "ERROR: Unsupported SLEPc position of spectrum: "
653  << this->_position_of_spectrum << std::endl;
654  libmesh_error();
655  }
656 }
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 606 of file slepc_eigen_solver.C.

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

607 {
608  PetscErrorCode ierr = 0;
609 
610  switch (this->_eigen_problem_type)
611  {
612  case NHEP:
613  ierr = EPSSetProblemType (_eps, EPS_NHEP); LIBMESH_CHKERRABORT(ierr); return;
614  case GNHEP:
615  ierr = EPSSetProblemType (_eps, EPS_GNHEP); LIBMESH_CHKERRABORT(ierr); return;
616  case HEP:
617  ierr = EPSSetProblemType (_eps, EPS_HEP); LIBMESH_CHKERRABORT(ierr); return;
618  case GHEP:
619  ierr = EPSSetProblemType (_eps, EPS_GHEP); LIBMESH_CHKERRABORT(ierr); return;
620 
621  default:
622  libMesh::err << "ERROR: Unsupported SLEPc Eigen Problem: "
623  << this->_eigen_problem_type << std::endl
624  << "Continuing with SLEPc defaults" << std::endl;
625  }
626 }
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 571 of file slepc_eigen_solver.C.

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

572 {
573  PetscErrorCode ierr = 0;
574 
575  switch (this->_eigen_solver_type)
576  {
577  case POWER:
578  ierr = EPSSetType (_eps, (char*) EPSPOWER); LIBMESH_CHKERRABORT(ierr); return;
579  case SUBSPACE:
580  ierr = EPSSetType (_eps, (char*) EPSSUBSPACE); LIBMESH_CHKERRABORT(ierr); return;
581  case LAPACK:
582  ierr = EPSSetType (_eps, (char*) EPSLAPACK); LIBMESH_CHKERRABORT(ierr); return;
583  case ARNOLDI:
584  ierr = EPSSetType (_eps, (char*) EPSARNOLDI); LIBMESH_CHKERRABORT(ierr); return;
585  case LANCZOS:
586  ierr = EPSSetType (_eps, (char*) EPSLANCZOS); LIBMESH_CHKERRABORT(ierr); return;
587 #if !SLEPC_VERSION_LESS_THAN(2,3,2)
588  // EPSKRYLOVSCHUR added in 2.3.2
589  case KRYLOVSCHUR:
590  ierr = EPSSetType (_eps, (char*) EPSKRYLOVSCHUR); LIBMESH_CHKERRABORT(ierr); return;
591 #endif
592  // case ARPACK:
593  // ierr = EPSSetType (_eps, (char*) EPSARPACK); LIBMESH_CHKERRABORT(ierr); return;
594 
595  default:
596  libMesh::err << "ERROR: Unsupported SLEPc Eigen Solver: "
597  << Utility::enum_to_string(this->_eigen_solver_type) << std::endl
598  << "Continuing with SLEPc defaults" << std::endl;
599  }
600 }
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 286 of file slepc_eigen_solver.C.

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

292 {
293  this->init ();
294 
295  // Make sure the data passed in are really of Petsc types
296  PetscMatrix<T>* matrix_A = libmesh_cast_ptr<PetscMatrix<T>*>(&matrix_A_in);
297  PetscMatrix<T>* matrix_B = libmesh_cast_ptr<PetscMatrix<T>*>(&matrix_B_in);
298 
299  // Close the matrix and vectors in case this wasn't already done.
300  matrix_A->close ();
301  matrix_B->close ();
302 
303 
304  return _solve_generalized_helper (matrix_A->mat(), matrix_B->mat(), nev, ncv, tol, m_its);
305 }
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 309 of file slepc_eigen_solver.C.

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

315 {
316  this->init ();
317 
319 
320  // Prepare the matrix.
321  Mat mat_A;
322  ierr = MatCreateShell(this->comm().get(),
323  shell_matrix_A.m(), // Specify the number of local rows
324  shell_matrix_A.n(), // Specify the number of local columns
325  PETSC_DETERMINE,
326  PETSC_DETERMINE,
327  const_cast<void*>(static_cast<const void*>(&shell_matrix_A)),
328  &mat_A);
329 
330  PetscMatrix<T>* matrix_B = libmesh_cast_ptr<PetscMatrix<T>*>(&matrix_B_in);
331 
332  // Close the matrix and vectors in case this wasn't already done.
333  matrix_B->close ();
334 
335  /* Note that the const_cast above is only necessary because PETSc
336  does not accept a const void*. Inside the member function
337  _petsc_shell_matrix() below, the pointer is casted back to a
338  const ShellMatrix<T>*. */
339 
340  LIBMESH_CHKERRABORT(ierr);
341  ierr = MatShellSetOperation(mat_A,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
342  ierr = MatShellSetOperation(mat_A,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
343  LIBMESH_CHKERRABORT(ierr);
344 
345  return _solve_generalized_helper (mat_A, matrix_B->mat(), nev, ncv, tol, m_its);
346 }
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 350 of file slepc_eigen_solver.C.

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

356 {
357  this->init ();
358 
360 
361  PetscMatrix<T>* matrix_A = libmesh_cast_ptr<PetscMatrix<T>*>(&matrix_A_in);
362 
363  // Close the matrix and vectors in case this wasn't already done.
364  matrix_A->close ();
365 
366  // Prepare the matrix.
367  Mat mat_B;
368  ierr = MatCreateShell(this->comm().get(),
369  shell_matrix_B.m(), // Specify the number of local rows
370  shell_matrix_B.n(), // Specify the number of local columns
371  PETSC_DETERMINE,
372  PETSC_DETERMINE,
373  const_cast<void*>(static_cast<const void*>(&shell_matrix_B)),
374  &mat_B);
375 
376 
377  /* Note that the const_cast above is only necessary because PETSc
378  does not accept a const void*. Inside the member function
379  _petsc_shell_matrix() below, the pointer is casted back to a
380  const ShellMatrix<T>*. */
381 
382  LIBMESH_CHKERRABORT(ierr);
383  ierr = MatShellSetOperation(mat_B,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
384  ierr = MatShellSetOperation(mat_B,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
385  LIBMESH_CHKERRABORT(ierr);
386 
387  return _solve_generalized_helper (matrix_A->mat(), mat_B, nev, ncv, tol, m_its);
388 }
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 392 of file slepc_eigen_solver.C.

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

398 {
399  this->init ();
400 
402 
403  // Prepare the matrix.
404  Mat mat_A;
405  ierr = MatCreateShell(this->comm().get(),
406  shell_matrix_A.m(), // Specify the number of local rows
407  shell_matrix_A.n(), // Specify the number of local columns
408  PETSC_DETERMINE,
409  PETSC_DETERMINE,
410  const_cast<void*>(static_cast<const void*>(&shell_matrix_A)),
411  &mat_A);
412 
413  Mat mat_B;
414  ierr = MatCreateShell(this->comm().get(),
415  shell_matrix_B.m(), // Specify the number of local rows
416  shell_matrix_B.n(), // Specify the number of local columns
417  PETSC_DETERMINE,
418  PETSC_DETERMINE,
419  const_cast<void*>(static_cast<const void*>(&shell_matrix_B)),
420  &mat_B);
421 
422  /* Note that the const_cast above is only necessary because PETSc
423  does not accept a const void*. Inside the member function
424  _petsc_shell_matrix() below, the pointer is casted back to a
425  const ShellMatrix<T>*. */
426 
427  LIBMESH_CHKERRABORT(ierr);
428  ierr = MatShellSetOperation(mat_A,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
429  ierr = MatShellSetOperation(mat_A,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
430  LIBMESH_CHKERRABORT(ierr);
431 
432  LIBMESH_CHKERRABORT(ierr);
433  ierr = MatShellSetOperation(mat_B,MATOP_MULT,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_mult));
434  ierr = MatShellSetOperation(mat_B,MATOP_GET_DIAGONAL,reinterpret_cast<void(*)(void)>(_petsc_shell_matrix_get_diagonal));
435  LIBMESH_CHKERRABORT(ierr);
436 
437  return _solve_generalized_helper (mat_A, mat_B, nev, ncv, tol, m_its);
438 }
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 99 of file slepc_eigen_solver.C.

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

104 {
105 // START_LOG("solve_standard()", "SlepcEigenSolver");
106 
107  this->init ();
108 
109  // Make sure the SparseMatrix passed in is really a PetscMatrix
110  PetscMatrix<T>* matrix_A = libmesh_cast_ptr<PetscMatrix<T>*>(&matrix_A_in);
111 
112  // Close the matrix and vectors in case this wasn't already done.
113  matrix_A->close ();
114 
115  // just for debugging, remove this
116 // char mat_file[] = "matA.petsc";
117 // PetscViewer petsc_viewer;
118 // ierr = PetscViewerBinaryOpen(this->comm().get(), mat_file, PETSC_FILE_CREATE, &petsc_viewer);
119 // LIBMESH_CHKERRABORT(ierr);
120 // ierr = MatView(matrix_A->mat(),petsc_viewer);
121 // LIBMESH_CHKERRABORT(ierr);
122 
123  return _solve_standard_helper(matrix_A->mat(), nev, ncv, tol, m_its);
124 }
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 129 of file slepc_eigen_solver.C.

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

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

Member Data Documentation

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
template<typename T>
EigenProblemType libMesh::EigenSolver< T >::_eigen_problem_type
protectedinherited
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 137 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 255 of file slepc_eigen_solver.h.

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

Flag indicating if the data structures have been initialized.

Definition at line 237 of file eigen_solver.h.

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

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

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 131 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 126 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 232 of file eigen_solver.h.

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


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:02 UTC

Hosted By:
SourceForge.net Logo