19 #include "libmesh/libmesh_config.h" 23 #if defined(LIBMESH_HAVE_SLEPC) 26 #include "libmesh/eigen_system.h" 27 #include "libmesh/equation_systems.h" 28 #include "libmesh/sparse_matrix.h" 29 #include "libmesh/shell_matrix.h" 30 #include "libmesh/eigen_solver.h" 31 #include "libmesh/dof_map.h" 32 #include "libmesh/mesh_base.h" 33 #include "libmesh/enum_eigen_solver_type.h" 40 const std::string & name_in,
41 const unsigned int number_in
43 Parent (es, name_in, number_in),
46 precond_matrix (nullptr),
48 _n_converged_eigenpairs (0),
50 _eigen_problem_type (
NHEP),
51 _use_shell_matrices (false),
52 _use_shell_precond_matrix(false)
88 libmesh_error_msg(
"ERROR: Cannot change eigen problem type after system initialization");
166 if (condense_constraints)
174 if (condense_constraints)
182 if (condense_constraints)
230 parameters.
get<
unsigned int>(
"linear solver maximum iterations") :
231 es.
parameters.
get<
unsigned int>(
"linear solver maximum iterations");
241 std::pair<unsigned int, unsigned int> solve_data;
273 solve_data =
eigen_solver->solve_generalized(*A, *
B, nev, ncv, tol, maxits);
279 solve_data =
eigen_solver->solve_standard(*A, nev, ncv, tol, maxits);
290 libmesh_warning(
"EigenSystem does not have first-class support for constrained degrees of " 291 "freedom. You may see spurious effects of the constrained degrees of freedom " 292 "in a given eigenvector. If you wish to perform a reliable solve on a system " 293 "with constraints, please use the CondensedEigenSystem class instead");
498 #endif // LIBMESH_HAVE_SLEPC virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
virtual std::pair< Real, Real > get_eigenpair(dof_id_type i)
bool can_add_matrices() const
void solve_helper(SparseMatrix< Number > *const A, SparseMatrix< Number > *const B, SparseMatrix< Number > *const P)
const SparseMatrix< Number > & get_precond_matrix() const
This is the EquationSystems class.
virtual void clear()
Clear all the data structures associated with the system.
bool have_parameter(std::string_view) const
SparseMatrix< Number > * matrix_B
A second system matrix for generalized eigenvalue problems.
unsigned int _n_converged_eigenpairs
The number of converged eigenpairs.
virtual void init_matrices()
Initializes the matrices associated with this system.
const SparseMatrix< Number > & get_matrix_A() const
virtual bool condense_constrained_dofs() const
Whether this object should condense out constrained degrees of freedom.
virtual void reinit()
Reinitializes degrees of freedom and other required data on the current mesh.
std::unique_ptr< ShellMatrix< Number > > shell_precond_matrix
A preconditioning shell matrix.
const SparseMatrix< Number > & get_matrix_B() const
bool has_matrix_A() const
const EquationSystems & get_equation_systems() const
virtual void assemble()
Prepares matrix and _dof_map for matrix assembly.
static std::unique_ptr< ShellMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a ShellMatrix<T> using the linear solver package specified by solver_package.
bool has_shell_matrix_A() const
const Parallel::Communicator & comm() const
EigenProblemType
Defines an enum for eigenproblem types.
virtual void init_matrices() override
Initializes the matrices associated with the system.
void set_initial_space(NumericVector< Number > &initial_space_in)
Sets an initial eigen vector.
The libMesh namespace provides an interface to certain functionality in the library.
const EigenSolver< Number > & get_eigen_solver() const
const SparseMatrix< Number > * request_matrix(std::string_view mat_name) const
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
const ShellMatrix< Number > & get_shell_matrix_A() const
unsigned int _n_iterations
The number of iterations of the eigen solver algorithm.
std::unique_ptr< ShellMatrix< Number > > shell_matrix_A
The system shell matrix for standard eigenvalue problems.
SparseMatrix< Number > * precond_matrix
A preconditioning matrix.
const T & get(std::string_view) const
bool has_matrix_B() const
Manages consistently variables, degrees of freedom, and coefficient vectors.
bool has_precond_matrix() const
bool _use_shell_precond_matrix
A boolean flag to indicate whether or not to use a shell preconditioning matrix.
virtual void add_matrices()
Insertion point for adding matrices in derived classes before init_matrices() is called.
std::unique_ptr< ShellMatrix< Number > > shell_matrix_B
A second system shell matrix for generalized eigenvalue problems.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
SparseMatrix< Number > * matrix_A
The system matrix for standard eigenvalue problems.
bool has_shell_matrix_B() const
const ShellMatrix< Number > & get_shell_precond_matrix() const
bool has_shell_precond_matrix() const
virtual std::pair< Real, Real > get_eigenvalue(dof_id_type i)
virtual void solve() override
Assembles & solves the eigen system.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
EigenSystem(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Constructor.
bool _use_shell_matrices
A boolean flag to indicate whether or not to use shell matrices.
std::unique_ptr< EigenSolver< Number > > eigen_solver
The EigenSolver, defining which interface, i.e solver package to use.
const ShellMatrix< Number > & get_shell_matrix_B() const
virtual void add_matrices() override
Adds the necessary matrices and shell matrices.
EigenProblemType _eigen_problem_type
The type of the eigenvalue problem.
Parameters parameters
Data structure holding arbitrary parameters.
void set_eigenproblem_type(EigenProblemType ept)
Sets the type of the current eigen problem.
virtual void clear() override
Clear all the data structures associated with the system.
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
SparseMatrix< Number > & add_matrix(std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
Adds the additional matrix mat_name to this system.
const DofMap & get_dof_map() const
dof_id_type n_constrained_dofs() const
This class provides an interface to solvers for eigenvalue problems.