https://mooseframework.inl.gov
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Moose::MFEM::EigenproblemESProblemOperator Class Reference

Steady-state eigenproblem operator with an equation system. More...

#include <EigenproblemESProblemOperator.h>

Inheritance diagram for Moose::MFEM::EigenproblemESProblemOperator:
[legend]

Public Member Functions

 EigenproblemESProblemOperator (MFEMProblem &problem)
 
virtual void Solve () override
 
EigenproblemEquationSystemGetEquationSystem () const override
 Returns a pointer to the operator's equation system. More...
 
virtual void SetGridFunctions () override
 
void Mult (const mfem::Vector &, mfem::Vector &) const override
 
virtual void SetTrialVariablesFromTrueVectors ()
 
virtual void Init (mfem::BlockVector &X)
 

Public Attributes

mfem::Array< int_block_true_offsets_test
 
mfem::Array< int_block_true_offsets_trial
 
mfem::BlockVector _true_x
 
mfem::BlockVector _true_rhs
 

Protected Member Functions

void FormEquationSystemOperator ()
 Form the equation-system operator used by the eigensolver. More...
 
void SolveWithOperator (mfem::Operator &system_operator, mfem::Operator &linear_operator, const mfem::Vector &rhs, mfem::Vector &x)
 Solve the current system operator using the configured nonlinear and linear solvers. More...
 
void SolveWithOperator (mfem::Operator &system_operator, const mfem::Vector &rhs, mfem::Vector &x)
 Solve the current system operator using system_operator.GetGradient(x) as the linear operator. More...
 

Protected Attributes

MFEMProblem_problem
 Reference to the current problem. More...
 
MFEMProblemData_problem_data
 
std::vector< std::string > _trial_var_names
 Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector during solve. More...
 
std::vector< std::string > _test_var_names
 
std::vector< mfem::ParGridFunction * > _trial_variables
 
std::vector< mfem::ParGridFunction * > _test_variables
 
mfem::Vector * _trial_true_vector = nullptr
 

Private Member Functions

void RecoverEigenproblemSolution (GridFunctions &gridfunctions, EigensolverBase *eigensolver)
 

Detailed Description

Steady-state eigenproblem operator with an equation system.

Definition at line 22 of file EigenproblemESProblemOperator.h.

Constructor & Destructor Documentation

◆ EigenproblemESProblemOperator()

Moose::MFEM::EigenproblemESProblemOperator::EigenproblemESProblemOperator ( MFEMProblem problem)
inline

Definition at line 25 of file EigenproblemESProblemOperator.h.

26  {
27  mooseAssert(std::dynamic_pointer_cast<EigenproblemEquationSystem>(_problem_data.eqn_system),
28  "MFEMProblemData::eqn_system is not an EigenproblemEquationSystem.");
29  }
std::shared_ptr< Moose::MFEM::EquationSystem > eqn_system

Member Function Documentation

◆ FormEquationSystemOperator()

void Moose::MFEM::EigenproblemESProblemOperator::FormEquationSystemOperator ( )
protected

Form the equation-system operator used by the eigensolver.

Definition at line 35 of file EigenproblemESProblemOperator.C.

Referenced by Solve().

36 {
39 }
EigenproblemEquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
virtual void BuildEquationSystem()
Build all forms comprising this EquationSystem.
void BuildEigenproblemJacobian(mfem::BlockVector &trueX)
Build eigenproblem system, with essential boundary conditions accounted for.

◆ GetEquationSystem()

EigenproblemEquationSystem* Moose::MFEM::EigenproblemESProblemOperator::GetEquationSystem ( ) const
inlineoverridevirtual

Returns a pointer to the operator's equation system.

Reimplemented from Moose::MFEM::EquationSystemProblemOperator.

Definition at line 33 of file EigenproblemESProblemOperator.h.

Referenced by FormEquationSystemOperator(), and Solve().

