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);
166 LOG_SCOPE(
"solve()",
"CondensedEigenSystem");
220 LOG_SCOPE(
"get_eigenpair()",
"CondensedEigenSystem");
238 temp->init (n, n_local,
false,
PARALLEL);
240 std::pair<Real, Real> eval =
eigen_solver->get_eigenpair (i, *temp);
250 solution->set(index,(*temp)(temp->first_local_index()+j));
287 libmesh_assert_equal_to(sub.
local_size() + this->get_dof_map().n_local_constrained_dofs(),
290 *super_sub_view = sub;
299 libmesh_assert_equal_to(sub.
local_size() + this->get_dof_map().n_local_constrained_dofs(),
302 sub = *super_sub_view;
310 parallel_object_only();
313 libmesh_assert_equal_to(sub.
local_m() + this->get_dof_map().n_local_constrained_dofs(),
318 sub = *super_sub_view;
virtual void add_matrices() override
Adds the necessary matrices and shell matrices.
void copy_super_to_sub(NumericVector< Number > &super, NumericVector< Number > &sub)
Copy a logically super-vector into a sub-vector.
bool _have_condensed_dofs
Whether there are any condensed degrees of freedom.
std::vector< dof_id_type > local_non_condensed_dofs_vector
Vector storing the local dof indices that will not be condensed.
bool _condensed_dofs_initialized
A private flag to indicate whether the condensed dofs have been initialized.
virtual void solve() override
Override to solve the condensed eigenproblem with the dofs in local_non_condensed_dofs_vector strippe...
bool _create_submatrices_in_solve
Denotes whether to create the condensed submatrices from the global matrices in the solve.
void copy_sub_to_super(const NumericVector< Number > &sub, NumericVector< Number > &super)
Copy a logically sub-vector into a super-vector.
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.
SparseMatrix< Number > & get_condensed_matrix_B()
std::unique_ptr< SparseMatrix< Number > > _condensed_matrix_A
The (condensed) system matrix for standard eigenvalue problems.
virtual void clear() override
Clear all the data structures associated with the system.
void initialize_condensed_matrices()
Initializes the condensed matrices.
std::unique_ptr< SparseMatrix< Number > > _condensed_precond_matrix
The condensed preconditioning matrix.
virtual std::pair< Real, Real > get_eigenpair(dof_id_type i) override
Override get_eigenpair() to retrieve the eigenpair for the condensed eigensolve.
bool has_condensed_matrix_B() const
std::unique_ptr< SparseMatrix< Number > > _condensed_matrix_B
A second (condensed) system matrix for generalized eigenvalue problems.
SparseMatrix< Number > & get_condensed_precond_matrix()
bool has_condensed_precond_matrix() const
CondensedEigenSystem(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Constructor.
bool has_condensed_matrix_A() const
dof_id_type n_global_non_condensed_dofs() const
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
virtual ~CondensedEigenSystem()
SparseMatrix< Number > & get_condensed_matrix_A()
dof_id_type first_dof(const processor_id_type proc) const
dof_id_type end_dof(const processor_id_type proc) const
This class handles the numbering of degrees of freedom on a mesh.
dof_id_type n_constrained_dofs() const
bool is_constrained_dof(const dof_id_type dof) const
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.
Manages consistently variables, degrees of freedom, and coefficient vectors for eigenvalue problems.
SparseMatrix< Number > * matrix_A
The system matrix for standard eigenvalue problems.
SparseMatrix< Number > * matrix_B
A second system matrix for generalized eigenvalue problems.
bool use_shell_matrices() const
virtual void clear() override
Clear all the data structures associated with the system.
virtual void solve() override
Assembles & solves the eigen system.
virtual std::pair< Real, Real > get_eigenpair(dof_id_type i)
SparseMatrix< Number > * precond_matrix
A preconditioning matrix.
bool use_shell_precond_matrix() const
void solve_helper(SparseMatrix< Number > *const A, SparseMatrix< Number > *const B, SparseMatrix< Number > *const P)
std::unique_ptr< EigenSolver< Number > > eigen_solver
The EigenSolver, defining which interface, i.e solver package to use.
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
virtual void add_matrices() override
Adds the necessary matrices and shell matrices.
This is the EquationSystems class.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
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.
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...
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.
virtual numeric_index_type local_size() const =0
const Parallel::Communicator & _communicator
const Parallel::Communicator & comm() const
bool have_parameter(std::string_view) const
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.
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
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 numeric_index_type local_m() const
Get the number of rows owned by this process.
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...
dof_id_type n_dofs() const
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
virtual void assemble()
Prepares matrix and _dof_map for matrix assembly.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
const DofMap & get_dof_map() const
const EquationSystems & get_equation_systems() const
The libMesh namespace provides an interface to certain functionality in the library.
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...