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