www.mooseframework.org
SolutionHistory.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
18 
21 {
22  // Get the parameters from the parent object
24  params.addClassDescription("Outputs the non-linear and linear iteration solve history.");
25 
26  params.addParam<NonlinearSystemName>(
27  "nl_sys", "nl0", "The nonlinear system that we should output information for.");
28 
29  // Return the parameters
30  return params;
31 }
32 
34  : FileOutput(parameters),
35  _nl_sys_num(_problem_ptr->nlSysNum(getParam<NonlinearSystemName>("nl_sys")))
36 {
37 }
38 
39 std::string
41 {
42  return _file_base + ".slh";
43 }
44 
45 void
47 {
48  // Reference to the Non-linear System
50 
51  std::ofstream slh_file;
52  slh_file.open(filename().c_str(), std::ios::app);
53  if (slh_file.fail())
54  mooseError("Unable to open file ", filename());
55 
56  slh_file << nl_sys._current_nl_its;
57 
58  for (const auto & linear_its : nl_sys._current_l_its)
59  slh_file << " " << linear_its;
60 
61  slh_file << std::endl;
62 }
virtual void output() override
Output the data to *.slh file.
SolutionHistory(const InputParameters &parameters)
Class constructor.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::string _file_base
The base filename from the input paramaters.
Definition: FileOutput.h:89
static InputParameters validParams()
Nonlinear system to be solved.
std::vector< unsigned int > _current_l_its
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
Definition: Output.h:179
static InputParameters validParams()
Definition: FileOutput.C:24
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
virtual std::string filename() override
The filename for the output file.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
registerMooseObject("MooseApp", SolutionHistory)
An outputter with filename support.
Definition: FileOutput.h:20
const unsigned int _nl_sys_num
The nonlinear system number we should output information for.
Based class for adding basic filename support to output base class.