34  {
35  return static_cast<EigenproblemEquationSystem *>(
37  }
virtual EquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.

◆ Init()

void Moose::MFEM::ProblemOperatorBase::Init ( mfem::BlockVector &  X)
virtualinherited

Reimplemented in Moose::MFEM::TimeDependentEquationSystemProblemOperator.

Definition at line 49 of file ProblemOperatorBase.C.

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::Init().

50 {
52  for (const auto i : index_range(_trial_variables))
53  X.GetBlock(i) = _trial_variables[i]->GetTrueVector();
54  // Sync the flags from the global vector with the sub-vectors (copies to global vector location)
55  X.SyncFromBlocks();
56 
57  // After initial assignment of X from the grid function, which may contain initial conditions,
58  // we alias the grid function to X
59  for (const auto i : index_range(_trial_variables))
60  _trial_variables[i]->MakeTRef(
61  _trial_variables[i]->ParFESpace(), X, _block_true_offsets_trial[i]);
63 }
mfem::Array< int > _block_true_offsets_trial
std::vector< mfem::ParGridFunction * > _trial_variables
auto index_range(const T &sizable)

◆ Mult()

void Moose::MFEM::ProblemOperator::Mult ( const mfem::Vector &  ,
mfem::Vector &   
) const
inlineoverrideinherited

Definition at line 28 of file ProblemOperator.h.

28 {}

◆ RecoverEigenproblemSolution()

void Moose::MFEM::EigenproblemESProblemOperator::RecoverEigenproblemSolution ( GridFunctions gridfunctions,
EigensolverBase eigensolver 
)
private

Definition at line 42 of file EigenproblemESProblemOperator.C.

Referenced by Solve().

44 {
45  mfem::Array<mfem::real_t> eigenvalues;
46  eigensolver->GetEigenvalues(eigenvalues);
47 
48  const auto & trial_var_name = _trial_var_names.at(0);
49  const auto & sep = _problem_data.mode_separator;
50 
51  // Distribute the zeroth mode onto the base variable
52  gridfunctions.Get(trial_var_name)->Distribute(eigensolver->GetEigenvector(0));
53 
54  for (int i = 0; i < eigenvalues.Size(); ++i)
55  gridfunctions.Get(trial_var_name + sep + std::to_string(i))
56  ->Distribute(eigensolver->GetEigenvector(i));
57 }
std::vector< std::string > _trial_var_names
Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector dur...
std::string mode_separator

◆ SetGridFunctions()

void Moose::MFEM::EquationSystemProblemOperator::SetGridFunctions ( )
overridevirtualinherited

Reimplemented from Moose::MFEM::ProblemOperator.

Reimplemented in Moose::MFEM::ComplexEquationSystemProblemOperator.

Definition at line 17 of file EquationSystemProblemOperator.C.

18 {
22 }
std::vector< std::string > _test_var_names
virtual EquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
std::vector< std::string > _trial_var_names
Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector dur...
virtual void SetGridFunctions() override
const std::vector< std::string > & GetTrialVarNames() const
const std::vector< std::string > & GetTestVarNames() const

◆ SetTrialVariablesFromTrueVectors()

void Moose::MFEM::ProblemOperatorBase::SetTrialVariablesFromTrueVectors ( )
virtualinherited

Definition at line 66 of file ProblemOperatorBase.C.

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::Solve().

67 {
68  mooseAssert(_trial_true_vector, "The true vector should already have been set");
69  for (const auto trial_var : _trial_variables)
70  {
71  // Sync the memory flags from the global true vector to the gridfunction aliases
72  trial_var->GetTrueVector().SyncMemory(*_trial_true_vector);
73  trial_var->SetFromTrueVector();
74  }
75 }
std::vector< mfem::ParGridFunction * > _trial_variables

◆ Solve()

void Moose::MFEM::EigenproblemESProblemOperator::Solve ( )
overridevirtual

Reimplemented from Moose::MFEM::EquationSystemProblemOperator.

Definition at line 19 of file EigenproblemESProblemOperator.C.

20 {
22 
23  auto * const es = GetEquationSystem();
24  if (es->GetTestVarNames().size() > 1)
25  mooseError("Eigenproblems are only supported in single-variable systems");
26 
27  auto eigensolver =
29  es->PrepareEigensolver(*eigensolver);
30  eigensolver->Solve();
32 }
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&#39;s equation system.
std::shared_ptr< Moose::MFEM::LinearSolverBase > jacobian_solver
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 Solve()
For eigensolvers, this method calls the underlying Solve method.
void FormEquationSystemOperator()
Form the equation-system operator used by the eigensolver.
void RecoverEigenproblemSolution(GridFunctions &gridfunctions, EigensolverBase *eigensolver)
Moose::MFEM::GridFunctions gridfunctions
Base class for eigensolvers.

◆ SolveWithOperator() [1/2]

void Moose::MFEM::ProblemOperatorBase::SolveWithOperator ( mfem::Operator &  system_operator,
mfem::Operator &  linear_operator,
const mfem::Vector &  rhs,
mfem::Vector &  x 
)
protectedinherited

Solve the current system operator using the configured nonlinear and linear solvers.

Definition at line 78 of file ProblemOperatorBase.C.

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::ImplicitSolve(), Moose::MFEM::ComplexEquationSystemProblemOperator::Solve(), Moose::MFEM::EquationSystemProblemOperator::Solve(), and Moose::MFEM::ProblemOperatorBase::SolveWithOperator().

82 {
83  // Nonlinear solver path for both linear and nonlinear problems. (as a linear problem may still
84  // intentionally be solved through the nonlinear solver machinery when one is provided)
86  {
87  auto & nonlinear_solver = *_problem_data.nonlinear_solver;
88  if (nonlinear_solver.RequiresExternalLinearSolver())
89  {
91  mooseError("The configured MFEM nonlinear solver requires an external linear solver, but "
92  "none was provided.");
93  auto & linear_solver = *_problem_data.jacobian_solver;
94  linear_solver.SetOperator(linear_operator);
95  nonlinear_solver.SetLinearSolver(linear_solver.GetSolver());
96  }
97 
98  nonlinear_solver.SetOperator(system_operator);
99  nonlinear_solver.Mult(rhs, x);
100  }
101  // Linear solver path for linear problems.
102  else
103  {
105  mooseError("A linear MFEM solve requires a linear solver, but none was provided.");
106 
107  auto & linear_solver = *_problem_data.jacobian_solver;
108  linear_solver.SetOperator(linear_operator);
109  linear_solver.Mult(rhs, x);
110  }
111 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::shared_ptr< Moose::MFEM::LinearSolverBase > jacobian_solver
std::shared_ptr< Moose::MFEM::NonlinearSolverBase > nonlinear_solver

◆ SolveWithOperator() [2/2]

void Moose::MFEM::ProblemOperatorBase::SolveWithOperator ( mfem::Operator &  system_operator,
const mfem::Vector &  rhs,
mfem::Vector &  x 
)
inlineprotectedinherited

Solve the current system operator using system_operator.GetGradient(x) as the linear operator.

Definition at line 77 of file ProblemOperatorBase.h.

78  {
79  return SolveWithOperator(system_operator, system_operator.GetGradient(x), rhs, x);
80  }
void SolveWithOperator(mfem::Operator &system_operator, mfem::Operator &linear_operator, const mfem::Vector &rhs, mfem::Vector &x)
Solve the current system operator using the configured nonlinear and linear solvers.

Member Data Documentation

◆ _block_true_offsets_test

mfem::Array<int> Moose::MFEM::ProblemOperatorBase::_block_true_offsets_test
inherited

◆ _block_true_offsets_trial

mfem::Array<int> Moose::MFEM::ProblemOperatorBase::_block_true_offsets_trial
inherited

◆ _problem

MFEMProblem& Moose::MFEM::ProblemOperatorBase::_problem
protectedinherited

◆ _problem_data

MFEMProblemData& Moose::MFEM::ProblemOperatorBase::_problem_data
protectedinherited

◆ _test_var_names

std::vector<std::string> Moose::MFEM::ProblemOperatorBase::_test_var_names
protectedinherited

◆ _test_variables

std::vector<mfem::ParGridFunction *> Moose::MFEM::ProblemOperatorBase::_test_variables
protectedinherited

◆ _trial_true_vector

mfem::Vector* Moose::MFEM::ProblemOperatorBase::_trial_true_vector = nullptr
protectedinherited

◆ _trial_var_names

std::vector<std::string> Moose::MFEM::ProblemOperatorBase::_trial_var_names
protectedinherited

◆ _trial_variables

std::vector<mfem::ParGridFunction *> Moose::MFEM::ProblemOperatorBase::_trial_variables
protectedinherited

◆ _true_rhs

mfem::BlockVector Moose::MFEM::ProblemOperatorBase::_true_rhs
inherited

◆ _true_x

mfem::BlockVector Moose::MFEM::ProblemOperatorBase::_true_x
inherited

The documentation for this class was generated from the following files: