https://mooseframework.inl.gov
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"
15 
16 registerMooseObject("MooseApp", MFEMSteady);
17 
20 {
22  params += Executioner::validParams();
23  params.addClassDescription("Executioner for steady state MFEM problems.");
24  params.addParam<Real>("time", 0.0, "System time");
25  return params;
26 }
27 
29  : Executioner(params),
30  _mfem_problem(dynamic_cast<MFEMProblem &>(feProblem())),
31  _mfem_problem_data(_mfem_problem.getProblemData()),
32  _mfem_problem_solve(*this, getProblemOperators()),
33  _system_time(getParam<Real>("time")),
34  _time_step(_mfem_problem.timeStep()),
35  _time([this]() -> Real & { return this->_mfem_problem.time() = this->_system_time; }()),
36  _last_solve_converged(false)
37 {
38  // If no ProblemOperators have been added by the user, add a default
39  if (getProblemOperators().empty())
40  {
41  _mfem_problem_data.eqn_system = std::make_shared<Moose::MFEM::EquationSystem>();
42  auto problem_operator =
43  std::make_shared<Moose::MFEM::EquationSystemProblemOperator>(_mfem_problem);
44  addProblemOperator(std::move(problem_operator));
45  }
46 }
47 
48 void
50 {
53 
54  // Set up initial conditions
58  getParam<MooseEnum>("assembly_level").getEnum<mfem::AssemblyLevel>());
59 
60  for (const auto & problem_operator : getProblemOperators())
61  {
62  problem_operator->SetGridFunctions();
63  problem_operator->Init(_mfem_problem_data.f);
64  }
65 }
66 
67 void
69 {
70  if (_app.isRecovering())
71  {
72  _console << "\nCannot recover steady solves!\nExiting...\n" << std::endl;
73  return;
74  }
75 
76  _time_step = 0;
77  _time = _time_step;
80 
81  preExecute();
82 
84 
85  // first step in any steady state solve is always 1 (preserving backwards compatibility)
86  _time_step = 1;
88 
90 
93 
94  // need to keep _time in sync with _time_step to get correct output
95  _time = _time_step;
98 
99  {
100  TIME_SECTION("final", 1, "Executing Final Objects")
105  _time = _time_step;
108  }
109 
110  postExecute();
111 }
112 
113 #endif
void finalizeMultiApps()
virtual void preExecute()
Override this for actions that should take place before execution.
Definition: Executioner.h:73
void timestepSetup() override
Real _system_time
Definition: MFEMSteady.h:38
registerMooseObject("MooseApp", MFEMSteady)
virtual Real & time() const
int & _time_step
Definition: MFEMSteady.h:39
virtual void postExecute()
Method called at the end of the simulation.
virtual bool solve() override
Solve routine provided by this object.
MFEMProblemData & _mfem_problem_data
Definition: MFEMSteady.h:33
virtual void computeMarkers()
virtual std::vector< std::shared_ptr< ProblemOperatorBase > > & getProblemOperators()
Returns a pointer to the operator&#39;s equation system.
MFEMSteady(const InputParameters &params)
Definition: MFEMSteady.C:28
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const ExecFlagType EXEC_TIMESTEP_END
Definition: Moose.C:36
MFEMProblem & _mfem_problem
Definition: MFEMSteady.h:29
Real & _time
Definition: MFEMSteady.h:40
Moose::MFEM::FESpaces fespaces
virtual void advanceState()
Advance all of the state holding vectors / datastructures so that we can move to the next timestep...
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
mfem::BlockVector f
static InputParameters validParams()
Definition: Executioner.C:26
static InputParameters validParams()
Definition: MFEMSteady.C:19
const ExecFlagType EXEC_PRE_MULTIAPP_SETUP
Definition: Moose.C:54
virtual void computeIndicators()
virtual void postExecute()
Override this for actions that should take place after execution.
Definition: Executioner.h:78
virtual void initialSetup() override
Definition: MFEMProblem.C:41
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:30
static InputParameters validParams()
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:353
std::shared_ptr< Moose::MFEM::EquationSystem > eqn_system
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MFEMProblemSolve _mfem_problem_solve
Definition: MFEMSteady.h:34
virtual void init() override
Initialize the executioner.
Definition: MFEMSteady.C:49
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 void execute() override
Pure virtual execute function MUST be overridden by children classes.
Definition: MFEMSteady.C:68
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...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
Execute the MultiApps associated with the ExecFlagType.
Moose::MFEM::GridFunctions gridfunctions
bool _last_solve_converged
Flag showing if the last solve converged.
Definition: MFEMSteady.h:43
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:1801
const ExecFlagType EXEC_FINAL
Definition: Moose.C:46
virtual void outputStep(ExecFlagType type)
Output the current step.
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:30