Line data Source code
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 "EquationSystemProblemOperator.h" 15 : 16 : registerMooseObject("MooseApp", MFEMSteady); 17 : 18 : InputParameters 19 9102 : MFEMSteady::validParams() 20 : { 21 9102 : InputParameters params = MFEMProblemSolve::validParams(); 22 9102 : params += Executioner::validParams(); 23 18204 : params.addClassDescription("Executioner for steady state MFEM problems."); 24 27306 : params.addParam<Real>("time", 0.0, "System time"); 25 9102 : return params; 26 0 : } 27 : 28 236 : MFEMSteady::MFEMSteady(const InputParameters & params) 29 : : Executioner(params), 30 236 : _mfem_problem(dynamic_cast<MFEMProblem &>(feProblem())), 31 236 : _mfem_problem_data(_mfem_problem.getProblemData()), 32 236 : _mfem_problem_solve(*this, getProblemOperators()), 33 472 : _system_time(getParam<Real>("time")), 34 236 : _time_step(_mfem_problem.timeStep()), 35 472 : _time([this]() -> Real & { return this->_mfem_problem.time() = this->_system_time; }()), 36 236 : _last_solve_converged(false) 37 : { 38 : // If no ProblemOperators have been added by the user, add a default 39 236 : if (getProblemOperators().empty()) 40 : { 41 236 : _mfem_problem_data.eqn_system = std::make_shared<Moose::MFEM::EquationSystem>(); 42 : auto problem_operator = 43 236 : std::make_shared<Moose::MFEM::EquationSystemProblemOperator>(_mfem_problem); 44 236 : addProblemOperator(std::move(problem_operator)); 45 236 : } 46 236 : } 47 : 48 : void 49 236 : MFEMSteady::init() 50 : { 51 236 : _mfem_problem.execute(EXEC_PRE_MULTIAPP_SETUP); 52 236 : _mfem_problem.initialSetup(); 53 : 54 : // Set up initial conditions 55 236 : _mfem_problem_data.eqn_system->Init( 56 236 : _mfem_problem_data.gridfunctions, 57 236 : _mfem_problem_data.fespaces, 58 708 : getParam<MooseEnum>("assembly_level").getEnum<mfem::AssemblyLevel>()); 59 : 60 472 : for (const auto & problem_operator : getProblemOperators()) 61 : { 62 236 : problem_operator->SetGridFunctions(); 63 236 : problem_operator->Init(_mfem_problem_data.f); 64 : } 65 236 : } 66 : 67 : void 68 236 : MFEMSteady::execute() 69 : { 70 236 : if (_app.isRecovering()) 71 : { 72 0 : _console << "\nCannot recover steady solves!\nExiting...\n" << std::endl; 73 0 : return; 74 : } 75 : 76 236 : _time_step = 0; 77 236 : _time = _time_step; 78 236 : _mfem_problem.outputStep(EXEC_INITIAL); 79 236 : _time = _system_time; 80 : 81 236 : preExecute(); 82 : 83 236 : _mfem_problem.advanceState(); 84 : 85 : // first step in any steady state solve is always 1 (preserving backwards compatibility) 86 236 : _time_step = 1; 87 236 : _mfem_problem.timestepSetup(); 88 : 89 236 : _last_solve_converged = _mfem_problem_solve.solve(); 90 : 91 236 : _mfem_problem.computeIndicators(); 92 236 : _mfem_problem.computeMarkers(); 93 : 94 : // need to keep _time in sync with _time_step to get correct output 95 236 : _time = _time_step; 96 236 : _mfem_problem.outputStep(EXEC_TIMESTEP_END); 97 236 : _time = _system_time; 98 : 99 : { 100 1180 : TIME_SECTION("final", 1, "Executing Final Objects") 101 236 : _mfem_problem.execMultiApps(EXEC_FINAL); 102 236 : _mfem_problem.finalizeMultiApps(); 103 236 : _mfem_problem.postExecute(); 104 236 : _mfem_problem.execute(EXEC_FINAL); 105 236 : _time = _time_step; 106 236 : _mfem_problem.outputStep(EXEC_FINAL); 107 236 : _time = _system_time; 108 236 : } 109 : 110 236 : postExecute(); 111 : } 112 : 113 : #endif