10#ifdef MOOSE_MFEM_ENABLED
22 params.
addClassDescription(
"Problem type for building and solving a finite element eigenproblem "
23 "using the MFEM finite element library.");
24 params.
addParam<
int>(
"num_modes", 1,
"Set the number of lowest eigenmodes to compute.");
28 "Separator string inserted between a variable name and its eigenmode index when "
29 "registering the gridfunction that stores the corresponding eigenvector.");
30 params.
addParam<MFEMScalarCoefficientName>(
33 "Name of the coefficient to scale the right-hand side of the eigenproblem equation by.");
34 params.
addParam<MFEMMatrixCoefficientName>(
"rhs_matrix_coefficient",
35 "Name of the matrix coefficient to scale the "
36 "right-hand side of the eigenproblem equation by.");
45 mooseError(
"Complex numbers are not currently supported for eigenproblems.");
49 "Only one of 'rhs_coefficient' and 'rhs_matrix_coefficient' may be set to a "
50 "non-default value.");
58 getParam<MFEMMatrixCoefficientName>(
"rhs_matrix_coefficient"));
60 getParam<MFEMScalarCoefficientName>(
"rhs_coefficient"));
65 const std::string & var_name,
72 const auto num_modes = getParam<int>(
"num_modes");
77 "' clashes with an existing gridfunction (likely an eigenmode entry from another "
78 "variable). Choose a different variable name or set 'mode_separator' to a string "
79 "that avoids the clash.");
81 for (
int i = 0; i < num_modes; ++i)
83 const auto mode_name = var_name + sep + std::to_string(i);
89 "' clashes with an already-registered variable. Set 'mode_separator' to a "
90 "string that avoids the clash, or rename the conflicting variable.");
95 for (
int i = 0; i < num_modes; ++i)
105 mooseError(
"MFEMEigenproblem does not support nonlinear solver '",
110 !std::dynamic_pointer_cast<Moose::MFEM::EigensolverBase>(
getProblemData().jacobian_solver))
113 "' is not an eigensolver, but the problem is marked as an eigenproblem.");
registerMooseObject("MooseApp", MFEMEigenproblem)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
virtual void resolveMFEMSolvers() override
Construct recorded MFEM solvers in dependency order and select the problem driver solver(s).
static InputParameters validParams()
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters ¶meters) override
Override of MFEMProblem::addVariable.
Moose::MFEM::EigenRHSCoefficient getRHSCoefficient()
Returns the coefficient used to scale the right-hand side of the eigenproblem equation.
MFEMEigenproblem(const InputParameters ¶ms)
Moose::MFEM::CoefficientManager & getCoefficients()
Method to get the PropertyManager object for storing material properties and converting them to MFEM ...
MFEMProblemData & getProblemData()
Method to get the current MFEMProblemData object storing the current data specifying the FE problem.
void validateVariableNumericType(const std::string &var_type, const std::string &var_name) const
Verify that a primary variable's numeric type matches the problem's equation system.
static InputParameters validParams()
Return the input parameters used to construct an MFEM problem.
void addGridFunction(const std::string &var_type, const std::string &var_name, InputParameters ¶meters)
Adds one MFEM GridFunction to be used in the MFEM solve.
NumericType _num_type
The numeric representation currently active for this problem.
virtual void resolveMFEMSolvers()
Construct recorded MFEM solvers in dependency order and select the problem driver solver(s).
const InputParameters & parameters() const
Get the parameters of the object.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
bool isParamSetByUser(const std::string &name) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
mfem::MatrixCoefficient & getMatrixCoefficient(const std::string &name)
Return scalar coefficient with the given name.
mfem::Coefficient & getScalarCoefficient(const std::string &name)
Return a scalar coefficient with the given name or, if that doesn't exist, try interpreting the name ...
std::variant< mfem::Coefficient *, mfem::MatrixCoefficient * > EigenRHSCoefficient
Scalar or matrix coefficient scaling the eigenproblem right-hand side.
std::string mode_separator