www.mooseframework.org
Eigenvalues.C
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 #include "Eigenvalues.h"
11 
12 // MOOSE includes
13 #include "NonlinearEigenSystem.h"
14 
15 #include "libmesh/libmesh_config.h"
16 
17 registerMooseObject("MooseApp", Eigenvalues);
18 
19 template <>
22 {
24  return params;
25 }
26 
28  : GeneralVectorPostprocessor(parameters),
29  _eigen_values_real(declareVector("eigen_values_real")),
30  _eigen_values_imag(declareVector("eigen_values_imag")),
31  _nl_eigen(dynamic_cast<NonlinearEigenSystem *>(&_fe_problem.getNonlinearSystemBase()))
32 {
33  if (!_nl_eigen)
34  mooseError("Given system is not a NonlinearEigenSystem \n");
35 }
36 
37 void
39 {
40 }
41 
42 void
44 {
45 #if LIBMESH_HAVE_SLEPC
46  const std::vector<std::pair<Real, Real>> & eigenvalues = _nl_eigen->getAllConvergedEigenvalues();
47  unsigned int n_converged_eigenvalues = eigenvalues.size();
48  _eigen_values_real.resize(n_converged_eigenvalues);
49  _eigen_values_imag.resize(n_converged_eigenvalues);
50  for (unsigned int n = 0; n < n_converged_eigenvalues; n++)
51  {
52  _eigen_values_real[n] = eigenvalues[n].first;
53  _eigen_values_imag[n] = eigenvalues[n].second;
54  }
55 #else
56  _eigen_values_real.clear();
57  _eigen_values_imag.clear();
58 #endif
59 }
Nonlinear eigenvalue system to be solved.
virtual const std::vector< std::pair< Real, Real > > & getAllConvergedEigenvalues()
Get the number of converged eigenvalues.
This class is here to combine the VectorPostprocessor interface and the base class VectorPostprocesso...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
Eigenvalues(const InputParameters &parameters)
Definition: Eigenvalues.C:27
registerMooseObject("MooseApp", Eigenvalues)
InputParameters validParams< GeneralVectorPostprocessor >()
NonlinearEigenSystem * _nl_eigen
Definition: Eigenvalues.h:32
InputParameters validParams< Eigenvalues >()
Definition: Eigenvalues.C:21
VectorPostprocessorValue & _eigen_values_real
Definition: Eigenvalues.h:30
virtual void execute() override
Execute method.
Definition: Eigenvalues.C:43
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Definition: Eigenvalues.C:38
PetscInt n
VectorPostprocessorValue & _eigen_values_imag
Definition: Eigenvalues.h:31