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 "SolutionHistory.h" 12 : #include "NonlinearSystemBase.h" 13 : #include "FEProblem.h" 14 : 15 : #include <fstream> 16 : 17 : registerMooseObject("MooseApp", SolutionHistory); 18 : 19 : InputParameters 20 14289 : SolutionHistory::validParams() 21 : { 22 : // Get the parameters from the parent object 23 14289 : InputParameters params = FileOutput::validParams(); 24 14289 : params.addClassDescription("Outputs the non-linear and linear iteration solve history."); 25 : 26 14289 : params.addParam<NonlinearSystemName>( 27 : "nl_sys", "nl0", "The nonlinear system that we should output information for."); 28 : 29 : // Return the parameters 30 14289 : return params; 31 0 : } 32 : 33 12 : SolutionHistory::SolutionHistory(const InputParameters & parameters) 34 : : FileOutput(parameters), 35 12 : _nl_sys_num(_problem_ptr->nlSysNum(getParam<NonlinearSystemName>("nl_sys"))) 36 : { 37 12 : } 38 : 39 : std::string 40 34 : SolutionHistory::filename() 41 : { 42 34 : return _file_base + ".slh"; 43 : } 44 : 45 : void 46 22 : SolutionHistory::output() 47 : { 48 : // Reference to the Non-linear System 49 22 : NonlinearSystemBase & nl_sys = _problem_ptr->getNonlinearSystemBase(_nl_sys_num); 50 : 51 22 : std::ofstream slh_file; 52 22 : slh_file.open(filename().c_str(), std::ios::app); 53 22 : if (slh_file.fail()) 54 0 : mooseError("Unable to open file ", filename()); 55 : 56 22 : slh_file << nl_sys._current_nl_its; 57 : 58 22 : for (const auto & linear_its : nl_sys._current_l_its) 59 0 : slh_file << " " << linear_its; 60 : 61 22 : slh_file << std::endl; 62 22 : }