LCOV - code coverage report
Current view: top level - src/executioners - SteadyBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: fef103 Lines: 50 51 98.0 %
Date: 2025-09-03 20:01:23 Functions: 4 4 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             : // MOOSE includes
      11             : #include "SteadyBase.h"
      12             : #include "FEProblem.h"
      13             : #include "Factory.h"
      14             : #include "MooseApp.h"
      15             : #include "NonlinearSystem.h"
      16             : 
      17             : #include "libmesh/equation_systems.h"
      18             : 
      19             : InputParameters
      20      147641 : SteadyBase::validParams()
      21             : {
      22      147641 :   InputParameters params = Executioner::validParams();
      23      442923 :   params.addParam<Real>("time", 0.0, "System time");
      24      147641 :   return params;
      25           0 : }
      26             : 
      27       30665 : SteadyBase::SteadyBase(const InputParameters & parameters)
      28             :   : Executioner(parameters),
      29       30665 :     _problem(_fe_problem),
      30       30665 :     _system_time(getParam<Real>("time")),
      31       30665 :     _time_step(_problem.timeStep()),
      32       61330 :     _time([this]() -> Real & { return this->_problem.time() = this->_system_time; }()),
      33       30665 :     _output_iteration_number(0)
      34             : {
      35       30665 : }
      36             : 
      37             : void
      38       29570 : SteadyBase::execute()
      39             : {
      40       29570 :   if (_app.isRecovering())
      41             :   {
      42        1547 :     _console << "\nCannot recover steady-state solves of type: " << this->type()
      43        1547 :              << "!\nExiting...\n"
      44        1547 :              << std::endl;
      45        1547 :     _last_solve_converged = true;
      46        1547 :     return;
      47             :   }
      48             : 
      49       28023 :   _time_step = 0;
      50       28023 :   _time = _time_step;
      51       28023 :   _problem.outputStep(EXEC_INITIAL);
      52       28019 :   _time = _system_time;
      53             : 
      54       28019 :   preExecute();
      55             : 
      56       28019 :   _problem.advanceState();
      57             : 
      58             :   // first step in any SteadyBase state solve is always 1 (preserving backwards compatibility)
      59       28019 :   _time_step = 1;
      60             : 
      61             : #ifdef LIBMESH_ENABLE_AMR
      62             : 
      63             :   // Define the refinement loop
      64       28019 :   unsigned int steps = _problem.adaptivity().getSteps();
      65       56477 :   for (unsigned int r_step = 0; r_step <= steps; r_step++)
      66             :   {
      67             : #endif // LIBMESH_ENABLE_AMR
      68       28870 :     _problem.timestepSetup();
      69             : 
      70       28870 :     _last_solve_converged = _fixed_point_solve->solve();
      71             : 
      72       28661 :     if (!lastSolveConverged())
      73             :     {
      74         195 :       _console << "Aborting as solve did not converge" << std::endl;
      75         195 :       break;
      76             :     }
      77             : 
      78       28466 :     _problem.computeIndicators();
      79       28466 :     _problem.computeMarkers();
      80             : 
      81             :     // need to keep _time in sync with _time_step to get correct output
      82       28462 :     _time = _time_step;
      83       28462 :     _problem.outputStep(EXEC_TIMESTEP_END);
      84       28458 :     _time = _system_time;
      85             : 
      86             : #ifdef LIBMESH_ENABLE_AMR
      87       28458 :     if (r_step != steps)
      88             :     {
      89         851 :       _problem.adaptMesh();
      90             :     }
      91             : 
      92       28458 :     _time_step++;
      93             :   }
      94             : #endif
      95             : 
      96             :   {
      97      139010 :     TIME_SECTION("final", 1, "Executing Final Objects")
      98       27802 :     _problem.execMultiApps(EXEC_FINAL);
      99       27802 :     _problem.finalizeMultiApps();
     100       27802 :     _problem.postExecute();
     101       27802 :     _problem.execute(EXEC_FINAL);
     102       27802 :     _time = _time_step;
     103       27802 :     _problem.outputStep(EXEC_FINAL);
     104       27802 :     _time = _system_time;
     105       27802 :   }
     106             : 
     107       27802 :   postExecute();
     108             : }

Generated by: LCOV version 1.14