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 132904 : SolutionInvalidityOutput::validParams() 22 : { 23 132904 : InputParameters params = Output::validParams(); 24 : 25 398712 : params.set<ExecFlagEnum>("execute_on") = {EXEC_FINAL, EXEC_FAILED}; 26 : 27 398712 : params.addParam<unsigned int>("solution_invalidity_timestep_interval", 28 265808 : 1, 29 : "The number of time steps to group together in the table reporting " 30 : "the solution invalidity occurrences."); 31 : 32 132904 : params.addClassDescription("Controls output of the time history of solution invalidity object"); 33 : 34 132904 : return params; 35 132904 : } 36 : 37 56729 : SolutionInvalidityOutput::SolutionInvalidityOutput(const InputParameters & parameters) 38 : : Output(parameters), 39 56729 : _timestep_interval(getParam<unsigned int>("solution_invalidity_timestep_interval")), 40 113458 : _solution_invalidity(_app.solutionInvalidity()) 41 : { 42 56729 : } 43 : 44 : bool 45 1111631 : SolutionInvalidityOutput::shouldOutput() 46 : { 47 : // solver could have failed before any iteration completed, thus before a sync 48 : // Note: if this happens in other cases, we should just sync if solutionInvalidity is not synced 49 1111631 : if (_problem_ptr->getCurrentExecuteOnFlag() == EXEC_FAILED) 50 3867 : _solution_invalidity.syncIteration(); 51 1111631 : return Output::shouldOutput() && (_solution_invalidity.hasInvalidSolution()); 52 : } 53 : 54 : void 55 625 : SolutionInvalidityOutput::output() 56 : { 57 625 : if (isParamSetByUser("solution_invalidity_timestep_interval")) 58 10 : mooseInfo("Set Outputs/solution_invalidity_history=false to silence the default Solution " 59 : "Invalid Warnings History " 60 : "table above."); 61 625 : _console << '\n'; 62 625 : _solution_invalidity.printHistory(_console, _timestep_interval); 63 625 : _console << std::flush; 64 625 : }