https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMSteady.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
12#include "MFEMSteady.h"
13#include "MFEMProblem.h"
14#include "MFEMEigenproblem.h"
18
20
23{
25 params += Executioner::validParams();
26 params.addClassDescription("Executioner for steady state MFEM problems.");
27 params.addParam<Real>("time", 0.0, "System time");
28 return params;
29}
30
32 : Executioner(params),
33 _mfem_problem(dynamic_cast<MFEMProblem &>(feProblem())),
34 _mfem_problem_data(_mfem_problem.getProblemData()),
35 _mfem_problem_solve(*this, getProblemOperators()),
36 _system_time(getParam<Real>("time")),
37 _time_step(_mfem_problem.timeStep()),
38 _time([this]() -> Real & { return this->_mfem_problem.time() = this->_system_time; }()),
39 _last_solve_converged(false)
40{
41 // If no ProblemOperators have been added by the user, add a default
42 if (getProblemOperators().empty())
43 {
44 if (_mfem_problem.getNumericType() == MFEMProblem::NumericType::REAL)
45 {
46 if (dynamic_cast<MFEMEigenproblem *>(&_mfem_problem))
47 {
48 _mfem_problem_data.eqn_system = std::make_shared<Moose::MFEM::EigenproblemEquationSystem>();
49 auto problem_operator =
50 std::make_shared<Moose::MFEM::EigenproblemESProblemOperator>(_mfem_problem);
51 addProblemOperator(std::move(problem_operator));
52 }
53 else
54 {
55 _mfem_problem_data.eqn_system = std::make_shared<Moose::MFEM::EquationSystem>();
56 auto problem_operator =
57 std::make_shared<Moose::MFEM::EquationSystemProblemOperator>(_mfem_problem);
58 addProblemOperator(std::move(problem_operator));
59 }
60 }
61 else if (_mfem_problem.getNumericType() == MFEMProblem::NumericType::COMPLEX)
62 {
63 _mfem_problem_data.eqn_system = std::make_shared<Moose::MFEM::ComplexEquationSystem>();
64 auto problem_operator =
65 std::make_shared<Moose::MFEM::ComplexEquationSystemProblemOperator>(_mfem_problem);
66 addProblemOperator(std::move(problem_operator));
67 }
68 else
69 mooseError("Unknown numeric type. "
70 "Please set the Problem numeric type to either 'real' or 'complex'.");
71 }
72}
73
74void
76{
79
81 _mfem_problem_data.eqn_system->SetGradientRequired(
82 _mfem_problem_data.nonlinear_solver->RequiresGradient());
83
85
86 // Set up initial conditions
90 getParam<MooseEnum>("assembly_level").getEnum<mfem::AssemblyLevel>());
91
92 for (const auto & problem_operator : getProblemOperators())
93 {
94 problem_operator->SetGridFunctions();
95 problem_operator->Init(_mfem_problem_data.true_solution);
96 }
97}
98
99void
101{
102 if (_app.isRecovering())
103 {
104 _console << "\nCannot recover steady solves!\nExiting...\n" << std::endl;
105 return;
106 }
107
108 _time_step = 0;
112
113 preExecute();
114
116
117 // first step in any steady state solve is always 1 (preserving backwards compatibility)
118 _time_step = 1;
122 {
123 _last_solve_converged = false;
124 return;
125 }
127
129
132
133 // need to keep _time in sync with _time_step to get correct output
140
141 {
142 TIME_SECTION("final", 1, "Executing Final Objects")
150 }
151
152 postExecute();
153}
154
155#endif
registerMooseObject("MooseApp", MFEMSteady)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const ExecFlagType EXEC_PRE_MULTIAPP_SETUP
Definition Moose.C:56
const ExecFlagType EXEC_TIMESTEP_END
Definition Moose.C:36
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition Moose.C:37
const ExecFlagType EXEC_INITIAL
Definition Moose.C:30
const ExecFlagType EXEC_FINAL
Definition Moose.C:48
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
Executioners are objects that do the actual work of solving your problem.
Definition Executioner.h:37
static InputParameters validParams()
Definition Executioner.C:26
virtual void preExecute()
Override this for actions that should take place before execution.
Definition Executioner.h:73
virtual void postExecute()
Override this for actions that should take place after execution.
Definition Executioner.h:78
void execTransfers(ExecFlagType type)
Execute the Transfers associated with the ExecFlagType.
virtual void advanceState()
Advance all of the state holding vectors / datastructures so that we can move to the next timestep.
virtual void postExecute()
Method called at the end of the simulation.
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
Execute the MultiApps associated with the ExecFlagType.
void timestepSetup() override
virtual void computeIndicators()
void finalizeMultiApps()
virtual Real & time() const
virtual void computeMarkers()
virtual void outputStep(ExecFlagType type)
Output the current step.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
virtual bool solve() override
Solve routine provided by this object.
static InputParameters validParams()
virtual void execute(const ExecFlagType &exec_type) override
Convenience function for performing execution of MOOSE systems.
virtual void initialSetup() override
Definition MFEMProblem.C:88
MFEMSteady(const InputParameters &params)
Definition MFEMSteady.C:31
virtual void execute() override
Pure virtual execute function MUST be overridden by children classes.
Definition MFEMSteady.C:100
MFEMProblemSolve _mfem_problem_solve
Definition MFEMSteady.h:36
MFEMProblemData & _mfem_problem_data
Definition MFEMSteady.h:35
bool _last_solve_converged
Flag showing if the last solve converged.
Definition MFEMSteady.h:45
int & _time_step
Definition MFEMSteady.h:41
static InputParameters validParams()
Definition MFEMSteady.C:22
MFEMProblem & _mfem_problem
Definition MFEMSteady.h:34
virtual void init() override
Initialize the executioner.
Definition MFEMSteady.C:75
Real _system_time
Definition MFEMSteady.h:40
Real & _time
Definition MFEMSteady.h:42
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition MooseApp.C:1669
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
virtual std::vector< std::shared_ptr< ProblemOperatorBase > > & getProblemOperators()
Returns a pointer to the operator's equation system.
std::shared_ptr< Moose::MFEM::EquationSystem > eqn_system
Moose::MFEM::CoefficientManager coefficients
Moose::MFEM::ComplexGridFunctions cmplx_gridfunctions
mfem::BlockVector true_solution
Persistent true-DoF solution vector backing trial grid functions after problem operator init.
std::shared_ptr< Moose::MFEM::NonlinearSolverBase > nonlinear_solver
Moose::MFEM::GridFunctions gridfunctions