libMesh
condensed_eigen_system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 #ifndef LIBMESH_CONDENSED_EIGEN_SYSTEM_H
20 #define LIBMESH_CONDENSED_EIGEN_SYSTEM_H
21 
22 #include "libmesh/libmesh_config.h"
23 
24 // Currently, the EigenSystem should only be available
25 // if SLEPc support is enabled.
26 #if defined(LIBMESH_HAVE_SLEPC)
27 
28 // Local Includes
29 #include "libmesh/eigen_system.h"
30 #include "libmesh/sparse_matrix.h"
31 
32 namespace libMesh
33 {
34 
47 {
48 public:
49 
54  const std::string & name_in,
55  const unsigned int number_in);
56 
62  CondensedEigenSystem (const CondensedEigenSystem &) = delete;
66  virtual ~CondensedEigenSystem ();
67 
72 
77 
81  sys_type & system () { return *this; }
82 
95  void initialize_condensed_dofs(const std::set<dof_id_type> &
96  global_condensed_dofs_set =
97  std::set<dof_id_type>());
98 
103 
109  virtual void solve() override;
110 
111  virtual void clear () override;
112 
119  virtual std::pair<Real, Real> get_eigenpair(dof_id_type i) override;
120 
121  bool has_condensed_matrix_A() const { return _condensed_matrix_A.get(); }
122  bool has_condensed_matrix_B() const { return _condensed_matrix_B.get(); }
124 
129 
134 
139 
147 
154 
161 
170 
171 #ifdef LIBMESH_ENABLE_DEPRECATED
172 
179 
187 #endif
188 
194  std::vector<dof_id_type> local_non_condensed_dofs_vector;
195 
201 
205  bool have_condensed_dofs() const
207 
208  virtual void reinit() override;
209 
210 protected:
211  virtual void add_matrices () override;
212 
213 private:
214  virtual bool condense_constrained_dofs() const override final { return true; }
215 
216 #ifdef LIBMESH_ENABLE_DEPRECATED
217  void set_raw_pointers();
218 #endif
219 
225 
230 
235 
239  std::unique_ptr<SparseMatrix<Number>> _condensed_matrix_A;
240 
244  std::unique_ptr<SparseMatrix<Number>> _condensed_matrix_B;
245 
249  std::unique_ptr<SparseMatrix<Number>> _condensed_precond_matrix;
250 };
251 
252 
253 } // namespace libMesh
254 
255 
256 #endif // LIBMESH_HAVE_SLEPC
257 
258 #endif // LIBMESH_CONDENSED_EIGEN_SYSTEM_H
void initialize_condensed_matrices()
Initializes the condensed matrices.
This is the EquationSystems class.
bool _condensed_dofs_initialized
A private flag to indicate whether the condensed dofs have been initialized.
CondensedEigenSystem & operator=(const CondensedEigenSystem &)=delete
SparseMatrix< Number > & get_condensed_precond_matrix()
CondensedEigenSystem sys_type
The type of system.
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.
virtual void clear() override
Clear all the data structures associated with the system.
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.
void dont_create_submatrices_in_solve()
Instructs not to create the condensed submatrices from the global matrices right before the solve...
virtual void solve() override
Override to solve the condensed eigenproblem with the dofs in local_non_condensed_dofs_vector strippe...
SparseMatrix< Number > & get_condensed_matrix_A()
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.
libmesh_assert(ctx)
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.
This class extends EigenSystem to allow a simple way of solving (standard or generalized) eigenvalue ...
virtual void add_matrices() override
Adds the necessary matrices and shell matrices.
std::unique_ptr< SparseMatrix< Number > > _condensed_matrix_B
A second (condensed) system matrix for generalized eigenvalue problems.
EigenSystem Parent
The type of the parent.
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.
bool _create_submatrices_in_solve
Denotes whether to create the condensed submatrices from the global matrices in the solve...
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()
Manages consistently variables, degrees of freedom, and coefficient vectors for eigenvalue problems...
Definition: eigen_system.h:55
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.
uint8_t dof_id_type
Definition: id_types.h:67
virtual bool condense_constrained_dofs() const override final
Whether this object should condense out constrained degrees of freedom.