18 #include "libmesh/libmesh_config.h" 22 #if defined(LIBMESH_HAVE_SLEPC) 24 #include "libmesh/condensed_eigen_system.h" 26 #include "libmesh/dof_map.h" 27 #include "libmesh/equation_systems.h" 28 #include "libmesh/int_range.h" 29 #include "libmesh/libmesh_logging.h" 30 #include "libmesh/numeric_vector.h" 31 #include "libmesh/parallel.h" 37 const std::string & name_in,
38 const unsigned int number_in)
39 :
Parent(es, name_in, number_in),
40 _condensed_dofs_initialized(false),
41 _have_condensed_dofs(false),
42 _create_submatrices_in_solve(true)
60 std::set<dof_id_type> local_non_condensed_dofs_set;
62 #if LIBMESH_ENABLE_CONSTRAINTS 65 local_non_condensed_dofs_set.insert(i);
68 for (
const auto dof : global_dirichlet_dofs_set)
70 local_non_condensed_dofs_set.erase(dof);
75 for (
const auto dof : local_non_condensed_dofs_set)
127 this->
comm().
sum(n_global_non_condensed_dofs);
133 #ifdef LIBMESH_ENABLE_DEPRECATED 149 #ifdef LIBMESH_ENABLE_DEPRECATED 175 #ifdef LIBMESH_ENABLE_DEPRECATED 182 LOG_SCOPE(
"solve()",
"CondensedEigenSystem");
236 LOG_SCOPE(
"get_eigenpair()",
"CondensedEigenSystem");
254 temp->init (n, n_local,
false,
PARALLEL);
256 std::pair<Real, Real> eval =
eigen_solver->get_eigenpair (i, *temp);
266 solution->set(index,(*temp)(temp->first_local_index()+j));
306 *super_sub_view = sub;
318 sub = *super_sub_view;
326 parallel_object_only();
334 sub = *super_sub_view;
340 #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)
void solve_helper(SparseMatrix< Number > *const A, SparseMatrix< Number > *const B, SparseMatrix< Number > *const P)
virtual void create_submatrix(SparseMatrix< T > &submatrix, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols) const
This function creates a matrix called "submatrix" which is defined by the row and column indices give...
void initialize_condensed_matrices()
Initializes the condensed matrices.
dof_id_type end_dof(const processor_id_type proc) const
This is the EquationSystems class.
bool _condensed_dofs_initialized
A private flag to indicate whether the condensed dofs have been initialized.
bool has_condensed_matrix_A() const
bool have_parameter(std::string_view) const
SparseMatrix< Number > * matrix_B
A second system matrix for generalized eigenvalue problems.
SparseMatrix< Number > & get_condensed_precond_matrix()
virtual numeric_index_type local_m() const
Get the number of rows owned by this process.
dof_id_type n_local_constrained_dofs() const
bool has_condensed_precond_matrix() const
const EquationSystems & get_equation_systems() const
virtual void assemble()
Prepares matrix and _dof_map for matrix assembly.
CondensedEigenSystem(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Constructor.
SparseMatrix< Number > * condensed_matrix_B
A second (condensed) system matrix for generalized eigenvalue problems.
const Parallel::Communicator & comm() const
bool use_shell_precond_matrix() const
const Parallel::Communicator & _communicator
virtual void clear() override
Clear all the data structures associated with the system.
virtual ~CondensedEigenSystem()
The libMesh namespace provides an interface to certain functionality in the library.
void copy_super_to_sub(NumericVector< Number > &super, NumericVector< Number > &sub)
Copy a logically super-vector into a sub-vector.
SparseMatrix< Number > * condensed_matrix_A
The (condensed) system matrix for standard eigenvalue problems.
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
static std::unique_ptr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
virtual void solve() override
Override to solve the condensed eigenproblem with the dofs in local_non_condensed_dofs_vector strippe...
dof_id_type n_dofs() const
This class handles the numbering of degrees of freedom on a mesh.
SparseMatrix< Number > * precond_matrix
A preconditioning matrix.
SparseMatrix< Number > & get_condensed_matrix_A()
bool use_shell_matrices() const
dof_id_type n_global_non_condensed_dofs() const
void copy_sub_to_super(const NumericVector< Number > &sub, NumericVector< Number > &super)
Copy a logically sub-vector into a super-vector.
bool _have_condensed_dofs
Whether there are any condensed degrees of freedom.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
bool is_constrained_dof(const dof_id_type dof) const
SparseMatrix< Number > * matrix_A
The system matrix for standard eigenvalue problems.
void initialize_condensed_dofs(const std::set< dof_id_type > &global_condensed_dofs_set=std::set< dof_id_type >())
Loop over the dofs on each processor to initialize the list of non-condensed dofs.
virtual std::unique_ptr< NumericVector< T > > get_subvector(const std::vector< numeric_index_type > &)
Creates a view into this vector using the indices in rows.
virtual void solve() override
Assembles & solves the eigen system.
virtual void add_matrices() override
Adds the necessary matrices and shell matrices.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
dof_id_type n_constrained_dofs() const
std::unique_ptr< SparseMatrix< Number > > _condensed_matrix_B
A second (condensed) system matrix for generalized eigenvalue problems.
std::unique_ptr< EigenSolver< Number > > eigen_solver
The EigenSolver, defining which interface, i.e solver package to use.
virtual numeric_index_type local_size() const =0
virtual void add_matrices() override
Adds the necessary matrices and shell matrices.
virtual std::pair< Real, Real > get_eigenpair(dof_id_type i) override
Override get_eigenpair() to retrieve the eigenpair for the condensed eigensolve.
std::vector< dof_id_type > local_non_condensed_dofs_vector
Vector storing the local dof indices that will not be condensed.
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
bool _create_submatrices_in_solve
Denotes whether to create the condensed submatrices from the global matrices in the solve...
bool has_condensed_matrix_B() const
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
SparseMatrix< Number > & get_condensed_matrix_B()
dof_id_type first_dof(const processor_id_type proc) const
virtual void clear() override
Clear all the data structures associated with the system.
Manages consistently variables, degrees of freedom, and coefficient vectors for eigenvalue problems...
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
const DofMap & get_dof_map() const
std::unique_ptr< SparseMatrix< Number > > _condensed_precond_matrix
The condensed preconditioning matrix.
std::unique_ptr< SparseMatrix< Number > > _condensed_matrix_A
The (condensed) system matrix for standard eigenvalue problems.
virtual void init(const numeric_index_type m, const numeric_index_type n, const numeric_index_type m_l, const numeric_index_type n_l, const numeric_index_type nnz=30, const numeric_index_type noz=10, const numeric_index_type blocksize=1)=0
Initialize SparseMatrix with the specified sizes.
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
Constrains the numeric vector v, which represents a solution defined on the mesh. ...
virtual void restore_subvector(std::unique_ptr< NumericVector< T >>, const std::vector< numeric_index_type > &)
Restores a view into this vector using the indices in rows.