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 "SolutionInvalidityOutput.h" 12 : #include "MooseApp.h" 13 : #include "MooseObjectParameterName.h" 14 : #include "InputParameterWarehouse.h" 15 : #include "ConsoleUtils.h" 16 : #include "FEProblemBase.h" 17 : 18 : registerMooseObject("MooseApp", SolutionInvalidityOutput); 19 : 20 : InputParameters 21 129375 : SolutionInvalidityOutput::validParams() 22 : { 23 129375 : InputParameters params = Output::validParams(); 24 : 25 388125 : params.set<ExecFlagEnum>("execute_on") = {EXEC_FINAL}; 26 : 27 388125 : params.addParam<unsigned int>("solution_invalidity_timestep_interval", 28 258750 : 1, 29 : "The number of time steps to group together in the table reporting " 30 : "the warnings and solution invalidity occurrences."); 31 : 32 129375 : params.addClassDescription("Controls output of the time history of regular warnings and solution " 33 : "invalidity errors and warnings"); 34 : 35 129375 : return params; 36 129375 : } 37 : 38 60381 : SolutionInvalidityOutput::SolutionInvalidityOutput(const InputParameters & parameters) 39 : : Output(parameters), 40 60381 : _timestep_interval(getParam<unsigned int>("solution_invalidity_timestep_interval")), 41 120762 : _solution_invalidity(_app.solutionInvalidity()) 42 : { 43 60381 : } 44 : 45 : bool 46 1200609 : SolutionInvalidityOutput::shouldOutput() 47 : { 48 : // solver could have failed before any iteration completed, thus before a sync 49 : // Note: if this happens in other cases, we should just sync if solutionInvalidity is not synced 50 1200609 : if (_problem_ptr->getCurrentExecuteOnFlag() == EXEC_FAILED) 51 1853 : _solution_invalidity.syncIteration(); 52 : // At the known end of a simulation, always output the total summary if anything happened 53 2399365 : if (_problem_ptr->getCurrentExecuteOnFlag() == EXEC_FAILED || 54 1198756 : _problem_ptr->getCurrentExecuteOnFlag() == EXEC_FINAL) 55 56734 : return Output::shouldOutput() && _solution_invalidity.hasEverHadSolutionIssue(); 56 : // At other points, we check the current state of the simulation 57 1143875 : return Output::shouldOutput() && _solution_invalidity.hasInvalidSolution(); 58 : } 59 : 60 : void 61 1426 : SolutionInvalidityOutput::output() 62 : { 63 4278 : if (isParamSetByUser("solution_invalidity_timestep_interval")) 64 9 : mooseInfo("Set Outputs/solution_invalidity_history=false to silence the default Solution " 65 : "Invalid Warnings History table above."); 66 1426 : _console << '\n'; 67 1426 : _solution_invalidity.printHistory(_console, _timestep_interval); 68 1426 : _console << std::flush; 69 1426 : }