https://mooseframework.inl.gov
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 
15 namespace Moose::MFEM
16 {
17 
18 void
20 {
22 
23  if (GetEquationSystem()->GetTestVarNames().size() > 1)
24  mooseError("Eigenproblems are only supported in single-variable systems");
25 
27  eigensolver->setMassMatrix(_mass_rhs);
28  eigensolver->setOperator(GetEquationSystem()->_jacobian);
29  eigensolver->solve();
31 }
32 
33 void
35 {
38 }
39 
40 void
42  Moose::MFEM::GridFunctions & gridfunctions, MFEMEigensolverBase * eigensolver)
43 {
44  mfem::Array<mfem::real_t> eigenvalues;
45  eigensolver->getEigenvalues(eigenvalues);
46 
47  const auto & trial_var_name = _trial_var_names.at(0);
48  const auto & sep = _problem_data.mode_separator;
49 
50  // Distribute the zeroth mode onto the base variable
51  gridfunctions.Get(trial_var_name)->Distribute(eigensolver->getEigenvector(0));
52 
53  for (int i = 0; i < eigenvalues.Size(); ++i)
54  gridfunctions.Get(trial_var_name + sep + std::to_string(i))
55  ->Distribute(eigensolver->getEigenvector(i));
56 }
57 
58 } // namespace Moose::MFEM
59 
60 #endif
void BuildEquationSystemOperator()
Add kernels/bcs and assemble the linear part of the equation system.
void BuildEigenproblemJacobian(mfem::BlockVector &trueX, mfem::OperatorHandle &massRHS)
Build eigenproblem system, with essential boundary conditions accounted for.
std::vector< std::string > _trial_var_names
Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector dur...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
Base class for eigensolvers.
EigenproblemEquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
virtual void setMassMatrix(mfem::OperatorHandle &mass)=0
Sets the mass matrix for the eigensolver in derived classes.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
virtual void getEigenvalues(mfem::Array< mfem::real_t > &eigenvalues) const =0
Retrieves the computed eigenvalues.
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...
virtual void BuildEquationSystem()
Build all forms comprising this EquationSystem.
void RecoverEigenproblemSolution(Moose::MFEM::GridFunctions &gridfunctions, MFEMEigensolverBase *eigensolver)
virtual const mfem::HypreParVector & getEigenvector(int index) const =0
Retrieves the computed eigenvector corresponding to the given index.
std::string mode_separator
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
Moose::MFEM::GridFunctions gridfunctions
std::shared_ptr< MFEMSolverBase > jacobian_solver