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 MFEM_ENABLED 11 : 12 : #include "MFEMSteady.h" 13 : #include "MFEMProblem.h" 14 : 15 : registerMooseObject("MooseApp", MFEMSteady); 16 : 17 : InputParameters 18 8850 : MFEMSteady::validParams() 19 : { 20 8850 : InputParameters params = MFEMExecutioner::validParams(); 21 8850 : params.addClassDescription("Executioner for steady state MFEM problems."); 22 8850 : params.addParam<Real>("time", 0.0, "System time"); 23 8850 : return params; 24 0 : } 25 : 26 110 : MFEMSteady::MFEMSteady(const InputParameters & params) 27 : : MFEMExecutioner(params), 28 110 : _system_time(getParam<Real>("time")), 29 110 : _time_step(_mfem_problem.timeStep()), 30 110 : _time(_mfem_problem.time()), 31 220 : _output_iteration_number(0) 32 : { 33 110 : _time = _system_time; 34 110 : } 35 : 36 : void 37 110 : MFEMSteady::constructProblemOperator() 38 : { 39 110 : _problem_data.eqn_system = std::make_shared<Moose::MFEM::EquationSystem>(); 40 : auto problem_operator = 41 110 : std::make_unique<Moose::MFEM::EquationSystemProblemOperator>(_problem_data); 42 : 43 110 : _problem_operator.reset(); 44 110 : _problem_operator = std::move(problem_operator); 45 110 : } 46 : 47 : void 48 110 : MFEMSteady::init() 49 : { 50 110 : _mfem_problem.execute(EXEC_PRE_MULTIAPP_SETUP); 51 110 : _mfem_problem.initialSetup(); 52 : 53 : // Set up initial conditions 54 110 : _problem_data.eqn_system->Init( 55 110 : _problem_data.gridfunctions, 56 110 : _problem_data.fespaces, 57 220 : getParam<MooseEnum>("assembly_level").getEnum<mfem::AssemblyLevel>()); 58 : 59 110 : _problem_operator->SetGridFunctions(); 60 110 : _problem_operator->Init(_problem_data.f); 61 110 : } 62 : 63 : void 64 110 : MFEMSteady::execute() 65 : { 66 110 : if (_app.isRecovering()) 67 : { 68 0 : _console << "\nCannot recover steady solves!\nExiting...\n" << std::endl; 69 0 : return; 70 : } 71 : 72 110 : _time_step = 0; 73 110 : _time = _time_step; 74 110 : _mfem_problem.outputStep(EXEC_INITIAL); 75 110 : _time = _system_time; 76 : 77 110 : preExecute(); 78 : 79 110 : _mfem_problem.advanceState(); 80 : 81 : // first step in any steady state solve is always 1 (preserving backwards compatibility) 82 110 : _time_step = 1; 83 110 : _mfem_problem.timestepSetup(); 84 : 85 : // Solve equation system. 86 110 : if (_mfem_problem.shouldSolve()) 87 78 : _problem_operator->Solve(_problem_data.f); 88 : 89 : // Displace mesh, if required 90 110 : _mfem_problem.displaceMesh(); 91 : 92 110 : _mfem_problem.computeIndicators(); 93 110 : _mfem_problem.computeMarkers(); 94 : 95 : // need to keep _time in sync with _time_step to get correct output 96 110 : _time = _time_step; 97 : // Execute user objects at timestep end 98 110 : _mfem_problem.execute(EXEC_TIMESTEP_END); 99 110 : _mfem_problem.outputStep(EXEC_TIMESTEP_END); 100 110 : _time = _system_time; 101 : 102 : { 103 110 : TIME_SECTION("final", 1, "Executing Final Objects") 104 110 : _mfem_problem.execMultiApps(EXEC_FINAL); 105 110 : _mfem_problem.finalizeMultiApps(); 106 110 : _mfem_problem.postExecute(); 107 110 : _mfem_problem.execute(EXEC_FINAL); 108 110 : _time = _time_step; 109 110 : _mfem_problem.outputStep(EXEC_FINAL); 110 110 : _time = _system_time; 111 110 : } 112 : 113 110 : postExecute(); 114 : } 115 : 116 : #endif