www.mooseframework.org
NonlinearEigenSystem.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "libmesh/libmesh_config.h"
13 
14 #include "NonlinearSystemBase.h"
15 
16 #include "libmesh/transient_system.h"
17 #include "libmesh/eigen_system.h"
18 
19 // forward declarations
20 class EigenProblem;
21 class KernelBase;
22 
23 #if LIBMESH_HAVE_SLEPC
24 
29 {
30 public:
31  NonlinearEigenSystem(EigenProblem & problem, const std::string & name);
32 
33  virtual void solve() override;
34 
38  virtual void stopSolve() override;
39 
44  virtual unsigned int getCurrentNonlinearIterationNumber() override;
45 
46  virtual void setupFiniteDifferencedPreconditioner() override;
47 
53  virtual bool converged() override;
54 
55  virtual NumericVector<Number> & RHS() override;
56 
60  template <typename T>
62 
63  virtual void initialSetup() override;
64 
70  virtual unsigned int getNumConvergedEigenvalues() const
71  {
72  return _transient_sys.get_n_converged();
73  };
74 
75  virtual NonlinearSolver<Number> * nonlinearSolver() override;
76 
77  NumericVector<Number> & solutionOld() override { return *_transient_sys.old_local_solution; }
78 
79  NumericVector<Number> & solutionOlder() override { return *_transient_sys.older_local_solution; }
80 
81  const NumericVector<Number> & solutionOld() const override
82  {
83  return *_transient_sys.old_local_solution;
84  }
85 
86  const NumericVector<Number> & solutionOlder() const override
87  {
88  return *_transient_sys.older_local_solution;
89  }
90 
91  virtual TransientEigenSystem & sys() { return _transient_sys; }
92 
98  void checkIntegrity();
99 
107  virtual const std::pair<Real, Real> getNthConvergedEigenvalue(dof_id_type n);
108 
114  virtual const std::vector<std::pair<Real, Real>> & getAllConvergedEigenvalues()
115  {
116  return _eigen_values;
117  }
118 
123 
128 
133 
138 
139 protected:
140  TransientEigenSystem & _transient_sys;
142  std::vector<std::pair<Real, Real>> _eigen_values;
148 };
149 
150 #else
151 
152 class NonlinearEigenSystem : public libMesh::ParallelObject
153 {
154 public:
155  NonlinearEigenSystem(EigenProblem & problem, const std::string & name);
156 
161  bool converged() { return false; }
162 
163  void checkIntegrity() {}
164 };
165 
166 #endif
167 
Nonlinear eigenvalue system to be solved.
virtual const std::vector< std::pair< Real, Real > > & getAllConvergedEigenvalues()
Get the number of converged eigenvalues.
const NumericVector< Number > & solutionOld() const override
TagID nonEigenVectorTag()
Vector tag ID of left hand side.
const NumericVector< Number > & solutionOlder() const override
virtual TransientEigenSystem & sys()
unsigned int TagID
Definition: MooseTypes.h:162
TagID nonEigenMatrixTag()
Matrix tag ID of left hand side.
virtual NonlinearSolver< Number > * nonlinearSolver() override
void addEigenTagToMooseObjects(MooseObjectTagWarehouse< T > &warehouse)
Add the eigen tag to the right kernels.
TagID eigenMatrixTag()
Matrix tag ID of right hand side.
virtual void initialSetup() override
virtual unsigned int getNumConvergedEigenvalues() const
Get the number of converged eigenvalues.
bool converged()
Returns the convergence state.
NonlinearEigenSystem(EigenProblem &problem, const std::string &name)
Nonlinear system to be solved.
virtual const std::string & name() const
Definition: SystemBase.C:1088
TagID eigenVectorTag()
Vector tag ID of right hand side.
This is the common base class for the two main kernel types implemented in MOOSE, EigenKernel and Ker...
Definition: KernelBase.h:44
virtual const std::pair< Real, Real > getNthConvergedEigenvalue(dof_id_type n)
Return the Nth converged eigenvalue.
virtual bool converged() override
Returns the convergence state.
virtual void stopSolve() override
Quit the current solve as soon as possible.
A storage container for MooseObjects that inherit from SetupInterface.
virtual void setupFiniteDifferencedPreconditioner() override
NumericVector< Number > & solutionOlder() override
virtual unsigned int getCurrentNonlinearIterationNumber() override
Returns the current nonlinear iteration number.
TransientEigenSystem & _transient_sys
NumericVector< Number > & solutionOld() override
PetscInt n
Problem for solving eigenvalue problems.
Definition: EigenProblem.h:25
std::vector< std::pair< Real, Real > > _eigen_values
virtual NumericVector< Number > & RHS() override
unsigned int _n_eigen_pairs_required
virtual void solve() override
Solve the system (using libMesh magic)
void checkIntegrity()
For eigenvalue problems (including standard and generalized), inhomogeneous (Dirichlet or Neumann) bo...