LCOV - code coverage report
Current view: top level - src/mfem/executioners - MFEMSteady.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 57 60 95.0 %
Date: 2025-08-08 20:01:16 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14