https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SolutionHistory.C
Go to the documentation of this file.
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
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
39std::string
41{
42 return _file_base + ".slh";
43}
44
45void
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}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", SolutionHistory)
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
An outputter with filename support.
Definition FileOutput.h:21
static InputParameters validParams()
Definition FileOutput.C:24
std::string _file_base
The base filename from the input paramaters.
Definition FileOutput.h:89
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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.
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:185
Based class for adding basic filename support to output base class.
virtual std::string filename() override
The filename for the output file.
const unsigned int _nl_sys_num
The nonlinear system number we should output information for.
static InputParameters validParams()
SolutionHistory(const InputParameters &parameters)
Class constructor.
virtual void output() override
Output the data to *.slh file.