https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | 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, const std::string &weak_form_name="")
 
virtual void Solve () override
 
EigenproblemEquationSystem * GetEquationSystem () const override
 Returns a pointer to the operator's equation system.
 
virtual void SetGridFunctions () override
 
void Mult (const mfem::Vector &, mfem::Vector &) const override
 
virtual void SetTrialVariablesFromTrueVectors ()
 
virtual void Init ()
 
PerfGraph & perfGraph ()
 Get the PerfGraph.
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

mfem::Array< int > _block_true_offsets_test
 
mfem::Array< int > _block_true_offsets_trial
 
mfem::BlockVector _true_x
 
mfem::BlockVector _true_rhs
 
mfem::BlockVector _true_solution
 Persistent true-DoF solution vector backing this operator's trial grid functions after Init().
 

Protected Member Functions

void FormEquationSystemOperator ()
 Form the equation-system operator used by the eigensolver.
 
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.
 
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.
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 Call to register a named section for timing.
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 Call to register a named section for timing.
 
std::string timedSectionName (const std::string &section_name) const
 

Protected Attributes

MFEMProblem & _problem
 Reference to the current problem.
 
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.
 
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
 
MooseApp & _pg_moose_app
 The MooseApp that owns the PerfGraph.
 
const std::string _prefix
 A prefix to use for all sections.
 

Private Member Functions

void RecoverEigenproblemSolution (GridFunctions &gridfunctions, EigensolverBase *eigensolver)
 

Private Attributes

std::shared_ptr< EquationSystem > _equation_system {nullptr}
 

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,
const std::string &  weak_form_name = "" 
)

Definition at line 19 of file EigenproblemESProblemOperator.C.

21 : EquationSystemProblemOperator(problem, weak_form_name)
22{
23 if (!std::dynamic_pointer_cast<EigenproblemEquationSystem>(
24 problem.getEquationSystem(weak_form_name)))
25 mooseError("The weak form supplying this operator does not provide an "
26 "EigenproblemEquationSystem, which is required by "
27 "EigenproblemESProblemOperator.");
28}
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::EquationSystem > getEquationSystem(const std::string &weak_form_name="") const
Return the EquationSystem built by the weak form named weak_form_name.
EquationSystemProblemOperator(MFEMProblem &problem, const std::string &weak_form_name="")

Member Function Documentation

◆ FormEquationSystemOperator()

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

Form the equation-system operator used by the eigensolver.

Definition at line 54 of file EigenproblemESProblemOperator.C.

55{
58 _true_x, cast_ref<MFEMEigenproblem &>(_problem).getRHSCoefficient());
59}
EigenproblemEquationSystem * GetEquationSystem() const override
Returns a pointer to the operator's equation system.
void BuildEigenproblemJacobian(mfem::BlockVector &trueX, EigenRHSCoefficient rhs_coefficient)
Build eigenproblem system, with essential boundary conditions accounted for.
virtual void BuildEquationSystem()
Build all forms comprising this EquationSystem.
MFEMProblem & _problem
Reference to the current problem.

Referenced by Solve().

◆ 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 29 of file EigenproblemESProblemOperator.h.

