www.mooseframework.org
EigenProblem.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "libmesh/libmesh_config.h"
16 
17 #include "EigenProblem.h"
18 
19 #include "Assembly.h"
20 #include "AuxiliarySystem.h"
21 #include "DisplacedProblem.h"
22 #include "NonlinearEigenSystem.h"
23 #include "SlepcSupport.h"
24 #include "RandomData.h"
25 #include "OutputWarehouse.h"
26 #include "Function.h"
27 
28 #include "libmesh/system.h"
29 #include "libmesh/eigen_solver.h"
30 
31 template <>
34 {
36  return params;
37 }
38 
40  : FEProblemBase(parameters),
41  // By default, we want to compute an eigenvalue only (smallest or largest)
42  _n_eigen_pairs_required(1),
43  _generalized_eigenvalue_problem(false),
44  _nl_eigen(std::make_shared<NonlinearEigenSystem>(*this, "eigen0")),
45  _is_residual_initialed(false)
46 {
47 #if LIBMESH_HAVE_SLEPC
48  _nl = _nl_eigen;
49  _aux = std::make_shared<AuxiliarySystem>(*this, "aux0");
50 
52 
54 
55  _eq.parameters.set<EigenProblem *>("_eigen_problem") = this;
56 
57 #else
58  mooseError("Need to install SLEPc to solve eigenvalue problems, please reconfigure\n");
59 #endif /* LIBMESH_HAVE_SLEPC */
60 }
61 
63 {
64 #if LIBMESH_HAVE_SLEPC
66 #endif /* LIBMESH_HAVE_SLEPC */
67 }
68 
69 #if LIBMESH_HAVE_SLEPC
70 void
72 {
73  switch (eigen_problem_type)
74  {
76  _nl_eigen->sys().set_eigenproblem_type(libMesh::HEP);
78  break;
79 
81  _nl_eigen->sys().set_eigenproblem_type(libMesh::NHEP);
83  break;
84 
86  _nl_eigen->sys().set_eigenproblem_type(libMesh::GHEP);
88  break;
89 
91  _nl_eigen->sys().set_eigenproblem_type(libMesh::GHIEP);
93  break;
94 
96  _nl_eigen->sys().set_eigenproblem_type(libMesh::GNHEP);
98  break;
99 
101  mooseError("libMesh does not support EPT_POS_GEN_NON_HERMITIAN currently \n");
102  break;
103 
106  break;
107 
108  default:
109  mooseError("Unknown eigen solver type \n");
110  }
111 }
112 #endif
113 
114 void
115 EigenProblem::computeJacobian(const NumericVector<Number> & soln,
116  SparseMatrix<Number> & jacobian,
117  Moose::KernelType kernel_type)
118 {
119  // to avoid computing residual
121  FEProblemBase::computeJacobian(soln, jacobian, kernel_type);
122 }
123 
124 void
126 {
128  _nl_eigen->checkIntegrity();
129 }
130 
131 void
133 {
134  Moose::perf_log.push("Eigen_solve()", "Execution");
135  if (_solve)
136  {
137  _nl->solve();
138  _nl->update();
139  }
140 
141  // sync solutions in displaced problem
142  if (_displaced_problem)
143  _displaced_problem->syncSolutions();
144 
145  Moose::perf_log.pop("Eigen_solve()", "Execution");
146 }
147 
148 bool
150 {
151  return _nl_eigen->converged();
152 }
153 
154 bool
156 {
161 }
162 
163 void
164 EigenProblem::computeResidualTypeBx(const NumericVector<Number> & soln,
165  NumericVector<Number> & residual,
167 {
168  _nl->setSolution(soln);
169 
170  _nl->zeroVariablesForResidual();
171 
172  _nl->computeResidual(residual, type);
173 }
174 
175 void
176 EigenProblem::computeResidualType(const NumericVector<Number> & soln,
177  NumericVector<Number> & residual,
179 {
180  // if Ax is just compputed, we do not do extra computation such as Transfer
182  {
183  computeResidualTypeBx(soln, residual, type);
184  _is_residual_initialed = false;
185  }
186  else
187  {
188  FEProblemBase::computeResidualType(soln, residual, type);
189  if (type == Moose::KT_NONEIGEN)
190  _is_residual_initialed = true;
191  }
192 }
Nonlinear eigenvalue system to be solved.
Generalized Non-Hermitian.
Definition: MooseTypes.h:278
Newton-based eigen solver.
Definition: MooseTypes.h:265
virtual bool isNonlinearEigenvalueSolver()
Definition: EigenProblem.C:155
Generalized Hermitian indefinite.
Definition: MooseTypes.h:277
Moose::EigenSolveType _eigen_solve_type
Definition: SolverParams.h:30
Full Newton Solve.
Definition: MooseTypes.h:249
SolverParams & solverParams()
Get the solver parameters.
std::shared_ptr< NonlinearSystemBase > _nl
virtual void computeResidualType(const NumericVector< Number > &soln, NumericVector< Number > &residual, Moose::KernelType type=Moose::KT_ALL)
Matrix-free Newton-based eigen solver.
Definition: MooseTypes.h:266
virtual void solve() override
Definition: EigenProblem.C:132
virtual void initNullSpaceVectors(const InputParameters &parameters, NonlinearSystemBase &nl)
EigenProblem(const InputParameters &parameters)
Definition: EigenProblem.C:39
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Matrix-free nonlinear inverse power.
Definition: MooseTypes.h:264
use whatever SLPEC has by default
Definition: MooseTypes.h:280
Generalized Non-Hermitian with positive (semi-)definite B.
Definition: MooseTypes.h:279
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
std::shared_ptr< NonlinearEigenSystem > _nl_eigen
Definition: EigenProblem.h:75
bool _generalized_eigenvalue_problem
Definition: EigenProblem.h:74
virtual void newAssemblyArray(NonlinearSystemBase &nl)
std::shared_ptr< AuxiliarySystem > _aux
PerfLog perf_log
Perflog to be used by applications.
void computeResidualTypeBx(const NumericVector< Number > &soln, NumericVector< Number > &residual, Moose::KernelType type)
Definition: EigenProblem.C:164
Moose::SolveType _type
Definition: SolverParams.h:25
bool _is_residual_initialed
Definition: EigenProblem.h:76
virtual void checkProblemIntegrity()
Nonlinear inverse power.
Definition: MooseTypes.h:263
KernelType
Definition: MooseTypes.h:162
bool _solve
Whether or not to actually solve the nonlinear system.
MatType type
virtual void computeJacobian(const NumericVector< Number > &soln, SparseMatrix< Number > &jacobian, Moose::KernelType kernel_type) override
Definition: EigenProblem.C:115
InputParameters validParams< EigenProblem >()
Definition: EigenProblem.C:33
InputParameters validParams< FEProblemBase >()
virtual ~EigenProblem()
Definition: EigenProblem.C:62
Non-Hermitian.
Definition: MooseTypes.h:275
virtual bool converged() override
Definition: EigenProblem.C:149
void computeResidualType(const NumericVector< Number > &soln, NumericVector< Number > &residual, Moose::KernelType type) override
Definition: EigenProblem.C:176
std::shared_ptr< DisplacedProblem > _displaced_problem
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
EquationSystems _eq
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition: EigenProblem.h:32
virtual void deleteAssemblyArray()
virtual void computeJacobian(NonlinearImplicitSystem &sys, const NumericVector< Number > &soln, SparseMatrix< Number > &jacobian)
virtual void checkProblemIntegrity() override
Definition: EigenProblem.C:125
EigenProblemType
Type of the eigen problem.
Definition: MooseTypes.h:272
void setEigenproblemType(Moose::EigenProblemType eigen_problem_type)
Definition: EigenProblem.C:71
Generalized Hermitian.
Definition: MooseTypes.h:276