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 147255 : SteadyBase::validParams() 21 : { 22 147255 : InputParameters params = Executioner::validParams(); 23 147255 : params.addParam<Real>("time", 0.0, "System time"); 24 147255 : return params; 25 0 : } 26 : 27 30472 : SteadyBase::SteadyBase(const InputParameters & parameters) 28 : : Executioner(parameters), 29 30472 : _problem(_fe_problem), 30 30472 : _system_time(getParam<Real>("time")), 31 30472 : _time_step(_problem.timeStep()), 32 30472 : _time(_problem.time()), 33 30472 : _output_iteration_number(0) 34 : { 35 30472 : _time = _system_time; 36 30472 : } 37 : 38 : void 39 29314 : SteadyBase::execute() 40 : { 41 29314 : if (_app.isRecovering()) 42 : { 43 1536 : _console << "\nCannot recover steady-state solves of type: " << this->type() 44 1536 : << "!\nExiting...\n" 45 1536 : << std::endl; 46 1536 : _last_solve_converged = true; 47 1536 : return; 48 : } 49 : 50 27778 : _time_step = 0; 51 27778 : _time = _time_step; 52 27778 : _problem.outputStep(EXEC_INITIAL); 53 27774 : _time = _system_time; 54 : 55 27774 : preExecute(); 56 : 57 27774 : _problem.advanceState(); 58 : 59 : // first step in any SteadyBase state solve is always 1 (preserving backwards compatibility) 60 27774 : _time_step = 1; 61 : 62 : #ifdef LIBMESH_ENABLE_AMR 63 : 64 : // Define the refinement loop 65 27774 : unsigned int steps = _problem.adaptivity().getSteps(); 66 55993 : for (unsigned int r_step = 0; r_step <= steps; r_step++) 67 : { 68 : #endif // LIBMESH_ENABLE_AMR 69 28625 : _problem.timestepSetup(); 70 : 71 28625 : _last_solve_converged = _fixed_point_solve->solve(); 72 : 73 28422 : if (!lastSolveConverged()) 74 : { 75 195 : _console << "Aborting as solve did not converge" << std::endl; 76 195 : break; 77 : } 78 : 79 28227 : _problem.computeIndicators(); 80 28227 : _problem.computeMarkers(); 81 : 82 : // need to keep _time in sync with _time_step to get correct output 83 28223 : _time = _time_step; 84 28223 : _problem.outputStep(EXEC_TIMESTEP_END); 85 28219 : _time = _system_time; 86 : 87 : #ifdef LIBMESH_ENABLE_AMR 88 28219 : if (r_step != steps) 89 : { 90 851 : _problem.adaptMesh(); 91 : } 92 : 93 28219 : _time_step++; 94 : } 95 : #endif 96 : 97 : { 98 27563 : TIME_SECTION("final", 1, "Executing Final Objects") 99 27563 : _problem.execMultiApps(EXEC_FINAL); 100 27563 : _problem.finalizeMultiApps(); 101 27563 : _problem.postExecute(); 102 27563 : _problem.execute(EXEC_FINAL); 103 27563 : _time = _time_step; 104 27563 : _problem.outputStep(EXEC_FINAL); 105 27563 : _time = _system_time; 106 27563 : } 107 : 108 27563 : postExecute(); 109 : }