https://mooseframework.inl.gov
Loading...
Searching...
No Matches
EigenproblemESProblemOperator.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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#ifdef MOOSE_MFEM_ENABLED
11
13#include "MFEMEigensolverBase.h"
14#include "MFEMEigenproblem.h"
15
16namespace Moose::MFEM
17{
18
19void
21{
23
24 auto * const es = GetEquationSystem();
25 if (es->GetTestVarNames().size() > 1)
26 mooseError("Eigenproblems are only supported in single-variable systems");
27
28 auto eigensolver =
29 std::dynamic_pointer_cast<Moose::MFEM::EigensolverBase>(_problem_data.jacobian_solver);
30 es->PrepareEigensolver(*eigensolver);
31 eigensolver->Solve();
33}
34
35void
42
43void
45 Moose::MFEM::GridFunctions & gridfunctions, Moose::MFEM::EigensolverBase * eigensolver)
46{
47 mfem::Array<mfem::real_t> eigenvalues;
48 eigensolver->GetEigenvalues(eigenvalues);
49
50 const auto & trial_var_name = _trial_var_names.at(0);
51 const auto & sep = _problem_data.mode_separator;
52
53 // Distribute the zeroth mode onto the base variable
54 gridfunctions.Get(trial_var_name)->Distribute(eigensolver->GetEigenvector(0));
55
56 for (int i = 0; i < eigenvalues.Size(); ++i)
57 gridfunctions.Get(trial_var_name + sep + std::to_string(i))
58 ->Distribute(eigensolver->GetEigenvector(i));
59}
60
61} // namespace Moose::MFEM
62
63#endif
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
EigenproblemEquationSystem * GetEquationSystem() const override
Returns a pointer to the operator's equation system.
void FormEquationSystemOperator()
Form the equation-system operator used by the eigensolver.
void RecoverEigenproblemSolution(GridFunctions &gridfunctions, EigensolverBase *eigensolver)
void BuildEigenproblemJacobian(mfem::BlockVector &trueX, EigenRHSCoefficient rhs_coefficient)
Build eigenproblem system, with essential boundary conditions accounted for.
Base class for eigensolvers.
virtual void GetEigenvalues(mfem::Array< mfem::real_t > &eigenvalues) const =0
Retrieves the computed eigenvalues.
virtual const mfem::HypreParVector & GetEigenvector(int index) const =0
Retrieves the computed eigenvector corresponding to the given index.
virtual void BuildEquationSystem()
Build all forms comprising this EquationSystem.
T * Get(const std::string &field_name) const
Returns a non-owning pointer to the field. This is guaranteed to return a non-null pointer.
MFEMProblem & _problem
Reference to the current problem.
std::vector< std::string > _trial_var_names
Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector dur...
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
std::shared_ptr< Moose::MFEM::LinearSolverBase > jacobian_solver
std::string mode_separator
Moose::MFEM::GridFunctions gridfunctions