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 142277 : SolutionInvalidityOutput::validParams() 22 : { 23 142277 : InputParameters params = Output::validParams(); 24 : 25 426831 : params.set<ExecFlagEnum>("execute_on") = {EXEC_FINAL, EXEC_FAILED}; 26 : 27 426831 : params.addParam<unsigned int>("solution_invalidity_timestep_interval", 28 284554 : 1, 29 : "The number of time steps to group together in the table reporting " 30 : "the solution invalidity occurrences."); 31 : 32 142277 : params.addClassDescription("Controls output of the time history of solution invalidity object"); 33 : 34 142277 : return params; 35 142277 : } 36 : 37 61249 : SolutionInvalidityOutput::SolutionInvalidityOutput(const InputParameters & parameters) 38 : : Output(parameters), 39 61249 : _timestep_interval(getParam<unsigned int>("solution_invalidity_timestep_interval")), 40 122498 : _solution_invalidity(_app.solutionInvalidity()) 41 : { 42 61249 : } 43 : 44 : bool 45 1274528 : 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 1274528 : if (_problem_ptr->getCurrentExecuteOnFlag() == EXEC_FAILED) 50 3916 : _solution_invalidity.syncIteration(); 51 1274528 : return Output::shouldOutput() && (_solution_invalidity.hasInvalidSolution()); 52 : } 53 : 54 : void 55 626 : SolutionInvalidityOutput::output() 56 : { 57 626 : 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 626 : _console << '\n'; 62 626 : _solution_invalidity.printHistory(_console, _timestep_interval); 63 626 : _console << std::flush; 64 626 : }