30 {
31 return cast_ptr<EigenproblemEquationSystem *>(
33 }
virtual EquationSystem * GetEquationSystem() const override
Returns a pointer to the operator's equation system.

Referenced by FormEquationSystemOperator(), and Solve().

◆ Init()

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

Reimplemented in Moose::MFEM::TimeDependentEquationSystemProblemOperator.

Definition at line 50 of file ProblemOperatorBase.C.

51{
54 for (const auto i : index_range(_trial_variables))
55 _true_solution.GetBlock(i) = _trial_variables[i]->GetTrueVector();
56 // Sync the flags from the global vector with the sub-vectors (copies to global vector location)
57 _true_solution.SyncFromBlocks();
58
59 // After initial assignment of the true solution from the grid function, which may contain
60 // initial conditions, we alias the grid function to it
61 for (const auto i : index_range(_trial_variables))
62 _trial_variables[i]->MakeTRef(
65}
std::vector< mfem::ParGridFunction * > _trial_variables
mfem::BlockVector _true_solution
Persistent true-DoF solution vector backing this operator's trial grid functions after Init().
auto index_range(const T &sizable)

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

◆ Mult()

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

Definition at line 28 of file ProblemOperator.h.

28{}

◆ perfGraph()

PerfGraph & PerfGraphInterface::perfGraph ( )
inherited

Get the PerfGraph.

Definition at line 86 of file PerfGraphInterface.C.

87{
88 return _pg_moose_app.perfGraph();
89}
PerfGraph & perfGraph()
Get the PerfGraph for this app.
Definition MooseApp.h:176
MooseApp & _pg_moose_app
The MooseApp that owns the PerfGraph.

Referenced by CommonOutputAction::act(), PerfGraphData::finalize(), PerfGraphReporter::finalize(), and PerfGraphOutput::output().

◆ RecoverEigenproblemSolution()

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

Definition at line 62 of file EigenproblemESProblemOperator.C.

64{
65 mfem::Array<mfem::real_t> eigenvalues;
66 eigensolver->GetEigenvalues(eigenvalues);
67
68 const auto & trial_var_name = _trial_var_names.at(0);
69 const auto & sep = _problem_data.mode_separator;
70
71 // Distribute the zeroth mode onto the base variable
72 gridfunctions.Get(trial_var_name)->Distribute(eigensolver->GetEigenvector(0));
73
74 for (int i = 0; i < eigenvalues.Size(); ++i)
75 gridfunctions.Get(trial_var_name + sep + std::to_string(i))
76 ->Distribute(eigensolver->GetEigenvector(i));
77}
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

Referenced by Solve().

◆ registerTimedSection() [1/2]

PerfID PerfGraphInterface::registerTimedSection ( const std::string &  section_name,
const unsigned int  level 
) const
protectedinherited

Call to register a named section for timing.

Parameters
section_nameThe name of the code section to be timed
levelThe importance of the timer - lower is more important (0 will always come out)
Returns
The ID of the section - use when starting timing

Definition at line 61 of file PerfGraphInterface.C.

63{
64 const auto timed_section_name = timedSectionName(section_name);
65 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
66 return moose::internal::getPerfGraphRegistry().registerSection(timed_section_name, level);
67 else
68 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
69}
std::string timedSectionName(const std::string &section_name) const
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID @section_name The name of the section.
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.

◆ registerTimedSection() [2/2]

PerfID PerfGraphInterface::registerTimedSection ( const std::string &  section_name,
const unsigned int  level,
const std::string &  live_message,
const bool  print_dots = true 
) const
protectedinherited

Call to register a named section for timing.

Parameters
section_nameThe name of the code section to be timed
levelThe importance of the timer - lower is more important (0 will always come out)
live_messageThe message to be printed to the screen during execution
print_dotsWhether or not progress dots should be printed for this section
Returns
The ID of the section - use when starting timing

Definition at line 72 of file PerfGraphInterface.C.

76{
77 const auto timed_section_name = timedSectionName(section_name);
78 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
80 timedSectionName(section_name), level, live_message, print_dots);
81 else
82 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
83}

◆ SetGridFunctions()

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

Reimplemented from Moose::MFEM::ProblemOperator.

Reimplemented in Moose::MFEM::ComplexEquationSystemProblemOperator.

Definition at line 24 of file EquationSystemProblemOperator.C.

25{
29}
const std::vector< std::string > & GetTrialVarNames() const
const std::vector< std::string > & GetTestVarNames() const
std::vector< std::string > _test_var_names
virtual void SetGridFunctions() override

◆ SetTrialVariablesFromTrueVectors()

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

Definition at line 68 of file ProblemOperatorBase.C.

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

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

◆ Solve()

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

Reimplemented from Moose::MFEM::EquationSystemProblemOperator.

Definition at line 31 of file EigenproblemESProblemOperator.C.

32{
33 {
34 TIME_SECTION("EigenproblemESProblemOperator::FormSystem", 2, "Assembling MFEM Eigenproblem");
36 }
37
38 auto * const es = GetEquationSystem();
39 if (es->GetTestVarNames().size() > 1)
40 mooseError("Eigenproblems are only supported in single-variable systems");
41
42 auto eigensolver =
43 std::dynamic_pointer_cast<Moose::MFEM::EigensolverBase>(_problem_data.jacobian_solver);
44
45 {
46 TIME_SECTION("EigenproblemESProblemOperator::SolveSystem", 2, "Solving MFEM Eigenproblem");
47 es->PrepareEigensolver(*eigensolver);
48 eigensolver->Solve();
49 }
51}
void FormEquationSystemOperator()
Form the equation-system operator used by the eigensolver.
void RecoverEigenproblemSolution(GridFunctions &gridfunctions, EigensolverBase *eigensolver)
std::shared_ptr< Moose::MFEM::LinearSolverBase > jacobian_solver
Moose::MFEM::GridFunctions gridfunctions

◆ SolveWithOperator() [1/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 88 of file ProblemOperatorBase.h.

89 {
90 return SolveWithOperator(system_operator, system_operator.GetGradient(x), rhs, x);
91 }
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.

◆ SolveWithOperator() [2/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 80 of file ProblemOperatorBase.C.

84{
85 // Nonlinear solver path for both linear and nonlinear problems. (as a linear problem may still
86 // intentionally be solved through the nonlinear solver machinery when one is provided)
88 {
89 auto & nonlinear_solver = *_problem_data.nonlinear_solver;
90 if (nonlinear_solver.RequiresExternalLinearSolver())
91 {
93 mooseError("The configured MFEM nonlinear solver requires an external linear solver, but "
94 "none was provided.");
95 auto & linear_solver = *_problem_data.jacobian_solver;
96 linear_solver.SetOperator(linear_operator);
97 nonlinear_solver.SetLinearSolver(linear_solver.GetSolver());
98 }
99
100 nonlinear_solver.SetOperator(system_operator);
101 nonlinear_solver.Mult(rhs, x);
102 }
103 // Linear solver path for linear problems.
104 else
105 {
107 mooseError("A linear MFEM solve requires a linear solver, but none was provided.");
108
109 auto & linear_solver = *_problem_data.jacobian_solver;
110 linear_solver.SetOperator(linear_operator);
111 linear_solver.Mult(rhs, x);
112 }
113}
std::shared_ptr< Moose::MFEM::NonlinearSolverBase > nonlinear_solver

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

◆ timedSectionName()

std::string PerfGraphInterface::timedSectionName ( const std::string &  section_name) const
protectedinherited
Returns
The name of the timed section with the name section_name.

Optionally adds a prefix if one is defined.

Definition at line 55 of file PerfGraphInterface.C.

56{
57 return _prefix.empty() ? section_name : _prefix + "::" + section_name;
58}
const std::string _prefix
A prefix to use for all sections.

Referenced by PerfGraphInterface::registerTimedSection(), and PerfGraphInterface::registerTimedSection().

◆ validParams()

InputParameters PerfGraphInterface::validParams ( )
staticinherited

Definition at line 16 of file PerfGraphInterface.C.

17{
19 return params;
20}
InputParameters emptyInputParameters()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.

Referenced by Convergence::validParams().

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

◆ _equation_system

std::shared_ptr<EquationSystem> Moose::MFEM::EquationSystemProblemOperator::_equation_system {nullptr}
privateinherited

◆ _pg_moose_app

MooseApp& PerfGraphInterface::_pg_moose_app
protectedinherited

The MooseApp that owns the PerfGraph.

Definition at line 135 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::perfGraph().

◆ _prefix

const std::string PerfGraphInterface::_prefix
protectedinherited

A prefix to use for all sections.

Definition at line 138 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::timedSectionName().

◆ _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_solution

mfem::BlockVector Moose::MFEM::ProblemOperatorBase::_true_solution
inherited

Persistent true-DoF solution vector backing this operator's trial grid functions after Init().

Each operator owns its own, because Init() aliases its trial grid functions into this vector; sharing one across operators would make each alias the same storage.

Definition at line 77 of file ProblemOperatorBase.h.

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

◆ _true_x

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

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