https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMTransient.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 "MFEMTransient.h"
13#include "MFEMProblem.h"
15#include "TimeStepper.h"
16
18
21{
24 params.addClassDescription("Executioner for transient MFEM problems.");
25 return params;
26}
27
29 : TransientBase(params),
30 _mfem_problem(dynamic_cast<MFEMProblem &>(feProblem())),
31 _mfem_problem_data(_mfem_problem.getProblemData()),
32 _mfem_problem_solve(*this, getProblemOperators())
33{
34 // If no ProblemOperators have been added by the user, add a default
36 {
37 std::string name = "__DefaultWeakFormProblemComposer";
38 InputParameters params = _factory.getValidParams("MFEMWeakFormProblemComposer");
39 _mfem_problem.addMFEMProblemComposer("MFEMTimeDependentWeakFormProblemComposer", name, params);
40 }
42}
43
44void
46{
48
49 // verify that the requested time integration scheme is actually supported by MFEM transient
51 paramError("scheme",
52 "Time Integration scheme \"" + stringify(getTimeScheme()) +
53 "\" is not supported by MFEMTransient Executioner.");
54
56 {
58 _mfem_problem_data.eqn_system->SetGradientRequired(
59 _mfem_problem_data.nonlinear_solver->RequiresGradient());
60
62
63 // Set up initial conditions
67 getParam<MooseEnum>("assembly_level").getEnum<mfem::AssemblyLevel>());
68 }
69
70 for (const auto & problem_operator : getProblemOperators())
71 {
72 problem_operator->SetGridFunctions();
73 problem_operator->Init(_mfem_problem_data.true_solution);
74 }
75}
76
77void
79{
80 _dt_old = _dt;
81
82 if (input_dt == -1.0)
84 else
85 _dt = input_dt;
86
88
89 // Unfortunately, time needs to be temporarily incremented so we get
90 // meaningful console output in timestepSetup(). We decrement it back
91 // immediately after so step() below behaves as expected.
92 _time += _dt;
94 _time -= _dt;
95
98 {
100 return;
101 }
103
104 // Advance time step of the MFEM problem. Time is also updated here, and
105 // _problem_operator->SetTime is called inside the ode_solver->Step method to
106 // update the time used by time dependent (function) coefficients.
108
109 // Continue with usual TransientBase::takeStep() finalisation
111
112 if (!lastSolveConverged())
113 {
114 _console << "Aborting as solve did not converge" << std::endl;
115 return;
116 }
117
120
121 if (lastSolveConverged())
123 else
125
126 // Set time to time old, since final time is updated in TransientBase::endStep()
128
130}
131
132#endif
registerMooseObject("MooseApp", MFEMTransient)
const ExecFlagType EXEC_TIMESTEP_END
Definition Moose.C:37
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition Moose.C:38
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.
void timestepSetup() override
virtual void onTimestepBegin() override
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition Factory.C:68
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
static InputParameters validParams()
std::shared_ptr< MFEMProblemComposer > & getProblemComposer()
Method to get the Problem Composer(s).
void addMFEMProblemComposer(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
Method called in AddMFEMProblemComposerAction which will create the problem composer.
static InputParameters validParams()
MFEMTransient(const InputParameters &params)
MFEMProblemData & _mfem_problem_data
virtual void init() override
Initialize the executioner.
virtual void takeStep(Real input_dt=-1.0) override
Do whatever is necessary to advance one step.
MFEMProblem & _mfem_problem
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:457
virtual std::vector< std::shared_ptr< ProblemOperatorBase > > & getProblemOperators()
Returns a pointer to the operator's equation system.
virtual void addProblemOperator(std::shared_ptr< ProblemOperatorBase > problem_operator)
Add an MFEM problem operator. Takes ownership.
Factory & _factory
The Factory associated with the MooseApp.
virtual void postSolve()
Definition TimeStepper.h:37
virtual bool converged() const
If the time step converged.
virtual void rejectStep()
This gets called when time step is rejected.
virtual void acceptStep()
This gets called when time step is accepted.
virtual void preSolve()
Definition TimeStepper.h:36
virtual void step()
Take a time step.
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
bool & _last_solve_converged
Whether or not the last solve converged.
FEProblemBase & _problem
Here for backward compatibility.
Moose::TimeIntegratorType getTimeScheme() const
Get the time scheme used.
Real & _time_old
Previous time.
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
Real & _time
Current time.
virtual Real computeConstrainedDT()
TimeStepper * _time_stepper
static InputParameters validParams()
virtual void init() override
Initialize the executioner.
Real & _dt
Current delta t... or timestep size.
@ TI_IMPLICIT_EULER
Definition MooseTypes.h:958
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